Added the gamma_correct materials and shader materials key, which allows to specify whether the diffuse, specular, emmission and illumination maps of a material will be gamma corrected by the default shader or not. The default setting at this moment is YES and it can be adjusted in the .GNUStepDefaults file with the key no-gamma-correct.
parent
9153b506d5
commit
97f3e07041
|
@ -556,6 +556,8 @@ static void SynthSpecular(OOMaterialSynthContext *context)
|
|||
GLfloat gloss = [context->inConfig oo_gloss];
|
||||
if (gloss < 0.0f || gloss > 1.0f) return;
|
||||
|
||||
BOOL gammaCorrect = [context->inConfig oo_gammaCorrect];
|
||||
|
||||
NSDictionary *specularMapSpec = nil;
|
||||
OOColor *specularColor = nil;
|
||||
|
||||
|
@ -586,6 +588,12 @@ static void SynthSpecular(OOMaterialSynthContext *context)
|
|||
[context->outConfig setObject:[specularColor normalizedArray] forKey:kOOMaterialSpecularColorName];
|
||||
}
|
||||
[context->macros setObject:@"1" forKey:@"OOSTD_SPECULAR"];
|
||||
|
||||
// setting a bool as a float uniform, to be used in the shader as a bool again
|
||||
// this is how hackish I can get... maybe a better way exists, but this is quick
|
||||
// and can be used also for the shader materials in a not too different way
|
||||
// - Nikos 20181001
|
||||
SetUniformFloat(context, @"uGammaCorrect", (float)gammaCorrect);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,8 @@ SOFTWARE.
|
|||
- (float) oo_parallaxScale;
|
||||
- (float) oo_parallaxBias;
|
||||
|
||||
- (BOOL) oo_gammaCorrect;
|
||||
|
||||
- (float) oo_gloss;
|
||||
|
||||
- (int) oo_specularExponent;
|
||||
|
@ -90,6 +92,8 @@ extern NSString * const kOOMaterialEmissionAndIlluminationMapName;
|
|||
extern NSString * const kOOMaterialParallaxScaleName;
|
||||
extern NSString * const kOOMaterialParallaxBiasName;
|
||||
|
||||
extern NSString * const kOOMaterialGammaCorrName;
|
||||
|
||||
extern NSString * const kOOMaterialGlossName;
|
||||
|
||||
extern NSString * const kOOMaterialSpecularExponentName;
|
||||
|
|
|
@ -59,6 +59,8 @@ NSString * const kOOMaterialEmissionAndIlluminationMapName = @"emission_and_illu
|
|||
NSString * const kOOMaterialParallaxScaleName = @"parallax_scale";
|
||||
NSString * const kOOMaterialParallaxBiasName = @"parallax_bias";
|
||||
|
||||
NSString * const kOOMaterialGammaCorrectName = @"gamma_correct";
|
||||
|
||||
NSString * const kOOMaterialGlossName = @"gloss";
|
||||
|
||||
NSString * const kOOMaterialSpecularExponentName = @"specular_exponent";
|
||||
|
@ -234,6 +236,12 @@ NSString * const kOOMaterialLightMapsName = @"light_map";
|
|||
}
|
||||
|
||||
|
||||
- (BOOL) oo_gammaCorrect
|
||||
{
|
||||
return [self oo_boolForKey:kOOMaterialGammaCorrectName defaultValue:![[NSUserDefaults standardUserDefaults] boolForKey:@"no-gamma-correct"]];
|
||||
}
|
||||
|
||||
|
||||
- (float) oo_gloss
|
||||
{
|
||||
return OOClamp_0_1_f([self oo_floatForKey:kOOMaterialGlossName defaultValue:0.375f]);
|
||||
|
|
|
@ -259,13 +259,20 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||
|
||||
if (OK)
|
||||
{
|
||||
// write gloss and index of refraction to the uniforms dictionary
|
||||
// write gloss and gamma correction preference to the uniforms dictionary
|
||||
|
||||
if (![uniforms objectForKey:@"uGloss"])
|
||||
{
|
||||
float gloss = OOClamp_0_1_f([configuration oo_floatForKey:@"gloss" defaultValue:0.5f]);
|
||||
[self setUniform:@"uGloss" floatValue:gloss];
|
||||
}
|
||||
|
||||
if (![uniforms objectForKey:@"uGammaCorrect"])
|
||||
{
|
||||
BOOL gammaCorrect = [configuration oo_boolForKey:@"gamma_correct"
|
||||
defaultValue:![[NSUserDefaults standardUserDefaults] boolForKey:@"no-gamma-correct"]];
|
||||
[self setUniform:@"uGammaCorrect" floatValue:(float)gammaCorrect];
|
||||
}
|
||||
}
|
||||
|
||||
if (!OK)
|
||||
|
|
Loading…
Reference in New Issue