Skip to content

Fix volumetric fog in planar reflections #4736

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 3 commits into from
Jun 7, 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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed some aliasing ussues with the volumetric clouds.
- Fixed reflection probes being injected into the ray tracing light cluster even if not baked (case 1329083).
- Fixed the double sided option moving when toggling it in the material UI (case 1328877).
- Fixed volumetric fog in planar reflections.

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ GenerateMaxZParameters PrepareGenerateMaxZParameters(HDCamera hdCamera, HDUtils.
{
var parameters = new GenerateMaxZParameters();
parameters.generateMaxZCS = defaultResources.shaders.maxZCS;
parameters.generateMaxZCS.shaderKeywords = null;
bool planarReflection = hdCamera.camera.cameraType == CameraType.Reflection && hdCamera.parentCamera != null;
CoreUtils.SetKeyword(parameters.generateMaxZCS, "PLANAR_OBLIQUE_DEPTH", planarReflection);

parameters.maxZKernel = parameters.generateMaxZCS.FindKernel("ComputeMaxZ");
parameters.maxZDownsampleKernel = parameters.generateMaxZCS.FindKernel("ComputeFinalMask");
parameters.dilateMaxZKernel = parameters.generateMaxZCS.FindKernel("DilateMask");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma kernel ComputeFinalMask FINAL_MASK=1
#pragma kernel DilateMask DILATE_MASK=1

#pragma multi_compile _ PLANAR_OBLIQUE_DEPTH

// In some cases we might want to avoid stopping integrating volumetric even if > max distance if the gradient is very big.
// Realistically, with the dilation step this was never seen as necessary.
Expand Down Expand Up @@ -48,14 +49,20 @@ groupshared float gs_maxDepth[GROUP_SIZE * GROUP_SIZE];

RW_TEXTURE2D_X(float, _OutputTexture);


float GetDepthToDownsample(uint2 pixCoord)
{
float deviceDepth = LoadCameraDepth(pixCoord);
float outputDepth = 0;

if (deviceDepth == UNITY_RAW_FAR_CLIP_VALUE)
outputDepth = 1e10f;
else
#ifdef PLANAR_OBLIQUE_DEPTH
outputDepth = ComputeViewSpacePosition(float2(pixCoord) * _ScreenSize.zw, deviceDepth, UNITY_MATRIX_I_P).z;
#else
outputDepth = LinearEyeDepth(LoadCameraDepth(pixCoord), _ZBufferParams);
#endif

return outputDepth;
}
Expand Down