void UpdatePostProcess(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            var postEffects = renderingData.cameraData.camera.GetComponents <APostProcessBase>().FindAll(p => p.enabled);

            if (!postEffects.Any())
            {
                return;
            }

            var dictionary = postEffects.ToListDictionary(p => p.m_IsOpaqueProcess);

            foreach (bool key in from key in dictionary.Keys let count = dictionary[key].Count() where count != 0 select key)
            {
                renderer.EnqueuePass(key ? m_PostProcesssing_Opaque.Setup(renderer, dictionary[true]) : m_PostProcesssing_AfterAll.Setup(renderer, dictionary[false]));
            }
        }
Beispiel #2
0
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (shader == null)
        {
            return;
        }
        if (_Material == null)
        {
            _Material = CoreUtils.CreateEngineMaterial(shader);
        }
        var cameraColorTarget = renderer.cameraColorTarget;

        GenSampleKernal();
        volume.Setup(cameraColorTarget, _Material, samplePoint);
        renderer.EnqueuePass(volume);
    }
Beispiel #3
0
 public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
 {
     if (Enabled)
     {
         if (Settings != null)
         {
             renderPass.SetSettings(Settings);
             renderPass.SetScreenTarget(renderer.cameraColorTarget);
             renderer.EnqueuePass(renderPass);
         }
         else
         {
             Debug.LogWarning("Please attach post processor settings!");
         }
     }
 }
        public override void AddRenderPasses(ScriptableRenderer renderer,
                                             ref RenderingData renderingData)
        {
            int     numFrustumsX, numFrustumsY;
            Vector2 screenSizeRatio;

            SetupScreenReferenceInfo(ref renderingData, out numFrustumsX, out numFrustumsY,
                                     out screenSizeRatio);

            if (m_precomputeFrustumsPass != null)
            {
                m_precomputeFrustumsPass.Setup(ref screenSizeRatio, m_frustumTileSize,
                                               m_inverseProjectionMatrixFloats, numFrustumsX, numFrustumsY);
                renderer.EnqueuePass(m_precomputeFrustumsPass);
            }

            if (renderingData.cameraData.cameraType == CameraType.Game)
            {
                renderer.EnqueuePass(m_depthOnlyPass);
            }

            if (m_copyDepthPass != null)
            {
                m_copyDepthPass.Setup(renderer.cameraDepth);
                renderer.EnqueuePass(m_copyDepthPass);
            }

            if (m_tileLightCullingPass != null)
            {
                m_tileLightCullingPass.Setup(
                    m_precomputeFrustumsPass.GetFrustumsBuffer(),
                    m_inverseProjectionMatrixFloats,
                    ref screenSizeRatio, m_frustumTileSize, numFrustumsX,
                    numFrustumsY);
                renderer.EnqueuePass(m_tileLightCullingPass);
            }

            if (m_copyColorPass != null)
            {
                Downsampling downsamplingMethod =
                    UniversalRenderPipeline.asset.opaqueDownsampling;
                m_copyColorPass.Setup(renderer.cameraColorTarget,
                                      m_backgroundRT, downsamplingMethod);
                renderer.EnqueuePass(m_copyColorPass);
            }

            if ((m_showLightGridsPass == null) || m_showTileLightGridRatio <= 0.0f)
            {
                return;
            }
            m_showDebugTileLightGridMaterial.SetColor("_GridColor", m_tileLightGridColor);
            m_showDebugTileLightGridMaterial.SetFloat("_Show", m_showTileLightGridRatio);
            m_showLightGridsPass.Setup(renderer.cameraColorTarget);
            renderer.EnqueuePass(m_showLightGridsPass);
        }
Beispiel #5
0
 // Here you can inject one or multiple render passes in the renderer.
 // This method is called when setting up the renderer once per-camera.
 public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
 {
     if (GlobalVolumePass.volumeHolder == null)
     {
         var old = GameObject.Find("[DefaultVolume]");
         if (Application.isPlaying)
         {
             Destroy(old);
         }
         else
         {
             DestroyImmediate(old);
         }
     }
     renderer.EnqueuePass(m_ScriptablePass);
 }
        /// <summary>
        /// Add the background rendering pass when rendering a game camera with an enabled AR camera background component.
        /// </summary>
        /// <param name="renderer">The sriptable renderer in which to enqueue the render pass.</param>
        /// <param name="renderingData">Additional rendering data about the current state of rendering.</param>
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
#if !UNITY_EDITOR
            Camera currentCamera = renderingData.cameraData.camera;
            if ((currentCamera != null) && (currentCamera.cameraType == CameraType.Game))
            {
                ARCameraBackground cameraBackground = currentCamera.gameObject.GetComponent <ARCameraBackground>();
                if ((cameraBackground != null) && cameraBackground.backgroundRenderingEnabled && (cameraBackground.material != null))
                {
                    bool invertCulling = cameraBackground.GetComponent <ARCameraManager>()?.subsystem?.invertCulling ?? false;
                    m_ScriptablePass.Setup(cameraBackground.material, renderer.cameraColorTarget, renderer.cameraDepth, invertCulling);
                    renderer.EnqueuePass(m_ScriptablePass);
                }
            }
#endif // !UNITY_EDITOR
        }
Beispiel #7
0
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            if (settings.blitMaterial == null)
            {
                Debug.LogWarningFormat("Missing Blit Material. {0} blit pass will not execute. Check for missing reference in the assigned renderer.", GetType().Name);
                return;
            }

#if !UNITY_2021_2_OR_NEWER
            // AfterRenderingPostProcessing event is fixed in 2021.2+ so this workaround is no longer required

            if (settings.Event == RenderPassEvent.AfterRenderingPostProcessing)
            {
            }
            else if (settings.Event == RenderPassEvent.AfterRendering && renderingData.postProcessingEnabled)
            {
                // If event is AfterRendering, and src/dst is using CameraColor, switch to _AfterPostProcessTexture instead.
                if (settings.srcType == Target.CameraColor)
                {
                    settings.srcType      = Target.TextureID;
                    settings.srcTextureId = "_AfterPostProcessTexture";
                }
                if (settings.dstType == Target.CameraColor)
                {
                    settings.dstType      = Target.TextureID;
                    settings.dstTextureId = "_AfterPostProcessTexture";
                }
            }
            else
            {
                // If src/dst is using _AfterPostProcessTexture, switch back to CameraColor
                if (settings.srcType == Target.TextureID && settings.srcTextureId == "_AfterPostProcessTexture")
                {
                    settings.srcType      = Target.CameraColor;
                    settings.srcTextureId = "";
                }
                if (settings.dstType == Target.TextureID && settings.dstTextureId == "_AfterPostProcessTexture")
                {
                    settings.dstType      = Target.CameraColor;
                    settings.dstTextureId = "";
                }
            }
#endif

            blitPass.Setup(renderer);
            renderer.EnqueuePass(blitPass);
        }
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        pass.Parameters.UseHDR = renderingData.cameraData.isHdrEnabled;

        pass.Parameters.Target = renderer.cameraColorTarget;
        pass.Parameters.PrimaryRendererScale = settings.PrimaryRendererScale;
        pass.Parameters.InfoBufferScale      = settings.InfoBufferScale;
        pass.Parameters.UsingInfoBuffer      = settings.UsingInfoBuffer;
        pass.Parameters.BlurIterations       = settings.BlurIterations;
        pass.Parameters.DilateIterations     = settings.DilateIterations;
        pass.Parameters.BlurShift            = settings.BlurShift;
        pass.Parameters.DilateShift          = settings.DilateShift;
        pass.Parameters.Depth = renderer.cameraDepth;
        pass.Parameters.SustainedPerformanceMode = settings.SustainedPerformanceMode;

        renderer.EnqueuePass(pass);
    }
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            if ((renderingData.cameraData.camera.cullingMask & m_settings.LayerMask) != 0)
            {
                IMeshesCache    meshesCache    = IOC.Resolve <IMeshesCache>(m_settings.MeshesCacheName);
                IRenderersCache renderersCache = IOC.Resolve <IRenderersCache>(m_settings.RenderersCacheName);

                if ((meshesCache == null || meshesCache.IsEmpty) && (renderersCache == null || renderersCache.IsEmpty))
                {
                    return;
                }

                var src = renderer.cameraColorTarget;
                m_scriptablePass.Setup(src, meshesCache, renderersCache);
                renderer.EnqueuePass(m_scriptablePass);
            }
        }
Beispiel #10
0
        // Called every frame, once per camera
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            var sourceTarget      = renderer.cameraColorTarget;
            var destinationTarget = (settings.Destination == Target.CameraTarget)
                                ? RenderTargetHandle.CameraTarget
                                : m_RenderTextureHandle;

            if (settings.BlitMaterial == null)
            {
                Debug.LogWarningFormat("Missing Blit Material. {0} blit pass will not execute. Check for missing reference in the assigned renderer.", GetType().Name);
                return;
            }

            // Setup and add the render pass
            _featurePass.Setup(sourceTarget, destinationTarget);
            renderer.EnqueuePass(_featurePass);
        }
Beispiel #11
0
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        Downsampling downSamplingMethod = LightweightRenderPipeline.asset.opaqueDownsampling;

        var cameraColorTarget = renderer.cameraColorTarget;
        var clearRenderPass   = new ClearColorPass(RenderPassEvent.BeforeRenderingOpaques, cameraColorTarget);

        var copyBeforeOpaquePass = new CopyColorPass(RenderPassEvent.BeforeRenderingOpaques, m_SamplingMaterial);

        copyBeforeOpaquePass.Setup(cameraColorTarget, beforeAll, downSamplingMethod);

        var copyAfterOpaquePass = new CopyColorPass(RenderPassEvent.AfterRenderingOpaques, m_SamplingMaterial);

        copyAfterOpaquePass.Setup(cameraColorTarget, afterOpaque, downSamplingMethod);

        var copyAfterSkyboxPass = new CopyColorPass(RenderPassEvent.AfterRenderingSkybox, m_SamplingMaterial);

        copyAfterSkyboxPass.Setup(cameraColorTarget, afterSkybox, downSamplingMethod);

        var copyAfterSkyboxPass2 = new CopyColorPass(RenderPassEvent.AfterRenderingSkybox, m_SamplingMaterial);

        copyAfterSkyboxPass.Setup(cameraColorTarget, afterSkybox2, downSamplingMethod);

        var copyAfterTransparents = new CopyColorPass(RenderPassEvent.AfterRenderingTransparents, m_SamplingMaterial);

        copyAfterTransparents.Setup(cameraColorTarget, afterTransparent, downSamplingMethod);

        var copyAfterEverything = new CopyColorPass(RenderPassEvent.AfterRendering, m_SamplingMaterial);

        copyAfterEverything.Setup(cameraColorTarget, afterAll, downSamplingMethod);

        var BlitRenderPassesToScreen = new BlitPass(RenderPassEvent.AfterRendering, cameraColorTarget);

        // Inserts out of order so we also test render passes sort correctly
        renderer.EnqueuePass(copyAfterEverything);
        renderer.EnqueuePass(BlitRenderPassesToScreen);
        renderer.EnqueuePass(copyAfterOpaquePass);
        renderer.EnqueuePass(copyAfterSkyboxPass);
        renderer.EnqueuePass(copyAfterSkyboxPass2);
        renderer.EnqueuePass(copyAfterTransparents);
        renderer.EnqueuePass(clearRenderPass);
        renderer.EnqueuePass(copyBeforeOpaquePass);
    }
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (!GetOutlinersToRenderWith(renderingData, outliners))
        {
            return;
        }

#if UNITY_2019_3_OR_NEWER && !UNITY_2019_3_0 && !UNITY_2019_3_1 && !UNITY_2019_3_2 && !UNITY_2019_3_3 && !UNITY_2019_3_4 && !UNITY_2019_3_5 && !UNITY_2019_3_6 && !UNITY_2019_3_7 && !UNITY_2019_3_8
        var additionalCameraData = renderingData.cameraData.camera.GetUniversalAdditionalCameraData();
        var activeStackCount     = 0;
        if (additionalCameraData != null)
        {
            var stack = additionalCameraData.renderType == CameraRenderType.Overlay ? null : additionalCameraData.cameraStack;
            if (stack != null)
            {
                foreach (var camera in stack)
                {
                    if (camera != null && camera.isActiveAndEnabled)
                    {
                        activeStackCount++;
                    }
                }
            }
        }
#endif

        var shouldUseDepthTarget = renderingData.cameraData.requiresDepthTexture && renderingData.cameraData.cameraTargetDescriptor.msaaSamples <= 1 && !renderingData.cameraData.isSceneViewCamera;

        foreach (var outliner in outliners)
        {
            var outline = outlinePool.Get();

            outline.Outliner = outliner;

            outline.UseColorTargetForDepth = (additionalCameraData == null || activeStackCount == 0 && additionalCameraData.renderType != CameraRenderType.Overlay) &&
                                             !shouldUseDepthTarget;

            outline.Renderer        = renderer;
            outline.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;

            renderer.EnqueuePass(outline);
        }

        outlinePool.ReleaseAll();
    }
Beispiel #13
0
        /// <inheritdoc/>
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            if (!GetMaterial())
            {
                Debug.LogErrorFormat(
                    "{0}.AddRenderPasses(): Missing material. {1} render pass will not be added. Check for missing reference in the renderer resources.",
                    GetType().Name, m_SSAOPass.profilerTag);
                return;
            }

            bool shouldAdd = m_SSAOPass.Setup(m_Settings);

            if (shouldAdd)
            {
                m_SSAOPass.source = renderer.cameraColorTarget;
                renderer.EnqueuePass(m_SSAOPass);
            }
        }
Beispiel #14
0
    // called every frame once per camera
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (!settings.IsEnabled)
        {
            // we can do nothing this frame if we want
            return;
        }

        // Gather up and pass any extra information our pass will need.
        // In this case we're getting the camera's color buffer target
        var cameraColorTargetIdent = renderer.cameraColorTarget;

        myRenderPass.Setup(cameraColorTargetIdent);

        // Ask the renderer to add our pass.
        // Could queue up multiple passes and/or pick passes to use
        renderer.EnqueuePass(myRenderPass);
    }
Beispiel #15
0
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        m_OutlinePass.settings = new OutlinePass.OutlineSettings
        {
            color      = settings.color,
            size       = settings.size,
            softness   = settings.softness,
            downsample = settings.downsample,
            drawOnTop  = settings.drawOnTop,
        };

        RenderTargetIdentifier cameraTargetID = new RenderTargetIdentifier(BuiltinRenderTextureType.CameraTarget);

        m_OutlinePass.cameraDepth       = renderer.cameraDepth == cameraTargetID ? renderer.cameraColorTarget : renderer.cameraDepth;
        m_OutlinePass.cameraColorTarget = renderer.cameraColorTarget;

        renderer.EnqueuePass(m_OutlinePass);
    }
Beispiel #16
0
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            int shadowIndex = 0;

            foreach (var visibleLight in renderingData.lightData.visibleLights)
            {
                if (visibleLight.light.shadows == LightShadows.None)
                {
                    continue;
                }

                renderer.EnqueuePass(m_ShadowPasses[shadowIndex].Setup(shadowIndex, visibleLight.light, m_ShadowData));
                shadowIndex++;
                if (shadowIndex >= m_ShadowPasses.Length)
                {
                    break;
                }
            }
        }
Beispiel #17
0
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        var currentCamera = renderingData.cameraData.camera;

        if (currentCamera != null && currentCamera.cameraType == CameraType.Game)
        {
            var humanParticle = currentCamera.GetComponent <HumanParticle>();
            if (humanParticle == null)
            {
                return;
            }
            if (humanParticle.LatestCameraFeedBuffer == null)
            {
                return;
            }
            _scriptablePass.Setup(renderer.cameraColorTarget, humanParticle.LatestCameraFeedBuffer);
            renderer.EnqueuePass(_scriptablePass);
        }
    }
Beispiel #18
0
    // 使用Blit的一定是主相机
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (!renderingData.cameraData.camera.name.Contains("Main Camera"))
        {
            return;
        }

        var src  = renderer.cameraColorTarget;
        var dest = (settings.destination == Target.Color) ? RenderTargetHandle.CameraTarget : m_RenderTextureHandle;

        if (settings.blitMaterial == null)
        {
            Debug.LogWarningFormat("Missing Blit Material. {0} blit pass will not execute. Check for missing reference in the assigned renderer.", GetType().Name);
            return;
        }

        blitPass.Setup(src, dest);
        renderer.EnqueuePass(blitPass);
    }
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        int width, height;

        if (settings.RenderTextureResolution <= 0)
        {
            width  = 16;
            height = 16;
        }

        else
        {
            width  = settings.RenderTextureResolution;
            height = width;
        }

        depthNormalsPass.Setup(new RenderTextureDescriptor(width, height), new RenderTargetHandle());
        renderer.EnqueuePass(depthNormalsPass);
    }
Beispiel #20
0
    // called every frame once per camera
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (!settings.IsEnabled)
        {
            return;
        }

        float angle = Mathf.PI * settings.RotationRange *
                      Mathf.Sin(Time.time * settings.RotationSpeed);

        // Gather up any extra information our pass will need.
        brightSpotsPass.Setup(
            renderer.cameraColorTarget,
            settings.LuminanceThreshold,
            angle
            );

        // Ask the renderer to add our pass.
        renderer.EnqueuePass(brightSpotsPass);
    }
 public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
 {
     if (renderingData.cameraData.renderType != CameraRenderType.Base)
     {
         return;
     }
     if (_pass == null)
     {
         if (_material)
         {
             _pass = new CopyColorWithAlphaPass(RenderPassEvent.AfterRenderingSkybox, _material);
         }
         else
         {
             return;
         }
     }
     _pass.Setup(renderer.cameraColorTarget, m_OpaqueColor, Downsampling._4xBox);
     renderer.EnqueuePass(_pass);
 }
Beispiel #22
0
        public override void AddRenderPasses(ScriptableRenderer renderer,
                                             ref RenderingData renderingData)
        {
#if UNITY_EDITOR
            if (renderingData.cameraData.isPreviewCamera)
            {
                return;
            }
#endif

            if (settings == null)
            {
                Debug.LogWarning("[FlatKit] Missing Fog Settings");
                return;
            }

            InitMaterial();

            _effectPass.Setup(renderer, RenderTargetHandle.CameraTarget);
            renderer.EnqueuePass(_effectPass);
        }
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            var cameraObject     = renderingData.cameraData.camera.gameObject;
            var perceptionCamera = cameraObject.GetComponent <PerceptionCamera>();

            if (perceptionCamera == null)
            {
                return;
            }

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                return;
            }
#endif
            perceptionCamera.OnGroundTruthRendererFeatureRun();
            foreach (var pass in perceptionCamera.passes)
            {
                renderer.EnqueuePass(pass);
            }
        }
Beispiel #24
0
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (!settings.IsEnabled)
        {
            return;
        }
        RenderTexture targetBlit = null;

        if (cameraTargetRTDict.ContainsKey(renderingData.cameraData.camera))
        {
            targetBlit = cameraTargetRTDict[renderingData.cameraData.camera];
        }
        if (targetBlit == null)
        {
            return;
        }
        var cameraColorTargetIdent = renderer.cameraColorTarget;

        gifRecorderPass.Setup(cameraColorTargetIdent, targetBlit);

        renderer.EnqueuePass(gifRecorderPass);
    }
        public override void AddRenderPasses(ScriptableRenderer renderer,
                                             ref RenderingData renderingData)
        {
            var tis = GetTIS(renderingData.cameraData.camera);

            if (tis == null || !tis.shouldUpdateBlur())
            {
                return;
            }

            tis.OnBeforeBlur();
            blurAlgorithm.Init(tis.BlurConfig);
            var passData = new TISPassData {
                cameraColorTarget = renderer.cameraColorTarget,
                blurAlgorithm     = blurAlgorithm, //hack for now
                blurSource        = tis,
                isPreviewing      = tis.preview
            };

            pass.Setup(passData);

            renderer.EnqueuePass(pass);
        }
Beispiel #26
0
    public void Setup(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        Init();

        Camera camera = renderingData.cameraData.camera;

        RenderTextureDescriptor baseDesc   = CoreUtils.CreateRenderTextureDescriptor(ref renderingData.cameraData);
        RenderTextureDescriptor shadowDesc = baseDesc;

        shadowDesc.dimension = TextureDimension.Tex2D;

        m_DirectionalShadowPass.Setup(DirectionalShadowmap, ref renderingData.shadowData);
        renderer.EnqueuePass(m_DirectionalShadowPass);

        if (renderingData.shadowData.supportSoftShadows)
        {
            if (renderingData.shadowData.shadowType == SoftShadowType.VSM)
            {
                m_BlurPass.Setup(DirectionalShadowmap, BluredDirectionalShadowmap);
                renderer.EnqueuePass(m_BlurPass);
            }
        }

        renderer.EnqueuePass(m_SetupForwardRenderingPass);

        m_DepthOnlyPass.Setup(baseDesc, DepthTexture, 1);
        renderer.EnqueuePass(m_DepthOnlyPass);

        m_ScreenSpaceShadowPass.Setup(baseDesc, ScreenSpaceShadowmap);
        renderer.EnqueuePass(m_ScreenSpaceShadowPass);

        //m_SetupLWDConstants.Setup();
        //renderer.EnqueuePass(m_SetupLWDConstants);

        RenderTargetHandle colorHandle = RenderTargetHandle.CameraTarget;
        RenderTargetHandle depthHandle = RenderTargetHandle.CameraTarget;

        RendererConfiguration rendererConfig = RendererConfiguration.None;

        m_RenderOpaqueForwardPass.Setup(baseDesc, colorHandle, depthHandle, ScriptableRenderer.GetClearFlag(camera), camera.backgroundColor, rendererConfig);
        renderer.EnqueuePass(m_RenderOpaqueForwardPass);

        //m_FinalBlitPass.Setup(baseDesc, colorHandle);
        //renderer.EnqueuePass(m_FinalBlitPass);
    }
Beispiel #27
0
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            if (renderingData.cameraData.isSceneViewCamera)
            {
                return;
            }
            if (renderingData.cameraData.camera != Camera.main)
            {
                return;
            }

            var src  = renderer.cameraColorTarget;
            var dest = (settings.destination == Target.Color) ? RenderTargetHandle.CameraTarget : renderTextureHandle;

            if (settings.atmosphereMaterial == null)
            {
                Debug.LogWarningFormat("Missing Atmosphere Material. {0} atmosphere pass will not execute. Check for missing reference in the assigned renderer.", GetType().Name);
                return;
            }

            atmospherePass.Setup(src, dest);
            renderer.EnqueuePass(atmospherePass);
        }
        //在这里,您可以在渲染器中注入一个或多个渲染通道。
        //每个摄像机设置一次渲染器时,将调用此方法。
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            // 检测Shader是否存在
            if (shader == null)
            {
                return;
            }

            // 创建材质
            if (_Material == null)
            {
                _Material = CoreUtils.CreateEngineMaterial(shader);
            }

            // 获取当前渲染相机的目标颜色,也就是主纹理
            var cameraColorTarget = renderer.cameraColorTarget;

            // 设置调用后处理Pass
            postPass.Setup(cameraColorTarget, _Material);

            // 添加该Pass到渲染管线中
            renderer.EnqueuePass(postPass);
        }
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            //删除scene camera效果
            //是因为 create RT 第一次draw 会执行clear
            //并且两个camera 的参数不一样 又会争夺 create destroy rt
            if (renderingData.cameraData.cameraType != CameraType.Game)
            {
                return;
            }

            if (enable && renderingData.postProcessingEnabled && solidCloudMaterial != null)
            {
                var settings = VolumeManager.instance.stack.GetComponent <SolidCloudRenderPostProcess>();

                if (settings != null && settings.IsActive())
                {
                    int width  = renderingData.cameraData.camera.scaledPixelWidth;
                    int height = renderingData.cameraData.camera.scaledPixelHeight;

                    solidCloudRenderPass.Setup(settings, width, height);
                    renderer.EnqueuePass(solidCloudRenderPass);
                }
            }
        }
Beispiel #30
0
    // Here you can inject one or multiple render passes in the renderer.
    // This method is called when setting up the renderer once per-camera.
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (settings == null)
        {
            Debug.LogWarning("Please attach HBAORendererSettings to settings field");
            return;
        }

        if (hbaoShader == null)
        {
            hbaoShader = Shader.Find(SHADER_PATH);
            if (hbaoShader == null)
            {
                Debug.LogWarning("HBAO shader was not found. Please ensure it compiles correctly");
                return;
            }
        }

        if (!settings.enable)
        {
            return;
        }

        // Configures where the render pass should be injected.
        m_HBAORenderPass.renderPassEvent = settings.displayMode == DisplayMode.Normal ?
                                           RenderPassEvent.BeforeRenderingTransparents :
                                           RenderPassEvent.AfterRenderingTransparents;

        m_HBAORenderPass.settings = settings;

        var material = CoreUtils.CreateEngineMaterial(hbaoShader);

        m_HBAORenderPass.Setup(material, renderer.cameraColorTarget);

        renderer.EnqueuePass(m_HBAORenderPass);
    }