Ejemplo n.º 1
0
        void FillBloomMipsTextureHandles(BloomData bloomData, RenderGraph renderGraph, RenderGraphBuilder builder)
        {
            for (int i = 0; i < m_BloomMipCount; i++)
            {
                var scale     = new Vector2(m_BloomMipsInfo[i].z, m_BloomMipsInfo[i].w);
                var pixelSize = new Vector2Int((int)m_BloomMipsInfo[i].x, (int)m_BloomMipsInfo[i].y);

                bloomData.mipsDown[i] = builder.CreateTransientTexture(new TextureDesc(scale, true, true)
                {
                    colorFormat = m_ColorFormat, enableRandomWrite = true
                });

                if (i != 0)
                {
                    bloomData.mipsUp[i] = builder.CreateTransientTexture(new TextureDesc(scale, true, true)
                    {
                        colorFormat = m_ColorFormat, enableRandomWrite = true
                    });
                }
            }

            // the mip up 0 will be used by uber, so not allocated as transient.
            var mip0Scale = new Vector2(m_BloomMipsInfo[0].z, m_BloomMipsInfo[0].w);

            bloomData.mipsUp[0] = renderGraph.CreateTexture(new TextureDesc(mip0Scale, true, true)
            {
                name              = "Bloom final mip up",
                colorFormat       = m_ColorFormat,
                useMipMap         = false,
                enableRandomWrite = true
            });
        }
Ejemplo n.º 2
0
        void PrepareVolumetricCloudsSkyLowPassData(RenderGraph renderGraph, RenderGraphBuilder builder, HDCamera hdCamera, int width, int height, Matrix4x4[] pixelCoordToViewDir, CubemapFace cubemapFace, VolumetricClouds settings, VolumetricCloudsSkyLowPassData data)
        {
            // Compute the cloud model data
            CloudModelData cloudModelData = GetCloudModelData(settings);

            // Fill the common data
            FillVolumetricCloudsCommonData(false, settings, TVolumetricCloudsCameraType.Sky, in cloudModelData, ref data.commonData);

            // We need to make sure that the allocated size of the history buffers and the dispatch size are perfectly equal.
            // The ideal approach would be to have a function for that returns the converted size from a viewport and texture size.
            // but for now we do it like this.
            // Final resolution at which the effect should be exported
            data.finalWidth  = width;
            data.finalHeight = height;
            // Intermediate resolution at which the effect is accumulated
            data.intermediateWidth  = Mathf.RoundToInt(0.5f * width);
            data.intermediateHeight = Mathf.RoundToInt(0.5f * height);
            // Resolution at which the effect is traced
            data.traceWidth  = Mathf.RoundToInt(0.25f * width);
            data.traceHeight = Mathf.RoundToInt(0.25f * height);

            // Sky
            data.cubemapFace      = cubemapFace;
            data.cloudCombinePass = m_CloudCombinePass;

            // Kernels
            data.renderKernel       = m_CloudRenderKernel;
            data.preUpscaleKernel   = m_PreUpscaleCloudsSkyKernel;
            data.finalUpscaleKernel = m_UpscaleAndCombineCloudsSkyKernel;

            data.pixelCoordToViewDir = pixelCoordToViewDir;

            // Update the constant buffer
            VolumetricCloudsCameraData cameraData;

            cameraData.cameraType            = data.commonData.cameraType;
            cameraData.traceWidth            = data.traceWidth;
            cameraData.traceHeight           = data.traceHeight;
            cameraData.intermediateWidth     = data.intermediateWidth;
            cameraData.intermediateHeight    = data.intermediateHeight;
            cameraData.finalWidth            = data.finalWidth;
            cameraData.finalHeight           = data.finalHeight;
            cameraData.viewCount             = 1;
            cameraData.enableExposureControl = data.commonData.enableExposureControl;
            cameraData.lowResolution         = true;
            cameraData.enableIntegration     = false;
            UpdateShaderVariableslClouds(ref data.commonData.cloudsCB, hdCamera, settings, cameraData, cloudModelData, false);

            int skyResolution = (int)m_Asset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize;

            data.intermediateLightingBuffer = builder.CreateTransientTexture(GetVolumetricCloudsIntermediateLightingBufferDesc());
            data.intermediateDepthBuffer    = builder.CreateTransientTexture(GetVolumetricCloudsIntermediateDepthBufferDesc());
            data.output             = builder.WriteTexture(renderGraph.CreateTexture(GetVolumetricCloudsIntermediateCubeTextureDesc()));
            data.maxZMask           = builder.ReadTexture(renderGraph.defaultResources.blackTextureXR);
            data.ambientProbeBuffer = builder.ReadComputeBuffer(renderGraph.ImportComputeBuffer(m_CloudsProbeBuffer));
        }
Ejemplo n.º 3
0
        void PrepareVolumetricCloudsSkyHighPassData(RenderGraph renderGraph, RenderGraphBuilder builder, HDCamera hdCamera, int width, int height, Matrix4x4[] pixelCoordToViewDir, CubemapFace cubemapFace, VolumetricClouds settings, TextureHandle output, VolumetricCloudsSkyHighPassData data)
        {
            // Compute the cloud model data
            CloudModelData cloudModelData = GetCloudModelData(settings);

            // Fill the common data
            FillVolumetricCloudsCommonData(false, settings, TVolumetricCloudsCameraType.Sky, in cloudModelData, ref data.commonData);

            // If this is a baked reflection, we run everything at full res
            data.finalWidth  = width;
            data.finalHeight = height;

            // Sky
            data.cubemapFace      = cubemapFace;
            data.cloudCombinePass = m_CloudCombinePass;

            // Compute shader and kernels
            data.renderKernel  = m_CloudRenderKernel;
            data.combineKernel = m_CombineCloudsSkyKernel;

            data.pixelCoordToViewDir = pixelCoordToViewDir;

            // Update the constant buffer
            VolumetricCloudsCameraData cameraData;

            cameraData.cameraType            = data.commonData.cameraType;
            cameraData.traceWidth            = data.finalWidth;
            cameraData.traceHeight           = data.finalHeight;
            cameraData.intermediateWidth     = data.finalWidth;
            cameraData.intermediateHeight    = data.finalHeight;
            cameraData.finalWidth            = data.finalWidth;
            cameraData.finalHeight           = data.finalHeight;
            cameraData.viewCount             = 1;
            cameraData.enableExposureControl = data.commonData.enableExposureControl;
            cameraData.lowResolution         = false;
            cameraData.enableIntegration     = false;
            UpdateShaderVariableslClouds(ref data.commonData.cloudsCB, hdCamera, settings, cameraData, cloudModelData, false);

            int skyResolution = (int)m_Asset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize;

            data.intermediateLightingBuffer0 = builder.CreateTransientTexture(GetVolumetricCloudsIntermediateLightingBufferDesc());
            data.intermediateDepthBuffer     = builder.CreateTransientTexture(GetVolumetricCloudsIntermediateDepthBufferDesc());
            if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal)
            {
                data.intermediateLightingBuffer1 = builder.CreateTransientTexture(GetVolumetricCloudsIntermediateLightingBufferDesc());
                data.output = builder.ReadWriteTexture(output);
            }
            else
            {
                data.output = builder.WriteTexture(output);
            }
            data.maxZMask           = builder.ReadTexture(renderGraph.defaultResources.blackTextureXR);
            data.ambientProbeBuffer = builder.ReadComputeBuffer(renderGraph.ImportComputeBuffer(m_CloudsProbeBuffer));
        }