Browse Source

Updated Resources (Direct3D11/OpenGL3 shaders, updated render paths, etc)

Josh Engebretson 10 years ago
parent
commit
87e51bbc08
70 changed files with 1151 additions and 443 deletions
  1. 1 0
      Data/AtomicPlayer/Resources/CoreData/RenderPaths/DeferredHWDepth.xml
  2. 5 1
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Atomic2D.glsl
  3. 2 2
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Bloom.glsl
  4. 23 15
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Depth.glsl
  5. 2 2
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/LitParticle.glsl
  6. 15 6
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/LitSolid.glsl
  7. 0 8
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/PostProcess.glsl
  8. 2 2
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/PrepassLight.glsl
  9. 27 10
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Samplers.glsl
  10. 2 2
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/ScreenPos.glsl
  11. 2 2
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Shadow.glsl
  12. 6 1
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Text.glsl
  13. 43 28
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Tonemap.glsl
  14. 132 6
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Uniforms.glsl
  15. 3 3
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Unlit.glsl
  16. 3 3
      Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/VegetationDepth.glsl
  17. 34 11
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/AutoExposure.hlsl
  18. 14 4
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Basic.hlsl
  19. 30 8
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Bloom.hlsl
  20. 62 9
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/BloomHDR.hlsl
  21. 17 0
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Blur.hlsl
  22. 9 5
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/ColorCorrection.hlsl
  23. 3 3
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/CopyFramebuffer.hlsl
  24. 9 9
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/DeferredLight.hlsl
  25. 27 12
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Depth.hlsl
  26. 50 44
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/FXAA3.hlsl
  27. 4 4
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Fog.hlsl
  28. 4 4
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/GreyScale.hlsl
  29. 38 58
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Lighting.hlsl
  30. 25 6
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/LitParticle.hlsl
  31. 59 33
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/LitSolid.hlsl
  32. 23 1
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/PostProcess.hlsl
  33. 7 7
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/PrepassLight.hlsl
  34. 93 42
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Samplers.hlsl
  35. 3 3
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/ScreenPos.hlsl
  36. 4 4
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Skybox.hlsl
  37. 2 2
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Stencil.hlsl
  38. 52 21
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/TerrainBlend.hlsl
  39. 27 15
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Text.hlsl
  40. 22 6
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Tonemap.hlsl
  41. 26 0
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Transform.hlsl
  42. 126 5
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Uniforms.hlsl
  43. 25 8
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Unlit.hlsl
  44. 8 1
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Vegetation.hlsl
  45. 38 5
      Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/VegetationDepth.hlsl
  46. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/Diff.xml
  47. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalAO.xml
  48. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalEmissive.xml
  49. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedAO.xml
  50. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedEmissive.xml
  51. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedSpecAO.xml
  52. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedSpecEmissive.xml
  53. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalSpecAO.xml
  54. 10 0
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalSpecEmissive.xml
  55. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/DiffVColAdd.xml
  56. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureAO.xml
  57. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureAddAlpha.xml
  58. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureAlpha.xml
  59. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureEnvCube.xml
  60. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureNormal.xml
  61. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureNormalAlpha.xml
  62. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureNormalPackedAlpha.xml
  63. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureUnlit.xml
  64. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureUnlitAlpha.xml
  65. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureUnlitVCol.xml
  66. 10 0
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVCol.xml
  67. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVColAdd.xml
  68. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVColAddAlpha.xml
  69. 1 1
      Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVColMultiply.xml
  70. 0 0
      Data/AtomicPlayer/Resources/CoreData/Techniques/TerrainBlend.xml

+ 1 - 0
Data/AtomicPlayer/Resources/CoreData/RenderPaths/DeferredHWDepth.xml

@@ -3,6 +3,7 @@
     <rendertarget name="normal" sizedivisor="1 1" format="rgba" />
     <rendertarget name="normal" sizedivisor="1 1" format="rgba" />
     <rendertarget name="depth" sizedivisor="1 1" format="readabledepth" />
     <rendertarget name="depth" sizedivisor="1 1" format="readabledepth" />
     <command type="clear" color="fog" depth="1.0" stencil="0" depthstencil="depth" />
     <command type="clear" color="fog" depth="1.0" stencil="0" depthstencil="depth" />
+    <command type="clear" color="0 0 0 0" output="albedo" depthstencil="depth" />
     <command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer" depthstencil="depth">
     <command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer" depthstencil="depth">
         <output index="0" name="viewport" />
         <output index="0" name="viewport" />
         <output index="1" name="albedo" />
         <output index="1" name="albedo" />

+ 5 - 1
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Atomic2D.glsl

@@ -43,7 +43,11 @@ void PS()
         gl_FragColor = diffColor * diffInput;
         gl_FragColor = diffColor * diffInput;
     #endif
     #endif
     #ifdef ALPHAMAP
     #ifdef ALPHAMAP
-        float alphaInput = texture2D(sDiffMap, vTexCoord).a;
+        #ifdef GL3
+            float alphaInput = texture2D(sDiffMap, vTexCoord).r;
+        #else
+            float alphaInput = texture2D(sDiffMap, vTexCoord).a;
+        #endif
         gl_FragColor = vec4(diffColor.rgb, diffColor.a * alphaInput);
         gl_FragColor = vec4(diffColor.rgb, diffColor.a * alphaInput);
     #endif
     #endif
 }
 }

+ 2 - 2
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Bloom.glsl

@@ -78,11 +78,11 @@ void PS()
     #endif
     #endif
 
 
     #if defined(SPOTLIGHT)
     #if defined(SPOTLIGHT)
-        vec4 spotPos = cLightMatricesPS[0] * projWorldPos;
+        vec4 spotPos = projWorldPos * cLightMatricesPS[0];
         lightColor = spotPos.w > 0.0 ? texture2DProj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : vec3(0.0);
         lightColor = spotPos.w > 0.0 ? texture2DProj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : vec3(0.0);
     #elif defined(CUBEMASK)
     #elif defined(CUBEMASK)
         mat3 lightVecRot = mat3(cLightMatricesPS[0][0].xyz, cLightMatricesPS[0][1].xyz, cLightMatricesPS[0][2].xyz);
         mat3 lightVecRot = mat3(cLightMatricesPS[0][0].xyz, cLightMatricesPS[0][1].xyz, cLightMatricesPS[0][2].xyz);
-        lightColor = textureCube(sLightCubeMap, lightVecRot * (worldPos - cLightPosPS.xyz)).rgb * cLightColor.rgb;
+        lightColor = textureCube(sLightCubeMap, (worldPos - cLightPosPS.xyz) * lightVecRot).rgb * cLightColor.rgb;
     #else
     #else
         lightColor = cLightColor.rgb;
         lightColor = cLightColor.rgb;
     #endif
     #endif

+ 23 - 15
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Depth.glsl

@@ -69,9 +69,9 @@ float GetVertexLightVolumetric(int index, vec3 worldPos)
 vec4 GetShadowPos(int index, vec4 projWorldPos)
 vec4 GetShadowPos(int index, vec4 projWorldPos)
 {
 {
     #if defined(DIRLIGHT)
     #if defined(DIRLIGHT)
-        return cLightMatrices[index] * projWorldPos;
+        return projWorldPos * cLightMatrices[index];
     #elif defined(SPOTLIGHT)
     #elif defined(SPOTLIGHT)
-        return cLightMatrices[1] * projWorldPos;
+        return projWorldPos * cLightMatrices[1];
     #else
     #else
         return vec4(projWorldPos.xyz - cLightPos.xyz, 1.0);
         return vec4(projWorldPos.xyz - cLightPos.xyz, 1.0);
     #endif
     #endif
@@ -135,16 +135,24 @@ float GetShadow(vec4 shadowPos)
             #else
             #else
                 vec2 offsets = cShadowMapInvSize;
                 vec2 offsets = cShadowMapInvSize;
             #endif
             #endif
-            vec4 inLight = vec4(
-                shadow2DProj(sShadowMap, shadowPos).r,
-                shadow2DProj(sShadowMap, vec4(shadowPos.x + offsets.x, shadowPos.yzw)).r,
-                shadow2DProj(sShadowMap, vec4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw)).r,
-                shadow2DProj(sShadowMap, vec4(shadowPos.xy + offsets.xy, shadowPos.zw)).r
-            );
-            return cShadowIntensity.y + dot(inLight, vec4(cShadowIntensity.x));
+            #ifndef GL3
+                return cShadowIntensity.y + cShadowIntensity.x * (shadow2DProj(sShadowMap, shadowPos).r +
+                    shadow2DProj(sShadowMap, vec4(shadowPos.x + offsets.x, shadowPos.yzw)).r +
+                    shadow2DProj(sShadowMap, vec4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw)).r +
+                    shadow2DProj(sShadowMap, vec4(shadowPos.xy + offsets.xy, shadowPos.zw)).r);
+            #else
+                return cShadowIntensity.y + cShadowIntensity.x * (textureProj(sShadowMap, shadowPos) +
+                    textureProj(sShadowMap, vec4(shadowPos.x + offsets.x, shadowPos.yzw)) +
+                    textureProj(sShadowMap, vec4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw)) +
+                    textureProj(sShadowMap, vec4(shadowPos.xy + offsets.xy, shadowPos.zw)));
+            #endif
         #else
         #else
             // Take one sample
             // Take one sample
-            float inLight = shadow2DProj(sShadowMap, shadowPos).r;
+            #ifndef GL3
+                float inLight = shadow2DProj(sShadowMap, shadowPos).r;
+            #else
+                float inLight = textureProj(sShadowMap, shadowPos);
+            #endif
             return cShadowIntensity.y + cShadowIntensity.x * inLight;
             return cShadowIntensity.y + cShadowIntensity.x * inLight;
         #endif
         #endif
     #else
     #else
@@ -222,13 +230,13 @@ float GetDirShadowDeferred(vec4 projWorldPos, float depth)
     vec4 shadowPos;
     vec4 shadowPos;
 
 
     if (depth < cShadowSplits.x)
     if (depth < cShadowSplits.x)
-        shadowPos = cLightMatricesPS[0] * projWorldPos;
+        shadowPos = projWorldPos * cLightMatricesPS[0];
     else if (depth < cShadowSplits.y)
     else if (depth < cShadowSplits.y)
-        shadowPos = cLightMatricesPS[1] * projWorldPos;
+        shadowPos = projWorldPos * cLightMatricesPS[1];
     else if (depth < cShadowSplits.z)
     else if (depth < cShadowSplits.z)
-        shadowPos = cLightMatricesPS[2] * projWorldPos;
+        shadowPos = projWorldPos * cLightMatricesPS[2];
     else
     else
-        shadowPos = cLightMatricesPS[3] * projWorldPos;
+        shadowPos = projWorldPos * cLightMatricesPS[3];
 
 
     return GetDirShadowFade(GetShadow(shadowPos), depth);
     return GetDirShadowFade(GetShadow(shadowPos), depth);
 }
 }
@@ -252,7 +260,7 @@ float GetShadowDeferred(vec4 projWorldPos, float depth)
     #if defined(DIRLIGHT)
     #if defined(DIRLIGHT)
         return GetDirShadowDeferred(projWorldPos, depth);
         return GetDirShadowDeferred(projWorldPos, depth);
     #elif defined(SPOTLIGHT)
     #elif defined(SPOTLIGHT)
-        vec4 shadowPos = cLightMatricesPS[1] * projWorldPos;
+        vec4 shadowPos = projWorldPos * cLightMatricesPS[1];
         return GetShadow(shadowPos);
         return GetShadow(shadowPos);
     #else
     #else
         vec3 shadowPos = projWorldPos.xyz - cLightPosPS.xyz;
         vec3 shadowPos = projWorldPos.xyz - cLightPosPS.xyz;

+ 2 - 2
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/LitParticle.glsl

@@ -47,11 +47,11 @@ void VS()
 
 
         #ifdef SPOTLIGHT
         #ifdef SPOTLIGHT
             // Spotlight projection: transform from world space to projector texture coordinates
             // Spotlight projection: transform from world space to projector texture coordinates
-            vSpotPos = cLightMatrices[0] * projWorldPos;
+            vSpotPos = projWorldPos * cLightMatrices[0];
         #endif
         #endif
     
     
         #ifdef POINTLIGHT
         #ifdef POINTLIGHT
-            vCubeMaskVec = mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz) * (worldPos - cLightPos.xyz);
+            vCubeMaskVec = (worldPos - cLightPos.xyz) * mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz);
         #endif
         #endif
     #else
     #else
         // Ambient & per-vertex lighting
         // Ambient & per-vertex lighting

+ 15 - 6
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/LitSolid.glsl

@@ -13,6 +13,9 @@
 #endif
 #endif
 varying vec3 vNormal;
 varying vec3 vNormal;
 varying vec4 vWorldPos;
 varying vec4 vWorldPos;
+#ifdef VERTEXCOLOR
+    varying vec4 vColor;
+#endif
 #ifdef PERPIXEL
 #ifdef PERPIXEL
     #ifdef SHADOW
     #ifdef SHADOW
         varying vec4 vShadowPos[NUMCASCADES];
         varying vec4 vShadowPos[NUMCASCADES];
@@ -42,6 +45,10 @@ void VS()
     vNormal = GetWorldNormal(modelMatrix);
     vNormal = GetWorldNormal(modelMatrix);
     vWorldPos = vec4(worldPos, GetDepth(gl_Position));
     vWorldPos = vec4(worldPos, GetDepth(gl_Position));
 
 
+    #ifdef VERTEXCOLOR
+        vColor = iColor;
+    #endif
+
     #ifdef NORMALMAP
     #ifdef NORMALMAP
         vec3 tangent = GetWorldTangent(modelMatrix);
         vec3 tangent = GetWorldTangent(modelMatrix);
         vec3 bitangent = cross(tangent, vNormal) * iTangent.w;
         vec3 bitangent = cross(tangent, vNormal) * iTangent.w;
@@ -63,11 +70,11 @@ void VS()
 
 
         #ifdef SPOTLIGHT
         #ifdef SPOTLIGHT
             // Spotlight projection: transform from world space to projector texture coordinates
             // Spotlight projection: transform from world space to projector texture coordinates
-            vSpotPos = cLightMatrices[0] * projWorldPos;
+            vSpotPos =  projWorldPos * cLightMatrices[0];
         #endif
         #endif
     
     
         #ifdef POINTLIGHT
         #ifdef POINTLIGHT
-            vCubeMaskVec = mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz) * (worldPos - cLightPos.xyz);
+            vCubeMaskVec = (worldPos - cLightPos.xyz) * mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz);
         #endif
         #endif
     #else
     #else
         // Ambient & per-vertex lighting
         // Ambient & per-vertex lighting
@@ -75,7 +82,7 @@ void VS()
             // If using lightmap, disregard zone ambient light
             // If using lightmap, disregard zone ambient light
             // If using AO, calculate ambient in the PS
             // If using AO, calculate ambient in the PS
             vVertexLight = vec3(0.0, 0.0, 0.0);
             vVertexLight = vec3(0.0, 0.0, 0.0);
-            vTexCoord2 = GetLightMapTexCoord(iTexCoord2);
+            vTexCoord2 = iTexCoord2;
         #else
         #else
             vVertexLight = GetAmbient(GetZonePos(worldPos));
             vVertexLight = GetAmbient(GetZonePos(worldPos));
         #endif
         #endif
@@ -106,6 +113,10 @@ void PS()
     #else
     #else
         vec4 diffColor = cMatDiffColor;
         vec4 diffColor = cMatDiffColor;
     #endif
     #endif
+
+    #ifdef VERTEXCOLOR
+        diffColor *= vColor;
+    #endif
     
     
     // Get material specular albedo
     // Get material specular albedo
     #ifdef SPECMAP
     #ifdef SPECMAP
@@ -217,9 +228,7 @@ void PS()
             finalColor += cMatEnvMapColor * textureCube(sEnvCubeMap, reflect(vReflectionVec, normal)).rgb;
             finalColor += cMatEnvMapColor * textureCube(sEnvCubeMap, reflect(vReflectionVec, normal)).rgb;
         #endif
         #endif
         #ifdef LIGHTMAP
         #ifdef LIGHTMAP
-            // Lightmap with HDR encoded in alpha
-            vec4 lightMapColor = texture2D(sEmissiveMap, vTexCoord2);
-            finalColor += lightMapColor.rgb * lightMapColor.a * 8.0 * diffColor.rgb;
+            finalColor += texture2D(sEmissiveMap, vTexCoord2).rgb * diffColor.rgb;
         #endif
         #endif
         #ifdef EMISSIVEMAP
         #ifdef EMISSIVEMAP
             finalColor += cMatEmissiveColor * texture2D(sEmissiveMap, vTexCoord.xy).rgb;
             finalColor += cMatEmissiveColor * texture2D(sEmissiveMap, vTexCoord.xy).rgb;

+ 0 - 8
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/PostProcess.glsl

@@ -11,13 +11,7 @@ vec2 Noise(vec2 coord)
 // Adapted: http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
 // Adapted: http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
 vec4 GaussianBlur(int blurKernelSize, vec2 blurDir, vec2 blurRadius, float sigma, sampler2D texSampler, vec2 texCoord)
 vec4 GaussianBlur(int blurKernelSize, vec2 blurDir, vec2 blurRadius, float sigma, sampler2D texSampler, vec2 texCoord)
 {
 {
-
-#if defined(GL_ES)
-    // hardcoded for GL_ES to avoid loop comparison issue below
-    const int blurKernelSizeHalfSize = 3 / 2;
-#else    
     int blurKernelSizeHalfSize = blurKernelSize / 2;
     int blurKernelSizeHalfSize = blurKernelSize / 2;
-#endif    
 
 
     // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
     // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
     vec3 gaussCoeff;
     vec3 gaussCoeff;
@@ -70,7 +64,6 @@ vec3 Uncharted2Tonemap(vec3 x)
    return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
    return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
 }
 }
 
 
-#if !defined(GL_ES)
 vec3 ColorCorrection(vec3 color, sampler3D lut)
 vec3 ColorCorrection(vec3 color, sampler3D lut)
 {
 {
     float lutSize = 16.0;
     float lutSize = 16.0;
@@ -78,7 +71,6 @@ vec3 ColorCorrection(vec3 color, sampler3D lut)
     float offset = 1.0 / (2.0 * lutSize);
     float offset = 1.0 / (2.0 * lutSize);
     return texture3D(lut, clamp(color, 0.0, 1.0) * scale + offset).rgb;
     return texture3D(lut, clamp(color, 0.0, 1.0) * scale + offset).rgb;
 }
 }
-#endif
 
 
 const float Gamma = 2.2;
 const float Gamma = 2.2;
 const float InverseGamma = 1.0 / 2.2;
 const float InverseGamma = 1.0 / 2.2;

+ 2 - 2
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/PrepassLight.glsl

@@ -76,11 +76,11 @@ void PS()
     #endif
     #endif
     
     
     #if defined(SPOTLIGHT)
     #if defined(SPOTLIGHT)
-        vec4 spotPos = cLightMatricesPS[0] * projWorldPos;
+        vec4 spotPos = projWorldPos * cLightMatricesPS[0];
         lightColor = spotPos.w > 0.0 ? texture2DProj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : vec3(0.0);
         lightColor = spotPos.w > 0.0 ? texture2DProj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : vec3(0.0);
     #elif defined(CUBEMASK)
     #elif defined(CUBEMASK)
         mat3 lightVecRot = mat3(cLightMatricesPS[0][0].xyz, cLightMatricesPS[0][1].xyz, cLightMatricesPS[0][2].xyz);
         mat3 lightVecRot = mat3(cLightMatricesPS[0][0].xyz, cLightMatricesPS[0][1].xyz, cLightMatricesPS[0][2].xyz);
-        lightColor = textureCube(sLightCubeMap, lightVecRot * (worldPos - cLightPosPS.xyz)).rgb * cLightColor.rgb;
+        lightColor = textureCube(sLightCubeMap, (worldPos - cLightPosPS.xyz) * lightVecRot).rgb * cLightColor.rgb;
     #else
     #else
         lightColor = cLightColor.rgb;
         lightColor = cLightColor.rgb;
     #endif
     #endif

+ 27 - 10
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Samplers.glsl

@@ -24,6 +24,13 @@ uniform samplerCube sLightCubeMap;
     uniform sampler2D sShadowMap;
     uniform sampler2D sShadowMap;
 #endif
 #endif
 
 
+#ifdef GL3
+#define texture2D texture
+#define texture2DProj textureProj
+#define texture3D texture
+#define textureCube texture
+#endif
+
 vec3 DecodeNormal(vec4 normalInput)
 vec3 DecodeNormal(vec4 normalInput)
 {
 {
     #ifdef PACKEDNORMAL
     #ifdef PACKEDNORMAL
@@ -38,20 +45,30 @@ vec3 DecodeNormal(vec4 normalInput)
 
 
 vec3 EncodeDepth(float depth)
 vec3 EncodeDepth(float depth)
 {
 {
-    vec3 ret;
-    depth *= 255.0;
-    ret.x = floor(depth);
-    depth = (depth - ret.x) * 255.0;
-    ret.y = floor(depth);
-    ret.z = (depth - ret.y);
-    ret.xy *= 1.0 / 255.0;
-    return ret;
+    #ifndef GL3
+        vec3 ret;
+        depth *= 255.0;
+        ret.x = floor(depth);
+        depth = (depth - ret.x) * 255.0;
+        ret.y = floor(depth);
+        ret.z = (depth - ret.y);
+        ret.xy *= 1.0 / 255.0;
+        return ret;
+    #else
+        // OpenGL 3 can use different MRT formats, so no need for encoding
+        return vec3(depth, 0.0, 0.0);
+    #endif
 }
 }
 
 
 float DecodeDepth(vec3 depth)
 float DecodeDepth(vec3 depth)
 {
 {
-    const vec3 dotValues = vec3(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0));
-    return dot(depth, dotValues);
+    #ifndef GL3
+        const vec3 dotValues = vec3(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0));
+        return dot(depth, dotValues);
+    #else
+        // OpenGL 3 can use different MRT formats, so no need for encoding
+        return depth.r;
+    #endif
 }
 }
 
 
 float ReconstructDepth(float hwDepth)
 float ReconstructDepth(float hwDepth)

+ 2 - 2
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/ScreenPos.glsl

@@ -36,7 +36,7 @@ vec3 GetFarRay(vec4 clipPos)
         clipPos.y / clipPos.w * cFrustumSize.y,
         clipPos.y / clipPos.w * cFrustumSize.y,
         cFrustumSize.z);
         cFrustumSize.z);
 
 
-    return cCameraRot * viewRay;
+    return viewRay * cCameraRot;
 }
 }
 
 
 vec3 GetNearRay(vec4 clipPos)
 vec3 GetNearRay(vec4 clipPos)
@@ -46,6 +46,6 @@ vec3 GetNearRay(vec4 clipPos)
         clipPos.y / clipPos.w * cFrustumSize.y,
         clipPos.y / clipPos.w * cFrustumSize.y,
         0.0);
         0.0);
     
     
-    return (cCameraRot * viewRay) * cDepthMode.x;
+    return (viewRay * cCameraRot) * cDepthMode.x;
 }
 }
 #endif
 #endif

+ 2 - 2
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Shadow.glsl

@@ -69,11 +69,11 @@ void VS()
 
 
         #ifdef SPOTLIGHT
         #ifdef SPOTLIGHT
             // Spotlight projection: transform from world space to projector texture coordinates
             // Spotlight projection: transform from world space to projector texture coordinates
-            vSpotPos = cLightMatrices[0] * projWorldPos;
+            vSpotPos = projWorldPos * cLightMatrices[0];
         #endif
         #endif
     
     
         #ifdef POINTLIGHT
         #ifdef POINTLIGHT
-            vCubeMaskVec = mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz) * (worldPos - cLightPos.xyz);
+            vCubeMaskVec = (worldPos - cLightPos.xyz) * mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz);
         #endif
         #endif
     #else
     #else
         // Ambient & per-vertex lighting
         // Ambient & per-vertex lighting

+ 6 - 1
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Text.glsl

@@ -54,6 +54,11 @@ void PS()
         gl_FragColor.a = vColor.a * smoothstep(0.5, 0.505, distance);
         gl_FragColor.a = vColor.a * smoothstep(0.5, 0.505, distance);
     }
     }
 #else
 #else
-    gl_FragColor.a = vColor.a * texture2D(sDiffMap, vTexCoord).a;
+    // Non-SDF font will likely be monochrome, in which case the alpha channel will be on the R channel on OpenGL 3
+    #ifdef GL3
+        gl_FragColor.a = vColor.a * texture2D(sDiffMap, vTexCoord).r;
+    #else
+        gl_FragColor.a = vColor.a * texture2D(sDiffMap, vTexCoord).a;
+    #endif
 #endif
 #endif
 }
 }

+ 43 - 28
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Tonemap.glsl

@@ -1,4 +1,11 @@
 #ifdef COMPILEVS
 #ifdef COMPILEVS
+
+// Silence GLSL 150 deprecation warnings
+#ifdef GL3
+#define attribute in
+#define varying out
+#endif
+
 attribute vec4 iPos;
 attribute vec4 iPos;
 attribute vec3 iNormal;
 attribute vec3 iNormal;
 attribute vec4 iColor;
 attribute vec4 iColor;
@@ -45,24 +52,21 @@ vec2 GetTexCoord(vec2 texCoord)
     return vec2(dot(texCoord, cUOffset.xy) + cUOffset.w, dot(texCoord, cVOffset.xy) + cVOffset.w);
     return vec2(dot(texCoord, cUOffset.xy) + cUOffset.w, dot(texCoord, cVOffset.xy) + cVOffset.w);
 }
 }
 
 
-vec2 GetLightMapTexCoord(vec2 texCoord)
-{
-    return vec2(texCoord.x * cLMOffset.x + cLMOffset.z, texCoord.y * cLMOffset.y + cLMOffset.w);
-}
-
 vec4 GetClipPos(vec3 worldPos)
 vec4 GetClipPos(vec3 worldPos)
 {
 {
-    vec4 ret = cViewProj * vec4(worldPos, 1.0);
+    vec4 ret = vec4(worldPos, 1.0) * cViewProj;
     // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
     // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
-    #ifndef GL_ES
-    gl_ClipVertex = ret;
+    #if !defined(GL_ES) && !defined(GL3)
+        gl_ClipVertex = ret;
+    #elif defined(GL3)
+        gl_ClipDistance[0] = dot(cClipPlane, ret);
     #endif
     #endif
     return ret;
     return ret;
 }
 }
 
 
 float GetZonePos(vec3 worldPos)
 float GetZonePos(vec3 worldPos)
 {
 {
-    return clamp((cZone * vec4(worldPos, 1.0)).z, 0.0, 1.0);
+    return clamp((vec4(worldPos, 1.0) * cZone).z, 0.0, 1.0);
 }
 }
 
 
 float GetDepth(vec4 clipPos)
 float GetDepth(vec4 clipPos)
@@ -70,18 +74,18 @@ float GetDepth(vec4 clipPos)
     return dot(clipPos.zw, cDepthMode.zw);
     return dot(clipPos.zw, cDepthMode.zw);
 }
 }
 
 
+#ifdef BILLBOARD
 vec3 GetBillboardPos(vec4 iPos, vec2 iSize, mat4 modelMatrix)
 vec3 GetBillboardPos(vec4 iPos, vec2 iSize, mat4 modelMatrix)
 {
 {
-    return (modelMatrix * iPos).xyz + cBillboardRot * vec3(iSize.x, iSize.y, 0.0);
+    return (iPos * modelMatrix).xyz + vec3(iSize.x, iSize.y, 0.0) * cBillboardRot;
 }
 }
 
 
 vec3 GetBillboardNormal()
 vec3 GetBillboardNormal()
 {
 {
-    return vec3(-cBillboardRot[2][0], -cBillboardRot[2][1], -cBillboardRot[2][2]);
+    return vec3(-cBillboardRot[0][2], -cBillboardRot[1][2], -cBillboardRot[2][2]);
 }
 }
+#endif
 
 
-// Note: the skinning/instancing model matrix is a transpose, so the matrix multiply order must be swapped
-// (see GetWorldPos(), GetWorldNormal() and GetWorldTangent() below)
 #if defined(SKINNED)
 #if defined(SKINNED)
     #define iModelMatrix GetSkinMatrix(iBlendWeights, iBlendIndices)
     #define iModelMatrix GetSkinMatrix(iBlendWeights, iBlendIndices)
 #elif defined(INSTANCED)
 #elif defined(INSTANCED)
@@ -92,33 +96,44 @@ vec3 GetBillboardNormal()
 
 
 vec3 GetWorldPos(mat4 modelMatrix)
 vec3 GetWorldPos(mat4 modelMatrix)
 {
 {
-    #if defined(SKINNED) || defined(INSTANCED)
-        return (iPos * modelMatrix).xyz;
-    #elif defined(BILLBOARD)
+    #if defined(BILLBOARD)
         return GetBillboardPos(iPos, iTexCoord2, modelMatrix);
         return GetBillboardPos(iPos, iTexCoord2, modelMatrix);
     #else
     #else
-        return (modelMatrix * iPos).xyz;
+        return (iPos * modelMatrix).xyz;
     #endif
     #endif
 }
 }
 
 
 vec3 GetWorldNormal(mat4 modelMatrix)
 vec3 GetWorldNormal(mat4 modelMatrix)
 {
 {
-    #if defined(SKINNED) || defined(INSTANCED)
-        return normalize(iNormal * GetNormalMatrix(modelMatrix));
-    #elif defined(BILLBOARD)
+    #if defined(BILLBOARD)
         return GetBillboardNormal();
         return GetBillboardNormal();
     #else
     #else
-        return normalize(GetNormalMatrix(modelMatrix) * iNormal);
+        return normalize(iNormal * GetNormalMatrix(modelMatrix));
     #endif
     #endif
 }
 }
 
 
 vec3 GetWorldTangent(mat4 modelMatrix)
 vec3 GetWorldTangent(mat4 modelMatrix)
-{   
-    mat3 normalMatrix = GetNormalMatrix(modelMatrix);
-    #if defined(SKINNED) || defined(INSTANCED)
-        return normalize(iTangent.xyz * normalMatrix);
-    #else
-        return normalize(normalMatrix * iTangent.xyz);
-    #endif
+{
+    return normalize(iTangent.xyz * GetNormalMatrix(modelMatrix));
 }
 }
+
+#else
+
+// Silence GLSL 150 deprecation warnings
+#ifdef GL3
+#define varying in
+
+// \todo: should not hardcode the number of MRT outputs according to defines
+#if defined(DEFERRED)
+out vec4 fragData[4];
+#elif defined(PREPASS)
+out vec4 fragData[2];
+#else
+out vec4 fragData[1];
 #endif
 #endif
+
+#define gl_FragColor fragData[0]
+#define gl_FragData fragData
+#endif
+
+#endif

+ 132 - 6
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Uniforms.glsl

@@ -1,4 +1,13 @@
+// Use of constant buffers on OpenGL 3 commented out for now as it seems to be slower in practice
+//#define USE_CBUFFERS
+
+#if !defined(GL3) || !defined(USE_CBUFFERS)
+
+// OpenGL 2 uniforms (no constant buffers)
+
 #ifdef COMPILEVS
 #ifdef COMPILEVS
+          
+// Vertex shader uniforms
 uniform vec3 cAmbientStartColor;
 uniform vec3 cAmbientStartColor;
 uniform vec3 cAmbientEndColor;
 uniform vec3 cAmbientEndColor;
 uniform mat3 cBillboardRot;
 uniform mat3 cBillboardRot;
@@ -17,7 +26,6 @@ uniform mat4 cModel;
 uniform mat4 cViewProj;
 uniform mat4 cViewProj;
 uniform vec4 cUOffset;
 uniform vec4 cUOffset;
 uniform vec4 cVOffset;
 uniform vec4 cVOffset;
-uniform vec4 cLMOffset;
 uniform mat4 cZone;
 uniform mat4 cZone;
 #if !defined(GL_ES) || defined(WEBGL)
 #if !defined(GL_ES) || defined(WEBGL)
     uniform mat4 cLightMatrices[4];
     uniform mat4 cLightMatrices[4];
@@ -25,18 +33,19 @@ uniform mat4 cZone;
     uniform mat4 cLightMatrices[2];
     uniform mat4 cLightMatrices[2];
 #endif
 #endif
 #ifdef SKINNED
 #ifdef SKINNED
-    #ifdef RPI
-        uniform vec4 cSkinMatrices[32*3];
-    #else
-        uniform vec4 cSkinMatrices[64*3];
-    #endif
+    uniform vec4 cSkinMatrices[MAXBONES*3];
 #endif
 #endif
 #ifdef NUMVERTEXLIGHTS
 #ifdef NUMVERTEXLIGHTS
     uniform vec4 cVertexLights[4*3];
     uniform vec4 cVertexLights[4*3];
 #endif
 #endif
+#ifdef GL3
+    uniform vec4 cClipPlane;
+#endif
 #endif
 #endif
 
 
 #ifdef COMPILEPS
 #ifdef COMPILEPS
+
+// Fragment shader uniforms
 #ifdef GL_ES
 #ifdef GL_ES
     precision mediump float;
     precision mediump float;
 #endif
 #endif
@@ -64,4 +73,121 @@ uniform vec2 cShadowIntensity;
 uniform vec2 cShadowMapInvSize;
 uniform vec2 cShadowMapInvSize;
 uniform vec4 cShadowSplits;
 uniform vec4 cShadowSplits;
 uniform mat4 cLightMatricesPS[4];
 uniform mat4 cLightMatricesPS[4];
+
+#endif
+
+#else
+
+// OpenGL 3 uniforms (using constant buffers)
+
+#ifdef COMPILEVS
+
+uniform FrameVS
+{
+    float cDeltaTime;
+    float cElapsedTime;
+};
+
+uniform CameraVS
+{
+    vec3 cCameraPos;
+    mat3 cCameraRot;
+    float cNearClip;
+    float cFarClip;
+    vec4 cDepthMode;
+    vec3 cFrustumSize;
+    vec4 cGBufferOffsets;
+    mat4 cViewProj;
+    vec4 cClipPlane;
+};
+
+uniform ZoneVS
+{
+    vec3 cAmbientStartColor;
+    vec3 cAmbientEndColor;
+    mat4 cZone;
+};
+
+uniform LightVS
+{
+    vec3 cLightDir;
+    vec4 cLightPos;
+#ifdef NUMVERTEXLIGHTS
+    vec4 cVertexLights[4 * 3];
+#else
+    mat4 cLightMatrices[4];
+#endif
+};
+
+#ifndef CUSTOM_MATERIAL_CBUFFER
+uniform MaterialVS
+{
+    vec4 cUOffset;
+    vec4 cVOffset;
+};
+#endif
+
+uniform ObjectVS
+{
+    mat4 cModel;
+#ifdef BILLBOARD
+    mat3 cBillboardRot;
+#endif
+#ifdef SKINNED
+    uniform vec4 cSkinMatrices[MAXBONES*3];
+#endif
+};
+
+#endif
+
+#ifdef COMPILEPS
+
+// Pixel shader uniforms
+uniform FramePS
+{
+    float cDeltaTimePS;
+    float cElapsedTimePS;
+};
+
+uniform CameraPS
+{
+    vec3 cCameraPosPS;
+    vec4 cDepthReconstruct;
+    vec2 cGBufferInvSize;
+    float cNearClipPS;
+    float cFarClipPS;
+};
+
+uniform ZonePS
+{
+    vec3 cAmbientColor;
+    vec4 cFogParams;
+    vec3 cFogColor;
+};
+
+uniform LightPS
+{
+    vec4 cLightColor;
+    vec4 cLightPosPS;
+    vec3 cLightDirPS;
+    vec4 cShadowCubeAdjust;
+    vec4 cShadowDepthFade;
+    vec2 cShadowIntensity;
+    vec2 cShadowMapInvSize;
+    vec4 cShadowSplits;
+    mat4 cLightMatricesPS[4];
+};
+
+#ifndef CUSTOM_MATERIAL_CBUFFER
+uniform MaterialPS
+{
+    vec4 cMatDiffColor;
+    vec3 cMatEmissiveColor;
+    vec3 cMatEnvMapColor;
+    vec4 cMatSpecColor;
+};
+#endif
+
+#endif
+
 #endif
 #endif

+ 3 - 3
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/Unlit.glsl

@@ -41,7 +41,7 @@ void VS()
 {
 {
     mat4 modelMatrix = iModelMatrix;
     mat4 modelMatrix = iModelMatrix;
     vec3 worldPos = GetWorldPos(modelMatrix);
     vec3 worldPos = GetWorldPos(modelMatrix);
-    float height = worldPos.y - cModel[3][1];
+    float height = worldPos.y - cModel[1][3];
 
 
     float windStrength = max(height - cWindHeightPivot, 0.0) * cWindHeightFactor;
     float windStrength = max(height - cWindHeightPivot, 0.0) * cWindHeightFactor;
     float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
     float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
@@ -73,11 +73,11 @@ void VS()
 
 
         #ifdef SPOTLIGHT
         #ifdef SPOTLIGHT
             // Spotlight projection: transform from world space to projector texture coordinates
             // Spotlight projection: transform from world space to projector texture coordinates
-            vSpotPos = cLightMatrices[0] * projWorldPos;
+            vSpotPos = projWorldPos * cLightMatrices[0];
         #endif
         #endif
     
     
         #ifdef POINTLIGHT
         #ifdef POINTLIGHT
-            vCubeMaskVec = mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz) * (worldPos - cLightPos.xyz);
+            vCubeMaskVec = (worldPos - cLightPos.xyz) * mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz);
         #endif
         #endif
     #else
     #else
         // Ambient & per-vertex lighting
         // Ambient & per-vertex lighting

+ 3 - 3
Data/AtomicPlayer/Resources/CoreData/Shaders/GLSL/VegetationDepth.glsl

@@ -7,7 +7,7 @@ void VS(float4 iPos : POSITION,
     float4 iColor : COLOR0,
     float4 iColor : COLOR0,
     out float4 oColor : COLOR0,
     out float4 oColor : COLOR0,
     out float2 oTexCoord : TEXCOORD0,
     out float2 oTexCoord : TEXCOORD0,
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -19,9 +19,9 @@ void VS(float4 iPos : POSITION,
 
 
 void PS(float4 iColor : COLOR0,
 void PS(float4 iColor : COLOR0,
         float2 iTexCoord : TEXCOORD0,
         float2 iTexCoord : TEXCOORD0,
-        out float4 oColor : COLOR0)
+        out float4 oColor : OUTCOLOR0)
 {
 {
     float4 diffColor = cMatDiffColor * iColor;
     float4 diffColor = cMatDiffColor * iColor;
-    float4 diffInput = tex2D(sDiffMap, iTexCoord);
+    float4 diffInput = Sample2D(DiffMap, iTexCoord);
     oColor = diffColor * diffInput;
     oColor = diffColor * diffInput;
 }
 }

+ 34 - 11
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/AutoExposure.hlsl

@@ -16,20 +16,31 @@ uniform float2 cLum64InvSize;
 uniform float2 cLum16InvSize;
 uniform float2 cLum16InvSize;
 uniform float2 cLum4InvSize;
 uniform float2 cLum4InvSize;
 
 
+#ifndef D3D11
 float GatherAvgLum(sampler2D texSampler, float2 texCoord, float2 texelSize)
 float GatherAvgLum(sampler2D texSampler, float2 texCoord, float2 texelSize)
+#else
+float GatherAvgLum(Texture2D tex, SamplerState texSampler, float2 texCoord, float2 texelSize)
+#endif
 {
 {
     float lumAvg = 0.0;
     float lumAvg = 0.0;
+    #ifndef D3D11
     lumAvg += tex2D(texSampler, texCoord + float2(0.0, 0.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(0.0, 0.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(0.0, 2.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(0.0, 2.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(2.0, 2.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(2.0, 2.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(2.0, 0.0) * texelSize).r;
     lumAvg += tex2D(texSampler, texCoord + float2(2.0, 0.0) * texelSize).r;
+    #else
+    lumAvg += tex.Sample(texSampler, texCoord + float2(0.0, 0.0) * texelSize).r;
+    lumAvg += tex.Sample(texSampler, texCoord + float2(0.0, 2.0) * texelSize).r;
+    lumAvg += tex.Sample(texSampler, texCoord + float2(2.0, 2.0) * texelSize).r;
+    lumAvg += tex.Sample(texSampler, texCoord + float2(2.0, 0.0) * texelSize).r;
+    #endif
     return lumAvg / 4.0;
     return lumAvg / 4.0;
 }
 }
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
     out float2 oTexCoord : TEXCOORD0,
     out float2 oTexCoord : TEXCOORD0,
-    out float2 oScreenPos : TEXCOORD1)
+    out float2 oScreenPos : TEXCOORD1,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -58,38 +69,50 @@ void VS(float4 iPos : POSITION,
 
 
 void PS(float2 iTexCoord : TEXCOORD0,
 void PS(float2 iTexCoord : TEXCOORD0,
     float2 iScreenPos : TEXCOORD1,
     float2 iScreenPos : TEXCOORD1,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     #ifdef LUMINANCE64
     #ifdef LUMINANCE64
     float logLumSum = 0.0;
     float logLumSum = 0.0;
-    logLumSum += log(dot(tex2D(sDiffMap, iTexCoord + float2(0.0, 0.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
-    logLumSum += log(dot(tex2D(sDiffMap, iTexCoord + float2(0.0, 2.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
-    logLumSum += log(dot(tex2D(sDiffMap, iTexCoord + float2(2.0, 2.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
-    logLumSum += log(dot(tex2D(sDiffMap, iTexCoord + float2(2.0, 0.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
+    logLumSum += log(dot(Sample2D(DiffMap, iTexCoord + float2(0.0, 0.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
+    logLumSum += log(dot(Sample2D(DiffMap, iTexCoord + float2(0.0, 2.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
+    logLumSum += log(dot(Sample2D(DiffMap, iTexCoord + float2(2.0, 2.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
+    logLumSum += log(dot(Sample2D(DiffMap, iTexCoord + float2(2.0, 0.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
     oColor = logLumSum;
     oColor = logLumSum;
     #endif
     #endif
 
 
     #ifdef LUMINANCE16
     #ifdef LUMINANCE16
+    #ifndef D3D11
     oColor = GatherAvgLum(sDiffMap, iTexCoord, cLum64InvSize);
     oColor = GatherAvgLum(sDiffMap, iTexCoord, cLum64InvSize);
+    #else
+    oColor = GatherAvgLum(tDiffMap, sDiffMap, iTexCoord, cLum64InvSize);
+    #endif
     #endif
     #endif
 
 
     #ifdef LUMINANCE4
     #ifdef LUMINANCE4
+    #ifndef D3D11
     oColor = GatherAvgLum(sDiffMap, iTexCoord, cLum16InvSize);
     oColor = GatherAvgLum(sDiffMap, iTexCoord, cLum16InvSize);
+    #else
+    oColor = GatherAvgLum(tDiffMap, sDiffMap, iTexCoord, cLum16InvSize);
+    #endif
     #endif
     #endif
 
 
     #ifdef LUMINANCE1
     #ifdef LUMINANCE1
+    #ifndef D3D11
     oColor = exp(GatherAvgLum(sDiffMap, iTexCoord, cLum4InvSize) / 16.0);
     oColor = exp(GatherAvgLum(sDiffMap, iTexCoord, cLum4InvSize) / 16.0);
+    #else
+    oColor = exp(GatherAvgLum(tDiffMap, sDiffMap, iTexCoord, cLum4InvSize) / 16.0);
+    #endif
     #endif
     #endif
 
 
     #ifdef ADAPTLUMINANCE
     #ifdef ADAPTLUMINANCE
-    float adaptedLum = tex2D(sDiffMap, iTexCoord).r;
-    float lum = clamp(tex2D(sNormalMap, iTexCoord).r, cAutoExposureLumRange.x, cAutoExposureLumRange.y);
+    float adaptedLum = Sample2D(DiffMap, iTexCoord).r;
+    float lum = clamp(Sample2D(NormalMap, iTexCoord).r, cAutoExposureLumRange.x, cAutoExposureLumRange.y);
     oColor = adaptedLum + (lum - adaptedLum) * (1.0 - exp(-cDeltaTimePS * cAutoExposureAdaptRate));
     oColor = adaptedLum + (lum - adaptedLum) * (1.0 - exp(-cDeltaTimePS * cAutoExposureAdaptRate));
     #endif
     #endif
 
 
     #ifdef EXPOSE
     #ifdef EXPOSE
-    float3 color = tex2D(sDiffMap, iScreenPos).rgb;
-    float adaptedLum = tex2D(sNormalMap, iTexCoord).r;
+    float3 color = Sample2D(DiffMap, iScreenPos).rgb;
+    float adaptedLum = Sample2D(NormalMap, iTexCoord).r;
     oColor = float4(color * (cAutoExposureMiddleGrey / adaptedLum), 1.0);
     oColor = float4(color * (cAutoExposureMiddleGrey / adaptedLum), 1.0);
     #endif
     #endif
 }
 }

+ 14 - 4
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Basic.hlsl

@@ -23,12 +23,19 @@ void VS(float4 iPos : POSITION,
     #ifdef DIFFMAP
     #ifdef DIFFMAP
         out float2 oTexCoord : TEXCOORD0,
         out float2 oTexCoord : TEXCOORD0,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);
     oPos = GetClipPos(worldPos);
 
 
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         oColor = iColor;
         oColor = iColor;
     #endif
     #endif
@@ -44,7 +51,10 @@ void PS(
     #if defined(DIFFMAP) || defined(ALPHAMAP)
     #if defined(DIFFMAP) || defined(ALPHAMAP)
         float2 iTexCoord : TEXCOORD0,
         float2 iTexCoord : TEXCOORD0,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif    
+    out float4 oColor : OUTCOLOR0)
 {
 {
     float4 diffColor = cMatDiffColor;
     float4 diffColor = cMatDiffColor;
 
 
@@ -56,7 +66,7 @@ void PS(
         oColor = diffColor;
         oColor = diffColor;
     #endif
     #endif
     #ifdef DIFFMAP
     #ifdef DIFFMAP
-        float4 diffInput = tex2D(sDiffMap, iTexCoord);
+        float4 diffInput = Sample2D(DiffMap, iTexCoord);
         #ifdef ALPHAMASK
         #ifdef ALPHAMASK
             if (diffInput.a < 0.5)
             if (diffInput.a < 0.5)
                 discard;
                 discard;
@@ -64,7 +74,7 @@ void PS(
         oColor = diffColor * diffInput;
         oColor = diffColor * diffInput;
     #endif
     #endif
     #ifdef ALPHAMAP
     #ifdef ALPHAMAP
-        float alphaInput = tex2D(sDiffMap, iTexCoord).a;
+        float alphaInput = Sample2D(DiffMap, iTexCoord).a;
         oColor = float4(diffColor.rgb, diffColor.a * alphaInput);
         oColor = float4(diffColor.rgb, diffColor.a * alphaInput);
     #endif
     #endif
 }
 }

+ 30 - 8
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Bloom.hlsl

@@ -3,11 +3,33 @@
 #include "Samplers.hlsl"
 #include "Samplers.hlsl"
 #include "ScreenPos.hlsl"
 #include "ScreenPos.hlsl"
 
 
+#ifndef D3D11
+
+// D3D9 uniforms
 uniform float cBloomThreshold;
 uniform float cBloomThreshold;
 uniform float2 cBloomMix;
 uniform float2 cBloomMix;
 uniform float2 cHBlurOffsets;
 uniform float2 cHBlurOffsets;
 uniform float2 cHBlurInvSize;
 uniform float2 cHBlurInvSize;
 
 
+#else
+
+// D3D11 constant buffers
+#ifdef COMPILEVS
+cbuffer CustomVS : register(b6)
+{
+    float2 cHBlurOffsets;
+}
+#else
+cbuffer CustomPS : register(b6)
+{
+    float cBloomThreshold;
+    float2 cBloomMix;
+    float2 cHBlurInvSize;
+}
+#endif
+
+#endif
+
 static const float offsets[5] = {
 static const float offsets[5] = {
     2.0,
     2.0,
     1.0,
     1.0,
@@ -25,9 +47,9 @@ static const float weights[5] = {
 };
 };
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
     out float2 oTexCoord : TEXCOORD0,
     out float2 oTexCoord : TEXCOORD0,
-    out float2 oScreenPos : TEXCOORD1)
+    out float2 oScreenPos : TEXCOORD1,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -38,30 +60,30 @@ void VS(float4 iPos : POSITION,
 
 
 void PS(float2 iTexCoord : TEXCOORD0,
 void PS(float2 iTexCoord : TEXCOORD0,
     float2 iScreenPos : TEXCOORD1,
     float2 iScreenPos : TEXCOORD1,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     #ifdef BRIGHT
     #ifdef BRIGHT
-    float3 rgb = tex2D(sDiffMap, iScreenPos).rgb;
+    float3 rgb = Sample2D(DiffMap, iScreenPos).rgb;
     oColor = float4((rgb - cBloomThreshold) / (1.0 - cBloomThreshold), 1.0);
     oColor = float4((rgb - cBloomThreshold) / (1.0 - cBloomThreshold), 1.0);
     #endif
     #endif
 
 
     #ifdef HBLUR
     #ifdef HBLUR
     float3 rgb = 0.0;
     float3 rgb = 0.0;
     for (int i = 0; i < 5; ++i)
     for (int i = 0; i < 5; ++i)
-        rgb += tex2D(sDiffMap, iTexCoord + (float2(offsets[i], 0.0)) * cHBlurInvSize).rgb * weights[i];
+        rgb += Sample2D(DiffMap, iTexCoord + (float2(offsets[i], 0.0)) * cHBlurInvSize).rgb * weights[i];
     oColor = float4(rgb, 1.0);
     oColor = float4(rgb, 1.0);
     #endif
     #endif
 
 
     #ifdef VBLUR
     #ifdef VBLUR
     float3 rgb = 0.0;
     float3 rgb = 0.0;
     for (int i = 0; i < 5; ++i)
     for (int i = 0; i < 5; ++i)
-        rgb += tex2D(sDiffMap, iTexCoord + (float2(0.0, offsets[i])) * cHBlurInvSize).rgb * weights[i];
+        rgb += Sample2D(DiffMap, iTexCoord + (float2(0.0, offsets[i])) * cHBlurInvSize).rgb * weights[i];
     oColor = float4(rgb, 1.0);
     oColor = float4(rgb, 1.0);
     #endif
     #endif
 
 
     #ifdef COMBINE
     #ifdef COMBINE
-    float3 original = tex2D(sDiffMap, iScreenPos).rgb * cBloomMix.x;
-    float3 bloom = tex2D(sNormalMap, iTexCoord).rgb  * cBloomMix.y;
+    float3 original = Sample2D(DiffMap, iScreenPos).rgb * cBloomMix.x;
+    float3 bloom = Sample2D(NormalMap, iTexCoord).rgb  * cBloomMix.y;
     // Prevent oversaturation
     // Prevent oversaturation
     original *= saturate(1.0 - bloom);
     original *= saturate(1.0 - bloom);
     oColor = float4(original + bloom, 1.0);
     oColor = float4(original + bloom, 1.0);

+ 62 - 9
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/BloomHDR.hlsl

@@ -4,6 +4,9 @@
 #include "ScreenPos.hlsl"
 #include "ScreenPos.hlsl"
 #include "PostProcess.hlsl"
 #include "PostProcess.hlsl"
 
 
+#ifndef D3D11
+
+// D3D9 uniforms
 uniform float cBloomHDRThreshold;
 uniform float cBloomHDRThreshold;
 uniform float2 cBloomHDRBlurDir;
 uniform float2 cBloomHDRBlurDir;
 uniform float cBloomHDRBlurRadius;
 uniform float cBloomHDRBlurRadius;
@@ -18,12 +21,40 @@ uniform float2 cBright4InvSize;
 uniform float2 cBright8InvSize;
 uniform float2 cBright8InvSize;
 uniform float2 cBright16InvSize;
 uniform float2 cBright16InvSize;
 
 
+#else
+
+// D3D11 constant buffers
+#ifdef COMPILEVS
+cbuffer CustomVS : register(b6)
+{
+    float2 cBright2Offsets;
+    float2 cBright4Offsets;
+    float2 cBright8Offsets;
+    float2 cBright16Offsets;
+}
+#else
+cbuffer CustomPS : register(b6)
+{
+    float cBloomHDRThreshold;
+    float2 cBloomHDRBlurDir;
+    float cBloomHDRBlurRadius;
+    float cBloomHDRBlurSigma;
+    float2 cBloomHDRMix;
+    float2 cBright2InvSize;
+    float2 cBright4InvSize;
+    float2 cBright8InvSize;
+    float2 cBright16InvSize;
+}
+#endif
+
+#endif
+
 static const int BlurKernelSize = 5;
 static const int BlurKernelSize = 5;
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
     out float2 oTexCoord : TEXCOORD0,
     out float2 oTexCoord : TEXCOORD0,
-    out float2 oScreenPos : TEXCOORD1)
+    out float2 oScreenPos : TEXCOORD1,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -68,13 +99,15 @@ void VS(float4 iPos : POSITION,
 
 
 void PS(float2 iTexCoord : TEXCOORD0,
 void PS(float2 iTexCoord : TEXCOORD0,
     float2 iScreenPos : TEXCOORD1,
     float2 iScreenPos : TEXCOORD1,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     #ifdef BRIGHT
     #ifdef BRIGHT
-    float3 color = tex2D(sDiffMap, iScreenPos).rgb;
+    float3 color = Sample2D(DiffMap, iScreenPos).rgb;
     oColor = float4(max(color - cBloomHDRThreshold, 0.0), 1.0);
     oColor = float4(max(color - cBloomHDRThreshold, 0.0), 1.0);
     #endif
     #endif
 
 
+    #ifndef D3D11
+
     #ifdef BLUR16
     #ifdef BLUR16
     oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright16InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, iTexCoord);
     oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright16InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, iTexCoord);
     #endif
     #endif
@@ -90,22 +123,42 @@ void PS(float2 iTexCoord : TEXCOORD0,
     #ifdef BLUR2
     #ifdef BLUR2
     oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright2InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, iTexCoord);
     oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright2InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, iTexCoord);
     #endif
     #endif
+    
+    #else
+
+    #ifdef BLUR16
+    oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright16InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, tDiffMap, sDiffMap, iTexCoord);
+    #endif
+
+    #ifdef BLUR8
+    oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright8InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, tDiffMap, sDiffMap, iTexCoord);
+    #endif
+
+    #ifdef BLUR4
+    oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright4InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, tDiffMap, sDiffMap, iTexCoord);
+    #endif
+
+    #ifdef BLUR2
+    oColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright2InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, tDiffMap, sDiffMap, iTexCoord);
+    #endif
+    
+    #endif
 
 
     #ifdef COMBINE16
     #ifdef COMBINE16
-    oColor = tex2D(sDiffMap, iScreenPos) + tex2D(sNormalMap, iTexCoord);
+    oColor = Sample2D(DiffMap, iScreenPos) + Sample2D(NormalMap, iTexCoord);
     #endif
     #endif
 
 
     #ifdef COMBINE8
     #ifdef COMBINE8
-    oColor = tex2D(sDiffMap, iScreenPos) + tex2D(sNormalMap, iTexCoord);
+    oColor = Sample2D(DiffMap, iScreenPos) + Sample2D(NormalMap, iTexCoord);
     #endif
     #endif
 
 
     #ifdef COMBINE4
     #ifdef COMBINE4
-    oColor = tex2D(sDiffMap, iScreenPos) + tex2D(sNormalMap, iTexCoord);
+    oColor = Sample2D(DiffMap, iScreenPos) + Sample2D(NormalMap, iTexCoord);
     #endif
     #endif
 
 
     #ifdef COMBINE2
     #ifdef COMBINE2
-    float3 color = tex2D(sDiffMap, iScreenPos).rgb * cBloomHDRMix.x;
-    float3 bloom = tex2D(sNormalMap, iTexCoord).rgb * cBloomHDRMix.y;
+    float3 color = Sample2D(DiffMap, iScreenPos).rgb * cBloomHDRMix.x;
+    float3 bloom = Sample2D(NormalMap, iTexCoord).rgb * cBloomHDRMix.y;
     oColor = float4(color + bloom, 1.0);
     oColor = float4(color + bloom, 1.0);
     #endif
     #endif
 }
 }

+ 17 - 0
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Blur.hlsl

@@ -0,0 +1,17 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+#include "ScreenPos.hlsl"
+
+void VS(float4 iPos : POSITION,
+    out float4 oPos : OUTPOSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+}
+
+void PS(out float4 oColor : OUTCOLOR0)
+{
+    oColor = cMatDiffColor;
+}

+ 9 - 5
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/ColorCorrection.hlsl

@@ -5,8 +5,8 @@
 #include "PostProcess.hlsl"
 #include "PostProcess.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float2 oScreenPos : TEXCOORD0)
+    out float2 oScreenPos : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -15,8 +15,12 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
-    float3 color = tex2D(sDiffMap, iScreenPos).rgb;
-    oColor = float4(ColorCorrection(color, sVolumeMap), 1.0);
+    float3 color = Sample2D(DiffMap, iScreenPos).rgb;
+    #ifndef D3D11
+        oColor = float4(ColorCorrection(color, sVolumeMap), 1.0);
+    #else
+        oColor = float4(ColorCorrection(color, tVolumeMap, sVolumeMap), 1.0);
+    #endif
 }
 }

+ 3 - 3
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/CopyFramebuffer.hlsl

@@ -5,7 +5,7 @@
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
     out float2 oScreenPos : TEXCOORD0,
     out float2 oScreenPos : TEXCOORD0,
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -14,7 +14,7 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
-    oColor = tex2D(sDiffMap, iScreenPos);
+    oColor = Sample2D(DiffMap, iScreenPos);
 }
 }

+ 9 - 9
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/DeferredLight.hlsl

@@ -14,7 +14,7 @@ void VS(float4 iPos : POSITION,
     #ifdef ORTHO
     #ifdef ORTHO
         out float3 oNearRay : TEXCOORD2,
         out float3 oNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -44,11 +44,11 @@ void PS(
     #ifdef ORTHO
     #ifdef ORTHO
         float3 iNearRay : TEXCOORD2,
         float3 iNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // If rendering a directional light quad, optimize out the w divide
     // If rendering a directional light quad, optimize out the w divide
     #ifdef DIRLIGHT
     #ifdef DIRLIGHT
-        float depth = Sample(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DLod0(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -57,10 +57,10 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth;
             float3 worldPos = iFarRay * depth;
         #endif
         #endif
-        float4 albedoInput = Sample(sAlbedoBuffer, iScreenPos);
-        float4 normalInput = Sample(sNormalBuffer, iScreenPos);
+        float4 albedoInput = Sample2DLod0(AlbedoBuffer, iScreenPos);
+        float4 normalInput = Sample2DLod0(NormalBuffer, iScreenPos);
     #else
     #else
-        float depth = tex2Dproj(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DProj(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -69,8 +69,8 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth / iScreenPos.w;
             float3 worldPos = iFarRay * depth / iScreenPos.w;
         #endif
         #endif
-        float4 albedoInput = tex2Dproj(sAlbedoBuffer, iScreenPos);
-        float4 normalInput = tex2Dproj(sNormalBuffer, iScreenPos);
+        float4 albedoInput = Sample2DProj(AlbedoBuffer, iScreenPos);
+        float4 normalInput = Sample2DProj(NormalBuffer, iScreenPos);
     #endif
     #endif
     
     
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
@@ -86,7 +86,7 @@ void PS(
 
 
     #if defined(SPOTLIGHT)
     #if defined(SPOTLIGHT)
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
-        lightColor = spotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : 0.0;
+        lightColor = spotPos.w > 0.0 ? Sample2DProj(LightSpotMap, spotPos).rgb * cLightColor.rgb : 0.0;
     #elif defined(CUBEMASK)
     #elif defined(CUBEMASK)
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
     #else
     #else

+ 27 - 12
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Depth.hlsl

@@ -11,11 +11,26 @@
 #include "Transform.hlsl"
 #include "Transform.hlsl"
 #include "ScreenPos.hlsl"
 #include "ScreenPos.hlsl"
 
 
+#ifndef D3D11
+
+// D3D9 uniforms
 uniform float4 cFXAAParams;
 uniform float4 cFXAAParams;
 
 
+#else
+
+// D3D11 constant buffers
+#ifdef COMPILEPS
+cbuffer CustomPS : register(b6)
+{
+    float4 cFXAAParams;
+}
+#endif
+
+#endif
+
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float2 oScreenPos : TEXCOORD0)
+    out float2 oScreenPos : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -24,7 +39,7 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     float FXAA_SUBPIX_SHIFT = 1.0/4.0; // Not used
     float FXAA_SUBPIX_SHIFT = 1.0/4.0; // Not used
     float FXAA_SPAN_MAX = 8.0;
     float FXAA_SPAN_MAX = 8.0;
@@ -33,11 +48,11 @@ void PS(float2 iScreenPos : TEXCOORD0,
 
 
     float2 posOffset = cGBufferInvSize.xy * cFXAAParams.x;
     float2 posOffset = cGBufferInvSize.xy * cFXAAParams.x;
 
 
-    float3 rgbNW = Sample(sDiffMap, iScreenPos + float2(-posOffset.x, -posOffset.y)).rgb;
-    float3 rgbNE = Sample(sDiffMap, iScreenPos + float2(posOffset.x, -posOffset.y)).rgb;
-    float3 rgbSW = Sample(sDiffMap, iScreenPos + float2(-posOffset.x, posOffset.y)).rgb;
-    float3 rgbSE = Sample(sDiffMap, iScreenPos + float2(posOffset.x, posOffset.y)).rgb;
-    float3 rgbM  = Sample(sDiffMap, iScreenPos).rgb;
+    float3 rgbNW = Sample2DLod0(DiffMap, iScreenPos + float2(-posOffset.x, -posOffset.y)).rgb;
+    float3 rgbNE = Sample2DLod0(DiffMap, iScreenPos + float2(posOffset.x, -posOffset.y)).rgb;
+    float3 rgbSW = Sample2DLod0(DiffMap, iScreenPos + float2(-posOffset.x, posOffset.y)).rgb;
+    float3 rgbSE = Sample2DLod0(DiffMap, iScreenPos + float2(posOffset.x, posOffset.y)).rgb;
+    float3 rgbM  = Sample2DLod0(DiffMap, iScreenPos).rgb;
 
 
     float3 luma = float3(0.299, 0.587, 0.114);
     float3 luma = float3(0.299, 0.587, 0.114);
     float lumaNW = dot(rgbNW, luma);
     float lumaNW = dot(rgbNW, luma);
@@ -66,11 +81,11 @@ void PS(float2 iScreenPos : TEXCOORD0,
         dir *= cFXAAParams.z;
         dir *= cFXAAParams.z;
     
     
         float3 rgbA = (1.0/2.0) * (
         float3 rgbA = (1.0/2.0) * (
-            Sample(sDiffMap, iScreenPos + dir * (1.0/3.0 - 0.5)).xyz +
-            Sample(sDiffMap, iScreenPos + dir * (2.0/3.0 - 0.5)).xyz);
+            Sample2DLod0(DiffMap, iScreenPos + dir * (1.0/3.0 - 0.5)).xyz +
+            Sample2DLod0(DiffMap, iScreenPos + dir * (2.0/3.0 - 0.5)).xyz);
         float3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
         float3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
-            Sample(sDiffMap, iScreenPos + dir * (0.0/3.0 - 0.5)).xyz +
-            Sample(sDiffMap, iScreenPos + dir * (3.0/3.0 - 0.5)).xyz);
+            Sample2DLod0(DiffMap, iScreenPos + dir * (0.0/3.0 - 0.5)).xyz +
+            Sample2DLod0(DiffMap, iScreenPos + dir * (3.0/3.0 - 0.5)).xyz);
         float lumaB = dot(rgbB, luma);
         float lumaB = dot(rgbB, luma);
         
         
         float3 rgbOut;
         float3 rgbOut;

+ 50 - 44
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/FXAA3.hlsl

@@ -49,6 +49,7 @@
 #include "Transform.hlsl"
 #include "Transform.hlsl"
 #include "ScreenPos.hlsl"
 #include "ScreenPos.hlsl"
 
 
+#ifdef COMPILEPS
 /*============================================================================
 /*============================================================================
                         FXAA QUALITY - TUNING KNOBS
                         FXAA QUALITY - TUNING KNOBS
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
@@ -296,10 +297,15 @@ float CalcLuma(float3 rgb)
 
 
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
 
 
-#define FxaaTexTop(t, p) float4(tex2Dlod(t, float4(p, 0.0, 0.0)).rgb, 1.0)
-
-#define LumaTop(t, p) CalcLuma(tex2Dlod(t, float4(p, 0.0, 0.0)).rgb)
-#define LumaOff(t, p, o, r) CalcLuma(tex2Dlod(t, float4(p + (o * r), 0, 0)).rgb)
+#ifndef D3D11
+#define FxaaTexTop(tex, p) float4(tex2Dlod(s##tex, float4(p, 0.0, 0.0)).rgb, 1.0)
+#define LumaTop(tex, p) CalcLuma(tex2Dlod(s##tex, float4(p, 0.0, 0.0)).rgb)
+#define LumaOff(tex, p, o, r) CalcLuma(tex2Dlod(s##tex, float4(p + (o * r), 0, 0)).rgb)
+#else
+#define FxaaTexTop(tex, p) float4(t##tex.SampleLevel(s##tex, p, 0.0).rgb, 1.0)
+#define LumaTop(tex, p) CalcLuma(t##tex.SampleLevel(s##tex, p, 0.0).rgb)
+#define LumaOff(tex, p, o, r) CalcLuma(t##tex.SampleLevel(s##tex, p + (o * r), 0.0).rgb)
+#endif
 
 
 /*============================================================================
 /*============================================================================
 
 
@@ -316,7 +322,7 @@ float4 FxaaPixelShader(
     // {rgb_} = color in linear or perceptual color space
     // {rgb_} = color in linear or perceptual color space
     // if (FXAA_GREEN_AS_LUMA == 0)
     // if (FXAA_GREEN_AS_LUMA == 0)
     //     {__a} = luma in perceptual color space (not linear)
     //     {__a} = luma in perceptual color space (not linear)
-    sampler2D tex,
+    //sampler2D tex,
     //
     //
     // Only used on FXAA Quality.
     // Only used on FXAA Quality.
     // This must be from a constant/uniform.
     // This must be from a constant/uniform.
@@ -367,13 +373,13 @@ float4 FxaaPixelShader(
     posM.x = pos.x;
     posM.x = pos.x;
     posM.y = pos.y;
     posM.y = pos.y;
     
     
-    float4 rgbyM = FxaaTexTop(tex, posM);
+    float4 rgbyM = FxaaTexTop(DiffMap, posM);
     rgbyM.y = CalcLuma(rgbyM.rgb);
     rgbyM.y = CalcLuma(rgbyM.rgb);
     #define lumaM rgbyM.y
     #define lumaM rgbyM.y
-    float lumaS = LumaOff(tex, posM, float2( 0, 1), fxaaQualityRcpFrame.xy);
-    float lumaE = LumaOff(tex, posM, float2( 1, 0), fxaaQualityRcpFrame.xy);
-    float lumaN = LumaOff(tex, posM, float2( 0,-1), fxaaQualityRcpFrame.xy);
-    float lumaW = LumaOff(tex, posM, float2(-1, 0), fxaaQualityRcpFrame.xy);
+    float lumaS = LumaOff(DiffMap, posM, float2( 0, 1), fxaaQualityRcpFrame.xy);
+    float lumaE = LumaOff(DiffMap, posM, float2( 1, 0), fxaaQualityRcpFrame.xy);
+    float lumaN = LumaOff(DiffMap, posM, float2( 0,-1), fxaaQualityRcpFrame.xy);
+    float lumaW = LumaOff(DiffMap, posM, float2(-1, 0), fxaaQualityRcpFrame.xy);
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
     float maxSM = max(lumaS, lumaM);
     float maxSM = max(lumaS, lumaM);
     float minSM = min(lumaS, lumaM);
     float minSM = min(lumaS, lumaM);
@@ -389,12 +395,12 @@ float4 FxaaPixelShader(
     bool earlyExit = range < rangeMaxClamped;
     bool earlyExit = range < rangeMaxClamped;
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
     if(earlyExit)
     if(earlyExit)
-        return FxaaTexTop(tex, pos);
+        return FxaaTexTop(DiffMap, pos);
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
-    float lumaNW = LumaOff(tex, posM, float2(-1,-1), fxaaQualityRcpFrame.xy);
-    float lumaSE = LumaOff(tex, posM, float2( 1, 1), fxaaQualityRcpFrame.xy);
-    float lumaNE = LumaOff(tex, posM, float2( 1,-1), fxaaQualityRcpFrame.xy);
-    float lumaSW = LumaOff(tex, posM, float2(-1, 1), fxaaQualityRcpFrame.xy);
+    float lumaNW = LumaOff(DiffMap, posM, float2(-1,-1), fxaaQualityRcpFrame.xy);
+    float lumaSE = LumaOff(DiffMap, posM, float2( 1, 1), fxaaQualityRcpFrame.xy);
+    float lumaNE = LumaOff(DiffMap, posM, float2( 1,-1), fxaaQualityRcpFrame.xy);
+    float lumaSW = LumaOff(DiffMap, posM, float2(-1, 1), fxaaQualityRcpFrame.xy);
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
     float lumaNS = lumaN + lumaS;
     float lumaNS = lumaN + lumaS;
     float lumaWE = lumaW + lumaE;
     float lumaWE = lumaW + lumaE;
@@ -452,9 +458,9 @@ float4 FxaaPixelShader(
     posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;
     posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;
     posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;
     posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;
     float subpixD = ((-2.0)*subpixC) + 3.0;
     float subpixD = ((-2.0)*subpixC) + 3.0;
-    float lumaEndN = LumaTop(tex, posN);
+    float lumaEndN = LumaTop(DiffMap, posN);
     float subpixE = subpixC * subpixC;
     float subpixE = subpixC * subpixC;
-    float lumaEndP = LumaTop(tex, posP);
+    float lumaEndP = LumaTop(DiffMap, posP);
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
     if(!pairN) lumaNN = lumaSS;
     if(!pairN) lumaNN = lumaSS;
     float gradientScaled = gradient * 1.0/4.0;
     float gradientScaled = gradient * 1.0/4.0;
@@ -473,8 +479,8 @@ float4 FxaaPixelShader(
     if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;
     if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
     if(doneNP) {
     if(doneNP) {
-        if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-        if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+        if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+        if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
         doneN = abs(lumaEndN) >= gradientScaled;
         doneN = abs(lumaEndN) >= gradientScaled;
@@ -487,8 +493,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
         #if (FXAA_QUALITY_PS > 3)
         #if (FXAA_QUALITY_PS > 3)
         if(doneNP) {
         if(doneNP) {
-            if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-            if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+            if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+            if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
             if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
             if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
             if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
             if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
             doneN = abs(lumaEndN) >= gradientScaled;
             doneN = abs(lumaEndN) >= gradientScaled;
@@ -501,8 +507,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
             #if (FXAA_QUALITY_PS > 4)
             #if (FXAA_QUALITY_PS > 4)
             if(doneNP) {
             if(doneNP) {
-                if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                 doneN = abs(lumaEndN) >= gradientScaled;
                 doneN = abs(lumaEndN) >= gradientScaled;
@@ -515,8 +521,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
                 #if (FXAA_QUALITY_PS > 5)
                 #if (FXAA_QUALITY_PS > 5)
                 if(doneNP) {
                 if(doneNP) {
-                    if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                    if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                    if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                    if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                     if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                     if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                     if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                     if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                     doneN = abs(lumaEndN) >= gradientScaled;
                     doneN = abs(lumaEndN) >= gradientScaled;
@@ -529,8 +535,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
                     #if (FXAA_QUALITY_PS > 6)
                     #if (FXAA_QUALITY_PS > 6)
                     if(doneNP) {
                     if(doneNP) {
-                        if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                        if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                        if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                        if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                         doneN = abs(lumaEndN) >= gradientScaled;
                         doneN = abs(lumaEndN) >= gradientScaled;
@@ -543,8 +549,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
                         #if (FXAA_QUALITY_PS > 7)
                         #if (FXAA_QUALITY_PS > 7)
                         if(doneNP) {
                         if(doneNP) {
-                            if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                            if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                            if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                            if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                             if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                             if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                             if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                             if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                             doneN = abs(lumaEndN) >= gradientScaled;
                             doneN = abs(lumaEndN) >= gradientScaled;
@@ -557,8 +563,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
     #if (FXAA_QUALITY_PS > 8)
     #if (FXAA_QUALITY_PS > 8)
     if(doneNP) {
     if(doneNP) {
-        if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-        if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+        if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+        if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
         doneN = abs(lumaEndN) >= gradientScaled;
         doneN = abs(lumaEndN) >= gradientScaled;
@@ -571,8 +577,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
         #if (FXAA_QUALITY_PS > 9)
         #if (FXAA_QUALITY_PS > 9)
         if(doneNP) {
         if(doneNP) {
-            if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-            if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+            if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+            if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
             if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
             if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
             if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
             if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
             doneN = abs(lumaEndN) >= gradientScaled;
             doneN = abs(lumaEndN) >= gradientScaled;
@@ -585,8 +591,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
             #if (FXAA_QUALITY_PS > 10)
             #if (FXAA_QUALITY_PS > 10)
             if(doneNP) {
             if(doneNP) {
-                if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                 doneN = abs(lumaEndN) >= gradientScaled;
                 doneN = abs(lumaEndN) >= gradientScaled;
@@ -599,8 +605,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
                 #if (FXAA_QUALITY_PS > 11)
                 #if (FXAA_QUALITY_PS > 11)
                 if(doneNP) {
                 if(doneNP) {
-                    if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                    if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                    if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                    if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                     if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                     if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                     if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                     if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                     doneN = abs(lumaEndN) >= gradientScaled;
                     doneN = abs(lumaEndN) >= gradientScaled;
@@ -613,8 +619,8 @@ float4 FxaaPixelShader(
 /*--------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*/
                     #if (FXAA_QUALITY_PS > 12)
                     #if (FXAA_QUALITY_PS > 12)
                     if(doneNP) {
                     if(doneNP) {
-                        if(!doneN) lumaEndN = LumaTop(tex, posN.xy);
-                        if(!doneP) lumaEndP = LumaTop(tex, posP.xy);
+                        if(!doneN) lumaEndN = LumaTop(DiffMap, posN.xy);
+                        if(!doneP) lumaEndP = LumaTop(DiffMap, posP.xy);
                         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                         if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
                         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                         if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
                         doneN = abs(lumaEndN) >= gradientScaled;
                         doneN = abs(lumaEndN) >= gradientScaled;
@@ -678,9 +684,10 @@ float4 FxaaPixelShader(
     float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
     float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
     if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
     if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
     if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
     if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
-    return FxaaTexTop(tex, posM);
+    return FxaaTexTop(DiffMap, posM);
 }
 }
 /*==========================================================================*/
 /*==========================================================================*/
+#endif
 
 
 /*============================================================================
 /*============================================================================
 
 
@@ -689,8 +696,8 @@ float4 FxaaPixelShader(
 ============================================================================*/
 ============================================================================*/
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float2 oScreenPos : TEXCOORD0)
+    out float2 oScreenPos : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -699,13 +706,12 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     float2 rcpFrame = float2(cGBufferInvSize.x, cGBufferInvSize.y);
     float2 rcpFrame = float2(cGBufferInvSize.x, cGBufferInvSize.y);
 
 
     oColor = FxaaPixelShader(
     oColor = FxaaPixelShader(
         iScreenPos,                         // float2 pos,
         iScreenPos,                         // float2 pos,
-        sDiffMap,                           // sampler2D tex,
         rcpFrame,                           // float2 fxaaQualityRcpFrame,
         rcpFrame,                           // float2 fxaaQualityRcpFrame,
         0.75f,                              // float fxaaQualitySubpix,
         0.75f,                              // float fxaaQualitySubpix,
         0.166f,                             // float fxaaQualityEdgeThreshold,
         0.166f,                             // float fxaaQualityEdgeThreshold,

+ 4 - 4
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Fog.hlsl

@@ -5,8 +5,8 @@
 #include "PostProcess.hlsl"
 #include "PostProcess.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float2 oScreenPos : TEXCOORD0)
+    out float2 oScreenPos : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -15,8 +15,8 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
-    float3 color = tex2D(sDiffMap, iScreenPos).rgb;
+    float3 color = Sample2D(DiffMap, iScreenPos).rgb;
     oColor = float4(ToInverseGamma(color), 1.0);
     oColor = float4(ToInverseGamma(color), 1.0);
 }
 }

+ 4 - 4
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/GreyScale.hlsl

@@ -5,8 +5,8 @@
 #include "Lighting.hlsl"
 #include "Lighting.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float2 oScreenPos : TEXCOORD0)
+    out float2 oScreenPos : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -15,9 +15,9 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
-    float3 rgb = tex2D(sDiffMap, iScreenPos).rgb;
+    float3 rgb = Sample2D(DiffMap, iScreenPos).rgb;
     float intensity = GetIntensity(rgb);
     float intensity = GetIntensity(rgb);
     oColor = float4(intensity, intensity, intensity, 1.0);
     oColor = float4(intensity, intensity, intensity, 1.0);
 }
 }

+ 38 - 58
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Lighting.hlsl

@@ -65,11 +65,7 @@ float GetVertexLightVolumetric(int index, float3 worldPos)
 #ifdef SHADOW
 #ifdef SHADOW
 
 
 #ifdef DIRLIGHT
 #ifdef DIRLIGHT
-    #ifdef SM3
-        #define NUMCASCADES 4
-    #else
-        #define NUMCASCADES 3
-    #endif
+    #define NUMCASCADES 4
 #else
 #else
     #define NUMCASCADES 1
     #define NUMCASCADES 1
 #endif
 #endif
@@ -81,9 +77,7 @@ void GetShadowPos(float4 projWorldPos, out float4 shadowPos[NUMCASCADES])
         shadowPos[0] = mul(projWorldPos, cLightMatrices[0]);
         shadowPos[0] = mul(projWorldPos, cLightMatrices[0]);
         shadowPos[1] = mul(projWorldPos, cLightMatrices[1]);
         shadowPos[1] = mul(projWorldPos, cLightMatrices[1]);
         shadowPos[2] = mul(projWorldPos, cLightMatrices[2]);
         shadowPos[2] = mul(projWorldPos, cLightMatrices[2]);
-        #ifdef SM3
-            shadowPos[3] = mul(projWorldPos, cLightMatrices[3]);
-        #endif
+        shadowPos[3] = mul(projWorldPos, cLightMatrices[3]);
     #elif defined(SPOTLIGHT)
     #elif defined(SPOTLIGHT)
         shadowPos[0] = mul(projWorldPos, cLightMatrices[1]);
         shadowPos[0] = mul(projWorldPos, cLightMatrices[1]);
     #else
     #else
@@ -103,7 +97,7 @@ float GetDiffuse(float3 normal, float3 worldPos, out float3 lightDir)
         float3 lightVec = (cLightPosPS.xyz - worldPos) * cLightPosPS.w;
         float3 lightVec = (cLightPosPS.xyz - worldPos) * cLightPosPS.w;
         float lightDist = length(lightVec);
         float lightDist = length(lightVec);
         lightDir = lightVec / lightDist;
         lightDir = lightVec / lightDist;
-        return saturate(dot(normal, lightDir)) * tex1D(sLightRampMap, lightDist).r;
+        return saturate(dot(normal, lightDir)) * Sample2D(LightRampMap, float2(lightDist, 0.0)).r;
     #endif
     #endif
 }
 }
 
 
@@ -114,14 +108,14 @@ float GetDiffuseVolumetric(float3 worldPos)
     #else
     #else
         float3 lightVec = (cLightPosPS.xyz - worldPos) * cLightPosPS.w;
         float3 lightVec = (cLightPosPS.xyz - worldPos) * cLightPosPS.w;
         float lightDist = length(lightVec);
         float lightDist = length(lightVec);
-        return tex1D(sLightRampMap, lightDist).r;
+        return Sample2D(LightRampMap, float2(lightDist, 0.0)).r;
     #endif
     #endif
 }
 }
 
 
 float GetSpecular(float3 normal, float3 eyeVec, float3 lightDir, float specularPower)
 float GetSpecular(float3 normal, float3 eyeVec, float3 lightDir, float specularPower)
 {
 {
     float3 halfVec = normalize(normalize(eyeVec) + lightDir);
     float3 halfVec = normalize(normalize(eyeVec) + lightDir);
-    return pow(dot(normal, halfVec), specularPower);
+    return saturate(pow(dot(normal, halfVec), specularPower));
 }
 }
 
 
 float GetIntensity(float3 color)
 float GetIntensity(float3 color)
@@ -132,30 +126,34 @@ float GetIntensity(float3 color)
 #ifdef SHADOW
 #ifdef SHADOW
 
 
 #ifdef DIRLIGHT
 #ifdef DIRLIGHT
-    #ifdef SM3
-        #define NUMCASCADES 4
-    #else
-        #define NUMCASCADES 3
-    #endif
+    #define NUMCASCADES 4
 #else
 #else
     #define NUMCASCADES 1
     #define NUMCASCADES 1
 #endif
 #endif
 
 
 float GetShadow(float4 shadowPos)
 float GetShadow(float4 shadowPos)
 {
 {
+    #ifdef D3D11
+        shadowPos.xyz /= shadowPos.w;
+    #endif
+
     #ifndef LQSHADOW
     #ifndef LQSHADOW
         // Take four samples and average them
         // Take four samples and average them
         // Note: in case of sampling a point light cube shadow, we optimize out the w divide as it has already been performed
         // Note: in case of sampling a point light cube shadow, we optimize out the w divide as it has already been performed
-        #ifndef POINTLIGHT
+        #if !defined(POINTLIGHT) && !defined(D3D11)
             float2 offsets = cShadowMapInvSize * shadowPos.w;
             float2 offsets = cShadowMapInvSize * shadowPos.w;
         #else
         #else
             float2 offsets = cShadowMapInvSize;
             float2 offsets = cShadowMapInvSize;
         #endif
         #endif
+        float4 shadowPos2 = float4(shadowPos.x + offsets.x, shadowPos.yzw);
+        float4 shadowPos3 = float4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw);
+        float4 shadowPos4 = float4(shadowPos.xy + offsets.xy, shadowPos.zw);
+
         float4 inLight = float4(
         float4 inLight = float4(
-            tex2Dproj(sShadowMap, shadowPos).r,
-            tex2Dproj(sShadowMap, float4(shadowPos.x + offsets.x, shadowPos.yzw)).r,
-            tex2Dproj(sShadowMap, float4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw)).r,
-            tex2Dproj(sShadowMap, float4(shadowPos.xy + offsets.xy, shadowPos.zw)).r
+            SampleShadow(ShadowMap, shadowPos).r,
+            SampleShadow(ShadowMap, shadowPos2).r,
+            SampleShadow(ShadowMap, shadowPos3).r,
+            SampleShadow(ShadowMap, shadowPos4).r
         );
         );
         #ifndef SHADOWCMP
         #ifndef SHADOWCMP
             return cShadowIntensity.y + dot(inLight, cShadowIntensity.x);
             return cShadowIntensity.y + dot(inLight, cShadowIntensity.x);
@@ -168,7 +166,7 @@ float GetShadow(float4 shadowPos)
         #endif
         #endif
     #else
     #else
         // Take one sample
         // Take one sample
-        float inLight = tex2Dproj(sShadowMap, shadowPos).r;
+        float inLight = SampleShadow(ShadowMap, shadowPos).r;
         #ifndef SHADOWCMP
         #ifndef SHADOWCMP
             return cShadowIntensity.y + cShadowIntensity.x * inLight;
             return cShadowIntensity.y + cShadowIntensity.x * inLight;
         #else
         #else
@@ -184,7 +182,7 @@ float GetShadow(float4 shadowPos)
 #ifdef POINTLIGHT
 #ifdef POINTLIGHT
 float GetPointShadow(float3 lightVec)
 float GetPointShadow(float3 lightVec)
 {
 {
-    float3 axis = texCUBE(sFaceSelectCubeMap, lightVec).rgb;
+    float3 axis = SampleCube(FaceSelectCubeMap, lightVec).rgb;
     float depth = abs(dot(lightVec, axis));
     float depth = abs(dot(lightVec, axis));
 
 
     // Expand the maximum component of the light vector to get full 0.0 - 1.0 UV range from the cube map,
     // Expand the maximum component of the light vector to get full 0.0 - 1.0 UV range from the cube map,
@@ -194,7 +192,7 @@ float GetPointShadow(float3 lightVec)
     lightVec += factor * axis * lightVec;
     lightVec += factor * axis * lightVec;
 
 
     // Read the 2D UV coordinates, adjust according to shadow map size and add face offset
     // Read the 2D UV coordinates, adjust according to shadow map size and add face offset
-    float4 indirectPos = texCUBE(sIndirectionCubeMap, lightVec);
+    float4 indirectPos = SampleCube(IndirectionCubeMap, lightVec);
     indirectPos.xy *= cShadowCubeAdjust.xy;
     indirectPos.xy *= cShadowCubeAdjust.xy;
     indirectPos.xy += float2(cShadowCubeAdjust.z + indirectPos.z * 0.5, cShadowCubeAdjust.w + indirectPos.w);
     indirectPos.xy += float2(cShadowCubeAdjust.z + indirectPos.z * 0.5, cShadowCubeAdjust.w + indirectPos.w);
 
 
@@ -213,23 +211,14 @@ float GetDirShadow(const float4 iShadowPos[NUMCASCADES], float depth)
 {
 {
     float4 shadowPos;
     float4 shadowPos;
 
 
-    #ifdef SM3
-        if (depth < cShadowSplits.x)
-            shadowPos = iShadowPos[0];
-        else if (depth < cShadowSplits.y)
-            shadowPos = iShadowPos[1];
-        else if (depth < cShadowSplits.z)
-            shadowPos = iShadowPos[2];
-        else
-            shadowPos = iShadowPos[3];
-    #else
-        if (depth < cShadowSplits.x)
-            shadowPos = iShadowPos[0];
-        else if (depth < cShadowSplits.y)
-            shadowPos = iShadowPos[1];
-        else
-            shadowPos = iShadowPos[2];
-    #endif
+    if (depth < cShadowSplits.x)
+        shadowPos = iShadowPos[0];
+    else if (depth < cShadowSplits.y)
+        shadowPos = iShadowPos[1];
+    else if (depth < cShadowSplits.z)
+        shadowPos = iShadowPos[2];
+    else
+        shadowPos = iShadowPos[3];
 
 
     return GetDirShadowFade(GetShadow(shadowPos), depth);
     return GetDirShadowFade(GetShadow(shadowPos), depth);
 }
 }
@@ -238,23 +227,14 @@ float GetDirShadowDeferred(float4 projWorldPos, float depth)
 {
 {
     float4 shadowPos;
     float4 shadowPos;
 
 
-    #ifdef SM3
-        if (depth < cShadowSplits.x)
-            shadowPos = mul(projWorldPos, cLightMatricesPS[0]);
-        else if (depth < cShadowSplits.y)
-            shadowPos = mul(projWorldPos, cLightMatricesPS[1]);
-        else if (depth < cShadowSplits.z)
-            shadowPos = mul(projWorldPos, cLightMatricesPS[2]);
-        else
-            shadowPos = mul(projWorldPos, cLightMatricesPS[3]);
-    #else
-        if (depth < cShadowSplits.x)
-            shadowPos = mul(projWorldPos, cLightMatricesPS[0]);
-        else if (depth < cShadowSplits.y)
-            shadowPos = mul(projWorldPos, cLightMatricesPS[1]);
-        else if (depth < cShadowSplits.z)
-            shadowPos = mul(projWorldPos, cLightMatricesPS[2]);
-    #endif
+    if (depth < cShadowSplits.x)
+        shadowPos = mul(projWorldPos, cLightMatricesPS[0]);
+    else if (depth < cShadowSplits.y)
+        shadowPos = mul(projWorldPos, cLightMatricesPS[1]);
+    else if (depth < cShadowSplits.z)
+        shadowPos = mul(projWorldPos, cLightMatricesPS[2]);
+    else
+        shadowPos = mul(projWorldPos, cLightMatricesPS[3]);
 
 
     return GetDirShadowFade(GetShadow(shadowPos), depth);
     return GetDirShadowFade(GetShadow(shadowPos), depth);
 }
 }

+ 25 - 6
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/LitParticle.hlsl

@@ -5,8 +5,12 @@
 #include "Fog.hlsl"
 #include "Fog.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    float3 iNormal : NORMAL,
-    float2 iTexCoord : TEXCOORD0,
+    #ifndef BILLBOARD
+        float3 iNormal : NORMAL,
+    #endif
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         float4 iColor : COLOR0,
         float4 iColor : COLOR0,
     #endif
     #endif
@@ -38,14 +42,26 @@ void VS(float4 iPos : POSITION,
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         out float4 oColor : COLOR0,
         out float4 oColor : COLOR0,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+    float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+    
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);
     oPos = GetClipPos(worldPos);
     oTexCoord = GetTexCoord(iTexCoord);
     oTexCoord = GetTexCoord(iTexCoord);
     oWorldPos = float4(worldPos, GetDepth(oPos));
     oWorldPos = float4(worldPos, GetDepth(oPos));
 
 
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         oColor = iColor;
         oColor = iColor;
     #endif
     #endif
@@ -96,11 +112,14 @@ void PS(float2 iTexCoord : TEXCOORD0,
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         float4 iColor : COLOR0,
         float4 iColor : COLOR0,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // Get material diffuse albedo
     // Get material diffuse albedo
     #ifdef DIFFMAP
     #ifdef DIFFMAP
-        float4 diffInput = tex2D(sDiffMap, iTexCoord);
+        float4 diffInput = Sample2D(DiffMap, iTexCoord);
         #ifdef ALPHAMASK
         #ifdef ALPHAMASK
             if (diffInput.a < 0.5)
             if (diffInput.a < 0.5)
                 discard;
                 discard;
@@ -133,7 +152,7 @@ void PS(float2 iTexCoord : TEXCOORD0,
         #endif
         #endif
 
 
         #if defined(SPOTLIGHT)
         #if defined(SPOTLIGHT)
-            lightColor = iSpotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
+            lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
         #elif defined(CUBEMASK)
         #elif defined(CUBEMASK)
             lightColor = texCUBE(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
             lightColor = texCUBE(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
         #else
         #else

+ 59 - 33
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/LitSolid.hlsl

@@ -5,14 +5,16 @@
 #include "Lighting.hlsl"
 #include "Lighting.hlsl"
 #include "Fog.hlsl"
 #include "Fog.hlsl"
 
 
-// When rendering a shadowed point light, disable specular calculations on Shader Model 2 to avoid exceeding the instruction limit
-#if !defined(SM3) && defined(SHADOW) && defined(POINTLIGHT)
-    #undef SPECULAR
-#endif
-
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    float3 iNormal : NORMAL,
-    float2 iTexCoord : TEXCOORD0,
+    #ifndef BILLBOARD
+        float3 iNormal : NORMAL,
+    #endif
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
     #if defined(LIGHTMAP) || defined(AO)
     #if defined(LIGHTMAP) || defined(AO)
         float2 iTexCoord2 : TEXCOORD1,
         float2 iTexCoord2 : TEXCOORD1,
     #endif
     #endif
@@ -57,14 +59,33 @@ void VS(float4 iPos : POSITION,
             out float2 oTexCoord2 : TEXCOORD7,
             out float2 oTexCoord2 : TEXCOORD7,
         #endif
         #endif
     #endif
     #endif
-    out float4 oPos : POSITION)
+    #ifdef VERTEXCOLOR
+        out float4 oColor : COLOR0,
+    #endif
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+    float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);
     oPos = GetClipPos(worldPos);
     oNormal = GetWorldNormal(modelMatrix);
     oNormal = GetWorldNormal(modelMatrix);
     oWorldPos = float4(worldPos, GetDepth(oPos));
     oWorldPos = float4(worldPos, GetDepth(oPos));
 
 
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+
+    #ifdef VERTEXCOLOR
+        oColor = iColor;
+    #endif
+
     #ifdef NORMALMAP
     #ifdef NORMALMAP
         float3 tangent = GetWorldTangent(modelMatrix);
         float3 tangent = GetWorldTangent(modelMatrix);
         float3 bitangent = cross(tangent, oNormal) * iTangent.w;
         float3 bitangent = cross(tangent, oNormal) * iTangent.w;
@@ -144,19 +165,25 @@ void PS(
             float2 iTexCoord2 : TEXCOORD7,
             float2 iTexCoord2 : TEXCOORD7,
         #endif
         #endif
     #endif
     #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif
     #ifdef PREPASS
     #ifdef PREPASS
-        out float4 oDepth : COLOR1,
+        out float4 oDepth : OUTCOLOR1,
     #endif
     #endif
     #ifdef DEFERRED
     #ifdef DEFERRED
-        out float4 oAlbedo : COLOR1,
-        out float4 oNormal : COLOR2,
-        out float4 oDepth : COLOR3,
+        out float4 oAlbedo : OUTCOLOR1,
+        out float4 oNormal : OUTCOLOR2,
+        out float4 oDepth : OUTCOLOR3,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // Get material diffuse albedo
     // Get material diffuse albedo
     #ifdef DIFFMAP
     #ifdef DIFFMAP
-        float4 diffInput = tex2D(sDiffMap, iTexCoord.xy);
+        float4 diffInput = Sample2D(DiffMap, iTexCoord.xy);
         #ifdef ALPHAMASK
         #ifdef ALPHAMASK
             if (diffInput.a < 0.5)
             if (diffInput.a < 0.5)
                 discard;
                 discard;
@@ -166,9 +193,13 @@ void PS(
         float4 diffColor = cMatDiffColor;
         float4 diffColor = cMatDiffColor;
     #endif
     #endif
 
 
+    #ifdef VERTEXCOLOR
+        diffColor *= iColor;
+    #endif
+
     // Get material specular albedo
     // Get material specular albedo
     #ifdef SPECMAP
     #ifdef SPECMAP
-        float3 specColor = cMatSpecColor.rgb * tex2D(sSpecMap, iTexCoord.xy).rgb;
+        float3 specColor = cMatSpecColor.rgb * Sample2D(SpecMap, iTexCoord.xy).rgb;
     #else
     #else
         float3 specColor = cMatSpecColor.rgb;
         float3 specColor = cMatSpecColor.rgb;
     #endif
     #endif
@@ -176,12 +207,7 @@ void PS(
     // Get normal
     // Get normal
     #ifdef NORMALMAP
     #ifdef NORMALMAP
         float3x3 tbn = float3x3(iTangent.xyz, float3(iTexCoord.zw, iTangent.w), iNormal);
         float3x3 tbn = float3x3(iTangent.xyz, float3(iTexCoord.zw, iTangent.w), iNormal);
-        // We may be running low on instructions on Shader Model 2, so skip normalize if necessary
-        #if defined(SM3) || !defined(SHADOW) || !defined(SPECULAR)
-            float3 normal = normalize(mul(DecodeNormal(tex2D(sNormalMap, iTexCoord.xy)), tbn));
-        #else
-            float3 normal = mul(DecodeNormal(tex2D(sNormalMap, iTexCoord.xy)), tbn);
-        #endif
+        float3 normal = normalize(mul(DecodeNormal(Sample2D(NormalMap, iTexCoord.xy)), tbn));
     #else
     #else
         float3 normal = normalize(iNormal);
         float3 normal = normalize(iNormal);
     #endif
     #endif
@@ -206,9 +232,9 @@ void PS(
         #endif
         #endif
 
 
         #if defined(SPOTLIGHT)
         #if defined(SPOTLIGHT)
-            lightColor = iSpotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
+            lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
         #elif defined(CUBEMASK)
         #elif defined(CUBEMASK)
-            lightColor = texCUBE(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
+            lightColor = SampleCube(LightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
         #else
         #else
             lightColor = cLightColor.rgb;
             lightColor = cLightColor.rgb;
         #endif
         #endif
@@ -241,16 +267,16 @@ void PS(
         float3 finalColor = iVertexLight * diffColor.rgb;
         float3 finalColor = iVertexLight * diffColor.rgb;
         #ifdef AO
         #ifdef AO
             // If using AO, the vertex light ambient is black, calculate occluded ambient here
             // If using AO, the vertex light ambient is black, calculate occluded ambient here
-            finalColor += tex2D(sEmissiveMap, iTexCoord2).rgb * cAmbientColor * diffColor.rgb;
+            finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * cAmbientColor * diffColor.rgb;
         #endif
         #endif
         #ifdef ENVCUBEMAP
         #ifdef ENVCUBEMAP
-            finalColor += cMatEnvMapColor * texCUBE(sEnvCubeMap, reflect(iReflectionVec, normal)).rgb;
+            finalColor += cMatEnvMapColor * SampleCube(EnvCubeMap, reflect(iReflectionVec, normal)).rgb;
         #endif
         #endif
         #ifdef LIGHTMAP
         #ifdef LIGHTMAP
-            finalColor += tex2D(sEmissiveMap, iTexCoord2).rgb * diffColor.rgb;
+            finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * diffColor.rgb;
         #endif
         #endif
         #ifdef EMISSIVEMAP
         #ifdef EMISSIVEMAP
-            finalColor += cMatEmissiveColor * tex2D(sEmissiveMap, iTexCoord.xy).rgb;
+            finalColor += cMatEmissiveColor * Sample2D(EmissiveMap, iTexCoord.xy).rgb;
         #else
         #else
             finalColor += cMatEmissiveColor;
             finalColor += cMatEmissiveColor;
         #endif
         #endif
@@ -264,26 +290,26 @@ void PS(
         float3 finalColor = iVertexLight * diffColor.rgb;
         float3 finalColor = iVertexLight * diffColor.rgb;
         #ifdef AO
         #ifdef AO
             // If using AO, the vertex light ambient is black, calculate occluded ambient here
             // If using AO, the vertex light ambient is black, calculate occluded ambient here
-            finalColor += tex2D(sEmissiveMap, iTexCoord2).rgb * cAmbientColor * diffColor.rgb;
+            finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * cAmbientColor * diffColor.rgb;
         #endif
         #endif
 
 
         #ifdef MATERIAL
         #ifdef MATERIAL
             // Add light pre-pass accumulation result
             // Add light pre-pass accumulation result
             // Lights are accumulated at half intensity. Bring back to full intensity now
             // Lights are accumulated at half intensity. Bring back to full intensity now
-            float4 lightInput = 2.0 * tex2Dproj(sLightBuffer, iScreenPos);
-            float3 lightSpecColor = lightInput.a * (lightInput.rgb / GetIntensity(lightInput.rgb));
+            float4 lightInput = 2.0 * Sample2DProj(LightBuffer, iScreenPos);
+            float3 lightSpecColor = lightInput.a * lightInput.rgb / max(GetIntensity(lightInput.rgb), 0.001);
 
 
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
         #endif
         #endif
 
 
         #ifdef ENVCUBEMAP
         #ifdef ENVCUBEMAP
-            finalColor += cMatEnvMapColor * texCUBE(sEnvCubeMap, reflect(iReflectionVec, normal)).rgb;
+            finalColor += cMatEnvMapColor * SampleCube(EnvCubeMap, reflect(iReflectionVec, normal)).rgb;
         #endif
         #endif
         #ifdef LIGHTMAP
         #ifdef LIGHTMAP
-            finalColor += tex2D(sEmissiveMap, iTexCoord2).rgb * diffColor.rgb;
+            finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * diffColor.rgb;
         #endif
         #endif
         #ifdef EMISSIVEMAP
         #ifdef EMISSIVEMAP
-            finalColor += cMatEmissiveColor * tex2D(sEmissiveMap, iTexCoord.xy).rgb;
+            finalColor += cMatEmissiveColor * Sample2D(EmissiveMap, iTexCoord.xy).rgb;
         #else
         #else
             finalColor += cMatEmissiveColor;
             finalColor += cMatEmissiveColor;
         #endif
         #endif

+ 23 - 1
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/PostProcess.hlsl

@@ -9,7 +9,11 @@ float2 Noise(float2 coord)
 }
 }
 
 
 // Adapted: http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
 // Adapted: http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
+#ifndef D3D11
 float4 GaussianBlur(int blurKernelSize, float2 blurDir, float2 blurRadius, float sigma, sampler2D texSampler, float2 texCoord)
 float4 GaussianBlur(int blurKernelSize, float2 blurDir, float2 blurRadius, float sigma, sampler2D texSampler, float2 texCoord)
+#else
+float4 GaussianBlur(int blurKernelSize, float2 blurDir, float2 blurRadius, float sigma, Texture2D tex, SamplerState texSampler, float2 texCoord)
+#endif
 {
 {
     const int blurKernelHalfSize = blurKernelSize / 2;
     const int blurKernelHalfSize = blurKernelSize / 2;
 
 
@@ -23,14 +27,24 @@ float4 GaussianBlur(int blurKernelSize, float2 blurDir, float2 blurRadius, float
     float4 avgValue = float4(0.0, 0.0, 0.0, 0.0);
     float4 avgValue = float4(0.0, 0.0, 0.0, 0.0);
     float gaussCoeffSum = 0.0;
     float gaussCoeffSum = 0.0;
 
 
+    #ifndef D3D11
     avgValue += tex2D(texSampler, texCoord) * gaussCoeff.x;
     avgValue += tex2D(texSampler, texCoord) * gaussCoeff.x;
+    #else
+    avgValue += tex.Sample(texSampler, texCoord) * gaussCoeff.x;
+    #endif
+
     gaussCoeffSum += gaussCoeff.x;
     gaussCoeffSum += gaussCoeff.x;
     gaussCoeff.xy *= gaussCoeff.yz;
     gaussCoeff.xy *= gaussCoeff.yz;
 
 
     for (int i = 1; i <= blurKernelHalfSize; i++)
     for (int i = 1; i <= blurKernelHalfSize; i++)
     {
     {
+        #ifndef D3D11
         avgValue += tex2D(texSampler, texCoord - i * blurVec) * gaussCoeff.x;
         avgValue += tex2D(texSampler, texCoord - i * blurVec) * gaussCoeff.x;
         avgValue += tex2D(texSampler, texCoord + i * blurVec) * gaussCoeff.x;
         avgValue += tex2D(texSampler, texCoord + i * blurVec) * gaussCoeff.x;
+        #else
+        avgValue += tex.Sample(texSampler, texCoord - i * blurVec) * gaussCoeff.x;
+        avgValue += tex.Sample(texSampler, texCoord + i * blurVec) * gaussCoeff.x;
+        #endif
 
 
         gaussCoeffSum += 2.0 * gaussCoeff.x;
         gaussCoeffSum += 2.0 * gaussCoeff.x;
         gaussCoeff.xy *= gaussCoeff.yz;
         gaussCoeff.xy *= gaussCoeff.yz;
@@ -64,12 +78,20 @@ float3 Uncharted2Tonemap(float3 x)
    return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
    return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
 }
 }
 
 
+#ifndef D3D11
 float3 ColorCorrection(float3 color, sampler3D lut)
 float3 ColorCorrection(float3 color, sampler3D lut)
+#else
+float3 ColorCorrection(float3 color, Texture3D lut, SamplerState lutSampler)
+#endif
 {
 {
     float lutSize = 16.0;
     float lutSize = 16.0;
     float scale = (lutSize - 1.0) / lutSize;
     float scale = (lutSize - 1.0) / lutSize;
     float offset = 1.0 / (2.0 * lutSize);
     float offset = 1.0 / (2.0 * lutSize);
-    return tex3D(lut, clamp(color, 0.0, 1.0) * scale + offset).rgb;
+    #ifndef D3D11
+        return tex3D(lut, clamp(color, 0.0, 1.0) * scale + offset).rgb;
+    #else
+        return lut.Sample(lutSampler, clamp(color, 0.0, 1.0) * scale + offset).rgb;
+    #endif
 }
 }
 
 
 static const float Gamma = 2.2;
 static const float Gamma = 2.2;

+ 7 - 7
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/PrepassLight.hlsl

@@ -14,7 +14,7 @@ void VS(float4 iPos : POSITION,
     #ifdef ORTHO
     #ifdef ORTHO
         out float3 oNearRay : TEXCOORD2,
         out float3 oNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -44,11 +44,11 @@ void PS(
     #ifdef ORTHO
     #ifdef ORTHO
         float3 iNearRay : TEXCOORD2,
         float3 iNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // If rendering a directional light quad, optimize out the w divide
     // If rendering a directional light quad, optimize out the w divide
     #ifdef DIRLIGHT
     #ifdef DIRLIGHT
-        float depth = Sample(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DLod0(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -57,9 +57,9 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth;
             float3 worldPos = iFarRay * depth;
         #endif
         #endif
-        float4 normalInput = Sample(sNormalBuffer, iScreenPos);
+        float4 normalInput = Sample2DLod0(NormalBuffer, iScreenPos);
     #else
     #else
-        float depth = tex2Dproj(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DProj(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -68,7 +68,7 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth / iScreenPos.w;
             float3 worldPos = iFarRay * depth / iScreenPos.w;
         #endif
         #endif
-        float4 normalInput = tex2Dproj(sNormalBuffer, iScreenPos);
+        float4 normalInput = Sample2DProj(NormalBuffer, iScreenPos);
     #endif
     #endif
 
 
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
@@ -85,7 +85,7 @@ void PS(
 
 
     #if defined(SPOTLIGHT)
     #if defined(SPOTLIGHT)
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
-        lightColor = spotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : 0.0;
+        lightColor = spotPos.w > 0.0 ? Sample2DProj(LightSpotMap, spotPos).rgb * cLightColor.rgb : 0.0;
     #elif defined(CUBEMASK)
     #elif defined(CUBEMASK)
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
     #else
     #else

+ 93 - 42
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Samplers.hlsl

@@ -1,53 +1,104 @@
 #ifdef COMPILEPS
 #ifdef COMPILEPS
-sampler2D sDiffMap : register(S0);
-samplerCUBE sDiffCubeMap : register(S0);
-sampler2D sAlbedoBuffer : register(S0);
-sampler2D sNormalMap : register(S1);
-sampler2D sNormalBuffer : register(S1);
-sampler2D sSpecMap : register(S2);
-sampler2D sEmissiveMap : register(S3);
-sampler2D sEnvMap : register(S4);
-samplerCUBE sEnvCubeMap : register(S4);
-sampler1D sLightRampMap : register(S5);
-sampler2D sLightSpotMap : register(S6);
-samplerCUBE sLightCubeMap : register(S6);
-sampler2D sShadowMap : register(S7);
-samplerCUBE sFaceSelectCubeMap : register(S8);
-samplerCUBE sIndirectionCubeMap : register(S9);
-sampler2D sDepthBuffer : register(S10);
-sampler2D sLightBuffer : register(S11);
-sampler3D sVolumeMap : register(S12);
-samplerCUBE sZoneCubeMap : register(S13);
-sampler3D sZoneVolumeMap : register(S13);
-
-float4 Sample(sampler2D map, float2 texCoord)
-{
-    // Use tex2Dlod if available to avoid divergence and allow branching
-    #ifdef SM3
-        return tex2Dlod(map, float4(texCoord, 0.0, 0.0));
-    #else
-        return tex2D(map, texCoord);
-    #endif
-}
+
+#ifndef D3D11
+
+// D3D9 samplers
+sampler2D sDiffMap : register(s0);
+samplerCUBE sDiffCubeMap : register(s0);
+sampler2D sAlbedoBuffer : register(s0);
+sampler2D sNormalMap : register(s1);
+sampler2D sNormalBuffer : register(s1);
+sampler2D sSpecMap : register(s2);
+sampler2D sEmissiveMap : register(s3);
+sampler2D sEnvMap : register(s4);
+sampler3D sVolumeMap : register(s5);
+samplerCUBE sEnvCubeMap : register(s4);
+sampler2D sLightRampMap : register(s8);
+sampler2D sLightSpotMap : register(s9);
+samplerCUBE sLightCubeMap : register(s9);
+sampler2D sShadowMap : register(s10);
+samplerCUBE sFaceSelectCubeMap : register(s11);
+samplerCUBE sIndirectionCubeMap : register(s12);
+sampler2D sDepthBuffer : register(s13);
+sampler2D sLightBuffer : register(s14);
+samplerCUBE sZoneCubeMap : register(s15);
+sampler3D sZoneVolumeMap : register(s15);
+
+#define Sample2D(tex, uv) tex2D(s##tex, uv)
+#define Sample2DProj(tex, uv) tex2Dproj(s##tex, uv)
+#define Sample2DLod0(tex, uv) tex2Dlod(s##tex, float4(uv, 0.0, 0.0))
+#define SampleCube(tex, uv) texCUBE(s##tex, uv)
+#define SampleShadow(tex, uv) tex2Dproj(s##tex, uv)
+
+#else
+
+// D3D11 textures and samplers
+
+Texture2D tDiffMap : register(t0);
+TextureCube tDiffCubeMap : register(t0);
+Texture2D tAlbedoBuffer : register(t0);
+Texture2D tNormalMap : register(t1);
+Texture2D tNormalBuffer : register(t1);
+Texture2D tSpecMap : register(t2);
+Texture2D tEmissiveMap : register(t3);
+Texture2D tEnvMap : register(t4);
+Texture3D tVolumeMap : register(t5);
+TextureCube tEnvCubeMap : register(t4);
+Texture2D tLightRampMap : register(t8);
+Texture2D tLightSpotMap : register(t9);
+TextureCube tLightCubeMap : register(t9);
+Texture2D tShadowMap : register(t10);
+TextureCube tFaceSelectCubeMap : register(t11);
+TextureCube tIndirectionCubeMap : register(t12);
+Texture2D tDepthBuffer : register(t13);
+Texture2D tLightBuffer : register(t14);
+TextureCube tZoneCubeMap : register(t15);
+Texture3D tZoneVolumeMap : register(t15);
+
+SamplerState sDiffMap : register(s0);
+SamplerState sDiffCubeMap : register(s0);
+SamplerState sAlbedoBuffer : register(s0);
+SamplerState sNormalMap : register(s1);
+SamplerState sNormalBuffer : register(s1);
+SamplerState sSpecMap : register(s2);
+SamplerState sEmissiveMap : register(s3);
+SamplerState sEnvMap : register(s4);
+SamplerState sVolumeMap : register(s5);
+SamplerState sEnvCubeMap : register(s4);
+SamplerState sLightRampMap : register(s8);
+SamplerState sLightSpotMap : register(s9);
+SamplerState sLightCubeMap : register(s9);
+SamplerComparisonState sShadowMap : register(s10);
+SamplerState sFaceSelectCubeMap : register(s11);
+SamplerState sIndirectionCubeMap : register(s12);
+SamplerState sDepthBuffer : register(s13);
+SamplerState sLightBuffer : register(s14);
+SamplerState sZoneCubeMap : register(s15);
+SamplerState sZoneVolumeMap : register(s15);
+
+#define Sample2D(tex, uv) t##tex.Sample(s##tex, uv)
+#define Sample2DProj(tex, uv) t##tex.Sample(s##tex, uv.xy / uv.w)
+#define Sample2DLod0(tex, uv) t##tex.SampleLevel(s##tex, uv, 0.0)
+#define SampleCube(tex, uv) t##tex.Sample(s##tex, uv)
+#define SampleShadow(tex, uv) t##tex.SampleCmpLevelZero(s##tex, uv.xy, uv.z)
+
+#endif
 
 
 float3 DecodeNormal(float4 normalInput)
 float3 DecodeNormal(float4 normalInput)
 {
 {
-    #ifdef PACKEDNORMAL
-        float3 normal;
-        normal.xy = normalInput.ag * 2.0 - 1.0;
-        #ifdef SM3
-            normal.z = sqrt(max(1.0 - dot(normal.xy, normal.xy), 0.0));
-        #else
-            normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
-        #endif
-        return normal;
-    #else
-        return normalInput.rgb * 2.0 - 1.0;
-    #endif
+#ifdef PACKEDNORMAL
+    float3 normal;
+    normal.xy = normalInput.ag * 2.0 - 1.0;
+    normal.z = sqrt(max(1.0 - dot(normal.xy, normal.xy), 0.0));
+    return normal;
+#else
+    return normalInput.rgb * 2.0 - 1.0;
+#endif
 }
 }
 
 
 float ReconstructDepth(float hwDepth)
 float ReconstructDepth(float hwDepth)
 {
 {
     return dot(float2(hwDepth, cDepthReconstruct.y / (hwDepth - cDepthReconstruct.x)), cDepthReconstruct.zw);
     return dot(float2(hwDepth, cDepthReconstruct.y / (hwDepth - cDepthReconstruct.x)), cDepthReconstruct.zw);
 }
 }
+
 #endif
 #endif

+ 3 - 3
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/ScreenPos.hlsl

@@ -12,7 +12,7 @@ void VS(float4 iPos : POSITION,
     #endif
     #endif
     float2 iTexCoord : TEXCOORD0,
     float2 iTexCoord : TEXCOORD0,
     out float2 oTexCoord : TEXCOORD0,
     out float2 oTexCoord : TEXCOORD0,
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -22,10 +22,10 @@ void VS(float4 iPos : POSITION,
 
 
 void PS(
 void PS(
     float2 iTexCoord : TEXCOORD0,
     float2 iTexCoord : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     #ifdef ALPHAMASK
     #ifdef ALPHAMASK
-        float alpha = tex2D(sDiffMap, iTexCoord).a;
+        float alpha = Sample2D(DiffMap, iTexCoord).a;
         if (alpha < 0.5)
         if (alpha < 0.5)
             discard;
             discard;
     #endif
     #endif

+ 4 - 4
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Skybox.hlsl

@@ -3,8 +3,8 @@
 #include "Transform.hlsl"
 #include "Transform.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float3 oTexCoord : TEXCOORD0)
+    out float3 oTexCoord : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -15,7 +15,7 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float3 iTexCoord : TEXCOORD0,
 void PS(float3 iTexCoord : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
-    oColor = cMatDiffColor * texCUBE(sDiffCubeMap, iTexCoord);
+    oColor = cMatDiffColor * SampleCube(DiffCubeMap, iTexCoord);
 }
 }

+ 2 - 2
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Stencil.hlsl

@@ -2,14 +2,14 @@
 #include "Transform.hlsl"
 #include "Transform.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);
     oPos = GetClipPos(worldPos);
 }
 }
 
 
-void PS(out float4 oColor : COLOR0)
+void PS(out float4 oColor : OUTCOLOR0)
 {
 {
     oColor = 1.0;
     oColor = 1.0;
 }
 }

+ 52 - 21
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/TerrainBlend.hlsl

@@ -5,17 +5,38 @@
 #include "Lighting.hlsl"
 #include "Lighting.hlsl"
 #include "Fog.hlsl"
 #include "Fog.hlsl"
 
 
-// When rendering a shadowed point light, disable specular calculations on Shader Model 2 to avoid exceeding the instruction limit
-#if !defined(SM3) && defined(SHADOW) && defined(POINTLIGHT)
-    #undef SPECULAR
+#ifndef D3D11
+
+// D3D9 uniforms and samplers
+#ifdef COMPILEVS
+uniform float2 cDetailTiling;
+#else
+sampler2D sWeightMap0 : register(s0);
+sampler2D sDetailMap1 : register(s1);
+sampler2D sDetailMap2 : register(s2);
+sampler2D sDetailMap3 : register(s3);
 #endif
 #endif
 
 
-sampler2D sWeightMap0 : register(S0);
-sampler2D sDetailMap1 : register(S1);
-sampler2D sDetailMap2 : register(S2);
-sampler2D sDetailMap3 : register(S3);
+#else
 
 
-uniform float2 cDetailTiling;
+// D3D11 constant buffers and samplers
+#ifdef COMPILEVS
+cbuffer CustomVS : register(b6)
+{
+    float2 cDetailTiling;
+}
+#else
+Texture2D tWeightMap0 : register(t0);
+Texture2D tDetailMap1 : register(t1);
+Texture2D tDetailMap2 : register(t2);
+Texture2D tDetailMap3 : register(t3);
+SamplerState sWeightMap0 : register(s0);
+SamplerState sDetailMap1 : register(s1);
+SamplerState sDetailMap2 : register(s2);
+SamplerState sDetailMap3 : register(s3);
+#endif
+
+#endif
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
     float3 iNormal : NORMAL,
     float3 iNormal : NORMAL,
@@ -48,7 +69,10 @@ void VS(float4 iPos : POSITION,
         out float3 oVertexLight : TEXCOORD4,
         out float3 oVertexLight : TEXCOORD4,
         out float4 oScreenPos : TEXCOORD5,
         out float4 oScreenPos : TEXCOORD5,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -58,6 +82,10 @@ void VS(float4 iPos : POSITION,
     oTexCoord = GetTexCoord(iTexCoord);
     oTexCoord = GetTexCoord(iTexCoord);
     oDetailTexCoord = cDetailTiling * oTexCoord;
     oDetailTexCoord = cDetailTiling * oTexCoord;
 
 
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+
     #ifdef PERPIXEL
     #ifdef PERPIXEL
         // Per-pixel forward lighting
         // Per-pixel forward lighting
         float4 projWorldPos = float4(worldPos.xyz, 1.0);
         float4 projWorldPos = float4(worldPos.xyz, 1.0);
@@ -106,24 +134,27 @@ void PS(float2 iTexCoord : TEXCOORD0,
         float3 iVertexLight : TEXCOORD4,
         float3 iVertexLight : TEXCOORD4,
         float4 iScreenPos : TEXCOORD5,
         float4 iScreenPos : TEXCOORD5,
     #endif
     #endif
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif
     #ifdef PREPASS
     #ifdef PREPASS
-        out float4 oDepth : COLOR1,
+        out float4 oDepth : OUTCOLOR1,
     #endif
     #endif
     #ifdef DEFERRED
     #ifdef DEFERRED
-        out float4 oAlbedo : COLOR1,
-        out float4 oNormal : COLOR2,
-        out float4 oDepth : COLOR3,
+        out float4 oAlbedo : OUTCOLOR1,
+        out float4 oNormal : OUTCOLOR2,
+        out float4 oDepth : OUTCOLOR3,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // Get material diffuse albedo
     // Get material diffuse albedo
-    float3 weights = tex2D(sWeightMap0, iTexCoord).rgb;
+    float3 weights = Sample2D(WeightMap0, iTexCoord).rgb;
     float sumWeights = weights.r + weights.g + weights.b;
     float sumWeights = weights.r + weights.g + weights.b;
     weights /= sumWeights;
     weights /= sumWeights;
     float4 diffColor = cMatDiffColor * (
     float4 diffColor = cMatDiffColor * (
-        weights.r * tex2D(sDetailMap1, iDetailTexCoord) +
-        weights.g * tex2D(sDetailMap2, iDetailTexCoord) +
-        weights.b * tex2D(sDetailMap3, iDetailTexCoord)
+        weights.r * Sample2D(DetailMap1, iDetailTexCoord) +
+        weights.g * Sample2D(DetailMap2, iDetailTexCoord) +
+        weights.b * Sample2D(DetailMap3, iDetailTexCoord)
     );
     );
 
 
     // Get material specular albedo
     // Get material specular albedo
@@ -152,9 +183,9 @@ void PS(float2 iTexCoord : TEXCOORD0,
         #endif
         #endif
     
     
         #if defined(SPOTLIGHT)
         #if defined(SPOTLIGHT)
-            lightColor = iSpotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
+            lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
         #elif defined(CUBEMASK)
         #elif defined(CUBEMASK)
-            lightColor = texCUBE(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
+            lightColor = SampleCube(LightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
         #else
         #else
             lightColor = cLightColor.rgb;
             lightColor = cLightColor.rgb;
         #endif
         #endif
@@ -197,7 +228,7 @@ void PS(float2 iTexCoord : TEXCOORD0,
         #ifdef MATERIAL
         #ifdef MATERIAL
             // Add light pre-pass accumulation result
             // Add light pre-pass accumulation result
             // Lights are accumulated at half intensity. Bring back to full intensity now
             // Lights are accumulated at half intensity. Bring back to full intensity now
-            float4 lightInput = 2.0 * tex2Dproj(sLightBuffer, iScreenPos);
+            float4 lightInput = 2.0 * Sample2DProj(LightBuffer, iScreenPos);
             float3 lightSpecColor = lightInput.a * (lightInput.rgb / GetIntensity(lightInput.rgb));
             float3 lightSpecColor = lightInput.a * (lightInput.rgb / GetIntensity(lightInput.rgb));
 
 
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;

+ 27 - 15
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Text.hlsl

@@ -2,21 +2,33 @@
 #include "Samplers.hlsl"
 #include "Samplers.hlsl"
 #include "Transform.hlsl"
 #include "Transform.hlsl"
 
 
-#ifdef TEXT_EFFECT_SHADOW
+#ifndef D3D11
+
+// D3D9 uniforms
 uniform float2 cShadowOffset;
 uniform float2 cShadowOffset;
 uniform float4 cShadowColor;
 uniform float4 cShadowColor;
+uniform float4 cStrokeColor;
+
+#else
+
+#ifdef COMPILEPS
+// D3D11 constant buffers
+cbuffer CustomPS : register(b6)
+{
+    float2 cShadowOffset;
+    float4 cShadowColor;
+    float4 cStrokeColor;
+}
 #endif
 #endif
 
 
-#ifdef TEXT_EFFECT_STROKE
-uniform float4 cStrokeColor;
 #endif
 #endif
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-        float4 iColor : COLOR0,
-        float2 iTexCoord : TEXCOORD0,
-        out float4 oPos : POSITION,
-        out float4 oColor : COLOR0,
-        out float2 oTexCoord : TEXCOORD0)
+    float2 iTexCoord : TEXCOORD0,
+    out float2 oTexCoord : TEXCOORD0,
+    float4 iColor : COLOR0,
+    out float4 oColor : COLOR0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -25,18 +37,18 @@ void VS(float4 iPos : POSITION,
     oTexCoord = iTexCoord;
     oTexCoord = iTexCoord;
 }
 }
 
 
-void PS(float4 iColor : COLOR0,
-        float2 iTexCoord : TEXCOORD0,
-        out float4 oColor : COLOR0)
+void PS(float2 iTexCoord : TEXCOORD0,
+    float4 iColor : COLOR0,
+    out float4 oColor : OUTCOLOR0)
 {
 {
     oColor.rgb = iColor.rgb;
     oColor.rgb = iColor.rgb;
 
 
 #ifdef SIGNED_DISTANCE_FIELD
 #ifdef SIGNED_DISTANCE_FIELD
-    float distance = tex2D(sDiffMap, iTexCoord).a;
+    float distance = Sample2D(DiffMap, iTexCoord).a;
     if (distance < 0.5f)
     if (distance < 0.5f)
     {
     {
     #ifdef TEXT_EFFECT_SHADOW
     #ifdef TEXT_EFFECT_SHADOW
-        if (tex2D(sDiffMap, iTexCoord - cShadowOffset).a > 0.5f)
+        if (Sample2D(DiffMap, iTexCoord - cShadowOffset).a > 0.5f)
             oColor = cShadowColor;
             oColor = cShadowColor;
         else
         else
     #endif
     #endif
@@ -50,13 +62,13 @@ void PS(float4 iColor : COLOR0,
     #endif
     #endif
 
 
     #ifdef TEXT_EFFECT_SHADOW
     #ifdef TEXT_EFFECT_SHADOW
-        if (tex2D(sDiffMap, iTexCoord + cShadowOffset).a < 0.5f)
+        if (Sample2D(DiffMap, iTexCoord + cShadowOffset).a < 0.5f)
             oColor.a = iColor.a;
             oColor.a = iColor.a;
         else
         else
     #endif
     #endif
         oColor.a = iColor.a * smoothstep(0.5f, 0.505f, distance);
         oColor.a = iColor.a * smoothstep(0.5f, 0.505f, distance);
     }
     }
 #else
 #else
-    oColor.a = iColor.a * tex2D(sDiffMap, iTexCoord).a;
+    oColor.a = iColor.a * Sample2D(DiffMap, iTexCoord).a;
 #endif
 #endif
 }
 }

+ 22 - 6
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Tonemap.hlsl

@@ -4,12 +4,28 @@
 #include "ScreenPos.hlsl"
 #include "ScreenPos.hlsl"
 #include "PostProcess.hlsl"
 #include "PostProcess.hlsl"
 
 
+#ifndef D3D11
+
+// D3D9 uniforms
 uniform float cTonemapExposureBias;
 uniform float cTonemapExposureBias;
 uniform float cTonemapMaxWhite;
 uniform float cTonemapMaxWhite;
 
 
+#else
+
+#ifdef COMPILEPS
+// D3D11 constant buffers
+cbuffer CustomPS : register(b6)
+{
+    float cTonemapExposureBias;
+    float cTonemapMaxWhite;
+}
+#endif
+
+#endif
+
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float2 oScreenPos : TEXCOORD0)
+    out float2 oScreenPos : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -18,20 +34,20 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float2 iScreenPos : TEXCOORD0,
 void PS(float2 iScreenPos : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     #ifdef REINHARDEQ3
     #ifdef REINHARDEQ3
-    float3 color = ReinhardEq3Tonemap(max(tex2D(sDiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0));
+    float3 color = ReinhardEq3Tonemap(max(Sample2D(DiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0));
     oColor = float4(color, 1.0);
     oColor = float4(color, 1.0);
     #endif
     #endif
 
 
     #ifdef REINHARDEQ4
     #ifdef REINHARDEQ4
-    float3 color = ReinhardEq4Tonemap(max(tex2D(sDiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0), cTonemapMaxWhite);
+    float3 color = ReinhardEq4Tonemap(max(Sample2D(DiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0), cTonemapMaxWhite);
     oColor = float4(color, 1.0);
     oColor = float4(color, 1.0);
     #endif
     #endif
 
 
     #ifdef UNCHARTED2
     #ifdef UNCHARTED2
-    float3 color = Uncharted2Tonemap(max(tex2D(sDiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0)) / 
+    float3 color = Uncharted2Tonemap(max(Sample2D(DiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0)) / 
         Uncharted2Tonemap(float3(cTonemapMaxWhite, cTonemapMaxWhite, cTonemapMaxWhite));
         Uncharted2Tonemap(float3(cTonemapMaxWhite, cTonemapMaxWhite, cTonemapMaxWhite));
     oColor = float4(color, 1.0);
     oColor = float4(color, 1.0);
     #endif
     #endif

+ 26 - 0
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Transform.hlsl

@@ -1,4 +1,11 @@
 #ifdef COMPILEVS
 #ifdef COMPILEVS
+
+#ifdef D3D11
+#define OUTPOSITION SV_POSITION
+#else
+#define OUTPOSITION POSITION
+#endif
+
 #ifdef SKINNED
 #ifdef SKINNED
 float4x3 GetSkinMatrix(float4 blendWeights, int4 blendIndices)
 float4x3 GetSkinMatrix(float4 blendWeights, int4 blendIndices)
 {
 {
@@ -29,6 +36,7 @@ float GetDepth(float4 clipPos)
     return dot(clipPos.zw, cDepthMode.zw);
     return dot(clipPos.zw, cDepthMode.zw);
 }
 }
 
 
+#ifdef BILLBOARD
 float3 GetBillboardPos(float4 iPos, float2 iSize, float4x3 modelMatrix)
 float3 GetBillboardPos(float4 iPos, float2 iSize, float4x3 modelMatrix)
 {
 {
     return mul(iPos, modelMatrix) + mul(float3(iSize.x, iSize.y, 0.0), cBillboardRot);
     return mul(iPos, modelMatrix) + mul(float3(iSize.x, iSize.y, 0.0), cBillboardRot);
@@ -38,6 +46,7 @@ float3 GetBillboardNormal()
 {
 {
     return float3(-cBillboardRot[2][0], -cBillboardRot[2][1], -cBillboardRot[2][2]);
     return float3(-cBillboardRot[2][0], -cBillboardRot[2][1], -cBillboardRot[2][2]);
 }
 }
+#endif
 
 
 #if defined(SKINNED)
 #if defined(SKINNED)
     #define iModelMatrix GetSkinMatrix(iBlendWeights, iBlendIndices);
     #define iModelMatrix GetSkinMatrix(iBlendWeights, iBlendIndices);
@@ -61,3 +70,20 @@ float3 GetBillboardNormal()
 
 
 #define GetWorldTangent(modelMatrix) normalize(mul(iTangent.xyz, (float3x3)modelMatrix))
 #define GetWorldTangent(modelMatrix) normalize(mul(iTangent.xyz, (float3x3)modelMatrix))
 #endif
 #endif
+
+#ifdef COMPILEPS
+
+#ifdef D3D11
+#define OUTCOLOR0 SV_TARGET
+#define OUTCOLOR1 SV_TARGET1
+#define OUTCOLOR2 SV_TARGET2
+#define OUTCOLOR3 SV_TARGET3
+#else
+#define OUTCOLOR0 COLOR0
+#define OUTCOLOR1 COLOR1
+#define OUTCOLOR2 COLOR2
+#define OUTCOLOR3 COLOR3
+#endif
+
+#endif
+

+ 126 - 5
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Uniforms.hlsl

@@ -1,8 +1,15 @@
+#ifndef D3D11
+
+// D3D9 uniforms (no constant buffers)
+
 #ifdef COMPILEVS
 #ifdef COMPILEVS
+
 // Vertex shader uniforms
 // Vertex shader uniforms
 uniform float3 cAmbientStartColor;
 uniform float3 cAmbientStartColor;
 uniform float3 cAmbientEndColor;
 uniform float3 cAmbientEndColor;
+#ifdef BILLBOARD
 uniform float3x3 cBillboardRot;
 uniform float3x3 cBillboardRot;
+#endif
 uniform float3 cCameraPos;
 uniform float3 cCameraPos;
 uniform float3x3 cCameraRot;
 uniform float3x3 cCameraRot;
 uniform float cNearClip;
 uniform float cNearClip;
@@ -19,16 +26,18 @@ uniform float4x4 cViewProj;
 uniform float4 cUOffset;
 uniform float4 cUOffset;
 uniform float4 cVOffset;
 uniform float4 cVOffset;
 uniform float4x3 cZone;
 uniform float4x3 cZone;
-uniform float4x4 cLightMatrices[4];
 #ifdef SKINNED
 #ifdef SKINNED
-    uniform float4x3 cSkinMatrices[64];
+    uniform float4x3 cSkinMatrices[MAXBONES];
 #endif
 #endif
 #ifdef NUMVERTEXLIGHTS
 #ifdef NUMVERTEXLIGHTS
     uniform float4 cVertexLights[4*3];
     uniform float4 cVertexLights[4*3];
+#else
+    uniform float4x4 cLightMatrices[4];
 #endif
 #endif
 #endif
 #endif
 
 
 #ifdef COMPILEPS
 #ifdef COMPILEPS
+
 // Pixel shader uniforms
 // Pixel shader uniforms
 uniform float3 cAmbientColor;
 uniform float3 cAmbientColor;
 uniform float3 cCameraPosPS;
 uniform float3 cCameraPosPS;
@@ -52,9 +61,121 @@ uniform float4 cShadowDepthFade;
 uniform float2 cShadowIntensity;
 uniform float2 cShadowIntensity;
 uniform float2 cShadowMapInvSize;
 uniform float2 cShadowMapInvSize;
 uniform float4 cShadowSplits;
 uniform float4 cShadowSplits;
-#ifdef SM3
-    uniform float4x4 cLightMatricesPS[4];
+uniform float4x4 cLightMatricesPS[4];
+#endif
+
 #else
 #else
-    uniform float4x4 cLightMatricesPS[3];
+
+// D3D11 uniforms (using constant buffers)
+
+#ifdef COMPILEVS
+
+// Vertex shader uniforms
+cbuffer FrameVS : register(b0)
+{
+    float cDeltaTime;
+    float cElapsedTime;
+}
+
+cbuffer CameraVS : register(b1)
+{
+    float3 cCameraPos;
+    float3x3 cCameraRot;
+    float cNearClip;
+    float cFarClip;
+    float4 cDepthMode;
+    float3 cFrustumSize;
+    float4 cGBufferOffsets;
+    float4x4 cViewProj;
+    float4 cClipPlane;
+}
+
+cbuffer ZoneVS : register(b2)
+{
+    float3 cAmbientStartColor;
+    float3 cAmbientEndColor;
+    float4x3 cZone;
+}
+
+cbuffer LightVS : register(b3)
+{
+    float3 cLightDir;
+    float4 cLightPos;
+#ifdef NUMVERTEXLIGHTS
+    float4 cVertexLights[4 * 3];
+#else
+    float4x4 cLightMatrices[4];
 #endif
 #endif
+}
+
+#ifndef CUSTOM_MATERIAL_CBUFFER
+cbuffer MaterialVS : register(b4)
+{
+    float4 cUOffset;
+    float4 cVOffset;
+}
+#endif
+
+cbuffer ObjectVS : register(b5)
+{
+    float4x3 cModel;
+#ifdef BILLBOARD
+    float3x3 cBillboardRot;
+#endif
+#ifdef SKINNED
+    uniform float4x3 cSkinMatrices[MAXBONES];
+#endif
+}
+#endif
+
+#ifdef COMPILEPS
+
+// Pixel shader uniforms
+cbuffer FramePS : register(b0)
+{
+    float cDeltaTimePS;
+    float cElapsedTimePS;
+}
+
+cbuffer CameraPS : register(b1)
+{
+    float3 cCameraPosPS;
+    float4 cDepthReconstruct;
+    float2 cGBufferInvSize;
+    float cNearClipPS;
+    float cFarClipPS;
+}
+
+cbuffer ZonePS : register(b2)
+{
+    float3 cAmbientColor;
+    float4 cFogParams;
+    float3 cFogColor;
+}
+
+cbuffer LightPS : register(b3)
+{
+    float4 cLightColor;
+    float4 cLightPosPS;
+    float3 cLightDirPS;
+    float4 cShadowCubeAdjust;
+    float4 cShadowDepthFade;
+    float2 cShadowIntensity;
+    float2 cShadowMapInvSize;
+    float4 cShadowSplits;
+    float4x4 cLightMatricesPS[4];
+}
+
+#ifndef CUSTOM_MATERIAL_CBUFFER
+cbuffer MaterialPS : register(b4)
+{
+    float4 cMatDiffColor;
+    float3 cMatEmissiveColor;
+    float3 cMatEnvMapColor;
+    float4 cMatSpecColor;
+}
+#endif
+
+#endif
+
 #endif
 #endif

+ 25 - 8
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Unlit.hlsl

@@ -4,7 +4,9 @@
 #include "Fog.hlsl"
 #include "Fog.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    float2 iTexCoord : TEXCOORD0,
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         float4 iColor : COLOR0,
         float4 iColor : COLOR0,
     #endif
     #endif
@@ -23,14 +25,26 @@ void VS(float4 iPos : POSITION,
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         out float4 oColor : COLOR0,
         out float4 oColor : COLOR0,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+    float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);
     oPos = GetClipPos(worldPos);
     oTexCoord = GetTexCoord(iTexCoord);
     oTexCoord = GetTexCoord(iTexCoord);
     oWorldPos = float4(worldPos, GetDepth(oPos));
     oWorldPos = float4(worldPos, GetDepth(oPos));
 
 
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+    
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         oColor = iColor;
         oColor = iColor;
     #endif
     #endif
@@ -41,19 +55,22 @@ void PS(float2 iTexCoord : TEXCOORD0,
     #ifdef VERTEXCOLOR
     #ifdef VERTEXCOLOR
         float4 iColor : COLOR0,
         float4 iColor : COLOR0,
     #endif
     #endif
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif
     #ifdef PREPASS
     #ifdef PREPASS
-        out float4 oDepth : COLOR1,
+        out float4 oDepth : OUTCOLOR1,
     #endif
     #endif
     #ifdef DEFERRED
     #ifdef DEFERRED
-        out float4 oAlbedo : COLOR1,
-        out float4 oNormal : COLOR2,
-        out float4 oDepth : COLOR3,
+        out float4 oAlbedo : OUTCOLOR1,
+        out float4 oNormal : OUTCOLOR2,
+        out float4 oDepth : OUTCOLOR3,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // Get material diffuse albedo
     // Get material diffuse albedo
     #ifdef DIFFMAP
     #ifdef DIFFMAP
-        float4 diffColor = cMatDiffColor * tex2D(sDiffMap, iTexCoord);
+        float4 diffColor = cMatDiffColor * Sample2D(DiffMap, iTexCoord);
         #ifdef ALPHAMASK
         #ifdef ALPHAMASK
             if (diffColor.a < 0.5)
             if (diffColor.a < 0.5)
                 discard;
                 discard;

+ 8 - 1
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/Vegetation.hlsl

@@ -57,7 +57,10 @@ void VS(float4 iPos : POSITION,
             out float2 oTexCoord2 : TEXCOORD7,
             out float2 oTexCoord2 : TEXCOORD7,
         #endif
         #endif
     #endif
     #endif
-    out float4 oPos : POSITION)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -72,6 +75,10 @@ void VS(float4 iPos : POSITION,
     oNormal = GetWorldNormal(modelMatrix);
     oNormal = GetWorldNormal(modelMatrix);
     oWorldPos = float4(worldPos, GetDepth(oPos));
     oWorldPos = float4(worldPos, GetDepth(oPos));
 
 
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+    
     #ifdef NORMALMAP
     #ifdef NORMALMAP
         float3 tangent = GetWorldTangent(modelMatrix);
         float3 tangent = GetWorldTangent(modelMatrix);
         float3 bitangent = cross(tangent, oNormal) * iTangent.w;
         float3 bitangent = cross(tangent, oNormal) * iTangent.w;

+ 38 - 5
Data/AtomicPlayer/Resources/CoreData/Shaders/HLSL/VegetationDepth.hlsl

@@ -4,12 +4,35 @@
 #include "ScreenPos.hlsl"
 #include "ScreenPos.hlsl"
 #include "Fog.hlsl"
 #include "Fog.hlsl"
 
 
+#ifndef D3D11
+
+// D3D9 uniforms
 uniform float2 cNoiseSpeed;
 uniform float2 cNoiseSpeed;
 uniform float cNoiseTiling;
 uniform float cNoiseTiling;
 uniform float cNoiseStrength;
 uniform float cNoiseStrength;
 uniform float cFresnelPower;
 uniform float cFresnelPower;
 uniform float3 cWaterTint;
 uniform float3 cWaterTint;
 
 
+#else
+
+// D3D11 constant buffers
+#ifdef COMPILEVS
+cbuffer CustomVS : register(b6)
+{
+    float2 cNoiseSpeed;
+    float cNoiseTiling;
+}
+#else
+cbuffer CustomPS : register(b6)
+{
+    float cNoiseStrength;
+    float cFresnelPower;
+    float3 cWaterTint;
+}
+#endif
+
+#endif
+
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
     float3 iNormal: NORMAL,
     float3 iNormal: NORMAL,
     float2 iTexCoord : TEXCOORD0,
     float2 iTexCoord : TEXCOORD0,
@@ -18,7 +41,10 @@ void VS(float4 iPos : POSITION,
     out float2 oWaterUV : TEXCOORD2,
     out float2 oWaterUV : TEXCOORD2,
     out float3 oNormal : TEXCOORD3,
     out float3 oNormal : TEXCOORD3,
     out float4 oEyeVec : TEXCOORD4,
     out float4 oEyeVec : TEXCOORD4,
-    out float4 oPos : POSITION)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -31,6 +57,10 @@ void VS(float4 iPos : POSITION,
     oWaterUV = iTexCoord * cNoiseTiling + cElapsedTime * cNoiseSpeed;
     oWaterUV = iTexCoord * cNoiseTiling + cElapsedTime * cNoiseSpeed;
     oNormal = GetWorldNormal(modelMatrix);
     oNormal = GetWorldNormal(modelMatrix);
     oEyeVec = float4(cCameraPos - worldPos, GetDepth(oPos));
     oEyeVec = float4(cCameraPos - worldPos, GetDepth(oPos));
+
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
 }
 }
 
 
 void PS(
 void PS(
@@ -39,12 +69,15 @@ void PS(
     float2 iWaterUV : TEXCOORD2,
     float2 iWaterUV : TEXCOORD2,
     float3 iNormal : TEXCOORD3,
     float3 iNormal : TEXCOORD3,
     float4 iEyeVec : TEXCOORD4,
     float4 iEyeVec : TEXCOORD4,
-    out float4 oColor : COLOR0)
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oColor : OUTCOLOR0)
 {
 {
     float2 refractUV = iScreenPos.xy / iScreenPos.w;
     float2 refractUV = iScreenPos.xy / iScreenPos.w;
     float2 reflectUV = iReflectUV.xy / iScreenPos.w;
     float2 reflectUV = iReflectUV.xy / iScreenPos.w;
 
 
-    float2 noise = (tex2D(sNormalMap, iWaterUV).rg - 0.5) * cNoiseStrength;
+    float2 noise = (Sample2D(NormalMap, iWaterUV).rg - 0.5) * cNoiseStrength;
     refractUV += noise;
     refractUV += noise;
     // Do not shift reflect UV coordinate upward, because it will reveal the clipping of geometry below water
     // Do not shift reflect UV coordinate upward, because it will reveal the clipping of geometry below water
     if (noise.y < 0.0)
     if (noise.y < 0.0)
@@ -52,8 +85,8 @@ void PS(
     reflectUV += noise;
     reflectUV += noise;
 
 
     float fresnel = pow(1.0 - saturate(dot(normalize(iEyeVec.xyz), iNormal)), cFresnelPower);
     float fresnel = pow(1.0 - saturate(dot(normalize(iEyeVec.xyz), iNormal)), cFresnelPower);
-    float3 refractColor = tex2D(sEnvMap, refractUV).rgb * cWaterTint;
-    float3 reflectColor = tex2D(sDiffMap, reflectUV).rgb;
+    float3 refractColor = Sample2D(EnvMap, refractUV).rgb * cWaterTint;
+    float3 reflectColor = Sample2D(DiffMap, reflectUV).rgb;
     float3 finalColor = lerp(refractColor, reflectColor, fresnel);
     float3 finalColor = lerp(refractColor, reflectColor, fresnel);
 
 
     oColor = float4(GetFog(finalColor, GetFogFactor(iEyeVec.w)), 1.0);
     oColor = float4(GetFog(finalColor, GetFogFactor(iEyeVec.w)), 1.0);

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/Diff.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalAO.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalEmissive.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedAO.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedEmissive.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL SPECMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL SPECMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL SPECMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL SPECMAP" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedSpecAO.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL SPECMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL SPECMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL SPECMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL SPECMAP" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalPackedSpecEmissive.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP SPECMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP SPECMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP SPECMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP SPECMAP" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalSpecAO.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP ALPHAMASK" alphamask="true">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP SPECMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP SPECMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP SPECMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP SPECMAP" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL SPECMAP" depthtest="equal" depthwrite="false" />

+ 10 - 0
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffNormalSpecEmissive.xml

@@ -0,0 +1,10 @@
+<technique vs="LitSolid" ps="LitSolid" vsdefines="VERTEXCOLOR" psdefines="DIFFMAP VERTEXCOLOR">
+    <pass name="base" />
+    <pass name="litbase" psdefines="AMBIENT" />
+    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="prepass" psdefines="PREPASS" />
+    <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/DiffVColAdd.xml

@@ -1,4 +1,4 @@
-<technique vs="LitSolid" ps="LitSolid">
+<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV" >
     <pass name="base" />
     <pass name="base" />
     <pass name="litbase" psdefines="AMBIENT" />
     <pass name="litbase" psdefines="AMBIENT" />
     <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" depthtest="equal" depthwrite="false" blend="add" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureAO.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="add" />
     <pass name="alpha" depthwrite="false" blend="add" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureAddAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="addalpha" />
     <pass name="alpha" depthwrite="false" blend="addalpha" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureAlpha.xml

@@ -1,4 +1,4 @@
-<technique vs="LitSolid" ps="LitSolid">
+<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV" >
     <pass name="alpha"  depthwrite="false" blend="alpha" />
     <pass name="alpha"  depthwrite="false" blend="alpha" />
     <pass name="litalpha" depthwrite="false" blend="addalpha" />
     <pass name="litalpha" depthwrite="false" blend="addalpha" />
     <pass name="shadow" vs="Shadow" ps="Shadow" />
     <pass name="shadow" vs="Shadow" ps="Shadow" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureEnvCube.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="multiply" />
     <pass name="alpha" depthwrite="false" blend="multiply" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureNormal.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid">
 <technique vs="LitSolid" ps="LitSolid">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureNormalAlpha.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid">
 <technique vs="LitSolid" ps="LitSolid">
     <pass name="base" />
     <pass name="base" />
-    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL" sm3="true" />
+    <pass name="litbase" vsdefines="NORMALMAP" psdefines="AMBIENT NORMALMAP PACKEDNORMAL" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP PACKEDNORMAL" depthtest="equal" depthwrite="false" blend="add" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL" />
     <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP PACKEDNORMAL" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
     <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureNormalPackedAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Basic" ps="Basic">
+<technique vs="Basic" ps="Basic" vsdefines="NOUV" >
     <pass name="postalpha" depthtest="always" depthwrite="false" />
     <pass name="postalpha" depthtest="always" depthwrite="false" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureUnlit.xml

@@ -1,4 +1,4 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="base" />
     <pass name="base" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="material" />
     <pass name="material" />

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureUnlitAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="alpha" />
     <pass name="alpha" depthwrite="false" blend="alpha" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureUnlitVCol.xml

@@ -1,4 +1,4 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="base" />
     <pass name="base" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="material" />
     <pass name="material" />

+ 10 - 0
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVCol.xml

@@ -0,0 +1,10 @@
+<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV VERTEXCOLOR" psdefines="VERTEXCOLOR" >
+    <pass name="base" />
+    <pass name="litbase" psdefines="AMBIENT" />
+    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="prepass" psdefines="PREPASS" />
+    <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVColAdd.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="alpha" depthwrite="false" blend="add" />
     <pass name="alpha" depthwrite="false" blend="add" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVColAddAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="alpha" depthwrite="false" blend="addalpha" />
     <pass name="alpha" depthwrite="false" blend="addalpha" />
 </technique>
 </technique>

+ 1 - 1
Data/AtomicPlayer/Resources/CoreData/Techniques/NoTextureVColMultiply.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="alpha" depthwrite="false" blend="multiply" />
     <pass name="alpha" depthwrite="false" blend="multiply" />
 </technique>
 </technique>

+ 0 - 0
Data/AtomicPlayer/Resources/CoreData/Techniques/TerrainBlend.xml