Beispiel #1
0
 public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
 {
     CommandBuffer buffer   = data.buffer;
     LastVPData    lastData = IPerCameraData.GetProperty <LastVPData>(cam, getLastVP);
     //Calculate Last VP for motion vector and Temporal AA
     Matrix4x4     nonJitterVP = GL.GetGPUProjectionMatrix(cam.cam.nonJitteredProjectionMatrix, false) * cam.cam.worldToCameraMatrix;
     ref Matrix4x4 lastVp      = ref lastData.lastVP;
        public void Render(ref PipelineCommandData data, PipelineCamera cam, PropertySetEvent proper)
        {
            SSRCameraData cameraData = IPerCameraData.GetProperty(cam, getDataFunc);

            SSR_UpdateVariable(cameraData, cam.cam, ref data, proper);
            RenderScreenSpaceReflection(data.buffer, cameraData, cam);
        }
Beispiel #3
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer buffer = data.buffer;

            buffer.SetRenderTarget(cam.targets.gbufferIdentifier, cam.targets.depthIdentifier);
            buffer.ClearRenderTarget(true, true, Color.black);
            HizOcclusionData     hizData = IPerCameraData.GetProperty(cam, () => new HizOcclusionData());
            RenderClusterOptions options = new RenderClusterOptions
            {
                command        = buffer,
                frustumPlanes  = data.frustumPlanes,
                cullingShader  = data.resources.shaders.gpuFrustumCulling,
                terrainCompute = data.resources.shaders.terrainCompute
            };

            if (enableOcclusionCulling)
            {
                HizOptions hizOptions;
                hizOptions = new HizOptions
                {
                    currentCameraUpVec = cam.cam.transform.up,
                    hizData            = hizData,
                    hizDepth           = hizDepth,
                    linearLODMaterial  = linearMat,
                    currentDepthTex    = cam.targets.depthIdentifier
                };
                SceneController.DrawClusterOccDoubleCheck(ref options, ref hizOptions, ref cam.targets, ref data, cam.cam);
            }
            else
            {
                SceneController.DrawCluster(ref options, ref cam.targets, ref data, cam.cam);
            }
        }
Beispiel #4
0
        private void RenderScreenSpaceReflection(CommandBuffer SSGi_Buffer, PipelineCamera cam, ref RenderTargets targets)
        {
            Camera   RenderCamera = cam.cam;
            SSGIData data         = IPerCameraData.GetProperty(cam, (cc) => new SSGIData(int2(cc.cam.pixelWidth, cc.cam.pixelHeight)));

            data.UpdateResolution(int2(cam.cam.pixelWidth, cam.cam.pixelHeight));
            //////Set HierarchicalDepthRT//////
            SSGi_Buffer.CopyTexture(ShaderIDs._CameraDepthTexture, 0, 0, data.SSGi_HierarchicalDepth_RT, 0, 0);
            for (int i = 1; i < HiZ_MaxLevel; ++i)
            {
                SSGi_Buffer.SetGlobalInt(SSGi_HiZ_PrevDepthLevel_ID, i - 1);
                SSGi_Buffer.SetRenderTarget(data.SSGi_HierarchicalDepth_BackUp_RT, i);
                SSGi_Buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, SSGi_Material, 0, RenderPass_HiZ_Depth);
                SSGi_Buffer.CopyTexture(data.SSGi_HierarchicalDepth_BackUp_RT, 0, i, data.SSGi_HierarchicalDepth_RT, 0, i);
            }
            SSGi_Buffer.SetGlobalTexture(SSGi_HierarchicalDepth_ID, data.SSGi_HierarchicalDepth_RT);

            SSGi_Buffer.GetTemporaryRT(SSGi_SceneColor_ID, RenderCamera.pixelWidth, RenderCamera.pixelHeight, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf);
            SSGi_Buffer.CopyTexture(targets.renderTargetIdentifier, 0, 0, SSGi_SceneColor_ID, 0, 0);


            //////RayCasting//////
            SSGi_Buffer.GetTemporaryRT(SSGi_Trace_ID, RenderCamera.pixelWidth, RenderCamera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf);
            SSGi_Buffer.BlitSRT(SSGi_Trace_ID, SSGi_Material, RenderPass_HiZ3D_MultiSpp);
            SSGi_Buffer.Blit(SSGi_Trace_ID, targets.renderTargetIdentifier);
        }
Beispiel #5
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            AOHistoryData historyData = IPerCameraData.GetProperty(cam, (c) => new AOHistoryData(c.cam.pixelWidth, c.cam.pixelHeight), this);

            UpdateVariable_SSAO(historyData, cam, ref data);
            RenderSSAO(historyData, cam, ref data);
        }
 public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
 {
     if (!cam.cam.TryGetCullingParameters(out cullParams))
     {
         return;
     }
     data.buffer.SetInvertCulling(cam.inverseRender);
     cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize;
     cullParams.cullingOptions = CullingOptions.NeedsLighting | CullingOptions.NeedsReflectionProbes;
     if (cam.cam.useOcclusionCulling)
     {
         cullParams.cullingOptions |= CullingOptions.OcclusionCull;
     }
     cullResults = data.context.Cull(ref cullParams);
     for (int i = 0; i < frustumPlanes.Length; ++i)
     {
         Plane p = cullParams.GetCullingPlane(i);
         //GPU Driven RP's frustum plane is inverse from SRP's frustum plane
         frustumPlanes[i] = new Vector4(-p.normal.x, -p.normal.y, -p.normal.z, -p.distance);
     }
     PipelineFunctions.InitRenderTarget(ref cam.targets, cam.cam, data.buffer);
     lastData     = IPerCameraData.GetProperty(cam, getLastVP);
     calculateJob = new CalculateMatrixJob
     {
         isD3D       = GraphicsUtility.platformIsD3D,
         nonJitterP  = cam.cam.nonJitteredProjectionMatrix,
         worldToView = cam.cam.worldToCameraMatrix,
         lastVP      = lastData.lastVP,
         rand        = (Random *)UnsafeUtility.AddressOf(ref rand),
         p           = cam.cam.projectionMatrix,
         VP          = (float4x4 *)UnsafeUtility.AddressOf(ref VP),
         inverseVP   = (float4x4 *)UnsafeUtility.AddressOf(ref inverseVP)
     };
     handle = calculateJob.ScheduleRefBurst();
 }
Beispiel #7
0
        public void Render(ref PipelineCommandData data, PipelineCamera cam, ReflectionEvent parentEvent)
        {
            RandomSampler = GenerateRandomOffset();
            SSRCameraData cameraData = IPerCameraData.GetProperty(cam, getDataFunc, parentEvent);

            SSR_UpdateVariable(cameraData, cam.cam, ref data);
            RenderScreenSpaceReflection(data.buffer, cameraData, cam);
        }
 public void PreRender(PipelineCamera cam)
 {
     PreviousDepthData.GetPreviousDepthData getDepthData = new PreviousDepthData.GetPreviousDepthData
     {
         currentSize = new Vector2Int(cam.cam.pixelWidth, cam.cam.pixelHeight)
     };
     prevDepthData = IPerCameraData.GetProperty <PreviousDepthData, PreviousDepthData.GetPreviousDepthData>(cam, getDepthData);
     prevDepthData.targetObject = this;
 }
Beispiel #9
0
 public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
 {
     texComponent  = IPerCameraData.GetProperty(cam, (c) => new HistoryTexture(c.cam));
     prevDepthData = IPerCameraData.GetProperty(cam, (cc) => new PreviousDepthData(new Vector2Int(cc.cam.pixelWidth, cc.cam.pixelHeight)));
     prevDepthData.targetObject = this;
     data.buffer.SetGlobalVector(ShaderIDs._LastJitter, texComponent.jitter);
     cam.cam.ResetProjectionMatrix();
     ConfigureJitteredProjectionMatrix(cam.cam, ref texComponent.jitter);
     data.buffer.SetGlobalVector(ShaderIDs._Jitter, texComponent.jitter);
 }
Beispiel #10
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            //   Material proceduralMaterial = data.baseBuffer.combinedMaterial;
            CommandBuffer buffer = data.buffer;

            buffer.SetRenderTarget(cam.targets.gbufferIdentifier, cam.targets.depthIdentifier);
            buffer.ClearRenderTarget(true, true, Color.black);
            PipelineBaseBuffer baseBuffer;

            if (!SceneController.current.GetBaseBufferAndCheck(out baseBuffer))
            {
                return;
            }
            HizOcclusionData     hizData = IPerCameraData.GetProperty <HizOcclusionData>(cam, getOcclusionData);
            RenderClusterOptions options = new RenderClusterOptions
            {
                command            = buffer,
                frustumPlanes      = data.arrayCollection.frustumPlanes,
                proceduralMaterial = proceduralMaterial,
                isOrtho            = cam.cam.orthographic,
                cullingShader      = data.resources.gpuFrustumCulling
            };
            HizOptions hizOptions;

            switch (occCullingMod)
            {
            case OcclusionCullingMode.None:
                SceneController.current.DrawCluster(ref options);
                break;

            case OcclusionCullingMode.SingleCheck:
                hizOptions = new HizOptions
                {
                    currentCameraUpVec = cam.cam.transform.up,
                    hizData            = hizData,
                    hizDepth           = hizDepth,
                    linearLODMaterial  = linearMat
                };
                SceneController.current.DrawClusterOccSingleCheck(ref options, ref hizOptions);
                break;

            case OcclusionCullingMode.DoubleCheck:
                hizOptions = new HizOptions
                {
                    currentCameraUpVec = cam.cam.transform.up,
                    hizData            = hizData,
                    hizDepth           = hizDepth,
                    linearLODMaterial  = linearMat
                };
                SceneController.current.DrawClusterOccDoubleCheck(ref options, ref hizOptions, ref cam.targets);
                break;
            }
            data.ExecuteCommandBuffer();
        }
Beispiel #11
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer buffer = data.buffer;

            buffer.SetRenderTarget(cam.targets.gbufferIdentifier, cam.targets.depthIdentifier);
            buffer.ClearRenderTarget(true, true, Color.black);
            PipelineBaseBuffer baseBuffer;
            bool                 isClusterEnabled = SceneController.GetBaseBuffer(out baseBuffer);
            HizOcclusionData     hizData          = IPerCameraData.GetProperty <HizOcclusionData>(cam, () => new HizOcclusionData());
            RenderClusterOptions options          = new RenderClusterOptions
            {
                command          = buffer,
                frustumPlanes    = data.arrayCollection.frustumPlanes,
                isOrtho          = cam.cam.orthographic,
                cullingShader    = data.resources.gpuFrustumCulling,
                terrainCompute   = data.resources.terrainCompute,
                isClusterEnabled = isClusterEnabled,
                isTerrainEnabled = true
            };
            HizOptions hizOptions;

            switch (occCullingMod)
            {
            case OcclusionCullingMode.None:
                SceneController.current.DrawCluster(ref options, ref cam.targets);
                break;

            case OcclusionCullingMode.SingleCheck:
                hizOptions = new HizOptions
                {
                    currentCameraUpVec = cam.cam.transform.up,
                    hizData            = hizData,
                    hizDepth           = hizDepth,
                    linearLODMaterial  = linearMat,
                    currentDepthTex    = cam.targets.depthTexture
                };
                SceneController.current.DrawClusterOccSingleCheck(ref options, ref hizOptions, ref cam.targets);
                break;

            case OcclusionCullingMode.DoubleCheck:
                hizOptions = new HizOptions
                {
                    currentCameraUpVec = cam.cam.transform.up,
                    hizData            = hizData,
                    hizDepth           = hizDepth,
                    linearLODMaterial  = linearMat,
                    currentDepthTex    = cam.targets.depthTexture
                };
                SceneController.current.DrawClusterOccDoubleCheck(ref options, ref hizOptions, ref cam.targets);
                break;
            }
            data.ExecuteCommandBuffer();
        }
Beispiel #12
0
        public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
        {
            if (!cam.cam.TryGetCullingParameters(out cullParams))
            {
                return;
            }
            data.buffer.SetInvertCulling(cam.inverseRender);
            cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize;
            cullParams.cullingOptions = CullingOptions.NeedsLighting | CullingOptions.NeedsReflectionProbes;
            if (cam.cam.useOcclusionCulling)
            {
                cullParams.cullingOptions |= CullingOptions.OcclusionCull;
            }
            cullResults = data.context.Cull(ref cullParams);
            for (int i = 0; i < frustumPlanes.Length; ++i)
            {
                Plane p = cullParams.GetCullingPlane(i);
                //GPU Driven RP's frustum plane is inverse from SRP's frustum plane
                frustumPlanes[i] = new Vector4(-p.normal.x, -p.normal.y, -p.normal.z, -p.distance);
            }
            PipelineFunctions.InitRenderTarget(ref cam.targets, cam.cam, data.buffer);
            lastData                 = IPerCameraData.GetProperty(cam, getLastVP);
            calculateJob.isD3D       = GraphicsUtility.platformIsD3D;
            calculateJob.nonJitterP  = cam.cam.nonJitteredProjectionMatrix;
            calculateJob.worldToView = cam.cam.worldToCameraMatrix;
            calculateJob.lastVP      = lastData.lastVP;
            calculateJob.rand        = (Random *)UnsafeUtility.AddressOf(ref rand);
            calculateJob.p           = cam.cam.projectionMatrix;
            calculateJob.VP          = (float4x4 *)UnsafeUtility.AddressOf(ref VP);
            calculateJob.inverseVP   = (float4x4 *)UnsafeUtility.AddressOf(ref inverseVP);
            Transform camTrans = cam.cam.transform;

            perspCam.forward       = camTrans.forward;
            perspCam.up            = camTrans.up;
            perspCam.right         = camTrans.right;
            perspCam.position      = camTrans.position;
            perspCam.nearClipPlane = cam.cam.nearClipPlane;
            perspCam.farClipPlane  = cam.cam.farClipPlane;
            perspCam.aspect        = cam.cam.aspect;
            perspCam.fov           = cam.cam.fieldOfView;
            float3 *corners = stackalloc float3[8];

            PipelineFunctions.GetFrustumCorner(ref perspCam, corners);
            frustumMinPoint = corners[0];
            frustumMaxPoint = corners[0];
            for (int i = 1; i < 8; ++i)
            {
                frustumMinPoint = min(frustumMinPoint, corners[i]);
                frustumMaxPoint = max(frustumMaxPoint, corners[i]);
            }
            handle = calculateJob.ScheduleRefBurst();
        }
Beispiel #13
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            int2         res       = int2(cam.cam.pixelWidth, cam.cam.pixelHeight);
            int2         originRes = int2(cam.cam.pixelWidth, cam.cam.pixelHeight);
            GetDataEvent evt       = new GetDataEvent
            {
                res = res
            };
            AOHistoryData historyData = IPerCameraData.GetProperty <AOHistoryData, GetDataEvent>(cam, evt);

            UpdateVariable_SSAO(historyData, cam, ref data, res, originRes);
            RenderSSAO(historyData, cam, ref data, res, originRes);
        }
        public int Render(ref PipelineCommandData data, PipelineCamera cam, PropertySetEvent proper)
        {
            SSRCameraData.GetSSRCameraData getCam = new SSRCameraData.GetSSRCameraData
            {
                currentSize = new Vector2Int(cam.cam.pixelWidth, cam.cam.pixelHeight),
                resolution  = 2
            };
            SSRCameraData cameraData = IPerCameraData.GetProperty <SSRCameraData, SSRCameraData.GetSSRCameraData>(cam, getCam);

            SSR_UpdateVariable(cameraData, cam.cam, ref data, proper);
            RenderScreenSpaceReflection(data.buffer, cameraData, cam);
            return(SSR_TemporalCurr_ID);
        }
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            //   Material proceduralMaterial = data.baseBuffer.combinedMaterial;
            CommandBuffer buffer = data.buffer;

            buffer.SetRenderTarget(cam.targets.gbufferIdentifier, cam.targets.depthIdentifier);
            buffer.ClearRenderTarget(true, true, Color.black);
            if (data.baseBuffer.clusterCount <= 0)
            {
                return;
            }
            HizOcclusionData hizData    = IPerCameraData.GetProperty <HizOcclusionData>(cam, getOcclusionData);
            ref var          baseBuffer = ref data.baseBuffer;
        public override void FrameUpdate(PipelineCamera camera, ref PipelineCommandData data)
        {
            CommandBuffer buffer = data.buffer;

            handle.Complete();
            SkyboxPreviewMatrix last = IPerCameraData.GetProperty(camera, () => new SkyboxPreviewMatrix());

            buffer.SetGlobalMatrix(_LastSkyVP, last.lastViewProj);
            targetIdentifiers[0] = camera.targets.renderTargetIdentifier;
            targetIdentifiers[1] = ShaderIDs._CameraMotionVectorsTexture;
            buffer.SetRenderTarget(colors: targetIdentifiers, depth: ShaderIDs._DepthBufferTexture);
            data.ExecuteCommandBuffer();
            data.context.DrawSkybox(camera.cam);
            last.lastViewProj = job.viewProj;
        }
Beispiel #17
0
        public override void FrameUpdate(PipelineCamera camera, ref PipelineCommandData data)
        {
            CommandBuffer buffer = data.buffer;

            handle.Complete();
            SkyboxPreviewMatrix last = IPerCameraData.GetProperty(camera, () => new SkyboxPreviewMatrix());

            buffer.SetGlobalMatrix(_InvSkyVP, job.invViewProj);
            buffer.SetGlobalMatrix(_LastSkyVP, last.lastViewProj);
            targetIdentifiers[0] = camera.targets.renderTargetIdentifier;
            targetIdentifiers[1] = ShaderIDs._CameraMotionVectorsTexture;
            buffer.SetRenderTarget(colors: targetIdentifiers, depth: ShaderIDs._DepthBufferTexture);
            buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, skyboxMaterial, 0, 0);
            last.lastViewProj = job.viewProj;
        }
 public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
 {
     HistoryTexture.GetHistoryTexture getHis = new HistoryTexture.GetHistoryTexture
     {
         cam = cam.cam
     };
     texComponent = IPerCameraData.GetProperty <HistoryTexture, HistoryTexture.GetHistoryTexture>(cam, getHis);
     PreviousDepthData.GetPreviousDepthData getDepthData = new PreviousDepthData.GetPreviousDepthData
     {
         currentSize = new Vector2Int(cam.cam.pixelWidth, cam.cam.pixelHeight)
     };
     prevDepthData = IPerCameraData.GetProperty <PreviousDepthData, PreviousDepthData.GetPreviousDepthData>(cam, getDepthData);
     prevDepthData.targetObject = this;
     data.buffer.SetGlobalVector(ShaderIDs._LastJitter, texComponent.jitter);
     cam.cam.ResetProjectionMatrix();
     ConfigureJitteredProjectionMatrix(cam.cam, ref texComponent.jitter);
     data.buffer.SetGlobalVector(ShaderIDs._Jitter, texComponent.jitter);
 }
Beispiel #19
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data, CommandBuffer buffer)
        {
            HistoryTexture texComponent = IPerCameraData.GetProperty <HistoryTexture>(cam, GetHistoryTex);

            texComponent.UpdateProperty(cam);
            SetHistory(cam.cam, buffer, ref texComponent.historyTex, cam.targets.renderTarget);
            historyTex = texComponent.historyTex;
            //TAA Start
            const float kMotionAmplification_Blending = 100f * 60f;
            const float kMotionAmplification_Bounding = 100f * 30f;

            block.SetVector(ShaderIDs._Jitter, jitter);
            block.SetFloat(ShaderIDs._Sharpness, sharpness);
            block.SetVector(ShaderIDs._TemporalClipBounding, new Vector4(stationaryAABBScale, motionAABBScale, kMotionAmplification_Bounding, 0f));
            block.SetVector(ShaderIDs._FinalBlendParameters, new Vector4(stationaryBlending, motionBlending, kMotionAmplification_Blending, 0f));
            block.SetTexture(ShaderIDs._HistoryTex, historyTex);
            PostFunctions.RunPostProcess(ref cam.targets, buffer, ref data, taaFunction);
        }
        public override void FrameUpdate(PipelineCamera camera, ref PipelineCommandData data)
        {
            SkyboxMatrixData skyData = IPerCameraData.GetProperty(camera, () => new SkyboxMatrixData(), this);
            float4x4         proj    = GL.GetGPUProjectionMatrix(camera.cam.nonJitteredProjectionMatrix, false);
            float4x4         viewProj;

            if (camera.cam.orthographic)
            {
                OrthoCam cam = new OrthoCam
                {
                    forward  = camera.cam.transform.forward,
                    up       = camera.cam.transform.up,
                    right    = camera.cam.transform.right,
                    position = 0
                };
                cam.UpdateTRSMatrix();
                viewProj = mul(proj, cam.worldToCameraMatrix);
            }
            else
            {
                PerspCam cam = new PerspCam
                {
                    forward  = camera.cam.transform.forward,
                    up       = camera.cam.transform.up,
                    right    = camera.cam.transform.right,
                    position = 0
                };
                cam.UpdateTRSMatrix();
                viewProj = mul(proj, cam.worldToCameraMatrix);
            }
            CommandBuffer buffer = data.buffer;

            buffer.SetGlobalMatrix(_InvSkyVP, inverse(viewProj));
            buffer.SetGlobalMatrix(_LastSkyVP, skyData.lastVP);
            targets[0] = camera.targets.renderTargetIdentifier;
            targets[1] = camera.targets.motionVectorTexture;
            buffer.SetRenderTarget(colors: targets, depth: camera.targets.depthBuffer);
            buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, skyboxMaterial, 0, 0);
            skyData.lastVP = viewProj;
        }
Beispiel #21
0
        public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
        {
            if (!cam.cam.TryGetCullingParameters(out cullParams))
            {
                return;
            }
            data.buffer.SetInvertCulling(cam.inverseRender);
            cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize;
            cullParams.cullingOptions = CullingOptions.NeedsLighting | CullingOptions.NeedsReflectionProbes;
            if (cam.cam.useOcclusionCulling)
            {
                cullParams.cullingOptions |= CullingOptions.OcclusionCull;
            }
            cullResults = data.context.Cull(ref cullParams);
            for (int i = 0; i < frustumPlanes.Length; ++i)
            {
                frustumPlanes[i] = cam.frustumArray[i];
            }
            PipelineFunctions.InitRenderTarget(ref cam.targets, cam.cam, data.buffer);
            var getter = new LastVPData.GetLastVPData
            {
                c = cam.cam
            };

            lastData                 = IPerCameraData.GetProperty <LastVPData, LastVPData.GetLastVPData>(cam, getter);
            calculateJob.isD3D       = GraphicsUtility.platformIsD3D;
            calculateJob.nonJitterP  = cam.cam.nonJitteredProjectionMatrix;
            calculateJob.worldToView = cam.cam.worldToCameraMatrix;
            //TODO
            //Set Camera
            calculateJob.lastCameraLocalToWorld = lastData.camlocalToWorld;
            calculateJob.lastP       = lastData.lastP;
            calculateJob.sceneOffset = RenderPipeline.sceneOffset;
            calculateJob.rand        = (Random *)UnsafeUtility.AddressOf(ref rand);
            calculateJob.p           = cam.cam.projectionMatrix;
            calculateJob.VP          = (float4x4 *)UnsafeUtility.AddressOf(ref VP);
            calculateJob.inverseVP   = (float4x4 *)UnsafeUtility.AddressOf(ref inverseVP);
            handle = calculateJob.ScheduleRefBurst();
        }
Beispiel #22
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer  buffer       = data.buffer;
            HistoryTexture texComponent = IPerCameraData.GetProperty <HistoryTexture>(cam, (c) => new HistoryTexture(c.cam));

            texComponent.UpdateProperty(cam);
            SetHistory(cam.cam, buffer, ref texComponent.historyTex, cam.targets.renderTargetIdentifier);
            historyTex = texComponent.historyTex;
            //TAA Start
            const float kMotionAmplification_Blending = 100f * 60f;
            const float kMotionAmplification_Bounding = 100f * 30f;

            buffer.SetGlobalFloat(ShaderIDs._Sharpness, sharpness);
            buffer.SetGlobalVector(ShaderIDs._TemporalClipBounding, new Vector4(stationaryAABBScale, motionAABBScale, kMotionAmplification_Bounding, 0f));
            buffer.SetGlobalVector(ShaderIDs._FinalBlendParameters, new Vector4(stationaryBlending, motionBlending, kMotionAmplification_Blending, 0f));
            buffer.SetGlobalTexture(ShaderIDs._HistoryTex, historyTex);
            int source, dest;

            PipelineFunctions.RunPostProcess(ref cam.targets, out source, out dest);
            buffer.BlitSRT(source, dest, taaMat, 0);
            buffer.CopyTexture(dest, historyTex);
        }
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer buffer  = data.buffer;
            ComputeShader scatter = data.resources.volumetricScattering;

            if (cbdr.lightFlag == 0)
            {
                cbdr.cubemapShadowArray = null;
                cbdr.dirLightShadowmap  = null;
                return;
            }
            int pass = 0;

            if (cbdr.cubemapShadowArray != null)
            {
                pass |= 0b001;
            }
            if (cbdr.dirLightShadowmap != null)
            {
                pass |= 0b010;
            }
            buffer.SetGlobalFloat(ShaderIDs._MaxDistance, availableDistance);
            buffer.SetGlobalInt(ShaderIDs._FrameCount, Time.frameCount);
            HistoryVolumetric historyVolume = IPerCameraData.GetProperty(cam, () => new HistoryVolumetric());
            //Volumetric Light
            RenderTextureDescriptor desc = new RenderTextureDescriptor
            {
                autoGenerateMips   = false,
                bindMS             = false,
                colorFormat        = RenderTextureFormat.ARGBHalf,
                depthBufferBits    = 0,
                dimension          = TextureDimension.Tex3D,
                enableRandomWrite  = true,
                height             = downSampledSize.y,
                width              = downSampledSize.x,
                memoryless         = RenderTextureMemoryless.None,
                msaaSamples        = 1,
                shadowSamplingMode = ShadowSamplingMode.None,
                sRGB        = false,
                useMipMap   = false,
                volumeDepth = downSampledSize.z,
                vrUsage     = VRTextureUsage.None
            };

            buffer.GetTemporaryRT(ShaderIDs._VolumeTex, desc, FilterMode.Bilinear);
            if (!historyVolume.lastVolume)
            {
                historyVolume.lastVolume            = new RenderTexture(desc);
                historyVolume.lastVolume.filterMode = FilterMode.Bilinear;
                historyVolume.lastVolume.wrapMode   = TextureWrapMode.Clamp;
                historyVolume.lastVolume.Create();
                buffer.SetGlobalFloat(ShaderIDs._TemporalWeight, 0);
            }
            else
            {
                if (historyVolume.lastVolume.volumeDepth != desc.volumeDepth)
                {
                    historyVolume.lastVolume.Release();
                    historyVolume.lastVolume.volumeDepth = desc.volumeDepth;
                    historyVolume.lastVolume.Create();
                    buffer.SetGlobalFloat(ShaderIDs._TemporalWeight, 0);
                }
                else
                {
                    buffer.SetGlobalFloat(ShaderIDs._TemporalWeight, 0.7f);
                }
            }
            buffer.SetGlobalVector(ShaderIDs._NearFarClip, new Vector4(cam.cam.farClipPlane / availableDistance, cam.cam.nearClipPlane / availableDistance, cam.cam.nearClipPlane));
            buffer.SetGlobalVector(ShaderIDs._Screen_TexelSize, new Vector4(1f / cam.cam.pixelWidth, 1f / cam.cam.pixelHeight, cam.cam.pixelWidth, cam.cam.pixelHeight));
            buffer.SetComputeBufferParam(scatter, pass, ShaderIDs._AllPointLight, cbdr.allPointLightBuffer);
            buffer.SetComputeTextureParam(scatter, pass, ShaderIDs._FroxelTileLightList, cbdr.froxelTileLightList);
            buffer.SetComputeBufferParam(scatter, pass, ShaderIDs._RandomBuffer, randomBuffer);
            buffer.SetComputeTextureParam(scatter, pass, ShaderIDs._VolumeTex, ShaderIDs._VolumeTex);
            buffer.SetComputeTextureParam(scatter, scatterPass, ShaderIDs._VolumeTex, ShaderIDs._VolumeTex);
            buffer.SetComputeTextureParam(scatter, pass, ShaderIDs._LastVolume, historyVolume.lastVolume);
            buffer.SetComputeTextureParam(scatter, pass, ShaderIDs._DirShadowMap, cbdr.dirLightShadowmap);
            buffer.SetComputeTextureParam(scatter, pass, ShaderIDs._CubeShadowMapArray, cbdr.cubemapShadowArray);
            buffer.SetGlobalVector(ShaderIDs._RandomSeed, (float4)(rand.NextDouble4() * 1000 + 100));

            cbdr.cubemapShadowArray = null;
            cbdr.dirLightShadowmap  = null;
            buffer.SetComputeIntParam(scatter, ShaderIDs._LightFlag, (int)cbdr.lightFlag);
            buffer.DispatchCompute(scatter, pass, downSampledSize.x / 8, downSampledSize.y / 2, downSampledSize.z / marchStep);
            buffer.CopyTexture(ShaderIDs._VolumeTex, historyVolume.lastVolume);
            buffer.DispatchCompute(scatter, scatterPass, downSampledSize.x / 32, downSampledSize.y / 2, 1);
            buffer.BlitSRT(cam.targets.renderTargetIdentifier, volumeMat, 0);
            buffer.ReleaseTemporaryRT(ShaderIDs._VolumeTex);
            cbdr.lightFlag = 0;
            PipelineFunctions.ExecuteCommandBuffer(ref data);
        }
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer        buffer  = data.buffer;
            RenderClusterOptions options = new RenderClusterOptions
            {
                command        = buffer,
                frustumPlanes  = proper.frustumPlanes,
                cullingShader  = data.resources.shaders.gpuFrustumCulling,
                terrainCompute = data.resources.shaders.terrainCompute
            };
            FilteringSettings alphaTestFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = new RenderQueueRange(2450, 2499)
            };
            FilteringSettings opaqueFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = new RenderQueueRange(2000, 2449)
            };
            FilteringSettings mvFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = RenderQueueRange.opaque
            };
            DrawingSettings depthAlphaTestDrawSettings = new DrawingSettings(new ShaderTagId("Depth"),
                                                                             new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.QuantizedFrontToBack | SortingCriteria.OptimizeStateChanges
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching = false,
                enableInstancing      = false
            };
            DrawingSettings depthOpaqueDrawSettings = new DrawingSettings(new ShaderTagId("Depth"),
                                                                          new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.QuantizedFrontToBack
            })
            {
                perObjectData             = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching     = false,
                enableInstancing          = false,
                overrideMaterial          = proper.overrideOpaqueMaterial,
                overrideMaterialPassIndex = 1
            };

            DrawingSettings drawSettings = new DrawingSettings(new ShaderTagId("GBuffer"), new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.RenderQueue | SortingCriteria.OptimizeStateChanges
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.Lightmaps,
                enableDynamicBatching = false,
                enableInstancing      = false
            };
            DrawingSettings mvDraw = new DrawingSettings(new ShaderTagId("MotionVector"), new SortingSettings {
                criteria = SortingCriteria.OptimizeStateChanges
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching = false,
                enableInstancing      = false
            };

            //Draw Depth Prepass
            data.buffer.SetRenderTarget(ShaderIDs._DepthBufferTexture);
            data.buffer.ClearRenderTarget(true, false, Color.black);
            cullHandle.Complete();
            var lst = CustomDrawRequest.allEvents;

            foreach (var i in gbufferCullResults)
            {
                lst[i].DrawDepthPrepass(buffer);
            }
            SceneController.RenderScene(ref data, ref opaqueFilter, ref depthOpaqueDrawSettings, ref proper.cullResults);
            data.context.DrawRenderers(proper.cullResults, ref depthAlphaTestDrawSettings, ref alphaTestFilter);
            decalEvt.FrameUpdate(cam, ref data);
            //Draw GBuffer
            data.buffer.SetRenderTarget(colors: cam.targets.gbufferIdentifier, depth: ShaderIDs._DepthBufferTexture);
            data.buffer.ClearRenderTarget(false, true, Color.black);
            HizOcclusionData hizOccData;

            if (useHiZ)
            {
                hizOccData = IPerCameraData.GetProperty(cam, () => new HizOcclusionData());
                SceneController.DrawCluster_LastFrameDepthHiZ(ref options, hizOccData, clusterMat, cam, proper.frustumMinPoint, proper.frustumMaxPoint);
            }

            foreach (var i in gbufferCullResults)
            {
                lst[i].DrawGBuffer(buffer);
            }
            SceneController.RenderScene(ref data, ref opaqueFilter, ref drawSettings, ref proper.cullResults);
            if (useHiZ)
            {
                SceneController.DrawCluster_RecheckHiz(ref options, ref hizDepth, hizOccData, clusterMat, linearMat, cam);
            }
            if (MTerrain.current)
            {
                MTerrain.current.DrawTerrain(buffer, 0, proper.frustumPlanes);
            }
            //Draw AlphaTest

            /* SortingSettings st = drawSettings.sortingSettings;
             * st.criteria = SortingCriteria.SortingLayer | SortingCriteria.RenderQueue | SortingCriteria.OptimizeStateChanges;
             * drawSettings.sortingSettings = st;*/
            SceneController.RenderScene(ref data, ref alphaTestFilter, ref drawSettings, ref proper.cullResults);
            //Draw Depth
            data.buffer.Blit(ShaderIDs._DepthBufferTexture, ShaderIDs._CameraDepthTexture);
            //Draw Motion Vector
            data.buffer.SetRenderTarget(color: ShaderIDs._CameraMotionVectorsTexture, depth: ShaderIDs._DepthBufferTexture);
            foreach (var i in gbufferCullResults)
            {
                lst[i].DrawMotionVector(buffer);
            }
            SceneController.RenderScene(ref data, ref mvFilter, ref mvDraw, ref proper.cullResults);
            //Draw Static Global Motion Vector
            data.buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, motionVecMat, 0, 0);
        }
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer        buffer  = data.buffer;
            RenderClusterOptions options = new RenderClusterOptions
            {
                command        = buffer,
                frustumPlanes  = proper.frustumPlanes,
                cullingShader  = data.resources.shaders.gpuFrustumCulling,
                terrainCompute = data.resources.shaders.terrainCompute
            };
            FilteringSettings alphaTestFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = new RenderQueueRange(2450, 2499)
            };
            FilteringSettings opaqueFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = new RenderQueueRange(2000, 2449)
            };
            FilteringSettings mvFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = RenderQueueRange.opaque
            };
            DrawingSettings depthAlphaTestDrawSettings = new DrawingSettings(new ShaderTagId("Depth"),
                                                                             new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.QuantizedFrontToBack | SortingCriteria.OptimizeStateChanges
            }
                                                                             )
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching = false,
                enableInstancing      = false
            };
            DrawingSettings depthOpaqueDrawSettings = new DrawingSettings(new ShaderTagId("Depth"),
                                                                          new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.QuantizedFrontToBack
            })
            {
                perObjectData             = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching     = false,
                enableInstancing          = false,
                overrideMaterial          = proper.overrideOpaqueMaterial,
                overrideMaterialPassIndex = 1
            };

            DrawingSettings drawSettings = new DrawingSettings(new ShaderTagId("GBuffer"), new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.RenderQueue | SortingCriteria.OptimizeStateChanges
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.Lightmaps,
                enableDynamicBatching = false,
                enableInstancing      = false
            };
            DrawingSettings mvDraw = new DrawingSettings(new ShaderTagId("MotionVector"), new SortingSettings {
                criteria = SortingCriteria.OptimizeStateChanges
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching = false,
                enableInstancing      = false
            };

            //Draw Depth Prepass
            data.buffer.SetRenderTarget(ShaderIDs._DepthBufferTexture);
            data.buffer.ClearRenderTarget(true, false, Color.black);
            cullHandle.Complete();
            var lst = CustomDrawRequest.allEvents;

            foreach (var i in gbufferCullResults)
            {
                lst[i].DrawDepthPrepass(buffer);
            }
            HizOcclusionData hizOccData = null;

            PipelineFunctions.UpdateFrustumMinMaxPoint(buffer, proper.frustumMinPoint, proper.frustumMaxPoint);
            if (useHiZ && SceneController.gpurpEnabled)
            {
#if UNITY_EDITOR
                if (Application.isPlaying)
                {
#endif
                hizOccData = IPerCameraData.GetProperty(cam, () => new HizOcclusionData());
                SceneController.CullCluster_LastFrameDepthHiZ(ref options, hizOccData, cam);
                buffer.DrawProceduralIndirect(Matrix4x4.identity, clusterMat, 2, MeshTopology.Triangles, SceneController.baseBuffer.instanceCountBuffer, 0);
#if UNITY_EDITOR
            }
#endif
            }
            RenderStateBlock depthBlock = new RenderStateBlock
            {
                depthState = new DepthState(true, CompareFunction.Less),
                mask       = RenderStateMask.Depth
            };
            SceneController.RenderScene(ref data, ref opaqueFilter, ref depthOpaqueDrawSettings, ref proper.cullResults, ref depthBlock);
            data.context.DrawRenderers(proper.cullResults, ref depthAlphaTestDrawSettings, ref alphaTestFilter);
            decalEvt.FrameUpdate(cam, ref data);
            //Draw GBuffer
            data.buffer.SetRenderTarget(colors: cam.targets.gbufferIdentifier, depth: ShaderIDs._DepthBufferTexture);
            data.buffer.ClearRenderTarget(false, true, Color.black);


            foreach (var i in gbufferCullResults)
            {
                lst[i].DrawGBuffer(buffer);
            }
            if (useHiZ && SceneController.gpurpEnabled)
            {
#if UNITY_EDITOR
                if (Application.isPlaying)
                {
#endif
                buffer.SetGlobalBuffer(ShaderIDs._MaterialBuffer, data.resources.clusterResources.vmManager.materialBuffer);
                buffer.SetGlobalTexture(ShaderIDs._GPURPMainTex, data.resources.clusterResources.rgbaPool.rt);
                buffer.SetGlobalTexture(ShaderIDs._GPURPEmissionMap, data.resources.clusterResources.emissionPool.rt);
                buffer.SetGlobalTexture(ShaderIDs._GPURPBumpMap, data.resources.clusterResources.normalPool.rt);
                buffer.SetGlobalTexture(ShaderIDs._GPURPHeightMap, data.resources.clusterResources.heightPool.rt);
                buffer.DrawProceduralIndirect(Matrix4x4.identity, clusterMat, 0, MeshTopology.Triangles, SceneController.baseBuffer.instanceCountBuffer, 0);
#if UNITY_EDITOR
            }
#endif
            }
            SceneController.RenderScene(ref data, ref opaqueFilter, ref drawSettings, ref proper.cullResults);
            if (useHiZ && SceneController.gpurpEnabled)
            {
#if UNITY_EDITOR
                if (Application.isPlaying)
#endif
                SceneController.DrawCluster_RecheckHiz(ref options, ref hizDepth, hizOccData, clusterMat, linearMat, cam);
            }
            if (MTerrain.current)
            {
                MTerrain.current.DrawTerrain(buffer, 0, proper.frustumPlanes);
            }
            //Draw AlphaTest

            /* SortingSettings st = drawSettings.sortingSettings;
             * st.criteria = SortingCriteria.SortingLayer | SortingCriteria.RenderQueue | SortingCriteria.OptimizeStateChanges;
             * drawSettings.sortingSettings = st;*/
            SceneController.RenderScene(ref data, ref alphaTestFilter, ref drawSettings, ref proper.cullResults);
            //Draw Depth
            data.buffer.Blit(ShaderIDs._DepthBufferTexture, ShaderIDs._CameraDepthTexture);
            //Draw Motion Vector
            data.buffer.SetRenderTarget(color: ShaderIDs._CameraMotionVectorsTexture, depth: ShaderIDs._DepthBufferTexture);
            foreach (var i in gbufferCullResults)
            {
                lst[i].DrawMotionVector(buffer);
            }
            SceneController.RenderScene(ref data, ref mvFilter, ref mvDraw, ref proper.cullResults);
            //Draw Static Global Motion Vector
            data.buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, motionVecMat, 0, 0);
        }
Beispiel #26
0
 public void PreRender(PipelineCamera cam)
 {
     prevDepthData = IPerCameraData.GetProperty(cam, (cc) => new PreviousDepthData(new Vector2Int(cc.cam.pixelWidth, cc.cam.pixelHeight)));
     prevDepthData.targetObject = this;
 }
Beispiel #27
0
        public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer        buffer  = data.buffer;
            RenderClusterOptions options = new RenderClusterOptions
            {
                command        = buffer,
                frustumPlanes  = proper.frustumPlanes,
                cullingShader  = data.resources.shaders.gpuFrustumCulling,
                terrainCompute = data.resources.shaders.terrainCompute
            };
            FilteringSettings alphaTestFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = new RenderQueueRange(2450, 2499)
            };
            FilteringSettings opaqueFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = new RenderQueueRange(2000, 2449)
            };
            FilteringSettings mvFilter = new FilteringSettings
            {
                layerMask          = cam.cam.cullingMask,
                renderingLayerMask = 1,
                renderQueueRange   = RenderQueueRange.opaque
            };
            DrawingSettings depthPrePassDrawSettings = new DrawingSettings(new ShaderTagId("Depth"), new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.QuantizedFrontToBack
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching = false,
                enableInstancing      = false
            };
            DrawingSettings drawSettings = new DrawingSettings(new ShaderTagId("GBuffer"), new SortingSettings(cam.cam)
            {
                criteria = SortingCriteria.CommonOpaque
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.Lightmaps,
                enableDynamicBatching = false,
                enableInstancing      = false
            };
            DrawingSettings mvDraw = new DrawingSettings(new ShaderTagId("MotionVector"), new SortingSettings {
                criteria = SortingCriteria.None
            })
            {
                perObjectData         = UnityEngine.Rendering.PerObjectData.None,
                enableDynamicBatching = false,
                enableInstancing      = false
            };

            data.buffer.SetRenderTarget(colors: cam.targets.gbufferIdentifier, depth: ShaderIDs._DepthBufferTexture);
            data.buffer.ClearRenderTarget(true, true, Color.black);
            HizOcclusionData hizOccData;

            if (useHiZ)
            {
                hizOccData = IPerCameraData.GetProperty(cam, () => new HizOcclusionData());
                SceneController.DrawCluster_LastFrameDepthHiZ(ref options, hizOccData, clusterMat, cam);
            }

            SceneController.RenderScene(ref data, ref opaqueFilter, ref drawSettings, ref proper.cullResults);
            if (useHiZ)
            {
                SceneController.DrawCluster_RecheckHiz(ref options, ref hizDepth, hizOccData, clusterMat, linearMat, cam);
            }
            data.buffer.SetRenderTarget(ShaderIDs._DepthBufferTexture);
            SceneController.RenderScene(ref data, ref alphaTestFilter, ref depthPrePassDrawSettings, ref proper.cullResults);
            data.buffer.SetRenderTarget(colors: cam.targets.gbufferIdentifier, depth: ShaderIDs._DepthBufferTexture);
            SortingSettings st = drawSettings.sortingSettings;

            st.criteria = SortingCriteria.SortingLayer | SortingCriteria.RenderQueue;
            drawSettings.sortingSettings = st;
            SceneController.RenderScene(ref data, ref alphaTestFilter, ref drawSettings, ref proper.cullResults);
            data.buffer.Blit(ShaderIDs._DepthBufferTexture, ShaderIDs._CameraDepthTexture);


            data.buffer.SetRenderTarget(color: ShaderIDs._CameraMotionVectorsTexture, depth: ShaderIDs._DepthBufferTexture);
            SceneController.RenderScene(ref data, ref mvFilter, ref mvDraw, ref proper.cullResults);
            data.buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, motionVecMat, 0, 0);
            decal.FrameUpdate(cam, ref data);
            //Generate DownSampled GBuffer
            if ((ao != null && ao.Enabled) || (reflection != null && reflection.Enabled && reflection.ssrEvents.enabled))
            {
                int2 res = int2(cam.cam.pixelWidth, cam.cam.pixelHeight) / 2;
                data.buffer.GetTemporaryRT(ShaderIDs._DownSampledGBuffer1, res.x, res.y, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1, false);
                data.buffer.GetTemporaryRT(ShaderIDs._DownSampledGBuffer2, res.x, res.y, 0, FilterMode.Point, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear, 1, false);
                data.buffer.GetTemporaryRT(ShaderIDs._DownSampledDepthTexture, res.x, res.y, 0, FilterMode.Point, RenderTextureFormat.RHalf, RenderTextureReadWrite.Linear, 1, false);
                downSampledGBuffers[0] = ShaderIDs._DownSampledDepthTexture;
                downSampledGBuffers[1] = ShaderIDs._DownSampledGBuffer1;
                downSampledGBuffers[2] = ShaderIDs._DownSampledGBuffer2;
                data.buffer.SetRenderTarget(colors: downSampledGBuffers, depth: downSampledGBuffers[0]);
                data.buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, downSampleMat, 0, 0);
                RenderPipeline.ReleaseRTAfterFrame(ShaderIDs._DownSampledGBuffer1);
                RenderPipeline.ReleaseRTAfterFrame(ShaderIDs._DownSampledGBuffer2);
                RenderPipeline.ReleaseRTAfterFrame(ShaderIDs._DownSampledDepthTexture);
                //TODO
            }
        }
Beispiel #28
0
 public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data, CommandBuffer buffer)
 {
     HizOcclusionData hizData    = IPerCameraData.GetProperty <HizOcclusionData>(cam, getOcclusionData);
     ref var          baseBuffer = ref data.baseBuffer;