예제 #1
0
 public CustomRenderPipeline(
     CameraBufferSettings cameraBufferSettings, bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher,
     bool useLightsPerObject, ShadowSettings shadowSettings, PostFXSettings postFXSettings, int colorLUTResolution, Shader cameraRendererShader)
 {
     this.colorLUTResolution   = colorLUTResolution;
     this.cameraBufferSettings = cameraBufferSettings;
     this.postFXSettings       = postFXSettings;
     this.shadowSettings       = shadowSettings;
     this.useDynamicBatching   = useDynamicBatching;
     this.useGPUInstancing     = useGPUInstancing;
     this.useLightsPerObject   = useLightsPerObject;
     GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher;
     GraphicsSettings.lightsUseLinearIntensity            = true;
     InitializeForEditor();
     renderer = new CameraRenderer(cameraRendererShader);
 }
예제 #2
0
 public void Setup(
     ScriptableRenderContext context, Camera camera, Vector2Int bufferSize,
     PostFXSettings settings, bool keepAlpha, bool useHDR, int colorLUTResolution,
     CameraSettings.FinalBlendMode finalBlendMode,
     CameraBufferSettings.BicubicRescalingMode bicubicRescaling,
     CameraBufferSettings.FXAA fxaa
     )
 {
     this.fxaa               = fxaa;
     this.bicubicRescaling   = bicubicRescaling;
     this.bufferSize         = bufferSize;
     this.finalBlendMode     = finalBlendMode;
     this.colorLUTResolution = colorLUTResolution;
     this.keepAlpha          = keepAlpha;
     this.useHDR             = useHDR;
     this.context            = context;
     this.camera             = camera;
     this.settings           =
         camera.cameraType <= CameraType.SceneView ? settings : null;
     ApplySceneViewState();
 }
예제 #3
0
        public void Render(
            ScriptableRenderContext context, Camera camera,
            CameraBufferSettings bufferSettings,
            bool useDynamicBatching, bool useGPUInstancing, bool useLightsPerObject,
            ShadowSettings shadowSettings, PostFXSettings postFXSettings,
            int colorLUTResolution
            )
        {
            this.context = context;
            this.camera  = camera;

            var            crpCamera      = camera.GetComponent <CustomRenderPipelineCamera>();
            CameraSettings cameraSettings =
                crpCamera ? crpCamera.Settings : defaultCameraSettings;

            if (camera.cameraType == CameraType.Reflection)
            {
                useColorTexture = bufferSettings.copyColorReflection;
                useDepthTexture = bufferSettings.copyDepthReflection;
            }
            else
            {
                useColorTexture = bufferSettings.copyColor && cameraSettings.copyColor;
                useDepthTexture = bufferSettings.copyDepth && cameraSettings.copyDepth;
            }

            if (cameraSettings.overridePostFX)
            {
                postFXSettings = cameraSettings.postFXSettings;
            }

            float renderScale = cameraSettings.GetRenderScale(bufferSettings.renderScale);

            useScaledRendering = renderScale <0.99f || renderScale> 1.01f;
            PrepareBuffer();
            PrepareForSceneWindow();
            if (!Cull(shadowSettings.maxDistance))
            {
                return;
            }

            useHDR = bufferSettings.allowHDR && camera.allowHDR;
            if (useScaledRendering)
            {
                renderScale  = Mathf.Clamp(renderScale, renderScaleMin, renderScaleMax);
                bufferSize.x = (int)(camera.pixelWidth * renderScale);
                bufferSize.y = (int)(camera.pixelHeight * renderScale);
            }
            else
            {
                bufferSize.x = camera.pixelWidth;
                bufferSize.y = camera.pixelHeight;
            }

            buffer.BeginSample(SampleName);
            buffer.SetGlobalVector(bufferSizeId, new Vector4(
                                       1f / bufferSize.x, 1f / bufferSize.y,
                                       bufferSize.x, bufferSize.y
                                       ));
            ExecuteBuffer();
            lighting.Setup(
                context, cullingResults, shadowSettings, useLightsPerObject,
                cameraSettings.maskLights ? cameraSettings.renderingLayerMask : -1
                );

            bufferSettings.fxaa.enabled &= cameraSettings.allowFXAA;
            postFXStack.Setup(
                context, camera, bufferSize, postFXSettings, cameraSettings.keepAlpha, useHDR,
                colorLUTResolution, cameraSettings.finalBlendMode,
                bufferSettings.bicubicRescaling, bufferSettings.fxaa
                );
            buffer.EndSample(SampleName);
            Setup();
            DrawVisibleGeometry(
                useDynamicBatching, useGPUInstancing, useLightsPerObject,
                cameraSettings.renderingLayerMask
                );
            DrawUnsupportedShaders();
            DrawGizmosBeforeFX();
            if (postFXStack.IsActive)
            {
                postFXStack.Render(colorAttachmentId);
            }
            else if (useIntermediateBuffer)
            {
                DrawFinal(cameraSettings.finalBlendMode);
                ExecuteBuffer();
            }
            DrawGizmosAfterFX();
            Cleanup();
            Submit();
        }