diff --git a/Content/Shaders/DebugDraw.flax b/Content/Shaders/DebugDraw.flax index 024978b04..d1dff466f 100644 --- a/Content/Shaders/DebugDraw.flax +++ b/Content/Shaders/DebugDraw.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:104aeb07ffbb68a6c37d8817565f842a2bcabcfd7980ad1ec45a43c81e1b7a02 -size 2115 +oid sha256:6ec2ded31f6042306c23a273c2cf6c5f54d046834d6c72b7c087d2c2bf0ea645 +size 2060 diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index d64494125..125ffd520 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -632,10 +632,10 @@ void DebugDrawService::Update() desc.VS = shader->GetVS("VS"); // Default - desc.PS = shader->GetPS("PSUnlit"); + desc.PS = shader->GetPS("PS", 0); desc.PrimitiveTopologyType = PrimitiveTopologyType::Line; failed |= DebugDrawPsLinesDefault.Create(desc); - desc.PS = shader->GetPS("PS"); + desc.PS = shader->GetPS("PS", 1); desc.PrimitiveTopologyType = PrimitiveTopologyType::Triangle; failed |= DebugDrawPsTrianglesDefault.Create(desc); desc.Wireframe = true; @@ -643,10 +643,10 @@ void DebugDrawService::Update() // Depth Test desc.Wireframe = false; - desc.PS = shader->GetPS("PS_DepthTestUnlit"); + desc.PS = shader->GetPS("PS", 2); desc.PrimitiveTopologyType = PrimitiveTopologyType::Line; failed |= DebugDrawPsLinesDepthTest.Create(desc); - desc.PS = shader->GetPS("PS_DepthTest"); + desc.PS = shader->GetPS("PS", 3); desc.PrimitiveTopologyType = PrimitiveTopologyType::Triangle; failed |= DebugDrawPsTrianglesDepthTest.Create(desc); desc.Wireframe = true; diff --git a/Source/Shaders/DebugDraw.shader b/Source/Shaders/DebugDraw.shader index 8782abe4b..018129302 100644 --- a/Source/Shaders/DebugDraw.shader +++ b/Source/Shaders/DebugDraw.shader @@ -27,49 +27,31 @@ VS2PS VS(float3 Position : POSITION, float4 Color : COLOR) return output; } -void PerformDepthTest(float4 svPosition) +META_PS(true, FEATURE_LEVEL_ES2) +META_PERMUTATION_2(USE_DEPTH_TEST=0,USE_FAKE_LIGHTING=0) +META_PERMUTATION_2(USE_DEPTH_TEST=0,USE_FAKE_LIGHTING=1) +META_PERMUTATION_2(USE_DEPTH_TEST=1,USE_FAKE_LIGHTING=0) +META_PERMUTATION_2(USE_DEPTH_TEST=1,USE_FAKE_LIGHTING=1) +float4 PS(VS2PS input) : SV_Target { +#if USE_DEPTH_TEST // Depth test manually if compositing editor primitives FLATTEN if (EnableDepthTest) { - float sceneDepthDeviceZ = SceneDepthTexture.Load(int3(svPosition.xy, 0)).r; - float interpolatedDeviceZ = svPosition.z; + float sceneDepthDeviceZ = SceneDepthTexture.Load(int3(input.Position.xy, 0)).r; + float interpolatedDeviceZ = input.Position.z; clip(sceneDepthDeviceZ - interpolatedDeviceZ); } -} +#endif -float4 PerformFakeLighting(float4 svPosition, float4 c) -{ + float4 color = input.Color; +#if USE_FAKE_LIGHTING // Reconstruct view normal and calculate faked lighting - float depth = svPosition.z * 10000; + float depth = input.Position.z * 10000; float3 n = normalize(float3(-ddx(depth), -ddy(depth), 1.0f)); - c.rgb *= saturate(abs(dot(n, float3(0, 1, 0))) + 0.5f); - return c; -} + color.rgb *= saturate(abs(dot(n, float3(0, 1, 0))) + 0.5f); +#endif -META_PS(true, FEATURE_LEVEL_ES2) -float4 PS(VS2PS input) : SV_Target -{ - return PerformFakeLighting(input.Position, input.Color); -} - -META_PS(true, FEATURE_LEVEL_ES2) -float4 PSUnlit(VS2PS input) : SV_Target -{ - return input.Color; -} - -META_PS(true, FEATURE_LEVEL_ES2) -float4 PS_DepthTest(VS2PS input) : SV_Target -{ - PerformDepthTest(input.Position); - return PerformFakeLighting(input.Position, input.Color); -} - -META_PS(true, FEATURE_LEVEL_ES2) -float4 PS_DepthTestUnlit(VS2PS input) : SV_Target -{ - PerformDepthTest(input.Position); - return input.Color; + return color; }