فهرست منبع

Merge branch 'development' of https://github.com/vvv-yeaf/Torque3D into development

vvv-yeaf 2 سال پیش
والد
کامیت
db08474827

+ 1 - 1
Engine/source/platformMac/macMain.mm

@@ -37,7 +37,7 @@ void Platform::init()
     Con::printf("Initializing platform...");
    
    // Set the platform variable for the scripts
-   Con::setVariable( "$platform", "MacOSX" );
+   Con::setVariable( "$platform", "macos" );
    
    Input::init();
    

+ 17 - 23
Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript

@@ -43,10 +43,10 @@ singleton GFXStateBlockData( AL_VectorLightState )
 
    samplersDefined = true;
    samplerStates[0] = SamplerClampPoint;  // G-buffer
-   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] = SamplerWrapPoint;   // Random Direction Map
+   samplerStates[3] = SamplerWrapPoint;   // gTapRotationTex Random Direction Map
+   samplerStates[4] = SamplerClampPoint;   // colorBuffer
+   samplerStates[5] = SamplerClampPoint;   // matInfoBuffer
    
    cullDefined = true;
    cullMode = GFXCullNone;
@@ -68,9 +68,8 @@ singleton shaderData( AL_VectorLightShader )
    samplerNames[0] = "$deferredBuffer";
    samplerNames[1] = "$shadowMap";
    samplerNames[2] = "$gTapRotationTex";
-   samplerNames[3] = "$lightBuffer";
-   samplerNames[4] = "$colorBuffer";
-   samplerNames[5] = "$matInfoBuffer";  
+   samplerNames[3] = "$colorBuffer";
+   samplerNames[4] = "$matInfoBuffer";  
    
    pixVersion = 3.0;
 };
@@ -82,7 +81,6 @@ singleton CustomMaterial( AL_VectorLightMaterial )
    
    sampler["deferredBuffer"] = "#deferred";
    sampler["shadowMap"] = "$dynamiclight";
-   sampler["lightBuffer"] = "#specularLighting";
    sampler["colorBuffer"] = "#color";
    sampler["matInfoBuffer"] = "#matinfo";
    
@@ -115,11 +113,11 @@ singleton GFXStateBlockData( AL_ConvexLightState )
 
    samplersDefined = true;
    samplerStates[0] = SamplerClampPoint;  // G-buffer
-   mSamplerNames[0] = "deferredBuffer";
    samplerStates[1] = SamplerClampPoint;  // Shadow Map (Do not use linear, these are perspective projections)
-   mSamplerNames[1] = "shadowMap";
-   samplerStates[3] = SamplerClampLinear; // Cookie Map   
-   samplerStates[4] = SamplerWrapPoint;   // Random Direction Map
+   samplerStates[2] = SamplerWrapPoint;   // gTapRotationTex Random Direction Map
+   samplerStates[3] = SamplerClampPoint;  // colorBuffer
+   samplerStates[4] = SamplerClampPoint;  // matInfoBuffer
+   samplerStates[5] = SamplerClampLinear; // Cookie Map
    
    cullDefined = true;
    cullMode = GFXCullCW;
@@ -140,11 +138,10 @@ singleton shaderData( AL_PointLightShader )
 
    samplerNames[0] = "$deferredBuffer";
    samplerNames[1] = "$shadowMap";
-   samplerNames[2] = "$cookieMap";
-   samplerNames[3] = "$gTapRotationTex";
-   samplerNames[4] = "$lightBuffer";
-   samplerNames[5] = "$colorBuffer";
-   samplerNames[6] = "$matInfoBuffer";
+   samplerNames[2] = "$gTapRotationTex";
+   samplerNames[3] = "$colorBuffer";
+   samplerNames[4] = "$matInfoBuffer";
+   samplerNames[5] = "$cookieMap";
    
    pixVersion = 3.0;
 };
@@ -157,7 +154,6 @@ singleton CustomMaterial( AL_PointLightMaterial )
    sampler["deferredBuffer"] = "#deferred";
    sampler["shadowMap"] = "$dynamiclight";
    sampler["cookieMap"] = "$dynamiclightmask";
-   sampler["lightBuffer"] = "#specularLighting";
    sampler["colorBuffer"] = "#color";
    sampler["matInfoBuffer"] = "#matinfo";
    
@@ -177,11 +173,10 @@ singleton shaderData( AL_SpotLightShader )
    
    samplerNames[0] = "$deferredBuffer";
    samplerNames[1] = "$shadowMap";
-   samplerNames[2] = "$cookieMap";
-   samplerNames[3] = "$gTapRotationTex";
-   samplerNames[4] = "$lightBuffer";
-   samplerNames[5] = "$colorBuffer";
-   samplerNames[6] = "$matInfoBuffer";
+   samplerNames[2] = "$gTapRotationTex";
+   samplerNames[3] = "$colorBuffer";
+   samplerNames[4] = "$matInfoBuffer";
+   samplerNames[5] = "$cookieMap";
 
    pixVersion = 3.0;
 };
@@ -194,7 +189,6 @@ singleton CustomMaterial( AL_SpotLightMaterial )
    sampler["deferredBuffer"] = "#deferred";
    sampler["shadowMap"] = "$dynamiclight";
    sampler["cookieMap"] = "$dynamiclightmask";
-   sampler["lightBuffer"] = "#specularLighting";
    sampler["colorBuffer"] = "#color";
    sampler["matInfoBuffer"] = "#matinfo";
    

+ 1 - 1
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl

@@ -87,7 +87,7 @@ vec3 Tonemap(vec3 x)
    //Linear Tonemap  
    else if (g_fTonemapMode == 5.0)
    {  
-      x = TO_Linear(x);  	   
+      x = toLinear(TO_Linear(toGamma(x)));    	   
    }
         
    return x;

+ 30 - 0
Templates/BaseGame/game/core/postFX/scripts/SMAA/BBtoGamma.hlsl

@@ -0,0 +1,30 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+#include "core/rendering/shaders/torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+
+TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
+
+float4 main(PFXVertToPix IN) : TORQUE_TARGET0
+{
+   return toGamma(TORQUE_TEX2D(backBuffer, IN.uv0));  
+}

+ 46 - 10
Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAAPostFX.tscript

@@ -103,23 +103,59 @@ singleton ShaderData( SMAA_Neighbor_H_Shader )
    pixVersion = 3.0;
 };
 
-singleton PostEffect( SMAAPostFX )
+singleton GFXStateBlockData( BBtoGamma_StateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+};
+
+singleton ShaderData( BBtoGammaShader )
 {
-   enabled = false;
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= "./BBtoGamma.hlsl";   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = "./gl/BBtoGamma.glsl";
    
-   allowReflectPass = false;
-   renderTime = "PFXAfterDiffuse";
+   samplerNames[0] = "$backBuffer";
    
-   texture[0] = "$backBuffer";
-   texture[1] = "#deferred";
+   pixVersion = 3.0;
+};
 
-   target = "#edgesPass";
+singleton PostEffect( SMAAPostFX )
+{
+   enabled = false;   
+   allowReflectPass = false;
+   renderTime = "PFXBeforeBin";
+   renderBin = "EditorBin";
+   texture[0] = "$backBuffer";
+   target = "#BBtoGamma";
+   renderPriority = 1; 
    targetClear = PFXTargetClear_OnDraw;
    targetClearColor = "0 0 0 0";
+   shader = BBtoGammaShader;
+   stateBlock = BBtoGamma_StateBlock;
+   
+   singleton PostEffect()
+   {
+      enabled = false;
    
-   shader = SMAA_Edge_D_Shader;
-   stateBlock = SMAA_Edge_D_StateBlock;
+      allowReflectPass = false;
+      renderTime = "PFXAfterDiffuse";
    
+      texture[0] = "#BBtoGamma";
+      texture[1] = "#deferred";
+
+      target = "#edgesPass";
+      targetClear = PFXTargetClear_OnDraw;
+      targetClearColor = "0 0 0 0";
+   
+      shader = SMAA_Edge_D_Shader;
+      stateBlock = SMAA_Edge_D_StateBlock;
+   }; 
    singleton PostEffect()
    {
       internalName = "Edge Pass";
@@ -141,7 +177,7 @@ singleton PostEffect( SMAAPostFX )
    {
       internalName = "BlendPass";
 	  
-      texture[0] = "$backBuffer";
+      texture[0] = "#BBtoGamma";
 	  texture[1] = "#blendPass";
 	  
 	  target = "$backBuffer";

+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAA_Neighbor_H_Blending_P.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 #include "core/rendering/shaders/shaderModel.hlsl"
-
+#include "core/rendering/shaders/torque.hlsl"
 #include "SMAA_Params.hlsl"
     
                                                                          
@@ -38,6 +38,6 @@ struct v_NHBlend
 float4 main( v_NHBlend IN ) : TORQUE_TARGET0
 {   
     //return float4(TORQUE_TEX2D(blendTex, IN.uv0));
-   return SMAANeighborhoodBlendingPS(IN.uv0, IN.offset, texture_sceneTex, texture_blendTex);
+   return toLinear(SMAANeighborhoodBlendingPS(IN.uv0, IN.offset, texture_sceneTex, texture_blendTex));
 } 
 

+ 31 - 0
Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/BBtoGamma.glsl

@@ -0,0 +1,31 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
+
+uniform sampler2D backBuffer; 
+out vec4 OUT_col;
+
+void main()
+{
+   OUT_col= toGamma(texture(backBuffer, uv0));  
+}

+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/SMAA_Neighbor_H_Blending_P.glsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 #include "core/rendering/shaders/gl/hlslCompat.glsl"
-
+#include "core/rendering/shaders/gl/torque.glsl"
 
 #include "SMAA_Params.glsl"
 #define SMAA_INCLUDE_VS 0
@@ -41,6 +41,6 @@ out vec4 OUT_col;
 void main() 
 {                                    
    //OUT_col =  vec4(texture(blendTex, uv0.xy));     
-  OUT_col= SMAANeighborhoodBlendingPS(uv0, offset, sceneTex, blendTex);
+  OUT_col= toLinear(SMAANeighborhoodBlendingPS(uv0, offset, sceneTex, blendTex));
 } 
 

+ 6 - 10
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl

@@ -26,7 +26,6 @@
 #include "farFrustumQuad.glsl"
 #include "../../../gl/lighting.glsl"
 #include "../../shadowMap/shadowMapIO_GLSL.h"
-#include "softShadow.glsl"
 #include "../../../gl/torque.glsl"
 #line 31
 
@@ -35,12 +34,6 @@ in vec4 ssPos;
 in vec4 vsEyeDir;
 in vec4 color;
 
-#ifdef USE_COOKIE_TEX
-
-/// The texture for cookie rendering.
-uniform samplerCube cookieMap;
-
-#endif
 
 
 #ifdef SHADOW_CUBE
@@ -106,16 +99,19 @@ uniform samplerCube cookieMap;
 #endif
 
 uniform sampler2D deferredBuffer;
-
 #ifdef SHADOW_CUBE
 	uniform samplerCube shadowMap;
 #else
 	uniform sampler2D shadowMap;
 #endif
-
-uniform sampler2D lightBuffer;
+//contains gTapRotationTex sampler 
+#include "softShadow.glsl"
 uniform sampler2D colorBuffer;
 uniform sampler2D matInfoBuffer;
+#ifdef USE_COOKIE_TEX
+/// The texture for cookie rendering.
+uniform samplerCube cookieMap;
+#endif
 
 uniform vec4 rtParams0;
 

+ 6 - 8
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl

@@ -24,7 +24,6 @@
 #include "farFrustumQuad.glsl"
 #include "../../shadowMap/shadowMapIO_GLSL.h"
 #include "shadergen:/autogenConditioners.h"
-#include "softShadow.glsl"
 #include "../../../gl/lighting.glsl"
 #include "../../../gl/torque.glsl"
 
@@ -33,17 +32,16 @@ in vec4 ssPos;
 in vec4 vsEyeDir;
 in vec4 color;
 
-#ifdef USE_COOKIE_TEX
-
-/// The texture for cookie rendering.
-uniform sampler2D cookieMap;
-
-#endif
-
 uniform sampler2D deferredBuffer;
 uniform sampler2D shadowMap;
+//contains gTapRotationTex sampler 
+#include "softShadow.glsl"
 uniform sampler2D colorBuffer;
 uniform sampler2D matInfoBuffer;
+#ifdef USE_COOKIE_TEX
+/// The texture for cookie rendering.
+uniform sampler2D cookieMap;
+#endif
 
 uniform vec4 rtParams0;
 

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

@@ -26,7 +26,6 @@
 #include "../../../gl/torque.glsl"
 #include "../../../gl/lighting.glsl"
 #include "../../shadowMap/shadowMapIO_GLSL.h"
-#include "softShadow.glsl"
 #line 30
 in vec4 hpos;
 in vec2 uv0;
@@ -35,6 +34,8 @@ in vec3 vsEyeRay;
 
 uniform sampler2D deferredBuffer;
 uniform sampler2D shadowMap;
+//contains gTapRotationTex sampler 
+#include "softShadow.glsl"
 
 uniform sampler2D colorBuffer;
 uniform sampler2D matInfoBuffer;             

+ 8 - 14
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl

@@ -25,7 +25,6 @@
 #include "farFrustumQuad.hlsl"
 #include "../../lighting.hlsl"
 #include "../shadowMap/shadowMapIO_HLSL.h"
-#include "softShadow.hlsl"
 #include "../../torque.hlsl"
 
 struct ConvexConnectP
@@ -36,14 +35,6 @@ struct ConvexConnectP
    float4 vsEyeDir : TEXCOORD2;
 };
 
-#ifdef USE_COOKIE_TEX
-
-/// The texture for cookie rendering.
-TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3);
-
-#endif
-
-
 #ifdef SHADOW_CUBE
 
    float3 decodeShadowCoord( float3 shadowCoord )
@@ -107,16 +98,19 @@ TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3);
 #endif
 
 TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
-
 #ifdef SHADOW_CUBE
 TORQUE_UNIFORM_SAMPLERCUBE(shadowMap, 1);
 #else
 TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
 #endif
-
-TORQUE_UNIFORM_SAMPLER2D(lightBuffer, 5);
-TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 6);
-TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 7);
+//contains gTapRotationTex sampler 
+#include "softShadow.hlsl"
+TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
+TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
+#ifdef USE_COOKIE_TEX
+/// The texture for cookie rendering.
+TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5);
+#endif
 
 uniform float4 rtParams0;
 uniform float4 lightColor;

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

@@ -70,7 +70,7 @@ static float2 sNonUniformTaps[NUM_PRE_TAPS] =
 
 /// The texture used to do per-pixel pseudorandom
 /// rotations of the filter taps.
-TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 3);
+TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 2);
 
 float softShadow_sampleTaps(  TORQUE_SAMPLER2D(shadowMap1),
                               float2 sinCos,

+ 5 - 7
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl

@@ -26,7 +26,6 @@
 #include "farFrustumQuad.hlsl"
 #include "../../lighting.hlsl"
 #include "../shadowMap/shadowMapIO_HLSL.h"
-#include "softShadow.hlsl"
 #include "../../torque.hlsl"
 
 struct ConvexConnectP
@@ -39,16 +38,15 @@ struct ConvexConnectP
 
 TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
 TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
-
+//contains gTapRotationTex sampler 
+#include "softShadow.hlsl"
+TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
+TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
 #ifdef USE_COOKIE_TEX
-
 /// The texture for cookie rendering.
-TORQUE_UNIFORM_SAMPLER2D(cookieMap, 2);
+TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
 
 #endif
-TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 5);
-TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 6);
-
 uniform float4 rtParams0;
 
 uniform float  lightBrightness;

+ 4 - 3
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/vectorLightP.hlsl

@@ -27,13 +27,14 @@
 #include "../../torque.hlsl"
 #include "../../lighting.hlsl"
 #include "../shadowMap/shadowMapIO_HLSL.h"
-#include "softShadow.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
 TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
 
-TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 5);
-TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 6);
+//contains gTapRotationTex sampler 
+#include "softShadow.hlsl"
+TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
+TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
 
 uniform float  lightBrightness;
 uniform float3 lightDirection;