public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data) { if (SunLight.current == null) { return; } CommandBuffer buffer = data.buffer; int pass; lightBlock.Clear(); if (SunLight.current.enableShadow) { PipelineFunctions.UpdateShadowMapState(ref SunLight.shadMap, lightBlock, ref SunLight.current.settings, buffer); PipelineFunctions.DrawShadow(cam.cam, data.resources.gpuFrustumCulling, buffer, ref data.baseBuffer, ref SunLight.current.settings, ref SunLight.shadMap, cascadeShadowMapVP, shadowFrustumVP); PipelineFunctions.UpdateShadowMaskState(lightBlock, ref SunLight.shadMap, cascadeShadowMapVP); pass = 0; } else { pass = 1; } lightBlock.SetVector(ShaderIDs._LightFinalColor, SunLight.shadMap.light.color * SunLight.shadMap.light.intensity); buffer.SetRenderTarget(cam.targets.renderTargetIdentifier, cam.targets.depthIdentifier); lightBlock.SetVector(ShaderIDs._LightPos, -SunLight.shadMap.shadCam.forward); buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, shadMaskMaterial, 0, pass, lightBlock); }
public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data) { if (SunLight.current == null) { return; } PipelineBaseBuffer baseBuffer; if (!SceneController.current.GetBaseBufferAndCheck(out baseBuffer)) { return; } CommandBuffer buffer = data.buffer; int pass; if (SunLight.current.enableShadow) { RenderClusterOptions opts = new RenderClusterOptions { frustumPlanes = shadowFrustumVP, command = buffer, cullingShader = data.resources.gpuFrustumCulling, isOrtho = true, proceduralMaterial = null }; PipelineFunctions.UpdateShadowMapState(ref SunLight.shadMap, ref SunLight.current.settings, buffer); SceneController.current.DrawDirectionalShadow(cam.cam, ref opts, ref SunLight.current.settings, ref SunLight.shadMap, cascadeShadowMapVP); PipelineFunctions.UpdateShadowMaskState(buffer, ref SunLight.shadMap, cascadeShadowMapVP); pass = 0; } else { pass = 1; } buffer.SetGlobalVector(ShaderIDs._LightFinalColor, SunLight.shadMap.light.color * SunLight.shadMap.light.intensity); buffer.SetRenderTarget(cam.targets.renderTargetIdentifier, cam.targets.depthIdentifier); buffer.SetGlobalVector(ShaderIDs._LightPos, -SunLight.shadMap.shadCam.forward); buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, shadMaskMaterial, 0, pass); data.ExecuteCommandBuffer(); }