浏览代码

Added programmatic control of depth clipping. Depth clipping is disabled for shadow cascades and enabled for everything else.

/Yibing-Project-2
uygar 7 年前
当前提交
20767512
共有 5 个文件被更改,包括 11 次插入4 次删除
  1. 7
      ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader

7
ScriptableRenderPipeline/Core/Shadow/Shadow.cs


{
public const uint k_MaxCascadesInShader = 4;
protected readonly int m_TempDepthId;
protected readonly int m_ZClipId;
protected RenderTexture m_Shadowmap;
protected RenderTargetIdentifier m_ShadowmapId;
protected VectorArray<CachedEntry> m_EntryCache = new VectorArray<CachedEntry>( 0, true );

public Key key;
public Data current;
public Data previous;
public bool zclip;
public int CompareTo( CachedEntry other )
{

public ShadowAtlas( ref AtlasInit init ) : base( ref init.baseInit )
{
m_ZClipId = Shader.PropertyToID( "_ZClip" );
if( !IsNativeDepth() )
{
m_TempDepthId = Shader.PropertyToID( "Temporary Shadowmap Depth" );

// read
float texelSizeX = 1.0f, texelSizeY = 1.0f;
CachedEntry ce = m_EntryCache[ceIdx];
ce.zclip = sr.shadowType != GPUShadowType.Directional;
// modify
Matrix4x4 vp, invvp;
if( sr.shadowType == GPUShadowType.Point )

cmd.SetViewport( m_EntryCache[i].current.viewport );
cmd.SetViewProjectionMatrices( m_EntryCache[i].current.view, m_EntryCache[i].current.proj );
cmd.SetGlobalVector( "g_vLightDirWs", m_EntryCache[i].current.lightDir );
cmd.SetGlobalFloat( m_ZClipId, m_EntryCache[i].zclip ? 1.0f : 0.0f );
//cmd.EndSample(cbName);
dss.lightIndex = m_EntryCache[i].key.visibleIdx;

cmd.EndSample("Shadowmap.DisableShaderKeyword");
}
cmd.SetGlobalFloat( m_ZClipId, 1.0f ); // Re-enable zclip globally
m_ActiveEntriesCount = 0;
profilingSample.Dispose();

2
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


Cull[_CullMode]
ZClip Off
ZClip [_ZClip]
ZWrite On
ZTest LEqual

2
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


Cull[_CullMode]
ZClip Off
ZClip [_ZClip]
ZWrite On
ZTest LEqual

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


Cull[_CullMode]
ZClip Off
ZClip [_ZClip]
ZWrite On
ZTest LEqual

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


Cull[_CullMode]
ZClip Off
ZClip [_ZClip]
ZWrite On
ZTest LEqual

正在加载...
取消
保存