Browse Source

Fix DeferredSP & PrepassSP renderpaths not clearing depth. Fix reverse saturation of faded billboard on D3D11. Fix depth shader compile error on D3D11 when alphamasked.

Lasse Öörni 9 years ago
parent
commit
3564686a34

+ 26 - 7
bin/CoreData/RenderPaths/DeferredSP.xml

@@ -1,8 +1,27 @@
-<renderpath inherit="RenderPaths/Deferred.xml">
-    <replace sel="/renderpath/command[@type='scenepass' and @pass='alpha']">
-        <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" vsdefines="SOFTPARTICLES" psdefines="SOFTPARTICLES" >
-            <parameter name="SoftParticleFadeScale" value="1" />
-            <texture unit="depth" name="depth" />
-        </command>
-    </replace>
+<renderpath>
+    <rendertarget name="albedo" sizedivisor="1 1" format="rgba" />
+    <rendertarget name="normal" sizedivisor="1 1" format="rgba" />
+    <rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
+    <command type="clear" color="1 1 1 1" output="depth" />
+    <command type="clear" color="fog" depth="1.0" stencil="0" />
+    <command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer">
+        <output index="0" name="viewport" />
+        <output index="1" name="albedo" />
+        <output index="2" name="normal" />
+        <output index="3" name="depth" />
+    </command>
+    <command type="lightvolumes" vs="DeferredLight" ps="DeferredLight">
+        <texture unit="albedo" name="albedo" />
+        <texture unit="normal" name="normal" />
+        <texture unit="depth" name="depth" />
+    </command>
+    <command type="scenepass" pass="postopaque" />
+    <command type="scenepass" pass="refract">
+        <texture unit="environment" name="viewport" />
+    </command>
+    <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" vsdefines="SOFTPARTICLES" psdefines="SOFTPARTICLES" >
+        <parameter name="SoftParticleFadeScale" value="1" />
+        <texture unit="depth" name="depth" />
+    </command>
+    <command type="scenepass" pass="postalpha" sort="backtofront" />
 </renderpath>

+ 27 - 7
bin/CoreData/RenderPaths/PrepassSP.xml

@@ -1,8 +1,28 @@
-<renderpath inherit="RenderPaths/Prepass.xml">
-    <replace sel="/renderpath/command[@type='scenepass' and @pass='alpha']">
-        <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" vsdefines="SOFTPARTICLES" psdefines="SOFTPARTICLES" >
-            <parameter name="SoftParticleFadeScale" value="1" />
-            <texture unit="depth" name="depth" />
-        </command>
-    </replace>
+<renderpath>
+    <rendertarget name="light" sizedivisor="1 1"  format="rgba" />
+    <rendertarget name="normal" sizedivisor="1 1" format="rgba" />
+    <rendertarget name="depth" sizedivisor="1 1"  format="lineardepth" />
+    <command type="clear" color="1 1 1 1" output="depth" />
+    <command type="clear" color="fog" depth="1.0" stencil="0" />
+    <command type="scenepass" pass="prepass" marktostencil="true" metadata="gbuffer">
+        <output index="0" name="normal" />
+        <output index="1" name="depth" />
+    </command>
+    <command type="clear" color="0 0 0 0" output="light" />
+    <command type="lightvolumes" vs="PrepassLight" ps="PrepassLight" output="light">
+        <texture unit="normal" name="normal" />
+        <texture unit="depth" name="depth" />
+    </command>
+    <command type="scenepass" pass="material" vertexlights="true">
+        <texture unit="light" name="light" />
+    </command>
+    <command type="scenepass" pass="postopaque" />
+    <command type="scenepass" pass="refract">
+        <texture unit="environment" name="viewport" />
+    </command>
+    <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" vsdefines="SOFTPARTICLES" psdefines="SOFTPARTICLES" >
+        <parameter name="SoftParticleFadeScale" value="1" />
+        <texture unit="depth" name="depth" />
+    </command>
+    <command type="scenepass" pass="postalpha" sort="backtofront" />
 </renderpath>

+ 1 - 1
bin/CoreData/Shaders/HLSL/Depth.hlsl

@@ -32,7 +32,7 @@ void PS(
     out float4 oColor : OUTCOLOR0)
 {
     #ifdef ALPHAMASK
-        float alpha = Sample2D(sDiffMap, iTexCoord.xy).a;
+        float alpha = Sample2D(DiffMap, iTexCoord.xy).a;
         if (alpha < 0.5)
             discard;
     #endif

+ 1 - 1
bin/CoreData/Shaders/HLSL/LitParticle.hlsl

@@ -176,7 +176,7 @@ void PS(float2 iTexCoord : TEXCOORD0,
         #endif
         float diffZ = abs(depth - particleDepth) * (cFarClipPS - cNearClipPS);
         float fade = saturate(1.0 - diffZ * cSoftParticleFadeScale);
-        diffColor.a -= fade;
+        diffColor.a = max(diffColor.a - fade, 0.0);
     #endif
 
     #ifdef PERPIXEL

+ 2 - 2
bin/CoreData/Shaders/HLSL/UnlitParticle.hlsl

@@ -122,9 +122,9 @@ void PS(float2 iTexCoord : TEXCOORD0,
         float diffZ = abs(depth - particleDepth) * (cFarClipPS - cNearClipPS);
         float fade = saturate(1.0 - diffZ * cSoftParticleFadeScale);
         #ifndef ADDITIVE
-            diffColor.a -= fade;
+            diffColor.a = max(diffColor.a - fade, 0.0);
         #else
-            diffColor.rgb -= fade;
+            diffColor.rgb = max(diffColor.rgb - fade, float3(0.0, 0.0, 0.0));
         #endif
     #endif