Skip to content

Commit 47656a8

Browse files
Merge Hd/bugfix #4830
1 parent 158e069 commit 47656a8

File tree

9 files changed

+40
-9
lines changed

9 files changed

+40
-9
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
8686
- Fixed CustomPassUtils scaling issues when used with RTHandles allocated from a RenderTexture.
8787
- Fixed undo of some properties on light editor.
8888
- Fixed material Emission properties not begin animated when recording an animation (case 1328108).
89+
- Fixed volumetric fog in planar reflections.
90+
- Fixed error with motion blur and small render targets.
91+
- Fixed issue with on-demand directional shadow maps looking broken when a reflection probe is updated at the same time.
92+
- Fixed cropping issue with the compositor camera bridge (case 1340549).
8993

9094
### Changed
9195
- Reduced the maximal number of bounces for both RTGI and RTR (case 1318876).
@@ -95,6 +99,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9599
- Changed ray tracing acceleration structure build, so that only meshes with HDRP materials are included (case 1322365).
96100
- Default black texture XR is now opaque (alpha = 1).
97101
- Changed default sidedness to double, when a mesh with a mix of single and double-sided materials is added to the ray tracing acceleration structure (case 1323451).
102+
- Updated the recursive rendering documentation (case 1338639).
98103

99104
## [10.4.0] - 2021-03-11
100105

com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Recursive-Rendering.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This feature is a replacement pipeline for rendering Meshes in the High Definiti
44

55
The smoothness of a Material does not affect the way a ray reflects or refracts, which makes this rendering mode useful for rendering multi-layered transparent GameObjects.
66

7+
HDRP might display the sky color instead of a GameObject that has ray tracing applied. This happens when the GameObject is further away from the Camera than the Max Ray Length value set in the volume component. To make the GameObject appear correctly, increase the value of the Max Ray Length property.
8+
79
![](Images/RayTracingRecursiveRendering1.png)
810

911
**Car gear shift rendered with recursive ray tracing**
@@ -37,5 +39,5 @@ Since recursive rendering uses an independent render pass, HDRP cannot render an
3739
| -------------- | ------------------------------------------------------------ |
3840
| **LayerMask** | Defines the layers that HDRP processes this ray-traced effect for. |
3941
| **Max Depth** | Controls the maximum number of times a ray can reflect or refract before it stops and returns the final color. Increasing this value increases execution time exponentially. |
40-
| **Ray Length** | Controls the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky. |
42+
| **Max Ray Length** | Controls the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky. |
4143
| **Min Smoothness** | Defines the threshold at which reflection rays are not cast if the smoothness value of the target surface is inferior to the one defined by the parameter. |

com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ While you are in the Unity Editor, HDRP updates shadow maps whenever you modify
146146
- SetShadowResolutionOverride()
147147
- SetShadowUpdateMode() or shadowUpdateMode. In this case, HDRP only refreshes the cached shadow maps if the mode changes between Every Frame and not Every Frame).
148148

149-
150149
Be aware that anything that is view-dependent is likely to create problems with cached shadow maps because HDRP does not automatically update them as the main view moves. A non-obvious example of this is tessellation. Because tessellation factor is view-dependent, the geometry that the main camera sees might mismatch the geometry that HDRP rendered into the cached shadow map. If this visibly occurs, trigger a request for HDRP to update the Light's shadow map. To do this, make sure the Light's **Update Mode** is set to **On Demand** and call `RequestShadowMapRendering`.
150+
Another non obvious scenario is when multiple views are available, the light will be updated only for a single view therefore causing the other views to have incorrect results. To avoid a common scenario in which the described artifact will occur, HDRP will not mark a shadow request as completed when performed from reflection probes with view dependent shadows and waiting until a non-reflection camera triggers a shadow update.
151151

152152

153153

com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionManager.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public bool shaderPropertiesAreDirty
152152

153153
ShaderVariablesGlobal m_ShaderVariablesGlobalCB = new ShaderVariablesGlobal();
154154

155+
int m_RecorderTempRT = Shader.PropertyToID("TempRecorder");
156+
155157
static private CompositionManager s_CompositorInstance;
156158

157159
// Built-in Color.black has an alpha of 1, so defien here a fully transparent black
@@ -824,14 +826,14 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera)
824826
if (recorderCaptureActions != null)
825827
{
826828
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrixFlipped;
827-
cmd.SetInvertCulling(true);
828829
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
829-
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, m_Material, m_Material.FindPass("ForwardOnly"));
830+
var format = m_InputLayers[0].GetRenderTarget().format;
831+
cmd.GetTemporaryRT(m_RecorderTempRT, camera.camera.pixelWidth, camera.camera.pixelHeight, 0, FilterMode.Point, format);
832+
cmd.Blit(null, m_RecorderTempRT, m_Material, m_Material.FindPass("ForwardOnly"));
830833
for (recorderCaptureActions.Reset(); recorderCaptureActions.MoveNext();)
831834
{
832-
recorderCaptureActions.Current(BuiltinRenderTextureType.CameraTarget, cmd);
835+
recorderCaptureActions.Current(m_RecorderTempRT, cmd);
833836
}
834-
cmd.SetInvertCulling(false);
835837
}
836838

837839
// When we render directly to game view, we render the image flipped up-side-down, like other HDRP cameras

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,8 @@ internal int UpdateShadowRequest(HDCamera hdCamera, HDShadowManager manager, HDS
22462246
shadowRequest.cachedAtlasViewport = resolutionRequest.cachedAtlasViewport;
22472247
manager.UpdateShadowRequest(shadowRequestIndex, shadowRequest, updateType);
22482248

2249-
if (needToUpdateCachedContent)
2249+
if (needToUpdateCachedContent && (lightType != HDLightType.Directional ||
2250+
hdCamera.camera.cameraType != CameraType.Reflection))
22502251
{
22512252
// Handshake with the cached shadow manager to notify about the rendering.
22522253
// Technically the rendering has not happened yet, but it is scheduled.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ GenerateMaxZParameters PrepareGenerateMaxZParameters(HDCamera hdCamera, HDUtils.
414414
{
415415
var parameters = new GenerateMaxZParameters();
416416
parameters.generateMaxZCS = defaultResources.shaders.maxZCS;
417+
parameters.generateMaxZCS.shaderKeywords = null;
418+
bool planarReflection = hdCamera.camera.cameraType == CameraType.Reflection && hdCamera.parentCamera != null;
419+
CoreUtils.SetKeyword(parameters.generateMaxZCS, "PLANAR_OBLIQUE_DEPTH", planarReflection);
420+
417421
parameters.maxZKernel = parameters.generateMaxZCS.FindKernel("ComputeMaxZ");
418422
parameters.maxZDownsampleKernel = parameters.generateMaxZCS.FindKernel("ComputeFinalMask");
419423
parameters.dilateMaxZKernel = parameters.generateMaxZCS.FindKernel("DilateMask");

com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,8 +2745,8 @@ MotionBlurParameters PrepareMotionBlurParameters(HDCamera camera)
27452745
tileSize = 16;
27462746
}
27472747

2748-
int tileTexWidth = Mathf.CeilToInt(camera.actualWidth / tileSize);
2749-
int tileTexHeight = Mathf.CeilToInt(camera.actualHeight / tileSize);
2748+
int tileTexWidth = Mathf.CeilToInt(camera.actualWidth / (float)tileSize);
2749+
int tileTexHeight = Mathf.CeilToInt(camera.actualHeight / (float)tileSize);
27502750
parameters.tileTargetSize = new Vector4(tileTexWidth, tileTexHeight, 1.0f / tileTexWidth, 1.0f / tileTexHeight);
27512751

27522752
float screenMagnitude = (new Vector2(camera.actualWidth, camera.actualHeight).magnitude);

com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldTileMax.compute

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ void KMain(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupThreadId : S
3636
{
3737
uint threadIdx = groupThreadId.y * TILE_SIZE + groupThreadId.x;
3838

39+
#if NEAR
3940
gs_cacheNear[threadIdx] = _InputNearCoCTexture[COORD_TEXTURE2D_X(min(dispatchThreadId, Size))].x;
41+
#endif
42+
43+
#if FAR
4044
gs_cacheFar[threadIdx] = _InputFarCoCTexture[COORD_TEXTURE2D_X(min(dispatchThreadId, Size))].x;
45+
#endif
4146

4247
GroupMemoryBarrierWithGroupSync();
4348

@@ -47,8 +52,13 @@ void KMain(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupThreadId : S
4752
{
4853
if (threadIdx < s)
4954
{
55+
#if NEAR
5056
gs_cacheNear[threadIdx] = max(gs_cacheNear[threadIdx], gs_cacheNear[threadIdx + s]);
57+
#endif
58+
59+
#if FAR
5160
gs_cacheFar[threadIdx] = max(gs_cacheFar[threadIdx], gs_cacheFar[threadIdx + s]);
61+
#endif
5262
}
5363

5464
GroupMemoryBarrierWithGroupSync();

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/GenerateMaxZ.compute

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma kernel ComputeFinalMask FINAL_MASK=1
99
#pragma kernel DilateMask DILATE_MASK=1
1010

11+
#pragma multi_compile _ PLANAR_OBLIQUE_DEPTH
1112

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

4950
RW_TEXTURE2D_X(float, _OutputTexture);
5051

52+
5153
float GetDepthToDownsample(uint2 pixCoord)
5254
{
5355
float deviceDepth = LoadCameraDepth(pixCoord);
5456
float outputDepth = 0;
57+
5558
if (deviceDepth == UNITY_RAW_FAR_CLIP_VALUE)
5659
outputDepth = 1e10f;
5760
else
61+
#ifdef PLANAR_OBLIQUE_DEPTH
62+
outputDepth = ComputeViewSpacePosition(float2(pixCoord) * _ScreenSize.zw, deviceDepth, UNITY_MATRIX_I_P).z;
63+
#else
5864
outputDepth = LinearEyeDepth(LoadCameraDepth(pixCoord), _ZBufferParams);
65+
#endif
5966

6067
return outputDepth;
6168
}

0 commit comments

Comments
 (0)