void GetPresetCloudMapValues(VolumetricClouds.CloudPresets preset, out CloudModelData cloudModelData) { switch (preset) { case VolumetricClouds.CloudPresets.Sparse: { cloudModelData.densityMultiplier = 0.25f; cloudModelData.shapeFactor = 0.9f; cloudModelData.shapeScale = 3.0f; cloudModelData.erosionFactor = 0.9f; cloudModelData.erosionScale = 61.4f; cloudModelData.erosionNoise = VolumetricClouds.CloudErosionNoise.Perlin32; return; } case VolumetricClouds.CloudPresets.Cloudy: { cloudModelData.densityMultiplier = 0.3f; cloudModelData.shapeFactor = 0.9f; cloudModelData.shapeScale = 5.0f; cloudModelData.erosionFactor = 0.95f; cloudModelData.erosionScale = 87.7f; cloudModelData.erosionNoise = VolumetricClouds.CloudErosionNoise.Perlin32; return; } case VolumetricClouds.CloudPresets.Overcast: { cloudModelData.densityMultiplier = 0.3f; cloudModelData.shapeFactor = 0.6f; cloudModelData.shapeScale = 6.0f; cloudModelData.erosionFactor = 0.75f; cloudModelData.erosionScale = 87.2f; cloudModelData.erosionNoise = VolumetricClouds.CloudErosionNoise.Perlin32; return; } case VolumetricClouds.CloudPresets.Stormy: { cloudModelData.densityMultiplier = 0.3f; cloudModelData.shapeFactor = 0.85f; cloudModelData.shapeScale = 3.0f; cloudModelData.erosionFactor = 0.9f; cloudModelData.erosionScale = 57.9f; cloudModelData.erosionNoise = VolumetricClouds.CloudErosionNoise.Perlin32; return; } } // Default unused values cloudModelData.densityMultiplier = 0.0f; cloudModelData.shapeFactor = 0.0f; cloudModelData.shapeScale = 0.0f; cloudModelData.erosionFactor = 0.0f; cloudModelData.erosionScale = 0.0f; cloudModelData.erosionNoise = VolumetricClouds.CloudErosionNoise.Perlin32; }
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)); }
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)); }
VolumetricCloudsParameters_FullResolution PrepareVolumetricCloudsParameters_FullResolution(HDCamera hdCamera, int width, int height, int viewCount, bool exposureControl, VolumetricClouds settings, TVolumetricCloudsCameraType cameraType) { VolumetricCloudsParameters_FullResolution parameters = new VolumetricCloudsParameters_FullResolution(); // Compute the cloud model data CloudModelData cloudModelData = GetCloudModelData(settings); // Fill the common data FillVolumetricCloudsCommonData(exposureControl, settings, cameraType, in cloudModelData, ref parameters.commonData); // If this is a baked reflection, we run everything at full res parameters.finalWidth = width; parameters.finalHeight = height; parameters.viewCount = viewCount; // MSAA support parameters.needsTemporaryBuffer = hdCamera.msaaEnabled; parameters.cloudCombinePass = m_CloudCombinePass; parameters.needExtraColorBufferCopy = (GetColorBufferFormat() == GraphicsFormat.B10G11R11_UFloatPack32 && // On PC and Metal, but not on console. (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan)); // In case of MSAA, we no longer require the preliminary copy as there is no longer a need for RW of the color buffer. parameters.needExtraColorBufferCopy &= !parameters.needsTemporaryBuffer; // Compute shader and kernels parameters.renderKernel = m_CloudRenderKernel; parameters.combineKernel = parameters.needExtraColorBufferCopy ? m_CombineCloudsKernelColorCopy : m_CombineCloudsKernelColorRW; // Update the constant buffer VolumetricCloudsCameraData cameraData; cameraData.cameraType = parameters.commonData.cameraType; cameraData.traceWidth = parameters.finalWidth; cameraData.traceHeight = parameters.finalHeight; cameraData.intermediateWidth = parameters.finalWidth; cameraData.intermediateHeight = parameters.finalHeight; cameraData.finalWidth = parameters.finalWidth; cameraData.finalHeight = parameters.finalHeight; cameraData.viewCount = parameters.viewCount; cameraData.enableExposureControl = parameters.commonData.enableExposureControl; cameraData.lowResolution = false; cameraData.enableIntegration = true; UpdateShaderVariableslClouds(ref parameters.commonData.cloudsCB, hdCamera, settings, cameraData, cloudModelData, false); return(parameters); }
VolumetricCloudsParameters_Accumulation PrepareVolumetricCloudsParameters_Accumulation(HDCamera hdCamera, VolumetricClouds settings, TVolumetricCloudsCameraType cameraType, bool historyValidity) { VolumetricCloudsParameters_Accumulation parameters = new VolumetricCloudsParameters_Accumulation(); // Compute the cloud model data CloudModelData cloudModelData = GetCloudModelData(settings); // Fill the common data FillVolumetricCloudsCommonData(hdCamera.exposureControlFS, settings, cameraType, in cloudModelData, ref parameters.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 parameters.finalWidth = hdCamera.actualWidth; parameters.finalHeight = hdCamera.actualHeight; // Intermediate resolution at which the effect is accumulated parameters.intermediateWidth = Mathf.RoundToInt(0.5f * hdCamera.actualWidth); parameters.intermediateHeight = Mathf.RoundToInt(0.5f * hdCamera.actualHeight); // Resolution at which the effect is traced parameters.traceWidth = Mathf.RoundToInt(0.25f * hdCamera.actualWidth); parameters.traceHeight = Mathf.RoundToInt(0.25f * hdCamera.actualHeight); parameters.viewCount = hdCamera.viewCount; parameters.previousViewportSize = hdCamera.historyRTHandleProperties.previousViewportSize; parameters.historyValidity = historyValidity; // MSAA support parameters.needsTemporaryBuffer = hdCamera.msaaEnabled; parameters.cloudCombinePass = m_CloudCombinePass; parameters.needExtraColorBufferCopy = (GetColorBufferFormat() == GraphicsFormat.B10G11R11_UFloatPack32 && // On PC and Metal, but not on console. (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan)); // In case of MSAA, we no longer require the preliminary copy as there is no longer a need for RW of the color buffer. parameters.needExtraColorBufferCopy &= !parameters.needsTemporaryBuffer; // Compute shader and kernels parameters.convertObliqueDepthKernel = m_ConvertObliqueDepthKernel; parameters.depthDownscaleKernel = m_CloudDownscaleDepthKernel; parameters.renderKernel = m_CloudRenderKernel; parameters.reprojectKernel = settings.ghostingReduction.value ? m_ReprojectCloudsRejectionKernel : m_ReprojectCloudsKernel; parameters.upscaleAndCombineKernel = parameters.needExtraColorBufferCopy ? m_UpscaleAndCombineCloudsKernelColorCopy : m_UpscaleAndCombineCloudsKernelColorRW; // Update the constant buffer VolumetricCloudsCameraData cameraData; cameraData.cameraType = parameters.commonData.cameraType; cameraData.traceWidth = parameters.traceWidth; cameraData.traceHeight = parameters.traceHeight; cameraData.intermediateWidth = parameters.intermediateWidth; cameraData.intermediateHeight = parameters.intermediateHeight; cameraData.finalWidth = parameters.finalWidth; cameraData.finalHeight = parameters.finalHeight; cameraData.viewCount = parameters.viewCount; cameraData.enableExposureControl = parameters.commonData.enableExposureControl; cameraData.lowResolution = true; cameraData.enableIntegration = true; UpdateShaderVariableslClouds(ref parameters.commonData.cloudsCB, hdCamera, settings, cameraData, cloudModelData, false); // If this is a default camera, we want the improved blending, otherwise we don't (in the case of a planar) parameters.commonData.cloudsCB._ImprovedTransmittanceBlend = parameters.commonData.cameraType == TVolumetricCloudsCameraType.Default ? 1 : 0; parameters.commonData.cloudsCB._CubicTransmittance = parameters.commonData.cameraType == TVolumetricCloudsCameraType.Default && hdCamera.msaaEnabled ? 1 : 0; return(parameters); }
VolumetricCloudsParameters_LowResolution PrepareVolumetricCloudsParameters_LowResolution(HDCamera hdCamera, int width, int height, int viewCount, bool exposureControl, VolumetricClouds settings, TVolumetricCloudsCameraType cameraType) { VolumetricCloudsParameters_LowResolution parameters = new VolumetricCloudsParameters_LowResolution(); // Compute the cloud model data CloudModelData cloudModelData = GetCloudModelData(settings); // Fill the common data FillVolumetricCloudsCommonData(exposureControl, settings, cameraType, in cloudModelData, ref parameters.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 parameters.finalWidth = width; parameters.finalHeight = height; // Intermediate resolution at which the effect is accumulated parameters.intermediateWidth = Mathf.RoundToInt(0.5f * width); parameters.intermediateHeight = Mathf.RoundToInt(0.5f * height); // Resolution at which the effect is traced parameters.traceWidth = Mathf.RoundToInt(0.25f * width); parameters.traceHeight = Mathf.RoundToInt(0.25f * height); parameters.viewCount = viewCount; // MSAA support parameters.needsTemporaryBuffer = hdCamera.msaaEnabled; parameters.cloudCombinePass = m_CloudCombinePass; parameters.needExtraColorBufferCopy = (GetColorBufferFormat() == GraphicsFormat.B10G11R11_UFloatPack32 && // On PC and Metal, but not on console. (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan)); // In case of MSAA, we no longer require the preliminary copy as there is no longer a need for RW of the color buffer. parameters.needExtraColorBufferCopy &= !parameters.needsTemporaryBuffer; // Compute shader and kernels parameters.depthDownscaleKernel = m_CloudDownscaleDepthKernel; parameters.renderKernel = m_CloudRenderKernel; parameters.preUpscaleKernel = m_PreUpscaleCloudsKernel; parameters.upscaleAndCombineKernel = parameters.needExtraColorBufferCopy ? m_UpscaleAndCombineCloudsKernelColorCopy : m_UpscaleAndCombineCloudsKernelColorRW; // Update the constant buffer VolumetricCloudsCameraData cameraData; cameraData.cameraType = parameters.commonData.cameraType; cameraData.traceWidth = parameters.traceWidth; cameraData.traceHeight = parameters.traceHeight; cameraData.intermediateWidth = parameters.intermediateWidth; cameraData.intermediateHeight = parameters.intermediateHeight; cameraData.finalWidth = parameters.finalWidth; cameraData.finalHeight = parameters.finalHeight; cameraData.viewCount = parameters.viewCount; cameraData.enableExposureControl = parameters.commonData.enableExposureControl; cameraData.lowResolution = true; cameraData.enableIntegration = false; UpdateShaderVariableslClouds(ref parameters.commonData.cloudsCB, hdCamera, settings, cameraData, cloudModelData, false); return(parameters); }