|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class LightweightShadowPass |
|
|
|
public class ShadowPass : ScriptableRenderPass |
|
|
|
{ |
|
|
|
public bool IsDirectionalShadowsEnabled { get { return m_ShadowSettings.supportsDirectionalShadows; } } |
|
|
|
public bool IsLocalShadowsEnabled { get { return m_ShadowSettings.supportsLocalShadows; } } |
|
|
|
|
|
|
public bool IsSoftShadowsEnabled { get { return m_ShadowSettings.supportsSoftShadows; } } |
|
|
|
|
|
|
|
// TODO: Remove this after we handle the passes dependencies
|
|
|
|
public bool requireScreenSpaceResolve { get; private set; } |
|
|
|
|
|
|
|
public float RenderingDistance { get { return m_ShadowSettings.maxShadowDistance; } } |
|
|
|
|
|
|
|
|
|
|
private ShadowSliceData[] m_LocalLightSlices; |
|
|
|
private float[] m_LocalShadowStrength; |
|
|
|
|
|
|
|
public LightweightShadowPass(LightweightPipelineAsset pipelineAsset, int maxLocalLightsCount) |
|
|
|
public ShadowPass(LightweightPipelineAsset pipelineAsset, int maxLocalLightsCount, |
|
|
|
RenderTextureFormat[] colorAttachments, RenderTextureFormat depthAttachment) : |
|
|
|
base(colorAttachments, depthAttachment) |
|
|
|
RegisterShaderPassName("ShadowCaster"); |
|
|
|
|
|
|
|
m_DirectionalShadowMatrices = new Matrix4x4[kMaxCascades + 1]; |
|
|
|
m_CascadeSlices = new ShadowSliceData[kMaxCascades]; |
|
|
|
|
|
|
Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
public void InitializeResources(CommandBuffer cmd, RenderTextureDescriptor renderTextureDesc) |
|
|
|
public override void BindSurface(CommandBuffer cmd, RenderTextureDescriptor attachmentDescriptor, int samples) |
|
|
|
renderTextureDesc.depthBufferBits = 0; |
|
|
|
renderTextureDesc.colorFormat = m_ShadowSettings.screenspaceShadowmapTextureFormat; |
|
|
|
cmd.GetTemporaryRT(m_ScreenSpaceShadowmapID, renderTextureDesc, FilterMode.Bilinear); |
|
|
|
attachmentDescriptor.depthBufferBits = 0; |
|
|
|
attachmentDescriptor.colorFormat = m_ShadowSettings.screenspaceShadowmapTextureFormat; |
|
|
|
cmd.GetTemporaryRT(m_ScreenSpaceShadowmapID, attachmentDescriptor, FilterMode.Bilinear); |
|
|
|
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref LightData lightData, |
|
|
|
Camera camera, bool stereoRendering) |
|
|
|
{ |
|
|
|
Clear(); |
|
|
|
public void Dispose(CommandBuffer cmd) |
|
|
|
bool directionalShadowmapRendered = false; |
|
|
|
if (IsDirectionalShadowsEnabled) |
|
|
|
directionalShadowmapRendered = RenderDirectionalCascadeShadowmap(ref cullResults, ref lightData, ref context); |
|
|
|
|
|
|
|
if (IsLocalShadowsEnabled) |
|
|
|
RenderLocalShadowmapAtlas(ref cullResults, ref lightData, ref context); |
|
|
|
|
|
|
|
requireScreenSpaceResolve = directionalShadowmapRendered && m_ShadowSettings.screenSpace; |
|
|
|
} |
|
|
|
|
|
|
|
public override void Dispose(CommandBuffer cmd) |
|
|
|
{ |
|
|
|
cmd.ReleaseTemporaryRT(m_ScreenSpaceShadowmapID); |
|
|
|
|
|
|
|
|
|
|
RenderTexture.ReleaseTemporary(m_LocalShadowmapTexture); |
|
|
|
m_LocalShadowmapTexture = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public bool Execute(ref CullResults cullResults, ref LightData lightData, ref ScriptableRenderContext context) |
|
|
|
{ |
|
|
|
Clear(); |
|
|
|
|
|
|
|
bool directionalShadowmapRendered = false; |
|
|
|
if (IsDirectionalShadowsEnabled) |
|
|
|
directionalShadowmapRendered = RenderDirectionalCascadeShadowmap(ref cullResults, ref lightData, ref context); |
|
|
|
|
|
|
|
if (IsLocalShadowsEnabled) |
|
|
|
RenderLocalShadowmapAtlas(ref cullResults, ref lightData, ref context); |
|
|
|
|
|
|
|
return directionalShadowmapRendered && m_ShadowSettings.screenSpace; |
|
|
|
} |
|
|
|
|
|
|
|
public void CollectShadows(Camera camera, FrameRenderingConfiguration frameRenderingConfiguration, ref ScriptableRenderContext context) |
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m_LocalShadowStrength.Length; ++i) |
|
|
|
m_LocalShadowStrength[i] = 0.0f; |
|
|
|
|
|
|
|
requireScreenSpaceResolve = false; |
|
|
|
} |
|
|
|
|
|
|
|
private void SetShadowCollectPassKeywords(CommandBuffer cmd) |
|
|
|