public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData) { Init(); renderer.Clear(); renderer.SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData); RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData); RenderTextureDescriptor shadowDescriptor = baseDescriptor; shadowDescriptor.dimension = TextureDimension.Tex2D; renderer.EnqueuePass(m_SetupForwardRenderingPass); RenderTargetHandle colorHandle = RenderTargetHandle.CameraTarget; RenderTargetHandle depthHandle = RenderTargetHandle.CameraTarget; var sampleCount = (SampleCount)renderingData.cameraData.msaaSamples; m_CreateLightweightRenderTexturesPass.Setup(baseDescriptor, colorHandle, depthHandle, sampleCount); renderer.EnqueuePass(m_CreateLightweightRenderTexturesPass); Camera camera = renderingData.cameraData.camera; bool dynamicBatching = renderingData.supportsDynamicBatching; RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount); m_SetupLightweightConstants.Setup(renderer.maxVisibleLocalLights, renderer.perObjectLightIndices); renderer.EnqueuePass(m_SetupLightweightConstants); m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching); renderer.EnqueuePass(m_RenderOpaqueForwardPass); }
public static void RenderSingleCamera(ScriptableRenderContext context, Camera camera, ref CullResults cullResults, IRendererSetup setup, ScriptableRenderer renderer) { CommandBuffer cmd = commandBufferPool.Get("RenderSingleCam"); CameraData cameraData; InitializeCameraData(camera, out cameraData); ScriptableCullingParameters cullingParam; if (!CullResults.GetCullingParameters(camera, false, out cullingParam)) { commandBufferPool.Release(cmd); return; } cullingParam.shadowDistance = Mathf.Min(ShadowDistance, camera.farClipPlane); context.ExecuteCommandBuffer(cmd); cmd.Clear(); #if UNITY_EDITOR //SceneView Camera #endif CullResults.Cull(ref cullingParam, context, ref cullResults); RenderingData renderingData; InitializeRenderingData(ref cameraData, ref cullResults, out renderingData); IRendererSetup setupToUse = setup; if (setupToUse == null) { setupToUse = defaultRenderSetup; } renderer.Clear(); setupToUse.Setup(renderer, ref renderingData); renderer.Execute(context, ref renderingData); context.ExecuteCommandBuffer(cmd); commandBufferPool.Release(cmd); context.Submit(); }