Merge pull request #1887 from Azaezel/hdrCleanups

HDR review: remove from reflections, kill depth check, order of ops
This commit is contained in:
Areloch 2016-12-27 22:10:41 -06:00 committed by GitHub
commit 50c856f797
10 changed files with 47 additions and 67 deletions

View file

@ -22,7 +22,7 @@
/// Blends between the scene and the tone mapped scene. /// Blends between the scene and the tone mapped scene.
$HDRPostFX::enableToneMapping = 1.0; $HDRPostFX::enableToneMapping = 0.5;
/// The tone mapping middle grey or exposure value used /// The tone mapping middle grey or exposure value used
/// to adjust the overall "balance" of the image. /// to adjust the overall "balance" of the image.
@ -318,7 +318,7 @@ function HDRPostFX::onDisabled( %this )
GammaPostFX.enable(); GammaPostFX.enable();
// Restore the non-HDR offscreen surface format. // Restore the non-HDR offscreen surface format.
%format = "GFXFormatR8G8B8A8"; %format = getBestHDRFormat();
AL_FormatToken.format = %format; AL_FormatToken.format = %format;
setReflectFormat( %format ); setReflectFormat( %format );
@ -333,7 +333,7 @@ function HDRPostFX::onDisabled( %this )
singleton PostEffect( HDRPostFX ) singleton PostEffect( HDRPostFX )
{ {
isEnabled = false; isEnabled = false;
allowReflectPass = true; allowReflectPass = false;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff
// and before we resolve the scene to the backbuffer. // and before we resolve the scene to the backbuffer.
@ -359,7 +359,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownScale4x4Shader; shader = HDR_DownScale4x4Shader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -370,7 +370,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "bloomH"; internalName = "bloomH";
shader = HDR_BloomGaussBlurHShader; shader = HDR_BloomGaussBlurHShader;
@ -382,7 +382,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "bloomV"; internalName = "bloomV";
shader = HDR_BloomGaussBlurVShader; shader = HDR_BloomGaussBlurVShader;
@ -397,7 +397,7 @@ singleton PostEffect( HDRPostFX )
// Now calculate the adapted luminance. // Now calculate the adapted luminance.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "adaptLum"; internalName = "adaptLum";
shader = HDR_SampleLumShader; shader = HDR_SampleLumShader;
@ -409,7 +409,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -420,7 +420,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -431,7 +431,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -445,7 +445,7 @@ singleton PostEffect( HDRPostFX )
// one... PostEffect takes care to manage that. // one... PostEffect takes care to manage that.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "finalLum"; internalName = "finalLum";
shader = HDR_CalcAdaptedLumShader; shader = HDR_CalcAdaptedLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
@ -462,7 +462,7 @@ singleton PostEffect( HDRPostFX )
// version of the scene. // version of the scene.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "combinePass"; internalName = "combinePass";
shader = HDR_CombineShader; shader = HDR_CombineShader;
@ -471,7 +471,6 @@ singleton PostEffect( HDRPostFX )
texture[1] = "#adaptedLum"; texture[1] = "#adaptedLum";
texture[2] = "#bloomFinal"; texture[2] = "#bloomFinal";
texture[3] = $HDRPostFX::colorCorrectionRamp; texture[3] = $HDRPostFX::colorCorrectionRamp;
texture[4] = "#prepass";
target = "$backBuffer"; target = "$backBuffer";
}; };
}; };

View file

@ -41,7 +41,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b; color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b;
// Apply gamma correction // Apply gamma correction
color.rgb = pow( abs(color.rgb), OneOverGamma ); color.rgb = pow( saturate(color.rgb), OneOverGamma );
// Apply contrast // Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f; color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -45,7 +45,7 @@ void main()
color.b = texture( colorCorrectionTex, color.b ).b; color.b = texture( colorCorrectionTex, color.b ).b;
// Apply gamma correction // Apply gamma correction
color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) ); color.rgb = pow( clamp(color.rgb, vec3(0.0),vec3(1.0)), vec3(OneOverGamma) );
// Apply contrast // Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f; color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -28,7 +28,6 @@ TORQUE_UNIFORM_SAMPLER2D(sceneTex, 0);
TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1); TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2); TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2);
TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3); TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 4);
uniform float2 texSize0; uniform float2 texSize0;
uniform float2 texSize2; uniform float2 texSize2;
@ -40,7 +39,6 @@ uniform float g_fEnableBlueShift;
uniform float3 g_fBlueShiftColor; uniform float3 g_fBlueShiftColor;
uniform float g_fBloomScale; uniform float g_fBloomScale;
uniform float g_fOneOverGamma; uniform float g_fOneOverGamma;
uniform float Brightness; uniform float Brightness;
uniform float Contrast; uniform float Contrast;
@ -71,6 +69,9 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
bloom.rgb = lerp( bloom.rgb, rodColor, coef ); bloom.rgb = lerp( bloom.rgb, rodColor, coef );
} }
// Add the bloom effect.
sample += g_fBloomScale * bloom;
// Map the high range of color values into a range appropriate for // Map the high range of color values into a range appropriate for
// display, taking into account the user's adaptation level, // display, taking into account the user's adaptation level,
// white point, and selected value for for middle gray. // white point, and selected value for for middle gray.
@ -82,19 +83,13 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
sample.rgb = lerp( sample.rgb, sample.rgb * toneScalar, g_fEnableToneMapping ); sample.rgb = lerp( sample.rgb, sample.rgb * toneScalar, g_fEnableToneMapping );
} }
// Add the bloom effect.
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
sample += g_fBloomScale * bloom;
// Apply the color correction. // Apply the color correction.
sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r; sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r;
sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g; sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g;
sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b; sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b;
// Apply gamma correction // Apply gamma correction
sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma ); sample.rgb = pow( saturate(sample.rgb), g_fOneOverGamma );
// Apply contrast // Apply contrast
sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f; sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -29,7 +29,6 @@ uniform sampler2D sceneTex;
uniform sampler2D luminanceTex; uniform sampler2D luminanceTex;
uniform sampler2D bloomTex; uniform sampler2D bloomTex;
uniform sampler1D colorCorrectionTex; uniform sampler1D colorCorrectionTex;
uniform sampler2D prepassTex;
uniform vec2 texSize0; uniform vec2 texSize0;
uniform vec2 texSize2; uniform vec2 texSize2;
@ -49,7 +48,6 @@ uniform float Contrast;
out vec4 OUT_col; out vec4 OUT_col;
void main() void main()
{ {
vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) ); vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) );
@ -76,6 +74,9 @@ void main()
bloom.rgb = mix( bloom.rgb, rodColor, coef ); bloom.rgb = mix( bloom.rgb, rodColor, coef );
} }
// Add the bloom effect.
_sample += g_fBloomScale * bloom;
// Map the high range of color values into a range appropriate for // Map the high range of color values into a range appropriate for
// display, taking into account the user's adaptation level, // display, taking into account the user's adaptation level,
// white point, and selected value for for middle gray. // white point, and selected value for for middle gray.
@ -87,18 +88,13 @@ void main()
_sample.rgb = mix( _sample.rgb, _sample.rgb * toneScalar, g_fEnableToneMapping ); _sample.rgb = mix( _sample.rgb, _sample.rgb * toneScalar, g_fEnableToneMapping );
} }
// Add the bloom effect.
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
if (depth>0.9999)
_sample += g_fBloomScale * bloom;
// Apply the color correction. // Apply the color correction.
_sample.r = texture( colorCorrectionTex, _sample.r ).r; _sample.r = texture( colorCorrectionTex, _sample.r ).r;
_sample.g = texture( colorCorrectionTex, _sample.g ).g; _sample.g = texture( colorCorrectionTex, _sample.g ).g;
_sample.b = texture( colorCorrectionTex, _sample.b ).b; _sample.b = texture( colorCorrectionTex, _sample.b ).b;
// Apply gamma correction // Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) ); _sample.rgb = pow( _sample.rgb, vec3(g_fOneOverGamma) );
// Apply contrast // Apply contrast
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f; _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -22,7 +22,7 @@
/// Blends between the scene and the tone mapped scene. /// Blends between the scene and the tone mapped scene.
$HDRPostFX::enableToneMapping = 1.0; $HDRPostFX::enableToneMapping = 0.5;
/// The tone mapping middle grey or exposure value used /// The tone mapping middle grey or exposure value used
/// to adjust the overall "balance" of the image. /// to adjust the overall "balance" of the image.
@ -333,7 +333,7 @@ function HDRPostFX::onDisabled( %this )
singleton PostEffect( HDRPostFX ) singleton PostEffect( HDRPostFX )
{ {
isEnabled = false; isEnabled = false;
allowReflectPass = true; allowReflectPass = false;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff
// and before we resolve the scene to the backbuffer. // and before we resolve the scene to the backbuffer.
@ -359,7 +359,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownScale4x4Shader; shader = HDR_DownScale4x4Shader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -370,7 +370,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "bloomH"; internalName = "bloomH";
shader = HDR_BloomGaussBlurHShader; shader = HDR_BloomGaussBlurHShader;
@ -382,7 +382,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "bloomV"; internalName = "bloomV";
shader = HDR_BloomGaussBlurVShader; shader = HDR_BloomGaussBlurVShader;
@ -397,7 +397,7 @@ singleton PostEffect( HDRPostFX )
// Now calculate the adapted luminance. // Now calculate the adapted luminance.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "adaptLum"; internalName = "adaptLum";
shader = HDR_SampleLumShader; shader = HDR_SampleLumShader;
@ -409,7 +409,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -420,7 +420,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -431,7 +431,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -445,7 +445,7 @@ singleton PostEffect( HDRPostFX )
// one... PostEffect takes care to manage that. // one... PostEffect takes care to manage that.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "finalLum"; internalName = "finalLum";
shader = HDR_CalcAdaptedLumShader; shader = HDR_CalcAdaptedLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
@ -462,7 +462,7 @@ singleton PostEffect( HDRPostFX )
// version of the scene. // version of the scene.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true; allowReflectPass = false;
internalName = "combinePass"; internalName = "combinePass";
shader = HDR_CombineShader; shader = HDR_CombineShader;
@ -471,7 +471,6 @@ singleton PostEffect( HDRPostFX )
texture[1] = "#adaptedLum"; texture[1] = "#adaptedLum";
texture[2] = "#bloomFinal"; texture[2] = "#bloomFinal";
texture[3] = $HDRPostFX::colorCorrectionRamp; texture[3] = $HDRPostFX::colorCorrectionRamp;
texture[4] = "#prepass";
target = "$backBuffer"; target = "$backBuffer";
}; };
}; };

View file

@ -41,7 +41,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b; color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b;
// Apply gamma correction // Apply gamma correction
color.rgb = pow( abs(color.rgb), OneOverGamma ); color.rgb = pow( saturate(color.rgb), OneOverGamma );
// Apply contrast // Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f; color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -45,7 +45,7 @@ void main()
color.b = texture( colorCorrectionTex, color.b ).b; color.b = texture( colorCorrectionTex, color.b ).b;
// Apply gamma correction // Apply gamma correction
color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) ); color.rgb = pow( clamp(color.rgb, vec3(0.0),vec3(1.0)), vec3(OneOverGamma) );
// Apply contrast // Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f; color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -28,7 +28,6 @@ TORQUE_UNIFORM_SAMPLER2D(sceneTex, 0);
TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1); TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2); TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2);
TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3); TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 4);
uniform float2 texSize0; uniform float2 texSize0;
uniform float2 texSize2; uniform float2 texSize2;
@ -40,7 +39,6 @@ uniform float g_fEnableBlueShift;
uniform float3 g_fBlueShiftColor; uniform float3 g_fBlueShiftColor;
uniform float g_fBloomScale; uniform float g_fBloomScale;
uniform float g_fOneOverGamma; uniform float g_fOneOverGamma;
uniform float Brightness; uniform float Brightness;
uniform float Contrast; uniform float Contrast;
@ -71,6 +69,9 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
bloom.rgb = lerp( bloom.rgb, rodColor, coef ); bloom.rgb = lerp( bloom.rgb, rodColor, coef );
} }
// Add the bloom effect.
sample += g_fBloomScale * bloom;
// Map the high range of color values into a range appropriate for // Map the high range of color values into a range appropriate for
// display, taking into account the user's adaptation level, // display, taking into account the user's adaptation level,
// white point, and selected value for for middle gray. // white point, and selected value for for middle gray.
@ -82,19 +83,13 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
sample.rgb = lerp( sample.rgb, sample.rgb * toneScalar, g_fEnableToneMapping ); sample.rgb = lerp( sample.rgb, sample.rgb * toneScalar, g_fEnableToneMapping );
} }
// Add the bloom effect.
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
sample += g_fBloomScale * bloom;
// Apply the color correction. // Apply the color correction.
sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r; sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r;
sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g; sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g;
sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b; sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b;
// Apply gamma correction // Apply gamma correction
sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma ); sample.rgb = pow( saturate(sample.rgb), g_fOneOverGamma );
// Apply contrast // Apply contrast
sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f; sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -29,7 +29,6 @@ uniform sampler2D sceneTex;
uniform sampler2D luminanceTex; uniform sampler2D luminanceTex;
uniform sampler2D bloomTex; uniform sampler2D bloomTex;
uniform sampler1D colorCorrectionTex; uniform sampler1D colorCorrectionTex;
uniform sampler2D prepassTex;
uniform vec2 texSize0; uniform vec2 texSize0;
uniform vec2 texSize2; uniform vec2 texSize2;
@ -49,7 +48,6 @@ uniform float Contrast;
out vec4 OUT_col; out vec4 OUT_col;
void main() void main()
{ {
vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) ); vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) );
@ -76,6 +74,9 @@ void main()
bloom.rgb = mix( bloom.rgb, rodColor, coef ); bloom.rgb = mix( bloom.rgb, rodColor, coef );
} }
// Add the bloom effect.
_sample += g_fBloomScale * bloom;
// Map the high range of color values into a range appropriate for // Map the high range of color values into a range appropriate for
// display, taking into account the user's adaptation level, // display, taking into account the user's adaptation level,
// white point, and selected value for for middle gray. // white point, and selected value for for middle gray.
@ -87,18 +88,13 @@ void main()
_sample.rgb = mix( _sample.rgb, _sample.rgb * toneScalar, g_fEnableToneMapping ); _sample.rgb = mix( _sample.rgb, _sample.rgb * toneScalar, g_fEnableToneMapping );
} }
// Add the bloom effect.
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
if (depth>0.9999)
_sample += g_fBloomScale * bloom;
// Apply the color correction. // Apply the color correction.
_sample.r = texture( colorCorrectionTex, _sample.r ).r; _sample.r = texture( colorCorrectionTex, _sample.r ).r;
_sample.g = texture( colorCorrectionTex, _sample.g ).g; _sample.g = texture( colorCorrectionTex, _sample.g ).g;
_sample.b = texture( colorCorrectionTex, _sample.b ).b; _sample.b = texture( colorCorrectionTex, _sample.b ).b;
// Apply gamma correction // Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) ); _sample.rgb = pow( _sample.rgb, vec3(g_fOneOverGamma) );
// Apply contrast // Apply contrast
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f; _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;