浏览代码

* Implementation of sRGB image support. Overhauls the linearization setup to utilize the sRGB image types, as well as refactors the use of ColorF and ColorI to be properly internally consistent. ColorIs are used only for front-facing/editing/UI settings, and ColorFs, now renamed to LinearColorF to reduce confusion of purpose, are used for color info in the engine itself. This avoids confusing and expensive conversions back and forth between types and avoids botches with linearity. Majority work done by @rextimmy

Areloch 8 年之前
父节点
当前提交
d07abe8ad2
共有 41 个文件被更改,包括 69 次插入184 次删除
  1. 1 0
      Templates/BaseGame/game/core/lighting/advanced/deferredShading.cs
  2. 10 10
      Templates/BaseGame/game/core/lighting/advanced/shaders.cs
  3. 2 3
      Templates/BaseGame/game/core/postFX/GammaPostFX.cs
  4. 0 4
      Templates/BaseGame/game/core/postFX/hdr.cs
  5. 2 1
      Templates/BaseGame/game/core/renderManager.cs
  6. 1 1
      Templates/BaseGame/game/core/shaders/VolumetricFog/VFogP.hlsl
  7. 2 2
      Templates/BaseGame/game/core/shaders/gl/particlesP.glsl
  8. 1 1
      Templates/BaseGame/game/core/shaders/lighting/advanced/deferredShadingP.hlsl
  9. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/gl/pointLightP.glsl
  10. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/gl/spotLightP.glsl
  11. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/gl/vectorLightP.glsl
  12. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/particlePointLightP.hlsl
  13. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/pointLightP.hlsl
  14. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/spotLightP.hlsl
  15. 2 2
      Templates/BaseGame/game/core/shaders/lighting/advanced/vectorLightP.hlsl
  16. 3 3
      Templates/BaseGame/game/core/shaders/particlesP.hlsl
  17. 3 3
      Templates/BaseGame/game/core/shaders/postFX/caustics/causticsP.hlsl
  18. 3 3
      Templates/BaseGame/game/core/shaders/postFX/caustics/gl/causticsP.glsl
  19. 4 4
      Templates/BaseGame/game/core/shaders/postFX/dof/DOF_DownSample_P.hlsl
  20. 2 2
      Templates/BaseGame/game/core/shaders/postFX/dof/DOF_Final_P.hlsl
  21. 1 1
      Templates/BaseGame/game/core/shaders/postFX/edgeaa/edgeDetectP.hlsl
  22. 2 2
      Templates/BaseGame/game/core/shaders/postFX/fogP.hlsl
  23. 0 3
      Templates/BaseGame/game/core/shaders/postFX/gammaP.hlsl
  24. 1 1
      Templates/BaseGame/game/core/shaders/postFX/gl/fogP.glsl
  25. 0 3
      Templates/BaseGame/game/core/shaders/postFX/gl/gammaP.glsl
  26. 0 9
      Templates/BaseGame/game/core/shaders/postFX/hdr/finalPassCombineP.hlsl
  27. 0 9
      Templates/BaseGame/game/core/shaders/postFX/hdr/gl/finalPassCombineP.glsl
  28. 1 1
      Templates/BaseGame/game/core/shaders/postFX/lightRay/lightRayOccludeP.hlsl
  29. 1 1
      Templates/BaseGame/game/core/shaders/postFX/motionBlurP.hlsl
  30. 2 2
      Templates/BaseGame/game/core/shaders/postFX/ssao/SSAO_Blur_P.hlsl
  31. 5 5
      Templates/BaseGame/game/core/shaders/postFX/ssao/SSAO_P.hlsl
  32. 1 1
      Templates/BaseGame/game/core/shaders/postFX/underwaterFogP.hlsl
  33. 2 2
      Templates/BaseGame/game/core/shaders/shaderModelAutoGen.hlsl
  34. 0 1
      Templates/BaseGame/game/core/shaders/water/gl/waterBasicP.glsl
  35. 0 1
      Templates/BaseGame/game/core/shaders/water/gl/waterP.glsl
  36. 0 1
      Templates/BaseGame/game/core/shaders/water/waterBasicP.hlsl
  37. 3 4
      Templates/BaseGame/game/core/shaders/water/waterP.hlsl
  38. 0 59
      Templates/BaseGame/game/data/ui/scripts/guis/optionsMenu.gui
  39. 0 25
      Templates/BaseGame/game/tools/gui/colorPicker.ed.gui
  40. 1 1
      Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.hlsl
  41. 1 1
      Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.hlsl

+ 1 - 0
Templates/BaseGame/game/core/lighting/advanced/deferredShading.cs

@@ -35,6 +35,7 @@ new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
    samplerStates[1] = SamplerWrapLinear;
    samplerStates[2] = SamplerWrapLinear;
    samplerStates[3] = SamplerWrapLinear;
+   samplerStates[4] = SamplerWrapLinear;
 };
 
 new ShaderData( AL_DeferredShader )

+ 10 - 10
Templates/BaseGame/game/core/lighting/advanced/shaders.cs

@@ -36,7 +36,7 @@ new GFXStateBlockData( AL_VectorLightState )
 
    samplersDefined = true;
    samplerStates[0] = SamplerClampPoint;  // G-buffer
-   mSamplerNames[0] = "prePassBuffer";
+   mSamplerNames[0] = "deferredBuffer";
    samplerStates[1] = SamplerClampPoint;  // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
    mSamplerNames[1] = "shadowMap";
    samplerStates[2] = SamplerClampPoint;  // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
@@ -66,7 +66,7 @@ new ShaderData( AL_VectorLightShader )
    OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/farFrustumQuadV.glsl";
    OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/vectorLightP.glsl";
    
-   samplerNames[0] = "$prePassBuffer";
+   samplerNames[0] = "$deferredBuffer";
    samplerNames[1] = "$shadowMap";
    samplerNames[2] = "$dynamicShadowMap";
    samplerNames[3] = "$ssaoMask";
@@ -83,7 +83,7 @@ new CustomMaterial( AL_VectorLightMaterial )
    shader = AL_VectorLightShader;
    stateBlock = AL_VectorLightState;
    
-   sampler["prePassBuffer"] = "#deferred";
+   sampler["deferredBuffer"] = "#deferred";
    sampler["shadowMap"] = "$dynamiclight";
    sampler["dynamicShadowMap"] = "$dynamicShadowMap";
    sampler["ssaoMask"] = "#ssaoMask";  
@@ -114,7 +114,7 @@ new GFXStateBlockData( AL_ConvexLightState )
 
    samplersDefined = true;
    samplerStates[0] = SamplerClampPoint;  // G-buffer
-   mSamplerNames[0] = "prePassBuffer";
+   mSamplerNames[0] = "deferredBuffer";
    samplerStates[1] = SamplerClampPoint;  // Shadow Map (Do not use linear, these are perspective projections)
    mSamplerNames[1] = "shadowMap";
    samplerStates[2] = SamplerClampPoint;  // Shadow Map (Do not use linear, these are perspective projections)
@@ -143,7 +143,7 @@ new ShaderData( AL_PointLightShader )
    OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
    OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
 
-   samplerNames[0] = "$prePassBuffer";
+   samplerNames[0] = "$deferredBuffer";
    samplerNames[1] = "$shadowMap";
    samplerNames[2] = "$dynamicShadowMap";
    samplerNames[3] = "$cookieMap";
@@ -160,7 +160,7 @@ new CustomMaterial( AL_PointLightMaterial )
    shader = AL_PointLightShader;
    stateBlock = AL_ConvexLightState;
    
-   sampler["prePassBuffer"] = "#deferred";
+   sampler["deferredBuffer"] = "#deferred";
    sampler["shadowMap"] = "$dynamiclight";
    sampler["dynamicShadowMap"] = "$dynamicShadowMap";
    sampler["cookieMap"] = "$dynamiclightmask";
@@ -182,7 +182,7 @@ new ShaderData( AL_SpotLightShader )
    OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
    OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/spotLightP.glsl";
    
-   samplerNames[0] = "$prePassBuffer";
+   samplerNames[0] = "$deferredBuffer";
    samplerNames[1] = "$shadowMap";
    samplerNames[2] = "$dynamicShadowMap";
    samplerNames[3] = "$cookieMap";
@@ -199,7 +199,7 @@ new CustomMaterial( AL_SpotLightMaterial )
    shader = AL_SpotLightShader;
    stateBlock = AL_ConvexLightState;
    
-   sampler["prePassBuffer"] = "#deferred";
+   sampler["deferredBuffer"] = "#deferred";
    sampler["shadowMap"] = "$dynamiclight";
    sampler["dynamicShadowMap"] = "$dynamicShadowMap";
    sampler["cookieMap"] = "$dynamiclightmask";
@@ -259,7 +259,7 @@ new ShaderData( AL_ParticlePointLightShader )
    OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
    OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
    
-   samplerNames[0] = "$prePassBuffer";   
+   samplerNames[0] = "$deferredBuffer";   
       
    pixVersion = 3.0;
 };
@@ -269,7 +269,7 @@ new CustomMaterial( AL_ParticlePointLightMaterial )
    shader = AL_ParticlePointLightShader;
    stateBlock = AL_ConvexLightState;
    
-   sampler["prePassBuffer"] = "#deferred";
+   sampler["deferredBuffer"] = "#deferred";
    target = "lightinfo";
    
    pixVersion = 3.0;

+ 2 - 3
Templates/BaseGame/game/core/postFX/GammaPostFX.cs

@@ -48,15 +48,14 @@ singleton PostEffect( GammaPostFX )
    
    renderTime = "PFXBeforeBin";
    renderBin = "EditorBin";
-   renderPriority = 9999;
+   renderPriority = 9998;
       
    shader = GammaShader;
    stateBlock = GammaStateBlock;
    
    texture[0] = "$backBuffer";  
    texture[1] = $HDRPostFX::colorCorrectionRamp;  
-   
-   targetFormat = getBestHDRFormat();
+   textureSRGB[1] = true;
 };
 
 function GammaPostFX::preProcess( %this )

+ 0 - 4
Templates/BaseGame/game/core/postFX/hdr.cs

@@ -273,10 +273,6 @@ function HDRPostFX::preProcess( %this )
 
 function HDRPostFX::onEnabled( %this )
 {
-   // We don't allow hdr on OSX yet.
-   if ( $platform $= "macos" )
-      return false;
-      
    // See what HDR format would be best.
    %format = getBestHDRFormat();
    if ( %format $= "" || %format $= "GFXFormatR8G8B8A8" )

+ 2 - 1
Templates/BaseGame/game/core/renderManager.cs

@@ -33,7 +33,8 @@ function initRenderManager()
    {
       enabled = "false";
       
-      format = getBestHDRFormat();
+      //When hdr is enabled this will be changed to the appropriate format
+      format = "GFXFormatR8G8B8A8_SRGB";
       depthFormat = "GFXFormatD24S8";
       aaLevel = 0; // -1 = match backbuffer
       

+ 1 - 1
Templates/BaseGame/game/core/shaders/VolumetricFog/VFogP.hlsl

@@ -56,7 +56,7 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
 	float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
 	uvscreen.y = 1.0 - uvscreen.y;
 	
-   float obj_test = TORQUE_PREPASS_UNCONDITION(deferredTex, uvscreen).w * preBias;
+   float obj_test = TORQUE_DEFERRED_UNCONDITION(deferredTex, uvscreen).w * preBias;
    float depth = TORQUE_TEX2D(depthBuffer, uvscreen).r;
    float front = TORQUE_TEX2D(frontBuffer, uvscreen).r;
 

+ 2 - 2
Templates/BaseGame/game/core/shaders/gl/particlesP.glsl

@@ -36,7 +36,7 @@
    uniform float oneOverFar;
    uniform sampler2D deferredTex;   
    //uniform vec3 vEye;
-   uniform vec4 prePassTargetParams;
+   uniform vec4 deferredTargetParams;
 #endif
 
 #define CLIP_Z // TODO: Make this a proper macro
@@ -86,7 +86,7 @@ void main()
    
    #ifdef SOFTPARTICLES
       vec2 tc = IN_pos.xy * vec2(1.0, -1.0) / IN_pos.w;
-      tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams); 
+      tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), deferredTargetParams); 
    
    	float sceneDepth = deferredUncondition( deferredTex, tc ).w;   	   	   			
    	float depth = IN_pos.w * oneOverFar;   	

+ 1 - 1
Templates/BaseGame/game/core/shaders/lighting/advanced/deferredShadingP.hlsl

@@ -35,7 +35,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    float4 colorBuffer = TORQUE_TEX2D( colorBufferTex, IN.uv0 );
    float4 matInfo = TORQUE_TEX2D( matInfoTex, IN.uv0 );
    float specular = saturate(lightBuffer.a);
-   float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
+   float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
 
    if (depth>0.9999)
       return float4(0,0,0,0);

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/gl/pointLightP.glsl

@@ -103,7 +103,7 @@ uniform samplerCube cookieMap ;
 
 #endif
 
-uniform sampler2D prePassBuffer;
+uniform sampler2D deferredBuffer;
 
 #ifdef SHADOW_CUBE
 	uniform samplerCube shadowMap;
@@ -159,7 +159,7 @@ void main()
 	}
 	
    // Sample/unpack the normal/z data
-   vec4 deferredSample = deferredUncondition( prePassBuffer, uvScene );
+   vec4 deferredSample = deferredUncondition( deferredBuffer, uvScene );
    vec3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
    

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/gl/spotLightP.glsl

@@ -46,7 +46,7 @@ uniform sampler2D cookieMap;
 
 #endif
 
-uniform sampler2D prePassBuffer;
+uniform sampler2D deferredBuffer;
 uniform sampler2D shadowMap;
 uniform sampler2D dynamicShadowMap;
 
@@ -101,7 +101,7 @@ void main()
 	}
 	
    // Sample/unpack the normal/z data
-   vec4 deferredSample = deferredUncondition( prePassBuffer, uvScene );
+   vec4 deferredSample = deferredUncondition( deferredBuffer, uvScene );
    vec3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
    

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/gl/vectorLightP.glsl

@@ -42,7 +42,7 @@ uniform sampler2D ssaoMask ;
 uniform vec4 rtParams3;
 #endif
 
-uniform sampler2D prePassBuffer;
+uniform sampler2D deferredBuffer;
 uniform sampler2D lightBuffer;
 uniform sampler2D colorBuffer;
 uniform sampler2D matInfoBuffer;             
@@ -214,7 +214,7 @@ void main()
 	}
 	
    // Sample/unpack the normal/z data
-   vec4 deferredSample = deferredUncondition( prePassBuffer, uv0 );
+   vec4 deferredSample = deferredUncondition( deferredBuffer, uv0 );
    vec3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
 

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/particlePointLightP.hlsl

@@ -34,7 +34,7 @@ struct ConvexConnectP
    float3 vsEyeDir : TEXCOORD1;
 };
 
-TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
+TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
 
 uniform float4 lightPosition;
 uniform float4 lightColor;
@@ -49,7 +49,7 @@ float4 main(   ConvexConnectP IN ) : TORQUE_TARGET0
    float2 uvScene = getUVFromSSPos(ssPos, rtParams0);
    
    // Sample/unpack the normal/z data
-   float4 deferredSample = TORQUE_PREPASS_UNCONDITION(prePassBuffer, uvScene);
+   float4 deferredSample = TORQUE_DEFERRED_UNCONDITION(deferredBuffer, uvScene);
    float3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
    

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/pointLightP.hlsl

@@ -106,7 +106,7 @@ TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3);
 
 #endif
 
-TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
+TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
 
 #ifdef SHADOW_CUBE
 TORQUE_UNIFORM_SAMPLERCUBE(shadowMap, 1);
@@ -161,7 +161,7 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
 	}
    
    // Sample/unpack the normal/z data
-   float4 deferredSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
+   float4 deferredSample = TORQUE_DEFERRED_UNCONDITION( deferredBuffer, uvScene );
    float3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
    

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/spotLightP.hlsl

@@ -38,7 +38,7 @@ struct ConvexConnectP
    float4 vsEyeDir : TEXCOORD2;
 };
 
-TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
+TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
 TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
 TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap,2);
 
@@ -99,7 +99,7 @@ float4 main(   ConvexConnectP IN ) : TORQUE_TARGET0
 	}
 	
    // Sample/unpack the normal/z data
-   float4 deferredSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
+   float4 deferredSample = TORQUE_DEFERRED_UNCONDITION( deferredBuffer, uvScene );
    float3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
    

+ 2 - 2
Templates/BaseGame/game/core/shaders/lighting/advanced/vectorLightP.hlsl

@@ -30,7 +30,7 @@
 #include "../shadowMap/shadowMapIO_HLSL.h"
 #include "softShadow.hlsl"
 
-TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
+TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
 TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
 TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap, 2);
 
@@ -213,7 +213,7 @@ float4 main( FarFrustumQuadConnectP IN ) : TORQUE_TARGET0
          subsurface = float3(0.337255, 0.772549, 0.262745);
 	}
    // Sample/unpack the normal/z data
-   float4 deferredSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, IN.uv0 );
+   float4 deferredSample = TORQUE_DEFERRED_UNCONDITION( deferredBuffer, IN.uv0 );
    float3 normal = deferredSample.rgb;
    float depth = deferredSample.a;
 

+ 3 - 3
Templates/BaseGame/game/core/shaders/particlesP.hlsl

@@ -35,7 +35,7 @@
    uniform float oneOverFar;
    TORQUE_UNIFORM_SAMPLER2D(deferredTex, 1);
    //uniform float3 vEye;
-   uniform float4 prePassTargetParams;
+   uniform float4 deferredTargetParams;
 #endif
 
 #define CLIP_Z // TODO: Make this a proper macro
@@ -82,9 +82,9 @@ float4 main( Conn IN ) : TORQUE_TARGET0
    
    #ifdef SOFTPARTICLES
       float2 tc = IN.pos.xy * float2(1.0, -1.0) / IN.pos.w;
-      tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams); 
+      tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), deferredTargetParams); 
    
-      float sceneDepth = TORQUE_PREPASS_UNCONDITION(deferredTex, tc).w;
+      float sceneDepth = TORQUE_DEFERRED_UNCONDITION(deferredTex, tc).w;
    	float depth = IN.pos.w * oneOverFar;   	
 	float diff = sceneDepth - depth;
 	#ifdef CLIP_Z

+ 3 - 3
Templates/BaseGame/game/core/shaders/postFX/caustics/causticsP.hlsl

@@ -40,10 +40,10 @@ float distanceToPlane(float4 plane, float3 pos)
 float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {   
    //Sample the pre-pass
-   float4 prePass = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 );
+   float4 deferred = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 );
    
    //Get depth
-   float depth = prePass.w;   
+   float depth = deferred.w;   
    if(depth > 0.9999)
       return float4(0,0,0,0);
    
@@ -71,7 +71,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    
    //Use normal Z to modulate caustics  
    //float waterDepth = 1 - saturate(pos.z + waterFogPlane.w + 1);
-   caustics *= saturate(prePass.z) * pow(abs(1-depth), 64) * waterDepth; 
+   caustics *= saturate(deferred.z) * pow(abs(1-depth), 64) * waterDepth; 
       
    return caustics;   
 }

+ 3 - 3
Templates/BaseGame/game/core/shaders/postFX/caustics/gl/causticsP.glsl

@@ -44,10 +44,10 @@ float distanceToPlane(vec4 plane, vec3 pos)
 void main()             
 {   
    //Sample the pre-pass
-   vec4 prePass = deferredUncondition( deferredTex, IN_uv0 );
+   vec4 deferred = deferredUncondition( deferredTex, IN_uv0 );
    
    //Get depth
-   float depth = prePass.w;   
+   float depth = deferred.w;   
    if(depth > 0.9999)
    {
       OUT_col = vec4(0,0,0,0);
@@ -81,7 +81,7 @@ void main()
    
    //Use normal Z to modulate caustics  
    //float waterDepth = 1 - saturate(pos.z + waterFogPlane.w + 1);
-   caustics *= saturate(prePass.z) * pow(1-depth, 64) * waterDepth; 
+   caustics *= saturate(deferred.z) * pow(1-depth, 64) * waterDepth; 
       
    OUT_col = caustics;   
 }

+ 4 - 4
Templates/BaseGame/game/core/shaders/postFX/dof/DOF_DownSample_P.hlsl

@@ -88,10 +88,10 @@ half4 main( Pixel IN ) : TORQUE_TARGET0
    [unroll]  //  coc[i] causes this anyway
    for (int i = 0; i < 4; i++)
    {
-      depth[0] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth0.xy + rowOfs[i])).w;
-      depth[1] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth1.xy + rowOfs[i])).w;
-      depth[2] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth2.xy + rowOfs[i])).w;
-      depth[3] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth3.xy + rowOfs[i])).w;
+      depth[0] = TORQUE_DEFERRED_UNCONDITION(depthSampler, (IN.tcDepth0.xy + rowOfs[i])).w;
+      depth[1] = TORQUE_DEFERRED_UNCONDITION(depthSampler, (IN.tcDepth1.xy + rowOfs[i])).w;
+      depth[2] = TORQUE_DEFERRED_UNCONDITION(depthSampler, (IN.tcDepth2.xy + rowOfs[i])).w;
+      depth[3] = TORQUE_DEFERRED_UNCONDITION(depthSampler, (IN.tcDepth3.xy + rowOfs[i])).w;
 
       coc = max(coc, clamp(dofEqWorld4X * half4(depth)+dofEqWorld4Y, zero4, maxWorldCoC4));
    }

+ 2 - 2
Templates/BaseGame/game/core/shaders/postFX/dof/DOF_Final_P.hlsl

@@ -71,7 +71,7 @@ half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
    // d0, the small to medium blur over distance d1, and the medium to  
    // large blur over distance d2, where d0 + d1 + d2 = 1.  
    //float4 dofLerpScale = float4( -1 / d0, -1 / d1, -1 / d2, 1 / d2 );  
-   //float4 dofLerpBias = float4( 1, (1 – d2) / d1, 1 / d2, (d2 – 1) / d2 );  
+   //float4 dofLerpBias = float4( 1, (1 � d2) / d1, 1 / d2, (d2 � 1) / d2 );  
    
    weights = half4(saturate( t * dofLerpScale + dofLerpBias ));  
    weights.yz = min( weights.yz, 1 - weights.xy );  
@@ -115,7 +115,7 @@ half4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    //med.rgb = large;
    
    //nearCoc = 0;
-   depth = half(TORQUE_PREPASS_UNCONDITION( depthSampler, IN.uv3 ).w);  
+   depth = half(TORQUE_DEFERRED_UNCONDITION( depthSampler, IN.uv3 ).w);  
    //return half4(depth.rrr,1);
    //return half4(nearCoc.rrr,1.0);
    

+ 1 - 1
Templates/BaseGame/game/core/shaders/postFX/edgeaa/edgeDetectP.hlsl

@@ -50,7 +50,7 @@ float GetEdgeWeight(float2 uv0, in float2 targetSize)
    for(int i = 0; i < 9; i++)
    {
       float2 uv = uv0 + offsets[i] * PixelSize;
-      float4 gbSample = TORQUE_PREPASS_UNCONDITION( deferredBuffer, uv );
+      float4 gbSample = TORQUE_DEFERRED_UNCONDITION( deferredBuffer, uv );
       Depth[i] = gbSample.a;
       Normal[i] = gbSample.rgb;
    }

+ 2 - 2
Templates/BaseGame/game/core/shaders/postFX/fogP.hlsl

@@ -34,7 +34,7 @@ uniform float4    rtParams0;
 float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {   
    //float2 deferredCoord = ( IN.uv0.xy * rtParams0.zw ) + rtParams0.xy;   
-   float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
+   float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
    //return float4( depth, 0, 0, 0.7 );
    
    float factor = computeSceneFog( eyePosWorld,
@@ -43,5 +43,5 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
                                    fogData.y, 
                                    fogData.z );
 
-   return hdrEncode( float4( toLinear(fogColor.rgb), 1.0 - saturate( factor ) ) );     
+   return hdrEncode( float4( fogColor.rgb, 1.0 - saturate( factor ) ) );    
 }

+ 0 - 3
Templates/BaseGame/game/core/shaders/postFX/gammaP.hlsl

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

+ 1 - 1
Templates/BaseGame/game/core/shaders/postFX/gl/fogP.glsl

@@ -48,5 +48,5 @@ void main()
                                    fogData.y, 
                                    fogData.z );
 
-   OUT_col = hdrEncode( vec4( toLinear(fogColor.rgb), 1.0 - saturate( factor ) ) );     
+   OUT_col = hdrEncode( vec4( fogColor.rgb, 1.0 - saturate( factor ) ) );   
 }

+ 0 - 3
Templates/BaseGame/game/core/shaders/postFX/gl/gammaP.glsl

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

+ 0 - 9
Templates/BaseGame/game/core/shaders/postFX/hdr/finalPassCombineP.hlsl

@@ -87,15 +87,6 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r;
    sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g;
    sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b;
-	  
-   // Apply gamma correction
-   sample.rgb = pow( saturate(sample.rgb), g_fOneOverGamma );
- 
-   // Apply contrast
-   sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;
- 
-   // Apply brightness
-   sample.rgb += Brightness;
 
    return sample;
 }

+ 0 - 9
Templates/BaseGame/game/core/shaders/postFX/hdr/gl/finalPassCombineP.glsl

@@ -93,14 +93,5 @@ void main()
    _sample.g = texture( colorCorrectionTex, _sample.g ).g;
    _sample.b = texture( colorCorrectionTex, _sample.b ).b;
 
-   // Apply gamma correction
-   _sample.rgb = pow( _sample.rgb, vec3(g_fOneOverGamma) );
-   
-   // Apply contrast
-   _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;
- 
-   // Apply brightness
-   _sample.rgb += Brightness;
-
    OUT_col = _sample;
 }

+ 1 - 1
Templates/BaseGame/game/core/shaders/postFX/lightRay/lightRayOccludeP.hlsl

@@ -36,7 +36,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
     float4 col = float4( 0, 0, 0, 1 );
     
     // Get the depth at this pixel.
-    float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
+    float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
     
     // If the depth is equal to 1.0, read from the backbuffer
     // and perform the exposure calculation on the result.

+ 1 - 1
Templates/BaseGame/game/core/shaders/postFX/motionBlurP.hlsl

@@ -37,7 +37,7 @@ float4 main(PFXVertToPix IN) : TORQUE_TARGET0
    float samples = 5;
    
    // First get the deferred texture for uv channel 0
-   float4 deferred = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 );
+   float4 deferred = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 );
    
    // Next extract the depth
    float depth = deferred.a;

+ 2 - 2
Templates/BaseGame/game/core/shaders/postFX/ssao/SSAO_Blur_P.hlsl

@@ -49,7 +49,7 @@ uniform float blurNormalTol;
 void sample( float2 uv, float weight, float4 centerTap, inout int usedCount, inout float occlusion, inout float total )
 {
    //return;
-   float4 tap = TORQUE_PREPASS_UNCONDITION( deferredMap, uv );   
+   float4 tap = TORQUE_DEFERRED_UNCONDITION( deferredMap, uv );   
    
    if ( abs( tap.a - centerTap.a ) < blurDepthTol )
    {
@@ -65,7 +65,7 @@ void sample( float2 uv, float weight, float4 centerTap, inout int usedCount, ino
 float4 main( VertToPix IN ) : TORQUE_TARGET0
 {   
    //float4 centerTap;
-   float4 centerTap = TORQUE_PREPASS_UNCONDITION( deferredMap, IN.uv0.zw );
+   float4 centerTap = TORQUE_DEFERRED_UNCONDITION( deferredMap, IN.uv0.zw );
    
    //return centerTap;
    

+ 5 - 5
Templates/BaseGame/game/core/shaders/postFX/ssao/SSAO_P.hlsl

@@ -143,7 +143,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    float3 reflectNormal = normalize( TORQUE_TEX2DLOD( randNormalTex, noiseMapUV ).xyz * 2.0 - 1.0 );   
    //return float4( reflectNormal, 1 );
    
-   float4 deferred = TORQUE_PREPASS_UNCONDITION( deferredMap, IN.uv0 );
+   float4 deferred = TORQUE_DEFERRED_UNCONDITION( deferredMap, IN.uv0 );
    float3 normal = deferred.xyz;
    float depth = deferred.a;
    //return float4( ( depth ).xxx, 1 );
@@ -183,7 +183,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    //if ( radiusDepth.x < 1.0 / targetSize.x )
    //   return color;      
    //radiusDepth.xyz = 0.0009;
-   
+   [unroll]
    for ( i = 0; i < sSampleCount; i++ )
    {
       baseRay = reflect( ptSphere[i], reflectNormal );
@@ -197,7 +197,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
        
       se = ep + ray;
             
-      occluderFragment = TORQUE_PREPASS_UNCONDITION( deferredMap, se.xy );                  
+      occluderFragment = TORQUE_DEFERRED_UNCONDITION( deferredMap, se.xy );                  
       
       depthDiff = se.z - occluderFragment.a; 
       
@@ -232,7 +232,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    //if ( radiusDepth.x < 1.0 / targetSize.x )
    //   return color;      
    //radiusDepth.xyz = 0.0009;   
-   
+   [unroll]
    for ( i = sSampleCount; i < totalSampleCount; i++ )
    {
       baseRay = reflect( ptSphere[i], reflectNormal );
@@ -246,7 +246,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
        
       se = ep + ray;
             
-      occluderFragment = TORQUE_PREPASS_UNCONDITION( deferredMap, se.xy );                  
+      occluderFragment = TORQUE_DEFERRED_UNCONDITION( deferredMap, se.xy );                  
       
       depthDiff = se.z - occluderFragment.a;       
       

+ 1 - 1
Templates/BaseGame/game/core/shaders/postFX/underwaterFogP.hlsl

@@ -55,7 +55,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {    
    //float2 deferredCoord = IN.uv0;
    //IN.uv0 = ( IN.uv0.xy * rtParams0.zw ) + rtParams0.xy;
-   float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
+   float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
    //return float4( depth.rrr, 1 );
    
    // Skip fogging the extreme far plane so that 

+ 2 - 2
Templates/BaseGame/game/core/shaders/shaderModelAutoGen.hlsl

@@ -27,9 +27,9 @@
 
 // Portability helpers for autogenConditioners
 #if (TORQUE_SM >= 10 && TORQUE_SM <=30)
-   #define TORQUE_PREPASS_UNCONDITION(tex, coords) deferredUncondition(tex, coords)
+   #define TORQUE_DEFERRED_UNCONDITION(tex, coords) deferredUncondition(tex, coords)
 #elif TORQUE_SM >= 40
-   #define TORQUE_PREPASS_UNCONDITION(tex, coords) deferredUncondition(tex, texture_##tex, coords)
+   #define TORQUE_DEFERRED_UNCONDITION(tex, coords) deferredUncondition(tex, texture_##tex, coords)
 #endif
 
 #endif //_TORQUE_SHADERMODEL_AUTOGEN_

+ 0 - 1
Templates/BaseGame/game/core/shaders/water/gl/waterBasicP.glsl

@@ -120,7 +120,6 @@ void main()
 { 
    // Modulate baseColor by the ambientColor.
    vec4 waterBaseColor = baseColor * vec4( ambientColor.rgb, 1 );
-   waterBaseColor = toLinear(waterBaseColor);
    
    // Get the bumpNorm...
    vec3 bumpNorm = ( texture( bumpMap, IN_rippleTexCoord01.xy ).rgb * 2.0 - 1.0 ) * rippleMagnitude.x;

+ 0 - 1
Templates/BaseGame/game/core/shaders/water/gl/waterP.glsl

@@ -324,7 +324,6 @@ void main()
    
    // Calculate the water "base" color based on depth.
    vec4 waterBaseColor = baseColor * texture( depthGradMap, saturate( delta / depthGradMax ) );
-   waterBaseColor = toLinear(waterBaseColor);
       
    // Modulate baseColor by the ambientColor.
    waterBaseColor *= vec4( ambientColor.rgb, 1 );     

+ 0 - 1
Templates/BaseGame/game/core/shaders/water/waterBasicP.hlsl

@@ -117,7 +117,6 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
 { 
    // Modulate baseColor by the ambientColor.
    float4 waterBaseColor = baseColor * float4( ambientColor.rgb, 1 );
-   waterBaseColor = toLinear(waterBaseColor);
    
    // Get the bumpNorm...
    float3 bumpNorm = ( TORQUE_TEX2D( bumpMap, IN.rippleTexCoord01.xy ).rgb * 2.0 - 1.0 ) * rippleMagnitude.x;

+ 3 - 4
Templates/BaseGame/game/core/shaders/water/waterP.hlsl

@@ -155,7 +155,7 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
    
    float2 deferredCoord = viewportCoordToRenderTarget( IN.posPostWave, rtParams1 );
 
-   float startDepth = TORQUE_PREPASS_UNCONDITION( deferredTex, deferredCoord ).w;  
+   float startDepth = TORQUE_DEFERRED_UNCONDITION( deferredTex, deferredCoord ).w;  
    
    // The water depth in world units of the undistorted pixel.
    float startDelta = ( startDepth - pixelDepth );
@@ -180,7 +180,7 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
    deferredCoord = viewportCoordToRenderTarget( distortPos, rtParams1 );   
 
    // Get deferred depth at the position of this distorted pixel.
-   float deferredDepth = TORQUE_PREPASS_UNCONDITION( deferredTex, deferredCoord ).w;      
+   float deferredDepth = TORQUE_DEFERRED_UNCONDITION( deferredTex, deferredCoord ).w;      
    if ( deferredDepth > 0.99 )
      deferredDepth = 5.0;
     
@@ -212,7 +212,7 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
          deferredCoord = viewportCoordToRenderTarget( distortPos, rtParams1 );
 
          // Get deferred depth at the position of this distorted pixel.
-         deferredDepth = TORQUE_PREPASS_UNCONDITION( deferredTex, deferredCoord ).w;
+         deferredDepth = TORQUE_DEFERRED_UNCONDITION( deferredTex, deferredCoord ).w;
 	 if ( deferredDepth > 0.99 )
             deferredDepth = 5.0;
          delta = ( deferredDepth - pixelDepth ) * farPlaneDist;
@@ -311,7 +311,6 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
    
    // Calculate the water "base" color based on depth.
    float4 waterBaseColor = baseColor * TORQUE_TEX1D( depthGradMap, saturate( delta / depthGradMax ) );
-   waterBaseColor = toLinear(waterBaseColor);
       
    // Modulate baseColor by the ambientColor.
    waterBaseColor *= float4( ambientColor.rgb, 1 );     

+ 0 - 59
Templates/BaseGame/game/data/ui/scripts/guis/optionsMenu.gui

@@ -865,65 +865,6 @@
                      canSaveDynamicFields = "0";
                   };
                };
-               new GuiControl() {
-                  position = "0 160";
-                  extent = "450 20";
-                  minExtent = "8 2";
-                  horizSizing = "right";
-                  vertSizing = "bottom";
-                  profile = "GuiDefaultProfile";
-                  visible = "1";
-                  active = "1";
-                  tooltipProfile = "GuiToolTipProfile";
-                  hovertime = "1000";
-                  isContainer = "1";
-                  canSave = "1";
-                  canSaveDynamicFields = "0";
-
-                  new GuiTextCtrl() {
-                     text = "Gamma";
-                     maxLength = "1024";
-                     margin = "0 0 0 0";
-                     padding = "0 0 0 0";
-                     anchorTop = "1";
-                     anchorBottom = "0";
-                     anchorLeft = "1";
-                     anchorRight = "0";
-                     position = "0 0";
-                     extent = "175 20";
-                     minExtent = "8 2";
-                     horizSizing = "right";
-                     vertSizing = "bottom";
-                     profile = "GuiMenuTextProfile";
-                     visible = "1";
-                     active = "1";
-                     tooltipProfile = "GuiToolTipProfile";
-                     hovertime = "1000";
-                     isContainer = "1";
-                     canSave = "1";
-                     canSaveDynamicFields = "0";
-                  };
-                  new GuiSliderCtrl() {
-                     range = "2 2.5";
-                     ticks = "0";
-                     snap = "0";
-                     value = "2";
-                     position = "190 0";
-                     extent = "261 20";
-                     minExtent = "8 2";
-                     horizSizing = "right";
-                     vertSizing = "bottom";
-                     profile = "GuiSliderProfile";
-                     visible = "1";
-                     active = "1";
-                     variable = "$pref::Video::Gamma";
-                     tooltipProfile = "GuiToolTipProfile";
-                     hovertime = "1000";
-                     isContainer = "0";
-                     canSave = "1";
-                     canSaveDynamicFields = "0";
-                  };
-               };
                new GuiControl() {
                   position = "0 180";
                   extent = "450 20";

+ 0 - 25
Templates/BaseGame/game/tools/gui/colorPicker.ed.gui

@@ -718,22 +718,6 @@
          canSave = "1";
          canSaveDynamicFields = "0";
       };
-      new GuiCheckBoxCtrl() {
-         text = "use sRGB";
-         groupNum = "-1";
-         buttonType = "ToggleButton";
-         useMouseEvents = "0";
-         position = "360 105";
-         extent = "66 16";
-         minExtent = "8 2";
-         horizSizing = "right";
-         vertSizing = "bottom";
-         profile = "GuiCheckBoxProfile";
-         visible = "1";
-         active = "1";
-         variable = "$displayAsSRGB";
-		 command = "useSRGBctrl($displayAsSRGB);";
-      };
    };
 };
 //--- OBJECT WRITE END ---
@@ -743,15 +727,6 @@ $ColorPickerCancelCallback = "";
 $ColorPickerUpdateCallback = "";
 $ColorCallbackType   = 1;  // ColorI
 
-function useSRGBctrl(%colorScale)
-{
-ColorPickerDlg.useSRGB = %colorScale;
-ColorRangeSelect.useSRGB = %colorScale;
-ColorBlendSelect.useSRGB = %colorScale;
-myColor.useSRGB = %colorScale;
-oldColor.useSRGB = %colorScale;
-}
-
 // This function pushes the color picker dialog and returns to a callback the selected value
 function GetColorI( %currentColor, %callback, %root, %updateCallback, %cancelCallback )
 {

+ 1 - 1
Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.hlsl

@@ -28,6 +28,6 @@ TORQUE_UNIFORM_SAMPLER1D(depthViz, 1);
 
 float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {
-   float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
+   float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
    return float4( TORQUE_TEX1D( depthViz, depth ).rgb, 1.0 );
 }

+ 1 - 1
Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.hlsl

@@ -27,6 +27,6 @@ TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0);
 
 float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {   
-   float3 normal = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).xyz;   
+   float3 normal = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).xyz;   
    return float4( ( normal + 1.0 ) * 0.5, 1.0 );
 }