Browse Source

Reverted previous change for increased readability as no performance difference was observed.

Lasse Öörni 13 years ago
parent
commit
a972435910

+ 3 - 3
SourceAssets/GLSLShaders/Ambient.vert

@@ -17,9 +17,9 @@ void main()
 
     vVertexLighting = vec4(GetAmbient(GetZonePos(worldPos)), GetDepth(gl_Position));
     #ifdef NUMVERTEXLIGHTS
-        vec3 normal = GetWorldNormal(modelMatrix);
-        for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
-            vVertexLighting.rgb += GetVertexLight(i, worldPos, normal) * cVertexLights[i * 3].rgb;
+    vec3 normal = GetWorldNormal(modelMatrix);
+    for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
+        vVertexLighting.rgb += GetVertexLight(i, worldPos, normal) * cVertexLights[i * 3].rgb;
     #endif
 
     #ifdef VERTEXCOLOR

+ 0 - 2
SourceAssets/GLSLShaders/DeferredLight.frag

@@ -1,5 +1,3 @@
-#define DEFERREDLIGHT
-
 #include "Uniforms.frag"
 #include "Samplers.frag"
 #include "Lighting.frag"

+ 10 - 10
SourceAssets/GLSLShaders/Lighting.frag

@@ -3,6 +3,11 @@ float GetDiffuseDir(vec3 normal, vec3 lightDir)
     return max(dot(normal, lightDir), 0.0);
 }
 
+float GetDiffuseDirVolumetric()
+{
+    return 1.0;
+}
+
 #if defined(POINTLIGHT) || defined(SPOTLIGHT)
 float GetDiffusePointOrSpot(vec3 normal, vec3 lightVec, out vec3 lightDir)
 {
@@ -12,11 +17,6 @@ float GetDiffusePointOrSpot(vec3 normal, vec3 lightVec, out vec3 lightDir)
 }
 #endif
 
-float GetDiffuseDirVolumetric()
-{
-    return 1.0;
-}
-
 #if defined(POINTLIGHT) || defined(SPOTLIGHT)
 float GetDiffusePointOrSpotVolumetric(vec3 lightVec)
 {
@@ -61,6 +61,11 @@ float GetShadow(vec4 shadowPos)
     #endif
 }
 
+float GetShadowFade(float depth)
+{
+    return clamp((depth - cShadowDepthFade.z) * cShadowDepthFade.w, 0.0, 1.0);
+}
+
 #ifdef POINTLIGHT
 float GetCubeShadow(vec3 lightVec)
 {
@@ -83,11 +88,6 @@ float GetCubeShadow(vec3 lightVec)
 }
 #endif
 
-float GetShadowFade(float depth)
-{
-    return clamp((depth - cShadowDepthFade.z) * cShadowDepthFade.w, 0.0, 1.0);
-}
-
 #ifdef DIRLIGHT
 vec4 GetDirShadowPos(const vec4 shadowPos[4], float depth)
 {

+ 0 - 2
SourceAssets/GLSLShaders/Material.frag

@@ -1,5 +1,3 @@
-#define PREPASSMATERIAL
-
 #include "Uniforms.frag"
 #include "Samplers.frag"
 #include "Lighting.frag"

+ 0 - 2
SourceAssets/GLSLShaders/PrepassLight.frag

@@ -1,5 +1,3 @@
-#define PREPASSLIGHT
-
 #include "Uniforms.frag"
 #include "Samplers.frag"
 #include "Lighting.frag"

+ 15 - 41
SourceAssets/GLSLShaders/Samplers.frag

@@ -1,45 +1,21 @@
 uniform sampler2D sDiffMap;
 uniform samplerCube sDiffCubeMap;
 uniform sampler2D sNormalMap;
-#ifdef SPECMAP
-    uniform sampler2D sSpecMap;
-#endif
-#ifdef EMISSIVEMAP
-    uniform sampler2D sEmissiveMap;
-#endif
-#ifdef DETAILMAP
-    uniform sampler2D sDetailMap;
-#endif
-#ifdef ENVMAP
-    uniform sampler2D sEnvMap;
-    uniform samplerCube sEnvCubeMap;
-#endif
-#ifdef SHADOW
-    uniform sampler2DShadow sShadowMap;
-#ifdef POINTLIGHT
-    uniform samplerCube sFaceSelectCubeMap;
-    uniform samplerCube sIndirectionCubeMap;
-#endif
-#endif
-#if defined(POINTLIGHT) || defined(SPOTLIGHT)
-    uniform sampler2D sLightRampMap;
-#endif
-#ifdef SPOTLIGHT
-    uniform sampler2D sLightSpotMap;
-#endif
-#ifdef CUBEMASK
-    uniform samplerCube sLightCubeMap;
-#endif
-#ifdef DEFERREDLIGHT
-    uniform sampler2D sAlbedoBuffer;
-#endif
-#if defined(DEFERREDLIGHT) || defined(PREPASSLIGHT)
-    uniform sampler2D sNormalBuffer;
-    uniform sampler2D sDepthBuffer;
-#endif
-#if defined (PREPASSMATERIAL)
-    uniform sampler2D sLightBuffer;
-#endif
+uniform sampler2D sSpecMap;
+uniform sampler2D sEmissiveMap;
+uniform sampler2D sDetailMap;
+uniform sampler2D sEnvMap;
+uniform samplerCube sEnvCubeMap;
+uniform sampler2DShadow sShadowMap;
+uniform sampler2D sLightRampMap;
+uniform sampler2D sLightSpotMap;
+uniform samplerCube sLightCubeMap;
+uniform samplerCube sFaceSelectCubeMap;
+uniform samplerCube sIndirectionCubeMap;
+uniform sampler2D sAlbedoBuffer;
+uniform sampler2D sNormalBuffer;
+uniform sampler2D sDepthBuffer;
+uniform sampler2D sLightBuffer;
 
 vec3 DecodeNormal(vec4 normalInput)
 {
@@ -67,10 +43,8 @@ float DecodeDepth(vec3 depth)
     return dot(depth, dotValues);
 }
 
-#if defined(DEFERREDLIGHT) || defined(PREPASSLIGHT)
 float ReconstructDepth(float hwDepth)
 {
     return cDepthReconstruct.y / (hwDepth - cDepthReconstruct.x);
 }
-#endif
 

+ 8 - 13
SourceAssets/GLSLShaders/Transform.vert

@@ -5,11 +5,7 @@ attribute vec2 iTexCoord;
 attribute vec2 iTexCoord2;
 attribute vec3 iCubeTexCoord;
 attribute vec4 iCubeTexCoord2;
-#ifdef NORMALMAP
-    attribute vec4 iTangent;
-#endif
-
-#ifdef SKINNED
+attribute vec4 iTangent;
 attribute vec4 iBlendWeights;
 attribute vec4 iBlendIndices;
 
@@ -23,11 +19,6 @@ mat4 GetSkinMatrix(vec4 blendWeights, vec4 blendIndices)
         mat4(cSkinMatrices[idx.w], cSkinMatrices[idx.w + 1], cSkinMatrices[idx.w + 2], lastColumn) * blendWeights.w;
 }
 
-#define iModelMatrix GetSkinMatrix(iBlendWeights, iBlendIndices)
-#else
-#define iModelMatrix cModel
-#endif
-
 mat3 GetNormalMatrix(mat4 modelMatrix)
 {
     return mat3(modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz);
@@ -63,6 +54,12 @@ vec3 GetBillboardNormal()
     return vec3(-cCameraRot[2][0], -cCameraRot[2][1], -cCameraRot[2][2]);
 }
 
+#ifdef SKINNED
+    #define iModelMatrix GetSkinMatrix(iBlendWeights, iBlendIndices)
+#else
+    #define iModelMatrix cModel
+#endif
+
 vec3 GetWorldPos(mat4 modelMatrix)
 {
     #if defined(BILLBOARD)
@@ -85,9 +82,8 @@ vec3 GetWorldNormal(mat4 modelMatrix)
     #endif
 }
 
-#ifdef NORMALMAP
 vec3 GetWorldTangent(mat4 modelMatrix)
-{
+{   
     mat3 normalMatrix = GetNormalMatrix(modelMatrix);
     #ifdef SKINNED
         return normalize(iTangent.xyz * normalMatrix);
@@ -95,5 +91,4 @@ vec3 GetWorldTangent(mat4 modelMatrix)
         return normalize(normalMatrix * iTangent.xyz);
     #endif
 }
-#endif
 

+ 9 - 13
SourceAssets/GLSLShaders/Uniforms.frag

@@ -1,22 +1,18 @@
 uniform vec3 cAmbientColor;
+uniform vec2 cDepthReconstruct;
 uniform vec2 cFogParams;
 uniform vec3 cFogColor;
 uniform vec2 cGBufferInvSize;
 uniform vec4 cLightColor;
+uniform vec3 cLightDirPS;
+uniform vec4 cLightPosPS;
 uniform vec4 cMatDiffColor;
 uniform vec3 cMatEmissiveColor;
 uniform vec3 cMatEnvMapColor;
 uniform vec4 cMatSpecColor;
-#ifdef SHADOW
-    uniform vec4 cShadowCubeAdjust;
-    uniform vec4 cShadowDepthFade;
-    uniform vec2 cShadowIntensity;
-    uniform vec2 cShadowMapInvSize;
-    uniform vec4 cShadowSplits;
-#endif
-#if defined(DEFERREDLIGHT) || defined(PREPASSLIGHT)
-    uniform vec2 cDepthReconstruct;
-    uniform vec3 cLightDirPS;
-    uniform vec4 cLightPosPS;
-    uniform mat4 cLightMatricesPS[4];
-#endif
+uniform vec4 cShadowCubeAdjust;
+uniform vec4 cShadowDepthFade;
+uniform vec2 cShadowIntensity;
+uniform vec2 cShadowMapInvSize;
+uniform vec4 cShadowSplits;
+uniform mat4 cLightMatricesPS[4];

+ 3 - 9
SourceAssets/GLSLShaders/Uniforms.vert

@@ -14,12 +14,6 @@ uniform vec4 cVOffset;
 uniform vec3 cViewRightVector;
 uniform vec3 cViewUpVector;
 uniform mat4 cZone;
-#if defined(SHADOW) || defined(POINTLIGHT) || defined(SPOTLIGHT)
-    uniform mat4 cLightMatrices[4];
-#endif
-#ifdef SKINNED
-    uniform vec4 cSkinMatrices[64*3];
-#endif
-#ifdef NUMVERTEXLIGHTS
-    uniform vec4 cVertexLights[6*3];
-#endif
+uniform mat4 cLightMatrices[4];
+uniform vec4 cSkinMatrices[64*3];
+uniform vec4 cVertexLights[6*3];