Skip to content

Exposed the volumetric clouds transmittance for volumetric clouds (case 1373283). #6228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,13 @@ void UpdateVolumetricClouds(HDCamera hdCamera, in VolumetricClouds settings)
}
}

void RenderVolumetricClouds(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBuffer, TextureHandle depthPyramid, TextureHandle motionVector, TextureHandle volumetricLighting, TextureHandle maxZMask)
TextureHandle RenderVolumetricClouds(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBuffer, TextureHandle depthPyramid, TextureHandle motionVector, TextureHandle volumetricLighting, TextureHandle maxZMask)
{
VolumetricClouds settings = hdCamera.volumeStack.GetComponent<VolumetricClouds>();

// If the current volume does not enable the feature, quit right away.
if (!HasVolumetricClouds(hdCamera, in settings))
return;
return renderGraph.defaultResources.whiteTextureXR;

// Make sure the volumetric clouds are animated properly
UpdateVolumetricClouds(hdCamera, in settings);
Expand All @@ -640,16 +640,20 @@ void RenderVolumetricClouds(RenderGraph renderGraph, HDCamera hdCamera, TextureH
bool accumulationClouds = cameraType == TVolumetricCloudsCameraType.Default || cameraType == TVolumetricCloudsCameraType.PlanarReflection;
bool fullResolutionClouds = cameraType == TVolumetricCloudsCameraType.BakedReflection;

TextureHandle result;
if (accumulationClouds)
{
RenderVolumetricClouds_Accumulation(renderGraph, hdCamera, cameraType, colorBuffer, depthPyramid, motionVector, volumetricLighting, maxZMask);
result = RenderVolumetricClouds_Accumulation(renderGraph, hdCamera, cameraType, colorBuffer, depthPyramid, motionVector, volumetricLighting, maxZMask);
// Make sure to mark the history frame index validity.
PropagateVolumetricCloudsHistoryValidity(hdCamera, settings.localClouds.value);
}
else if (fullResolutionClouds)
RenderVolumetricClouds_FullResolution(renderGraph, hdCamera, cameraType, colorBuffer, depthPyramid, motionVector, volumetricLighting, maxZMask);
result = RenderVolumetricClouds_FullResolution(renderGraph, hdCamera, cameraType, colorBuffer, depthPyramid, motionVector, volumetricLighting, maxZMask);
else
RenderVolumetricClouds_LowResolution(renderGraph, hdCamera, cameraType, colorBuffer, depthPyramid, motionVector, volumetricLighting, maxZMask);
result = RenderVolumetricClouds_LowResolution(renderGraph, hdCamera, cameraType, colorBuffer, depthPyramid, motionVector, volumetricLighting, maxZMask);

// Return the scattering and transmittance
return result;
}

void PreRenderVolumetricClouds(RenderGraph renderGraph, HDCamera hdCamera)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class VolumetricCloudsAccumulationData
TextureHandle RenderVolumetricClouds_Accumulation(RenderGraph renderGraph, HDCamera hdCamera, TVolumetricCloudsCameraType cameraType,
TextureHandle colorBuffer, TextureHandle depthPyramid, TextureHandle motionVectors, TextureHandle volumetricLighting, TextureHandle maxZMask)
{
using (var builder = renderGraph.AddRenderPass<VolumetricCloudsAccumulationData>("Generating the rays for RTR", out var passData, ProfilingSampler.Get(HDProfileId.VolumetricClouds)))
using (var builder = renderGraph.AddRenderPass<VolumetricCloudsAccumulationData>("Volumetric Clouds", out var passData, ProfilingSampler.Get(HDProfileId.VolumetricClouds)))
{
builder.EnableAsyncCompute(false);
VolumetricClouds settings = hdCamera.volumeStack.GetComponent<VolumetricClouds>();
Expand Down Expand Up @@ -405,9 +405,12 @@ TextureHandle RenderVolumetricClouds_Accumulation(RenderGraph renderGraph, HDCam
data.intermediateColorBufferCopy, data.intermediateBufferUpscale);
});

// Push the texture to the debug menu
PushFullScreenDebugTexture(m_RenderGraph, passData.currentHistoryBuffer0, FullScreenDebugMode.VolumetricClouds);

return passData.colorBuffer;
// We return the volumetric clouds buffers rendered at half resolution. We should ideally return the full resolution transmittance, but
// this should be enough for the initial case (which is the lens flares). The transmittance can be found in the alpha channel.
return passData.currentHistoryBuffer0;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ TextureHandle RenderVolumetricClouds_FullResolution(RenderGraph renderGraph, HDC
data.intermediateColorBufferCopy, data.intermediateBufferUpscale);
});

return passData.colorBuffer;
// In the case of reflection probes, we don't expect any pass that will need the transmittance mask of the clouds so we return white.
return renderGraph.defaultResources.whiteTextureXR;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ TextureHandle RenderVolumetricClouds_LowResolution(RenderGraph renderGraph, HDCa
data.intermediateColorBufferCopy, data.intermediateBufferUpscale);
});

return passData.colorBuffer;
// In the case of reflection probes, we don't expect any pass that will need the transmittance mask of the clouds so we return white.
return renderGraph.defaultResources.whiteTextureXR;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
TextureHandle backBuffer,
TextureHandle uiBuffer,
TextureHandle afterPostProcessBuffer,
TextureHandle sunOcclusionTexture,
CullingResults cullResults,
HDCamera hdCamera)
{
Expand Down Expand Up @@ -551,7 +552,7 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
// HDRP to reduce the amount of resolution lost at the center of the screen
source = PaniniProjectionPass(renderGraph, hdCamera, source);

source = LensFlareDataDrivenPass(renderGraph, hdCamera, source, depthBuffer);
source = LensFlareDataDrivenPass(renderGraph, hdCamera, source, depthBuffer, sunOcclusionTexture);

TextureHandle bloomTexture = BloomPass(renderGraph, hdCamera, source);
TextureHandle logLutOutput = ColorGradingPass(renderGraph);
Expand Down Expand Up @@ -3121,7 +3122,7 @@ void LensFlareMergeOcclusionDataDrivenPass(RenderGraph renderGraph, HDCamera hdC
}
}

TextureHandle LensFlareDataDrivenPass(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle source, TextureHandle depthBuffer)
TextureHandle LensFlareDataDrivenPass(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle source, TextureHandle depthBuffer, TextureHandle sunOcclusionTexture)
{
if (m_LensFlareDataDataDrivenFS && !LensFlareCommonSRP.Instance.IsEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void RecordRenderGraph(RenderRequest renderRequest,
ShadowResult shadowResult = new ShadowResult();
BuildGPULightListOutput gpuLightListOutput = new BuildGPULightListOutput();
TextureHandle uiBuffer = m_RenderGraph.defaultResources.blackTextureXR;
TextureHandle sunOcclusionTexture = m_RenderGraph.defaultResources.whiteTexture;

if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() && m_CurrentDebugDisplaySettings.IsFullScreenDebugPassEnabled())
{
Expand Down Expand Up @@ -175,7 +176,7 @@ void RecordRenderGraph(RenderRequest renderRequest,
RenderSubsurfaceScattering(m_RenderGraph, hdCamera, colorBuffer, historyValidationTexture, ref lightingBuffers, ref prepassOutput);

RenderSky(m_RenderGraph, hdCamera, colorBuffer, volumetricLighting, prepassOutput.depthBuffer, msaa ? prepassOutput.depthAsColor : prepassOutput.depthPyramidTexture);
RenderVolumetricClouds(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthPyramidTexture, prepassOutput.motionVectorsBuffer, volumetricLighting, maxZMask);
sunOcclusionTexture = RenderVolumetricClouds(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthPyramidTexture, prepassOutput.motionVectorsBuffer, volumetricLighting, maxZMask);

// Send all the geometry graphics buffer to client systems if required (must be done after the pyramid and before the transparent depth pre-pass)
SendGeometryGraphicsBuffers(m_RenderGraph, prepassOutput.normalBuffer, prepassOutput.depthPyramidTexture, hdCamera);
Expand Down Expand Up @@ -263,7 +264,7 @@ void RecordRenderGraph(RenderRequest renderRequest,


TextureHandle afterPostProcessBuffer = RenderAfterPostProcessObjects(m_RenderGraph, hdCamera, cullingResults, prepassOutput);
TextureHandle postProcessDest = RenderPostProcess(m_RenderGraph, prepassOutput, colorBuffer, backBuffer, uiBuffer, afterPostProcessBuffer, cullingResults, hdCamera);
TextureHandle postProcessDest = RenderPostProcess(m_RenderGraph, prepassOutput, colorBuffer, backBuffer, uiBuffer, afterPostProcessBuffer, sunOcclusionTexture, cullingResults, hdCamera);

var xyMapping = GenerateDebugHDRxyMapping(m_RenderGraph, hdCamera, postProcessDest);
GenerateDebugImageHistogram(m_RenderGraph, hdCamera, postProcessDest);
Expand Down