浏览代码

Modified creation of shadowmap, so subclasses can override texture settings before the RTID gets created.

/RenderPassXR_Sandbox
uygar 8 年前
当前提交
2e691da9
共有 2 个文件被更改,包括 25 次插入9 次删除
  1. 33
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 1
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs

33
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


public class ShadowAtlas : ShadowmapBase, IDisposable
{
public const uint k_MaxCascadesInShader = 4;
protected readonly RenderTexture m_Shadowmap;
protected readonly RenderTargetIdentifier m_ShadowmapId;
protected RenderTexture m_Shadowmap;
protected RenderTargetIdentifier m_ShadowmapId;
protected VectorArray<CachedEntry> m_EntryCache = new VectorArray<CachedEntry>( 0, true );
protected uint m_ActiveEntriesCount;
protected FrameId m_FrameId;

public ShadowAtlas( ref AtlasInit init ) : base( ref init.baseInit )
{
m_Shadowmap = new RenderTexture( (int) m_Width, (int) m_Height, (int) m_ShadowmapBits, m_ShadowmapFormat, RenderTextureReadWrite.Linear );
m_Shadowmap.hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild;
m_Shadowmap.dimension = TextureDimension.Tex2DArray;
m_Shadowmap.volumeDepth = (int) m_Slices;
m_ShadowmapId = new RenderTargetIdentifier( m_Shadowmap );
if( !IsNativeDepth() )
{
m_TempDepthId = Shader.PropertyToID( "Temporary Shadowmap Depth" );

}
public override void CreateShadowmap()
{
m_Shadowmap = new RenderTexture( (int) m_Width, (int) m_Height, (int) m_ShadowmapBits, m_ShadowmapFormat, RenderTextureReadWrite.Linear );
CreateShadowmap( m_Shadowmap );
}
virtual protected void CreateShadowmap( RenderTexture shadowmap )
{
m_Shadowmap.hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild;
m_Shadowmap.dimension = TextureDimension.Tex2DArray;
m_Shadowmap.volumeDepth = (int) m_Slices;
m_ShadowmapId = new RenderTargetIdentifier( m_Shadowmap );
}
override protected void Register( GPUShadowType type, ShadowRegistry registry )
{
ShadowPrecision precision = m_ShadowmapBits == 32 ? ShadowPrecision.High : ShadowPrecision.Low;

m_Flags |= (base.m_ShadowmapFormat == RenderTextureFormat.RGFloat || base.m_ShadowmapFormat == RenderTextureFormat.RGHalf) ? Flags.channels_2 : 0;
m_Flags |= SystemInfo.usesReversedZBuffer ? Flags.reversed_z : 0;
m_Shadowmap.enableRandomWrite = true;
m_SampleCount = 1; // TODO: Unity can't bind msaa rts as textures, yet, so this has to remain 1 for now
m_MomentBlurCS = Resources.Load<ComputeShader>( "ShadowBlurMoments" );

for( int j = 0; j < m_BlurWeights[i].Length; ++j )
m_BlurWeights[i][j] *= weightSum;
}
}
override protected void CreateShadowmap( RenderTexture shadowmap )
{
shadowmap.enableRandomWrite = true;
base.CreateShadowmap( shadowmap );
}
private void FillBlurWeights( int idx )

m_Shadowmaps = shadowmaps;
foreach( var sm in shadowmaps )
{
sm.CreateShadowmap();
sm.Register( this );
sm.ReserveSlots( m_ShadowCtxt );
ShadowmapBase.ShadowSupport smsupport = sm.QueryShadowSupport();

1
Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs


abstract public void Update( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
abstract public void ReserveSlots( ShadowContextStorage sc );
abstract public void Fill( ShadowContextStorage cs );
abstract public void CreateShadowmap();
abstract protected void Register( GPUShadowType type, ShadowRegistry registry );
abstract public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, uint slice, float screenX, float screenY, float screenSizeX, float screenSizeY);
}

正在加载...
取消
保存