private void DirLight(PipelineCamera cam, ref PipelineCommandData data) { PipelineBaseBuffer baseBuffer; if (SunLight.current == null || !SunLight.current.enabled || !SceneController.GetBaseBuffer(out baseBuffer)) { return; } cbdr.lightFlag |= 0b100; if (SunLight.current.enableShadow) { cbdr.lightFlag |= 0b010; } CommandBuffer buffer = data.buffer; int pass; if (SunLight.current.enableShadow) { RenderClusterOptions opts = new RenderClusterOptions { frustumPlanes = shadowFrustumVP, command = buffer, cullingShader = data.resources.gpuFrustumCulling, isOrtho = true }; ref ShadowmapSettings settings = ref SunLight.current.settings; buffer.SetGlobalVector(ShaderIDs._NormalBiases, settings.normalBias); //Only Depth buffer.SetGlobalVector(ShaderIDs._ShadowDisableDistance, new Vector4(settings.firstLevelDistance, settings.secondLevelDistance, settings.thirdLevelDistance, settings.farestDistance)); //Only Mask buffer.SetGlobalVector(ShaderIDs._SoftParam, settings.cascadeSoftValue / settings.resolution); SceneController.current.DrawDirectionalShadow(cam.cam, ref opts, ref SunLight.current.settings, ref SunLight.shadMap, cascadeShadowMapVP); buffer.SetGlobalMatrixArray(ShaderIDs._ShadowMapVPs, cascadeShadowMapVP); buffer.SetGlobalTexture(ShaderIDs._DirShadowMap, SunLight.shadMap.shadowmapTexture); cbdr.dirLightShadowmap = SunLight.shadMap.shadowmapTexture; pass = 0; }
public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data) { CommandBuffer buffer = data.buffer; buffer.SetRenderTarget(cam.targets.gbufferIdentifier, cam.targets.depthIdentifier); buffer.ClearRenderTarget(true, true, Color.black); PipelineBaseBuffer baseBuffer; bool isClusterEnabled = SceneController.GetBaseBuffer(out baseBuffer); HizOcclusionData hizData = IPerCameraData.GetProperty <HizOcclusionData>(cam, () => new HizOcclusionData()); RenderClusterOptions options = new RenderClusterOptions { command = buffer, frustumPlanes = data.arrayCollection.frustumPlanes, isOrtho = cam.cam.orthographic, cullingShader = data.resources.gpuFrustumCulling, terrainCompute = data.resources.terrainCompute, isClusterEnabled = isClusterEnabled, isTerrainEnabled = true }; HizOptions hizOptions; switch (occCullingMod) { case OcclusionCullingMode.None: SceneController.current.DrawCluster(ref options, ref cam.targets); break; case OcclusionCullingMode.SingleCheck: hizOptions = new HizOptions { currentCameraUpVec = cam.cam.transform.up, hizData = hizData, hizDepth = hizDepth, linearLODMaterial = linearMat, currentDepthTex = cam.targets.depthTexture }; SceneController.current.DrawClusterOccSingleCheck(ref options, ref hizOptions, ref cam.targets); break; case OcclusionCullingMode.DoubleCheck: hizOptions = new HizOptions { currentCameraUpVec = cam.cam.transform.up, hizData = hizData, hizDepth = hizDepth, linearLODMaterial = linearMat, currentDepthTex = cam.targets.depthTexture }; SceneController.current.DrawClusterOccDoubleCheck(ref options, ref hizOptions, ref cam.targets); break; } data.ExecuteCommandBuffer(); }