Exemplo n.º 1
0
        public GBufferPass(RenderPassEvent evt, RenderQueueRange renderQueueRange, LayerMask layerMask, StencilState stencilState, int stencilReference, DeferredLights deferredLights)
        {
            base.renderPassEvent = evt;
            m_DeferredLights     = deferredLights;
            m_HasDepthPrepass    = false;
            m_FilteringSettings  = new FilteringSettings(renderQueueRange, layerMask);
            m_RenderStateBlock   = new RenderStateBlock(RenderStateMask.Nothing);

            if (stencilState.enabled)
            {
                m_RenderStateBlock.stencilReference = stencilReference;
                m_RenderStateBlock.mask             = RenderStateMask.Stencil;
                m_RenderStateBlock.stencilState     = stencilState;
            }
        }
Exemplo n.º 2
0
            public void Setup(Shader shader, ScriptableRenderer renderer, RenderPassEvent renderPassEvent)
            {
                if (material == null)
                {
                    material = CoreUtils.CreateEngineMaterial(shader);
                }
                source = renderer.cameraColorTarget;

                // Configures where the render pass should be injected.
                this.renderPassEvent = renderPassEvent;

                m_ShaderTagId       = new ShaderTagId("UniversalForward");
                m_FilteringSettings = new FilteringSettings(RenderQueueRange.opaque, layerMask: -1);
                m_RenderStateBlock  = new RenderStateBlock(RenderStateMask.Nothing);
            }
            public DepthRenderPass()
            {
                m_Depth.Init("_CustomDepthTexture");
                m_ShaderTagIdList.Add(new ShaderTagId("SRPDefaultUnlit"));
                m_ShaderTagIdList.Add(new ShaderTagId("UniversalForward"));
                m_ShaderTagIdList.Add(new ShaderTagId("LightweightForward"));
                m_FilteringSettings = new FilteringSettings(RenderQueueRange.transparent, 0);
                Shader depthOnly = Shader.Find("Universal Render Pipeline/Unlit");

                if (depthOnly != null)
                {
                    depthOnlyMaterial = new Material(depthOnly);
                }
                SetupKeywords();
            }
Exemplo n.º 4
0
        void DrawVisibleGeometry(
            bool useDynamicBatching, bool useGPUInstancing, bool useLightsPerObject
            )
        {
            PerObjectData lightsPerObjectFlags = useLightsPerObject ?
                                                 PerObjectData.LightData | PerObjectData.LightIndices :
                                                 PerObjectData.None;
            var sortingSettings = new SortingSettings(camera)
            {
                criteria = SortingCriteria.CommonOpaque
            };
            var drawSettings = new DrawingSettings(
                unlitShaderTagId, sortingSettings
                )
            {
                enableDynamicBatching = useDynamicBatching,
                enableInstancing      = useGPUInstancing,
                perObjectData         = PerObjectData.ReflectionProbes |
                                        PerObjectData.Lightmaps | PerObjectData.ShadowMask |
                                        PerObjectData.LightProbe | PerObjectData.OcclusionProbe |
                                        PerObjectData.LightProbeProxyVolume |
                                        PerObjectData.OcclusionProbeProxyVolume
                                        //perObjectData =
                                        //    PerObjectData.ReflectionProbes |
                                        //    PerObjectData.Lightmaps | PerObjectData.ShadowMask |
                                        //    PerObjectData.LightProbe | PerObjectData.OcclusionProbe |
                                        //    PerObjectData.LightProbeProxyVolume |
                                        //    PerObjectData.OcclusionProbeProxyVolume |
                                        //    lightsPerObjectFlags
            };

            drawSettings.SetShaderPassName(1, litShaderTagId);

            var filterSettings = new FilteringSettings(RenderQueueRange.opaque);

            context.DrawRenderers(
                cullingResults, ref drawSettings, ref filterSettings
                );

            context.DrawSkybox(camera);

            sortingSettings.criteria        = SortingCriteria.CommonTransparent;
            drawSettings.sortingSettings    = sortingSettings;
            filterSettings.renderQueueRange = RenderQueueRange.transparent;

            context.DrawRenderers(
                cullingResults, ref drawSettings, ref filterSettings);
        }
Exemplo n.º 5
0
        public BasicFeaturePass(RenderPassEvent renderEvent, Material bM, float pD, int lM)
        {
            m_ProfilingSampler   = new ProfilingSampler("BasicFeature");
            this.renderPassEvent = renderEvent;
            blitMat      = bM;
            pixelDensity = pD;
            blitMat.SetFloat("_PixelDensity", pixelDensity);

            m_FilteringSettings = new FilteringSettings(RenderQueueRange.opaque, lM);

            m_ShaderTagIdList.Add(new ShaderTagId("UniversalForward"));
            m_ShaderTagIdList.Add(new ShaderTagId("LightweightForward"));
            m_ShaderTagIdList.Add(new ShaderTagId("SRPDefaultUnlit"));

            m_RenderStateBlock = new RenderStateBlock(RenderStateMask.Nothing);
        }
Exemplo n.º 6
0
        public void Render(ref CullingResults cullResult, ref ScriptableRenderContext context, CommandBuffer cmd, Camera camera)
        {
            SortingSettings opaqueSortSetting = new SortingSettings(camera)
            {
                criteria = SortingCriteria.CommonOpaque
            };

            DrawingSettings opaqueDrawSetting = new DrawingSettings(unlitShaderTagId[0], opaqueSortSetting)
            {
                perObjectData = PerObjectData.LightIndices | PerObjectData.LightData
            };

            FilteringSettings opaqueFilteringSeting = new FilteringSettings(RenderQueueRange.opaque);

            context.DrawRenderers(cullResult, ref opaqueDrawSetting, ref opaqueFilteringSeting);
        }
Exemplo n.º 7
0
 private static bool DllMayNotHaveBeenBuilt(TestInfo defaultTestInfo, FilteringSettings filteringSettings)
 {
     // Asks whether a version filter was set and if so, whether none of those specified versions matched any of the default testinfo's versions.
     // If so, it may be the case that the dll was not built because we are building tests against an older product version
     // than the tests in that dll are targeted to. In this case we return true, saying that the dll may not
     // have been built. Callers can use this method to determine whether they should throw or warn if they don't
     // see the expected dll.
     if (filteringSettings.Versions != null && !filteringSettings.Versions.Any(filterVersion => filteringSettings.VersionMatcher.VersionMatches(defaultTestInfo.Versions, filterVersion)))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 8
0
        public DrawObjectsPass(string profilerTag, RenderPassEvent evt, RenderQueueRange renderQueueRange, LayerMask layerMask, StencilState stencilState, int stencilReference)
        {
            m_ProfilerTag = profilerTag;
            m_ShaderTagIdList.Add(new ShaderTagId("LightweightForward"));
            m_ShaderTagIdList.Add(new ShaderTagId("SRPDefaultUnlit"));
            renderPassEvent     = evt;
            m_FilteringSettings = new FilteringSettings(renderQueueRange, layerMask);
            m_RenderStateBlock  = new RenderStateBlock(RenderStateMask.Nothing);

            if (stencilState.enabled)
            {
                m_RenderStateBlock.stencilReference = stencilReference;
                m_RenderStateBlock.mask             = RenderStateMask.Stencil;
                m_RenderStateBlock.stencilState     = stencilState;
            }
        }
Exemplo n.º 9
0
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer     cmd = CommandBufferPool.Get("RenderMask");
            RenderQueueRange  renderQueueRange = RenderQueueRange.all;
            FilteringSettings filters          = new FilteringSettings(renderQueueRange);

            filters.layerMask = LayerMask.GetMask(new string[] { "ViewMasks" });
            List <ShaderTagId> m_ShaderTagIdList = new List <ShaderTagId>();

            m_ShaderTagIdList.Add(new ShaderTagId("LightweightForward"));
            m_ShaderTagIdList.Add(new ShaderTagId("SRPDefaultUnlit"));
            ShaderTagId     id = new ShaderTagId("Opaque");
            DrawingSettings drawingSettings = CreateDrawingSettings(m_ShaderTagIdList, ref renderingData, SortingCriteria.CommonOpaque);

            context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filters);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Discover a collection of test cases.
        /// </summary>
        /// <param name="discoveryInfoPath">Path to Discovery Info. If path is relative, it will interpreted as relative to the current directory.</param>
        /// <param name="filteringSettings">Filtering settings.</param>
        /// <returns></returns>
        public static TestRecords Discover(FileInfo discoveryInfoPath, FilteringSettings filteringSettings)
        {
            Profiler.StartMethod();

            IEnumerable <TestInfo> testInfos = DiscoveryEngine.Discover(discoveryInfoPath, filteringSettings);
            TestRecords            tests     = new TestRecords();

            foreach (TestInfo testInfo in testInfos)
            {
                TestRecord testRecord = new TestRecord();
                testRecord.TestInfo = testInfo;
                tests.TestCollection.Add(testRecord);
            }
            Profiler.EndMethod();
            return(tests);
        }
Exemplo n.º 11
0
        public CharacterShadowCasterPass(RenderPassEvent evt, uint renderingLayerMask)
        {
            renderPassEvent = evt;

            m_ShaderTagIdList.Add(new ShaderTagId("ShadowCaster"));

            renderPassEvent     = evt;
            m_FilteringSettings = new FilteringSettings(RenderQueueRange.all, -1, renderingLayerMask);
            m_RenderStateBlock  = new RenderStateBlock(RenderStateMask.Nothing);

            CharacterShadowConstantBuffer._CharacterShadowMatrix      = Shader.PropertyToID("_CharacterShadowMatrix");
            CharacterShadowConstantBuffer._CharacterShadowmapSize     = Shader.PropertyToID("_CharacterShadowmapSize");
            CharacterShadowConstantBuffer._CharacterShadowFilterWidth = Shader.PropertyToID("_CharacterShadowFilterWidth");

            m_CharacterShadowmap.Init("_CharacterShadowMap");
        }
        // Here you can implement the rendering logic.
        // Use <c>ScriptableRenderContext</c> to issue drawing commands or execute command buffers
        // https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html
        // You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline.
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get();

            cmd.Blit(BuiltinRenderTextureType.CameraTarget, tempRTID);
            cmd.SetGlobalTexture(targetTextureID, tempRTID);
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);

            if (isRenderingObject)
            {
                DrawingSettings   drawingSettings   = CreateDrawingSettings(shaderTagID, ref renderingData, SortingCriteria.CommonTransparent);
                FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.transparent);
                context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
            }
        }
Exemplo n.º 13
0
        public SelectionOutlineRenderPass(string profilerTag,
                                          RenderPassEvent renderPassEvent, int layerMask, Material materialToBlit)
        {
            this.profilerTag     = profilerTag;
            this.renderPassEvent = renderPassEvent;
            this.materialToBlit  = materialToBlit;

            m_FilteringSettingsOpaque      = new FilteringSettings(RenderQueueRange.opaque, layerMask);
            m_FilteringSettingsTransparent = new FilteringSettings(RenderQueueRange.transparent, layerMask);
            m_RenderStateBlock             = new RenderStateBlock(RenderStateMask.Nothing);
            m_ShaderTagIdList.Add(new ShaderTagId("UniversalForward"));
            m_ShaderTagIdList.Add(new ShaderTagId("SRPDefaultUnlit"));

            m_blurTexture.Init("_MaskTexture");
            m_blurTexture.Init("_BlurTexture");
        }
Exemplo n.º 14
0
 public RenderPass(Material material) : base()
 {
     this.material = material;
     // This contains a list of shader tags. The renderer will only render objects with
     // materials containing a shader with at least one tag in this list
     this.shaderTags = new List <ShaderTagId>()
     {
         new ShaderTagId("DepthOnly"),
         //new ShaderTagId("SRPDefaultUnlit"),
         //new ShaderTagId("UniversalForward"),
         //new ShaderTagId("LightweightForward"),
     };
     // Render opaque materials
     this.filteringSettings = new FilteringSettings(RenderQueueRange.all);
     destinationHandle.Init("_DepthNormalsTexture");
 }
Exemplo n.º 15
0
 internal void DrawWithDebugRenderState(
     ScriptableRenderContext context,
     CommandBuffer cmd,
     ref RenderingData renderingData,
     ref DrawingSettings drawingSettings,
     ref FilteringSettings filteringSettings,
     ref RenderStateBlock renderStateBlock,
     DrawFunction func)
 {
     foreach (DebugRenderSetup debugRenderSetup in CreateDebugRenderSetupEnumerable(context, cmd))
     {
         DrawingSettings  debugDrawingSettings  = debugRenderSetup.CreateDrawingSettings(drawingSettings);
         RenderStateBlock debugRenderStateBlock = debugRenderSetup.GetRenderStateBlock(renderStateBlock);
         func(context, ref renderingData, ref debugDrawingSettings, ref filteringSettings, ref debugRenderStateBlock);
     }
 }
Exemplo n.º 16
0
        public DistortionMarkRenderPass()
        {
            profilingSampler = new ProfilingSampler(Tag);

            distortionMarkShaderTagIdList = new List <ShaderTagId>();
            distortionMarkShaderTagIdList.Add(new ShaderTagId("DistortionMarker"));

            distortionTexShaderPropertyId = Shader.PropertyToID("_DistortionTex");

            renderPassEvent = RenderPassEvent.BeforeRenderingTransparents;
            distorionMarkFilteringSettings = new FilteringSettings(
                RenderQueueRange.transparent,
                1 << LayerMask.NameToLayer("Marker"));
            //1 << DistortionMarkRenderPassFeature.DistortionMarkRenderingMaskLayer);
            distortionMarkRenderTextureHandle.Init(Tag);
        }
Exemplo n.º 17
0
    private void DrawVisibleGeometry()
    {
        SortingSettings sortingSettings = new SortingSettings(camera)
        {
            criteria = SortingCriteria.CommonOpaque
        };
        DrawingSettings   drawingSettrings  = new DrawingSettings(unlitShaderTagId, sortingSettings);
        FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.opaque);

        context.DrawRenderers(cullingResults, ref drawingSettrings, ref filteringSettings);
        context.DrawSkybox(camera);

        sortingSettings.criteria           = SortingCriteria.CommonTransparent;
        drawingSettrings.sortingSettings   = sortingSettings;
        filteringSettings.renderQueueRange = RenderQueueRange.transparent;
        context.DrawRenderers(cullingResults, ref drawingSettrings, ref filteringSettings);
    }
Exemplo n.º 18
0
    protected override void Render(ScriptableRenderContext context, Camera[] cameras)
    {
        //base.Render(context, cameras);

        foreach (var camera in cameras)
        {
            // Culling
            ScriptableCullingParameters cullingParams;
            if (!camera.TryGetCullingParameters(out cullingParams))
            {
                continue;
            }

            CullingResults cull = context.Cull(ref cullingParams);

            // Setup camera for rendering (sets render target, view/projection matrices and other
            // per-camera built-in shader variables).
            context.SetupCameraProperties(camera);

            // clear depth buffer
            var cmd = new CommandBuffer();
            cmd.ClearRenderTarget(true, false, Color.black);
            context.ExecuteCommandBuffer(cmd);
            cmd.Release();

            // Draw opaque objects using BasicPass shader pass
            SortingSettings sort = new SortingSettings(camera);
            sort.criteria = SortingCriteria.CommonOpaque;
            var settings = new DrawingSettings(new ShaderTagId("BasicPass"), sort);


            var filterSettings = new FilteringSettings(RenderQueueRange.opaque);
            context.DrawRenderers(cull, ref settings, ref filterSettings);

            // Draw skybox
            context.DrawSkybox(camera);

            // Draw transparent objects using BasicPass shader pass
            sort.criteria                   = SortingCriteria.CommonTransparent;
            settings.sortingSettings        = sort;
            filterSettings.renderQueueRange = RenderQueueRange.transparent;
            context.DrawRenderers(cull, ref settings, ref filterSettings);

            context.Submit();
        }
    }
Exemplo n.º 19
0
        /// <summary>
        /// 不支持的shader pass 使用errorMaterial 渲染
        /// </summary>
        void DrawUnsupportedShaders()
        {
            var sortingSettings = new SortingSettings(this.camera);
            var drawingSettings = new DrawingSettings(m_unsupported[0], sortingSettings);

            //替换material,好奇camera的replacement是不是同样机制
            drawingSettings.overrideMaterial = errorMaterial;

            for (int i = 1; i < m_unsupported.Length; ++i)
            {
                drawingSettings.SetShaderPassName(i, m_unsupported[i]);
            }

            var filteringSettings = new FilteringSettings(RenderQueueRange.all);

            context.DrawRenderers(this.cullingresult, ref drawingSettings, ref filteringSettings);
        }
Exemplo n.º 20
0
        public DrawOutlinePass(string profilerTag, bool opaque, RenderPassEvent evt, RenderQueueRange renderQueueRange, LayerMask layerMask, StencilState stencilState, int stencilReference)
        {
            m_ProfilerTag      = profilerTag;
            m_ProfilingSampler = new ProfilingSampler(profilerTag);
            m_ShaderTagIdList.Add(new ShaderTagId("Outline"));
            renderPassEvent     = evt;
            m_FilteringSettings = new FilteringSettings(renderQueueRange, layerMask);
            m_RenderStateBlock  = new RenderStateBlock(RenderStateMask.Nothing);
            m_IsOpaque          = opaque;

            if (stencilState.enabled)
            {
                m_RenderStateBlock.stencilReference = stencilReference;
                m_RenderStateBlock.mask             = RenderStateMask.Stencil;
                m_RenderStateBlock.stencilState     = stencilState;
            }
        }
Exemplo n.º 21
0
        void RenderLight(ScriptableRenderContext context, ref RenderingData renderingData, int lightIndex, ShaderTagId shaderTagId)
        {
            SetupLight(context, renderingData, lightIndex);

            FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.opaque);
            SortingSettings   sortingSettings   = new SortingSettings(renderingData.camera);

            sortingSettings.criteria = SortingCriteria.CommonOpaque;
            DrawingSettings drawingSettings = new DrawingSettings(shaderTagId, sortingSettings)
            {
                mainLightIndex        = GetMainLightIndex(ref renderingData),
                enableDynamicBatching = true,
            };
            RenderStateBlock stateBlock = new RenderStateBlock(RenderStateMask.Nothing);

            context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings, ref stateBlock);
        }
Exemplo n.º 22
0
        private static void RenderScene(ref PipelineCommandData data, Camera cam)
        {
            data.ExecuteCommandBuffer();
            FilteringSettings renderSettings = new FilteringSettings();

            renderSettings.renderQueueRange   = RenderQueueRange.opaque;
            renderSettings.layerMask          = cam.cullingMask;
            renderSettings.renderingLayerMask = (uint)cam.cullingMask;
            DrawingSettings dsettings = new DrawingSettings(new ShaderTagId("GBuffer"), new SortingSettings(cam))
            {
                enableDynamicBatching = true,
                enableInstancing      = false,
                perObjectData         = UnityEngine.Rendering.PerObjectData.MotionVectors
            };

            data.context.DrawRenderers(data.cullResults, ref dsettings, ref renderSettings);
        }
Exemplo n.º 23
0
    void DrawUnsupportedShaders(ref ScriptableRenderContext context, Camera camera, ref CullingResults cullingResults)
    {
        Material        errorMaterial   = new Material(Shader.Find("Hidden/InternalErrorShader"));
        DrawingSettings drawingSettings = new DrawingSettings()
        {
            sortingSettings  = new SortingSettings(camera),
            overrideMaterial = errorMaterial
        };

        for (int i = 0; i < legacyShaderTagIds.Length; i++)
        {
            drawingSettings.SetShaderPassName(i, legacyShaderTagIds[i]);
        }
        FilteringSettings filteringSettings = FilteringSettings.defaultValue;

        context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings);
    }
Exemplo n.º 24
0
        protected void GetDefaultDrawSettings(Camera camera, Material material, out DrawingSettings drawingSettings, out FilteringSettings filteringSettings)
        {
            drawingSettings = new DrawingSettings(m_shaderTagIdList[0], new SortingSettings(camera));
            for (int i = 1; i < m_shaderTagIdList.Length; ++i)
            {
                drawingSettings.SetShaderPassName(i, m_shaderTagIdList[i]);
            }
            drawingSettings.overrideMaterial          = material;
            drawingSettings.overrideMaterialPassIndex = 0;
            drawingSettings.enableDynamicBatching     = true;               // default value is true. please change it before draw call if needed.
            drawingSettings.enableInstancing          = material.enableInstancing;
            drawingSettings.perObjectData             = PerObjectData.None; // default value is None. please change it before draw call if needed.

            // default render queue range is opaque. please change it before draw call if needed.
            filteringSettings = new FilteringSettings(new RenderQueueRange(renderQueueLowerBound, renderQueueUpperBound), ~projector.ignoreLayers);
            filteringSettings.renderingLayerMask = (uint)renderingLayerMask;
        }
Exemplo n.º 25
0
    void Render(ScriptableRenderContext context, Camera camera)
    {
        ScriptableCullingParameters cullingParameters;

        if (!camera.TryGetCullingParameters(out cullingParameters))
        {
            return;
        }

        BeginCameraRendering(context, camera);
#if UNITY_EDITOR
        if (camera.cameraType == CameraType.SceneView)
        {
            ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
        }
#endif
        context.SetupCameraProperties(camera);
        commandBuffer.BeginSample("Render Camera commandBuffer");
        CameraClearFlags clearFlags = camera.clearFlags;
        commandBuffer.ClearRenderTarget((clearFlags & CameraClearFlags.Depth) != 0,
                                        (clearFlags & CameraClearFlags.Color) != 0, camera.backgroundColor);
        context.ExecuteCommandBuffer(commandBuffer);
        commandBuffer.Clear();

        cullingResults = context.Cull(ref cullingParameters);
        SortingSettings sortingSettings = new SortingSettings(camera);
        sortingSettings.criteria = SortingCriteria.CommonOpaque;
        DrawingSettings   drawingSettings   = new DrawingSettings(new ShaderTagId("SRPDefaultUnlit"), sortingSettings);
        FilteringSettings filteringSettings = FilteringSettings.defaultValue;
        filteringSettings.renderQueueRange = RenderQueueRange.opaque;
        context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings);
        context.DrawSkybox(camera);

        sortingSettings.criteria           = SortingCriteria.CommonTransparent;
        filteringSettings.renderQueueRange = RenderQueueRange.transparent;
        context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings);

        DrawDefaultPipeline(context, camera);

        commandBuffer.EndSample("Render Camera commandBuffer");
        context.ExecuteCommandBuffer(commandBuffer);
        commandBuffer.Clear();

        EndCameraRendering(context, camera);
    }
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            var instance = GrassCullingRenderer.instance;

            if (!instance)
            {
                //Debug.LogError("GrassCullingRenderer not found , abort GrassCullingRenderPass's Execute!");
                return;
            }

            CommandBuffer cmd = CommandBufferPool.Get("GrassBendingRT");

            var instanceTransform = instance.transform;

            //size z -1   unity 坐标左右手互换
            Matrix4x4 viewMatrix = Matrix4x4
                                   .TRS(instanceTransform.position + new Vector3(0, 1, 0),
                                        Quaternion.LookRotation(Vector3.down), new Vector3(1, 1, -1)).inverse;

            //ortho camera with 1:1 aspect, size = 50
            float     sizeX            = instanceTransform.localScale.x;
            float     sizeZ            = instanceTransform.localScale.z;
            Matrix4x4 projectionMatrix = Matrix4x4.Ortho(-sizeX, sizeX, -sizeZ, sizeZ, 0.01f, 1.5f);

            //set view projection
            cmd.SetViewProjectionMatrices(viewMatrix, projectionMatrix);
            context.ExecuteCommandBuffer(cmd);

            var drawSetting =
                CreateDrawingSettings(grassBending_stid, ref renderingData, SortingCriteria.CommonTransparent);
            var filterSetting = new FilteringSettings(RenderQueueRange.all);

            context.DrawRenderers(renderingData.cullResults, ref drawSetting, ref filterSetting);
            context.ExecuteCommandBuffer(cmd);

            //复原view projection
            cmd.Clear();
            cmd.SetViewProjectionMatrices(renderingData.cameraData.camera.worldToCameraMatrix,
                                          renderingData.cameraData.camera.projectionMatrix);

            cmd.SetGlobalTexture(_grassBendingRT_pid, _grassBendingRT_rti);

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
    public CustomUberPostPass(RenderPassEvent evt, RenderQueueRange renderQueueRange, LayerMask layerMask, Material blitMaterial, CustomUberPostFeature.CustomUberPostSettings settings)
    {
        this.renderPassEvent = evt;
        this.blitMaterial    = blitMaterial;
        m_FilteringSettings  = new FilteringSettings(renderQueueRange, layerMask);
        RefreshSettings(settings);

        /******** DualKawase ********/
        m_Pyramid = new BlurSampleLevel[k_MaxPyramidSize];
        for (int i = 0; i < k_MaxPyramidSize; i++)
        {
            m_Pyramid[i] = new BlurSampleLevel()
            {
                down = Shader.PropertyToID("_BlurMipDown" + i),
                up   = Shader.PropertyToID("_BlurMipUp" + i)
            };
        }
    }
Exemplo n.º 28
0
            public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
            {
                // Grab screen texture.
                var cmd = CommandBufferPool.Get(commandBufferName);

                cmd.GetTemporaryRT(tempRTPropertyId, renderingData.cameraData.cameraTargetDescriptor);
                cmd.Blit(BuiltinRenderTextureType.CameraTarget, tempRTPropertyId);
                cmd.SetGlobalTexture(grabTexturePropertyId, tempRTPropertyId);
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();
                CommandBufferPool.Release(cmd);

                // Draw objects using blend mode effect material.
                var drawingSettings   = CreateDrawingSettings(shaderTag, ref renderingData, SortingCriteria.CommonTransparent);
                var filteringSettings = new FilteringSettings(RenderQueueRange.transparent);

                context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
            }
Exemplo n.º 29
0
        private void Draw()
        {
            var sortingSettings = new SortingSettings(_camera)
            {
                criteria = SortingCriteria.CommonOpaque,
            };
            var drawingSetting = new DrawingSettings(
                _unlitShaderTagId, sortingSettings
                );
            var filteringSetting = new FilteringSettings(RenderQueueRange.opaque);

            _context.DrawRenderers(_cullingResults, ref drawingSetting, ref filteringSetting);
            _context.DrawSkybox(_camera);
            sortingSettings.criteria          = SortingCriteria.CommonTransparent;
            drawingSetting.sortingSettings    = sortingSettings;
            filteringSetting.renderQueueRange = RenderQueueRange.transparent;
            _context.DrawRenderers(_cullingResults, ref drawingSetting, ref filteringSetting);
        }
Exemplo n.º 30
0
        void RenderDefaultTransparent(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            var camera = renderingData.camera;
            FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.transparent);
            SortingSettings   sortingSettings   = new SortingSettings(camera);

            sortingSettings.criteria = SortingCriteria.CommonTransparent;
            DrawingSettings drawingSettings = new DrawingSettings(new ShaderTagId("TransparentBack"), sortingSettings)
            {
                enableDynamicBatching = true,
                perObjectData         = PerObjectData.ReflectionProbes,
            };

            drawingSettings.SetShaderPassName(1, new ShaderTagId("TransparentFront"));
            RenderStateBlock stateBlock = new RenderStateBlock(RenderStateMask.Nothing);

            context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings, ref stateBlock);
        }