Skip to content

Commit 5e99f9b

Browse files
anisunityAntoine LelievresebastienlagardeFrancescoC-unityadrien-de-tocqueville
authored
Fixed an issue with the frame count management for the volumetric fog (case 1299251). (#2947)
* [HDRP] Fix coat normal space (#2888) * Fix coat normal space * Update CHANGELOG.md Co-authored-by: Sebastien Lagarde <[email protected]> * Avoid issues causing faulty transitions in shadows (resulting in no shadows with unconventional aspect ratio) (#2776) * Fixed volume component tooltips using the same parameter name (#2754) * Use the proper history info for Bicubic resampling in TAA (#2759) * Use proper info for previous buffer info * changelog * Fixed lookdev movement (#2757) Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Fix issue with saving some quality settings in volume overrides (#2758) * Fix issue with saving some quality settings volume overrides * Fix typo in changelog Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Fixed NullReferenceException in HDRenderPipeline.UpgradeResourcesIfNeeded (case 1292524) (#2765) * fix issue with confusing text (#2766) * Fix * Fix white dots * Changelog * Rename the sunrise icon to fix typo, causing issue with 2x resolution loading. (#2809) * [HDRP] Rename HDRP to HD Render Pipeline in menu item (#2819) * [HDRP] Update HDRP menu in shader graph * Update CHANGELOG.md * HDRP/Fix package version showing package after the last "verified" package (#2783) * Fix typo * Remove last version checker from wizard and add link to package manager instead * Update CHANGELOG.md * Update documentation * Update Render-Pipeline-Wizard.md Co-authored-by: Sebastien Lagarde <[email protected]> * Revert bad changelog merge * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Adrien de Tocqueville <[email protected]> Co-authored-by: sebastienlagarde <[email protected]> Co-authored-by: Pavlos Mavridis <[email protected]> Co-authored-by: John Parsaie <[email protected]> Co-authored-by: Remi Slysz <[email protected]> * Fixed invalid loop length for probe baking (case 1289680) (#2830) * Fixed invalid loop length for probe baking (case 1289680) # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md * Update CHANGELOG.md Co-authored-by: sebastienlagarde <[email protected]> * Fix volumetric fog with XR single-pass (#2823) * fix volumetric fog with XR single-pass rendering * update changelog Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Fix rendering issues for the first frame (#2836) * Fix first frame exposure, depth pyramid / AO * Update changelog * Comment * Typo * Add missing RenderGraphBuilder.ReadTexture call * Move ComputePackedMipChainInfo at the beginning of ExecuteWithRenderGraph Co-authored-by: sebastienlagarde <[email protected]> * Update 5001_Fog_FogFallback.png * Revert "Update 5001_Fog_FogFallback.png" This reverts commit 2653b9c. * Update 5001_Fog_FogFallback.unity * Fix AOV API for render graph (#2909) * Fix AOV api in rendergraph # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs * Update changelog * Fix a small discrepancy in the marker placement in light intensity sliders (#2924) * Update CHANGELOG.md * Fix issue with VT spewing errors when transparent and opaque are disabled (#2925) * Fix * Changelog Co-authored-by: sebastienlagarde <[email protected]> * Fixed a bug in the sphere-aabb light cluster (case 1294767). (#2920) Co-authored-by: sebastienlagarde <[email protected]> * Move EndCameraRendering callback out of the profiling scope (#2917) * Move EndCameraRendering callback out of the profiling scope * added a comment Co-authored-by: sebastienlagarde <[email protected]> * Fixed baked light being included into the ray tracing light cluster (case 1296203). (#2915) Co-authored-by: sebastienlagarde <[email protected]> * Handle all enums the same way for UI (#2913) Co-authored-by: sebastienlagarde <[email protected]> * Changed the message when the graphics device doesn't support ray tracing (case 1287355). (#2916) * [HDRP] Fix default blocks for Hair and Eye shader graphs (#2919) * Fixed default eye shader blocks * Fix missing emission block in hair shader * Updated changelog Co-authored-by: sebastienlagarde <[email protected]> * Init scene camera debug framesettings (#2931) * Fixed using the wrong method to define if a light should be included in the light cluster depending on its baking status. (#2932) * - Fixed using the wrong method to define if a light should be included in the light cluster depending on its baking status. * Update CHANGELOG.md Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Change the behavior of custom passes when the volume is disabled (#2930) * Changed the behavior of custom passes when the Custom Pass Volume component is disabled * Updated changelog * Fixed display of LOD Bias and maximum level in frame settings when using Quality Levels (#2921) * Fixed display of LOD Bias and maximum level in frame settings when using Quality Levels * Update changelog Co-authored-by: sebastienlagarde <[email protected]> * Fixed an issue when trying to open a look dev env library when Look Dev is not supported. (#2929) * Fixed an issue when trying to open a look dev env library when Look Dev is not supported. * Update changelog Co-authored-by: sebastienlagarde <[email protected]> * Enable Reflector for Spotlight by default * - Fixed shader graph not supporting indirectdxr multibounce (case 1294694). (#2933) Co-authored-by: sebastienlagarde <[email protected]> * Fixed the planar depth texture not being properly created and rendered to (case 1299617). (#2926) * Fixed the planar depth texture not being properly created and rendered to (case 1299617). * adding comment Co-authored-by: sebastienlagarde <[email protected]> * Fixed an issue with the frame count management for the volumetric fog (case 1299251). * Update CHANGELOG.md Co-authored-by: Antoine Lelievre <[email protected]> Co-authored-by: Sebastien Lagarde <[email protected]> Co-authored-by: FrancescoC-unity <[email protected]> Co-authored-by: Adrien de Tocqueville <[email protected]> Co-authored-by: Pavlos Mavridis <[email protected]> Co-authored-by: John Parsaie <[email protected]> Co-authored-by: Remi Slysz <[email protected]> Co-authored-by: Frédéric Vauchelles <[email protected]> Co-authored-by: Fabien Houlmann <[email protected]> Co-authored-by: JulienIgnace-Unity <[email protected]>
1 parent a167ca2 commit 5e99f9b

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3030
- Fixed computation of geometric normal in path tracing (case 1293029).
3131
- Fixed issues with path-traced volumetric scattering (cases 1295222, 1295234).
3232
- Fixed the default background color for previews to use the original color.
33+
- Fixed an issue with the frame count management for the volumetric fog (case 1299251).
3334

3435
### Changed
3536
- Removed the material pass probe volumes evaluation mode.

com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ static internal void SafeDestroy(ref RenderTexture rt)
270270
}
271271
}
272272

273+
static uint VolumetricFrameIndex(HDCamera hdCamera)
274+
{
275+
// Here we do modulo 14 because we need the enable to detect a change every frame, but the accumulation is done on 7 frames (7x2=14)
276+
return hdCamera.GetCameraFrameCount() % 14;
277+
}
278+
273279
static internal Vector3Int ComputeVolumetricViewportSize(HDCamera hdCamera, ref float voxelSize)
274280
{
275281
var controller = hdCamera.volumeStack.GetComponent<Fog>();
@@ -356,7 +362,7 @@ static internal void ReinitializeVolumetricBufferParams(HDCamera hdCamera)
356362

357363
// This function relies on being called once per camera per frame.
358364
// The results are undefined otherwise.
359-
static internal void UpdateVolumetricBufferParams(HDCamera hdCamera, int frameIndex)
365+
static internal void UpdateVolumetricBufferParams(HDCamera hdCamera)
360366
{
361367
if (!Fog.IsVolumetricFogEnabled(hdCamera))
362368
return;
@@ -366,6 +372,7 @@ static internal void UpdateVolumetricBufferParams(HDCamera hdCamera, int frameIn
366372

367373
var currentParams = ComputeVolumetricBufferParameters(hdCamera);
368374

375+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
369376
var currIdx = (frameIndex + 0) & 1;
370377
var prevIdx = (frameIndex + 1) & 1;
371378

@@ -419,7 +426,7 @@ struct GenerateMaxZParameters
419426
}
420427

421428

422-
GenerateMaxZParameters PrepareGenerateMaxZParameters(HDCamera hdCamera, HDUtils.PackedMipChainInfo depthMipInfo, int frameIndex)
429+
GenerateMaxZParameters PrepareGenerateMaxZParameters(HDCamera hdCamera, HDUtils.PackedMipChainInfo depthMipInfo)
423430
{
424431
var parameters = new GenerateMaxZParameters();
425432
parameters.generateMaxZCS = defaultResources.shaders.maxZCS;
@@ -436,6 +443,7 @@ GenerateMaxZParameters PrepareGenerateMaxZParameters(HDCamera hdCamera, HDUtils.
436443
parameters.minDepthMipOffset.x = depthMipInfo.mipLevelOffsets[4].x;
437444
parameters.minDepthMipOffset.y = depthMipInfo.mipLevelOffsets[4].y;
438445

446+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
439447
var currIdx = frameIndex & 1;
440448
var currentParams = hdCamera.vBufferParams[currIdx];
441449

@@ -549,7 +557,7 @@ static internal void DestroyVolumetricHistoryBuffers(HDCamera hdCamera)
549557

550558
// Must be called AFTER UpdateVolumetricBufferParams.
551559
static readonly string[] volumetricHistoryBufferNames = new string[2] { "VBufferHistory0", "VBufferHistory1" };
552-
static internal void ResizeVolumetricHistoryBuffers(HDCamera hdCamera, int frameIndex)
560+
static internal void ResizeVolumetricHistoryBuffers(HDCamera hdCamera)
553561
{
554562
if (!hdCamera.IsVolumetricReprojectionEnabled())
555563
return;
@@ -558,6 +566,7 @@ static internal void ResizeVolumetricHistoryBuffers(HDCamera hdCamera, int frame
558566
Debug.Assert(hdCamera.vBufferParams.Length == 2);
559567
Debug.Assert(hdCamera.volumetricHistoryBuffers != null);
560568

569+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
561570
var currIdx = (frameIndex + 0) & 1;
562571
var prevIdx = (frameIndex + 1) & 1;
563572

@@ -627,7 +636,7 @@ internal void DestroyVolumetricLightingBuffers()
627636
}
628637

629638
// Must be called AFTER UpdateVolumetricBufferParams.
630-
internal void ResizeVolumetricLightingBuffers(HDCamera hdCamera, int frameIndex)
639+
internal void ResizeVolumetricLightingBuffers(HDCamera hdCamera)
631640
{
632641
if (!Fog.IsVolumetricFogEnabled(hdCamera))
633642
return;
@@ -643,6 +652,7 @@ internal void ResizeVolumetricLightingBuffers(HDCamera hdCamera, int frameIndex)
643652
CreateVolumetricLightingBuffers();
644653
}
645654

655+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
646656
var currIdx = (frameIndex + 0) & 1;
647657
var prevIdx = (frameIndex + 1) & 1;
648658

@@ -819,11 +829,12 @@ unsafe void SetPreconvolvedAmbientLightProbe(ref ShaderVariablesVolumetric cb, H
819829
cb._AmbientProbeCoeffs[i * 4 + j] = m_PackedCoeffs[i][j];
820830
}
821831

822-
unsafe void UpdateShaderVariableslVolumetrics(ref ShaderVariablesVolumetric cb, HDCamera hdCamera, in Vector4 resolution, int frameIndex)
832+
unsafe void UpdateShaderVariableslVolumetrics(ref ShaderVariablesVolumetric cb, HDCamera hdCamera, in Vector4 resolution)
823833
{
824834
var fog = hdCamera.volumeStack.GetComponent<Fog>();
825835
var vFoV = hdCamera.camera.GetGateFittedFieldOfView() * Mathf.Deg2Rad;
826836
var gpuAspect = HDUtils.ProjectionMatrixAspect(hdCamera.mainViewConstants.projMatrix);
837+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
827838

828839
// Compose the matrix which allows us to compute the world space view direction.
829840
hdCamera.GetPixelCoordToViewDirWS(resolution, gpuAspect, ref m_PixelCoordToViewDirWS);
@@ -886,10 +897,11 @@ unsafe void UpdateShaderVariableslVolumetrics(ref ShaderVariablesVolumetric cb,
886897
cb._NumTileBigTileY = (uint)GetNumTileBigTileY(hdCamera);
887898
}
888899

889-
VolumeVoxelizationParameters PrepareVolumeVoxelizationParameters(HDCamera hdCamera, int frameIndex)
900+
VolumeVoxelizationParameters PrepareVolumeVoxelizationParameters(HDCamera hdCamera)
890901
{
891902
var parameters = new VolumeVoxelizationParameters();
892903

904+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
893905
var currIdx = (frameIndex + 0) & 1;
894906
var prevIdx = (frameIndex + 1) & 1;
895907

@@ -912,7 +924,7 @@ VolumeVoxelizationParameters PrepareVolumeVoxelizationParameters(HDCamera hdCame
912924
parameters.volumeAtlas = CoreUtils.blackVolumeTexture;
913925
}
914926

915-
UpdateShaderVariableslVolumetrics(ref m_ShaderVariablesVolumetricCB, hdCamera, parameters.resolution, frameIndex);
927+
UpdateShaderVariableslVolumetrics(ref m_ShaderVariablesVolumetricCB, hdCamera, parameters.resolution);
916928
parameters.volumetricCB = m_ShaderVariablesVolumetricCB;
917929
parameters.lightListCB = m_ShaderVariablesLightListCB;
918930

@@ -992,10 +1004,11 @@ struct VolumetricLightingParameters
9921004
public ShaderVariablesLightList lightListCB;
9931005
}
9941006

995-
VolumetricLightingParameters PrepareVolumetricLightingParameters(HDCamera hdCamera, int frameIndex)
1007+
VolumetricLightingParameters PrepareVolumetricLightingParameters(HDCamera hdCamera)
9961008
{
9971009
var parameters = new VolumetricLightingParameters();
9981010

1011+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
9991012
var currIdx = (frameIndex + 0) & 1;
10001013
var prevIdx = (frameIndex + 1) & 1;
10011014

@@ -1032,7 +1045,7 @@ VolumetricLightingParameters PrepareVolumetricLightingParameters(HDCamera hdCame
10321045
parameters.filterVolume = ((int)fog.denoisingMode.value & (int)FogDenoisingMode.Gaussian) != 0;
10331046
parameters.sliceCount = (int)(cvp.z);
10341047

1035-
UpdateShaderVariableslVolumetrics(ref m_ShaderVariablesVolumetricCB, hdCamera, parameters.resolution, frameIndex);
1048+
UpdateShaderVariableslVolumetrics(ref m_ShaderVariablesVolumetricCB, hdCamera, parameters.resolution);
10361049
parameters.volumetricCB = m_ShaderVariablesVolumetricCB;
10371050
parameters.lightListCB = m_ShaderVariablesLightListCB;
10381051

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
573573
isFirstFrame = false;
574574
cameraFrameCount++;
575575

576-
HDRenderPipeline.UpdateVolumetricBufferParams(this, hdrp.GetFrameCount());
577-
HDRenderPipeline.ResizeVolumetricHistoryBuffers(this, hdrp.GetFrameCount());
576+
HDRenderPipeline.UpdateVolumetricBufferParams(this);
577+
HDRenderPipeline.ResizeVolumetricHistoryBuffers(this);
578578
}
579579

580580
/// <summary>Set the RTHandle scale to the actual camera size (can be scaled)</summary>

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,15 @@ TextureHandle VolumeVoxelizationPass(RenderGraph renderGraph,
600600
HDCamera hdCamera,
601601
ComputeBuffer visibleVolumeBoundsBuffer,
602602
ComputeBuffer visibleVolumeDataBuffer,
603-
ComputeBufferHandle bigTileLightList,
604-
int frameIndex)
603+
ComputeBufferHandle bigTileLightList)
605604
{
606605
if (Fog.IsVolumetricFogEnabled(hdCamera))
607606
{
608607
using (var builder = renderGraph.AddRenderPass<VolumeVoxelizationPassData>("Volume Voxelization", out var passData))
609608
{
610609
builder.EnableAsyncCompute(hdCamera.frameSettings.VolumeVoxelizationRunsAsync());
611610

612-
passData.parameters = PrepareVolumeVoxelizationParameters(hdCamera, frameIndex);
611+
passData.parameters = PrepareVolumeVoxelizationParameters(hdCamera);
613612
passData.visibleVolumeBoundsBuffer = visibleVolumeBoundsBuffer;
614613
passData.visibleVolumeDataBuffer = visibleVolumeDataBuffer;
615614
if (passData.parameters.tiledLighting)
@@ -657,7 +656,7 @@ TextureHandle GenerateMaxZPass(RenderGraph renderGraph, HDCamera hdCamera, Textu
657656

658657
using (var builder = renderGraph.AddRenderPass<GenerateMaxZMaskPassData>("Generate Max Z Mask for Volumetric", out var passData))
659658
{
660-
passData.parameters = PrepareGenerateMaxZParameters(hdCamera, depthMipInfo, frameIndex);
659+
passData.parameters = PrepareGenerateMaxZParameters(hdCamera, depthMipInfo);
661660
passData.depthTexture = builder.ReadTexture(depthTexture);
662661
passData.maxZ8xBuffer = builder.ReadTexture(renderGraph.ImportTexture(m_MaxZMask8x));
663662
passData.maxZ8xBuffer = builder.WriteTexture(passData.maxZ8xBuffer);
@@ -691,11 +690,12 @@ class VolumetricLightingPassData
691690
public ComputeBufferHandle bigTileLightListBuffer;
692691
}
693692

694-
TextureHandle VolumetricLightingPass(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthTexture, TextureHandle densityBuffer, TextureHandle maxZBuffer, ComputeBufferHandle bigTileLightListBuffer, ShadowResult shadowResult, int frameIndex)
693+
TextureHandle VolumetricLightingPass(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthTexture, TextureHandle densityBuffer, TextureHandle maxZBuffer, ComputeBufferHandle bigTileLightListBuffer, ShadowResult shadowResult)
695694
{
696695
if (Fog.IsVolumetricFogEnabled(hdCamera))
697696
{
698-
var parameters = PrepareVolumetricLightingParameters(hdCamera, frameIndex);
697+
// Evaluate the parameters
698+
var parameters = PrepareVolumetricLightingParameters(hdCamera);
699699

700700
using (var builder = renderGraph.AddRenderPass<VolumetricLightingPassData>("Volumetric Lighting", out var passData))
701701
{
@@ -717,6 +717,7 @@ TextureHandle VolumetricLightingPass(RenderGraph renderGraph, HDCamera hdCamera,
717717

718718
if (passData.parameters.enableReprojection)
719719
{
720+
int frameIndex = (int)VolumetricFrameIndex(hdCamera);
720721
var currIdx = (frameIndex + 0) & 1;
721722
var prevIdx = (frameIndex + 1) & 1;
722723

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
103103

104104
lightingBuffers.contactShadowsBuffer = RenderContactShadows(m_RenderGraph, hdCamera, msaa ? prepassOutput.depthValuesMSAA : prepassOutput.depthPyramidTexture, gpuLightListOutput, GetDepthBufferMipChainInfo().mipLevelOffsets[1].y);
105105

106-
var volumetricDensityBuffer = VolumeVoxelizationPass(m_RenderGraph, hdCamera, m_VisibleVolumeBoundsBuffer, m_VisibleVolumeDataBuffer, gpuLightListOutput.bigTileLightList, m_FrameCount);
106+
var volumetricDensityBuffer = VolumeVoxelizationPass(m_RenderGraph, hdCamera, m_VisibleVolumeBoundsBuffer, m_VisibleVolumeDataBuffer, gpuLightListOutput.bigTileLightList);
107107

108108
RenderShadows(m_RenderGraph, hdCamera, cullingResults, ref shadowResult);
109109

@@ -146,7 +146,7 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
146146

147147
var maxZMask = GenerateMaxZPass(m_RenderGraph, hdCamera, prepassOutput.depthPyramidTexture, m_DepthBufferMipChainInfo, m_FrameCount);
148148

149-
var volumetricLighting = VolumetricLightingPass(m_RenderGraph, hdCamera, prepassOutput.depthPyramidTexture, volumetricDensityBuffer, maxZMask, gpuLightListOutput.bigTileLightList, shadowResult, m_FrameCount);
149+
var volumetricLighting = VolumetricLightingPass(m_RenderGraph, hdCamera, prepassOutput.depthPyramidTexture, volumetricDensityBuffer, maxZMask, gpuLightListOutput.bigTileLightList, shadowResult);
150150

151151
var deferredLightingOutput = RenderDeferredLighting(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.depthPyramidTexture, lightingBuffers, prepassOutput.gbuffer, shadowResult, gpuLightListOutput);
152152

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ out ScriptableCullingParameters cullingParams
22992299

23002300
// From this point, we should only use frame settings from the camera
23012301
hdCamera.Update(currentFrameSettings, this, m_MSAASamples, xrPass);
2302-
ResizeVolumetricLightingBuffers(hdCamera, GetFrameCount()); // Safe to update the Volumetric Lighting System now
2302+
ResizeVolumetricLightingBuffers(hdCamera); // Safe to update the Volumetric Lighting System now
23032303

23042304
// Custom Render requires a proper HDCamera, so we return after the HDCamera was setup
23052305
if (additionalCameraData != null && additionalCameraData.hasCustomRender)

0 commit comments

Comments
 (0)