浏览代码

Implemented variance shadow specific debug shader.

/RenderPassXR_Sandbox
Julien Ignace 8 年前
当前提交
c6828cd2
共有 2 个文件被更改,包括 40 次插入3 次删除
  1. 25
      Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader
  2. 18
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs

25
Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader


HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragAtlas
#pragma fragment FragRegular
float4 FragAtlas(Varyings input) : SV_Target
float4 FragRegular(Varyings input) : SV_Target
}
ENDHLSL
}
Pass
{
Name "VarianceShadow"
ZTest Off
Blend One Zero
Cull Off
ZWrite On
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragVariance
float4 FragVariance(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D_ARRAY(_AtlasTexture, ltc_linear_clamp_sampler, input.texcoord, _TextureSlice).rgba; // Might want something more clever like a channel selector.
}
ENDHLSL

18
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


propertyBlock.SetVector("_TextureScaleBias", scaleBias);
propertyBlock.SetFloat("_TextureSlice", (float)slice);
debugCB.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugMaterial, m_DebugMaterial.FindPass("RegularShadow"), MeshTopology.Triangles, 3, 1, propertyBlock);
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugMaterial, m_DebugMaterial.FindPass("REGULARSHADOW"), MeshTopology.Triangles, 3, 1, propertyBlock);
renderContext.ExecuteCommandBuffer(debugCB);
debugCB.Dispose();

i++;
}
base.PostUpdate( frameId, cb, rendertargetSlice, lights );
}
override public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, uint slice, float screenX, float screenY, float screenSizeX, float screenSizeY)
{
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "";
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
propertyBlock.SetTexture("_AtlasTexture", m_Shadowmap);
propertyBlock.SetVector("_TextureScaleBias", scaleBias);
propertyBlock.SetFloat("_TextureSlice", (float)slice);
debugCB.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugMaterial, m_DebugMaterial.FindPass("VARIANCESHADOW"), MeshTopology.Triangles, 3, 1, propertyBlock);
renderContext.ExecuteCommandBuffer(debugCB);
debugCB.Dispose();
}
}
// -------------------------------------------------------------------------------------------------------------------------------------------------

正在加载...
取消
保存