protected override UnityEngine.Rendering.RenderPipeline CreatePipeline() { GameheadsRenderPipeline pipeline = null; try { pipeline = new GameheadsRenderPipeline(this); } catch (Exception e) { UnityEngine.Debug.LogError(e); } return(pipeline); }
protected override void Render(ScriptableRenderContext context, Camera[] cameras) { if (cameras.Length == 0) { return; } UnityEngine.Rendering.RenderPipeline.BeginFrameRendering(context, cameras); // Loop over all active cameras in the scene and render them. foreach (var camera in cameras) { if (camera == null) { continue; } // S E T U P UnityEngine.Rendering.RenderPipeline.BeginCameraRendering(context, camera); // TODO: Should we move this after we set the rasterization render target so that scene view UI is also pixelated? DrawSceneViewUI(camera); ScriptableCullingParameters cullingParameters; if (!camera.TryGetCullingParameters(camera.stereoEnabled, out cullingParameters)) { continue; } // Need to update the volume manager for the current camera before querying any volume parameter results. // This triggers the volume manager to blend volume parameters spatially, based on the camera position. VolumeManager.instance.Update(camera.transform, camera.cullingMask); // Compute the list of visible render meshes and light sources that are inside the camera's view. CullingResults cullingResults = context.Cull(ref cullingParameters); // Setup camera for rendering (sets render target, view/projection matrices and other per-camera built-in shader variables). context.SetupCameraProperties(camera); // R E N D E R S C E N E var cmd = CommandBufferPool.Get(GameheadsStringConstants.s_CommandBufferRenderForwardStr); int renderTargetWidth = camera.pixelWidth; int renderTargetHeight = camera.pixelHeight; RenderTexture rasterizationRT = RenderTexture.GetTemporary(renderTargetWidth, renderTargetHeight, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, 1, RenderTextureMemoryless.None, VRTextureUsage.None, false); cmd.SetRenderTarget(rasterizationRT); { PushGlobalRasterizationParameters(camera, cmd, renderTargetWidth, renderTargetHeight); PushFogParameters(camera, cmd); context.ExecuteCommandBuffer(cmd); cmd.Release(); DrawOpaque(context, camera, ref cullingResults); // DrawTransparent(context, camera, ref cullingResults); // TODO: DrawSkybox(context, camera); DrawLegacyCanvasUI(context, camera, ref cullingResults); DrawGizmos(context, camera, GizmoSubset.PreImageEffects); DrawGizmos(context, camera, GizmoSubset.PostImageEffects); } // R E N D E R P O S T P R O C E S S I N G cmd = CommandBufferPool.Get(GameheadsStringConstants.s_CommandBufferRenderPostProcessStr); cmd.SetRenderTarget(camera.targetTexture); { PushGlobalPostProcessingParameters(camera, cmd, m_Asset, rasterizationRT, renderTargetWidth, renderTargetHeight); PushTonemapperParameters(camera, cmd); GameheadsRenderPipeline.DrawFullScreenQuad(cmd, postProcessingMaterial); } // C L E A N U P context.ExecuteCommandBuffer(cmd); cmd.Release(); context.Submit(); RenderTexture.ReleaseTemporary(rasterizationRT); UnityEngine.Rendering.RenderPipeline.EndCameraRendering(context, camera); } UnityEngine.Rendering.RenderPipeline.EndFrameRendering(context, cameras); }