Skip to content

Commit

Permalink
[HDRP] Bunch of fixes for HDRP (Version 23)
Browse files Browse the repository at this point in the history
Gathering of PRs

[SpeedTree] Fix flying static trees (#35468) 
[HDRP] Fix Turkish OS incorrectly deducing DLSS is not available due to culture-variant lowercasing in DLSSPass.cs (#36628)
Update ReflectionProxyVolumeComponentEditor.cs (#36658) 
Change shadowsWithValidData access to TryAdd (#36678)
[HDRP][XR] Skip rendering when XR renders terrain in multipass with multicull. (#35449)
Updating path tracing docs with lack of box light support. (#36713) 
Limit lightShadowCasterMode to only affect caster culling when using shadowmask (#36637)
[SpeedTree] ImporterInspector: Fix null ref exception when making/saving changes on the asset (#36028)
add object space (#36542)
[HDRP] Update documentation to add limitation for an issue with Decal (#28587)
Updated documentation for view dependent changes (#35348)
Reset decal cached draw distances (#36642)
  • Loading branch information
sebastienlagarde authored and Evergreen committed Oct 11, 2023
1 parent 4daa43c commit ce6dbc5
Show file tree
Hide file tree
Showing 19 changed files with 849 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Shader "Hidden/Core/FallbackError"
{
SubShader
{
Tags
{
"DisableBatching" = "true"
}
Pass
{
CGPROGRAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ To remove this angle constraint on the normal at the cost of a higher memory usa

- A Decal Projector can only affect transparent Materials when you enable the **Affect Transparent** checkbox.

- With [Lit Shader Mode](Frame-Settings.md) setup to **Deferred**. Decals projected on objects relying on object motion vectors (Deformed objects) can exhibit artifacts like being visible even if not in the projector frustrum. This can be fixed by enabling **Full Depth Prepass within Deferred** option in [FrameSettings](Frame-Settings.md).

### Migration of data previous to Unity 2020.2

When you convert a project from 2020.2, Mesh renderers and Terrain do not receive any decals by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ These settings determine the method that the Cameras and Reflection Probes using
</tr>
<tr>
<td></td>
<td><strong>Depth Prepass within Deferred</strong></td>
<td>If you enable Decals then HDRP forces a depth prepass and you can not disable this feature. This feature fills the depth buffer with all Meshes, without rendering any color. It's an optimization option that depends on the Unity Project you are creating, meaning that you should measure the performance before and after you enable this feature to make sure it benefits your Project. This is only available if you set <strong>Lit Shader Mode</strong> to <strong>Deferred</strong>.</td>
<td><strong>Full Depth Prepass within Deferred</strong></td>
<td>By default HDRP try to minimize the number of Meshes sent in the depth prepass. This feature fills the depth buffer during depth prepass with all Meshes, without rendering any color. It's an optimization option that depends on the Unity Project you are creating, meaning that you should measure the performance before and after you enable this feature to make sure it benefits your Project. This is only available if you set <strong>Lit Shader Mode</strong> to <strong>Deferred</strong>.</td>
</tr>
<tr>
<td></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ HDRP ray tracing in Unity isn't compatible with the following features:
- Vertex animation, for example wind deformation of vegetation.
- Emission of [decals](Decal.md).
- Ray tracing is not compatible with the detail meshes and trees in the [Terrain system](https://docs.unity3d.com/Manual/script-Terrain.html). It is compatible with terrain geometry. To include detailed meshes and trees in ray traced reflections, use [mixed tracing](Override-Screen-Space-Reflection.md#mixed-tracing).
- Box-shaped spot lights.
- Volumetric [fog](Override-Fog.md).
- [Tessellation](Tessellation.md).
- Per-pixel displacement techniques such as parallax occlusion mapping, depth offset, and non-terrain height maps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ This setup is particularly useful if your environment consists of mostly static

**Note**: If a Light with mixed cached shadows moves and you don't update the cached counterpart, the result looks wrong. In such cases either enable the Light's **Update on light movement** option or set the Light's update mode to **OnDemand** and make sure to trigger an update when you move the Light.

### View Dependent Update

Anything that's view-dependent is likely to create problems with cached shadow maps because HDRP doesn't automatically update them as the main view moves. An example of this is tessellation. Tessellation factor is view-dependent, so the geometry that the main camera sees might not match 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 you set the Light's **Update Mode** to **On Demand** and call `RequestShadowMapRendering`.

Another example 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 won't 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.

#### Directional Light Update

The shadow cascades of a directional light are always view dependent. This means that camera movement that changes view direction or moves outside of the area in which the cached cascades were captured will lead to artifacts if the cached shadows are not updated. These artifacts can manifest as incorrect shadows around the camera or at the edges of cascades.

Because of this it is advisable to use **Update Mode** with **On Demand** and call `RequestShadowMapRendering` frequently if the main camera is moved to avoid artifacts.

### Notes

While you are in the Unity Editor, HDRP updates shadow maps whenever you modify the Light that casts them. In a built application, HDRP refreshes cached shadow maps when you change different properties on the Light or when you call one of the following functions:
Expand All @@ -202,10 +214,6 @@ While you are in the Unity Editor, HDRP updates shadow maps whenever you modify
- `SetShadowResolutionOverride()`
- `SetShadowUpdateMode()` or `shadowUpdateMode`. In this case, HDRP only refreshes the cached shadow maps if the mode changes between Every Frame and not Every Frame.

Anything that's view-dependent is likely to create problems with cached shadow maps because HDRP doesn't automatically update them as the main view moves. An example of this is tessellation. Tessellation factor is view-dependent, so the geometry that the main camera sees might not match 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 you set the Light's **Update Mode** to **On Demand** and call `RequestShadowMapRendering`.

Another example 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 won't 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.

## Contact Shadows

Contact Shadows are shadows that HDRP [ray marches](Glossary.md#RayMarching) in screen space, inside the depth buffer, at a close range. They provide small, detailed, shadows for details in geometry that shadow maps can't usually capture.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tr>
<td>**Add Custom Velocity**</td>
<td>Indicates whether HDRP changes the motion vector according to the provided velocity. HDRP adds the provided velocity (the difference between the current frame position and the last frame position) to the motion vector calculation. This provides correct motion vector calculations for any procedural geometry that HDRP calculates outside of Shader Graph. The motion vector still takes into account other deformations (for example, skinning or vertex animation).</td>
<td>Indicates whether HDRP changes the motion vector according to the provided velocity. HDRP adds the provided velocity (the difference between the current frame position and the last frame position in Object space) to the motion vector calculation. This provides correct motion vector calculations for any procedural geometry that HDRP calculates outside of Shader Graph. The motion vector still takes into account other deformations (for example, skinning or vertex animation).</td>
</tr>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using UnityEditor.Rendering;
using Object = UnityEngine.Object;

namespace UnityEditor.Rendering.HighDefinition
{
Expand All @@ -10,23 +12,30 @@ class ReflectionProxyVolumeComponentEditor : Editor
{
static readonly Color k_HandleColor = new Color(0 / 255f, 0xE5 / 255f, 0xFF / 255f, 1f).gamma;

HierarchicalSphere m_SphereHandle;
HierarchicalBox m_BoxHandle;
SerializedReflectionProxyVolumeComponent m_SerializedData;
ReflectionProxyVolumeComponent[] m_TypedTargets;
static ReflectionProxyVolumeComponent[] s_TypedTargets;

void OnEnable()
private static Lazy<HierarchicalSphere> s_SphereHandle = new Lazy<HierarchicalSphere>(() =>
{
m_SerializedData = new SerializedReflectionProxyVolumeComponent(serializedObject);
System.Array.Resize(ref m_TypedTargets, serializedObject.targetObjects.Length);
for (int i = 0; i < serializedObject.targetObjects.Length; ++i)
m_TypedTargets[i] = (ReflectionProxyVolumeComponent)serializedObject.targetObjects[i];
var value = new HierarchicalSphere(k_HandleColor);
return value;
});

m_SphereHandle = new HierarchicalSphere(k_HandleColor);
m_BoxHandle = new HierarchicalBox(k_HandleColor, new[] { k_HandleColor, k_HandleColor, k_HandleColor, k_HandleColor, k_HandleColor, k_HandleColor })
private static Lazy<HierarchicalBox> s_BoxHandle = new Lazy<HierarchicalBox>(() =>
{
var value = new HierarchicalBox(k_HandleColor, new[] { k_HandleColor, k_HandleColor, k_HandleColor, k_HandleColor, k_HandleColor, k_HandleColor })
{
monoHandle = false
};
return value;
});

void OnEnable()
{
m_SerializedData = new SerializedReflectionProxyVolumeComponent(serializedObject);
System.Array.Resize(ref s_TypedTargets, serializedObject.targetObjects.Length);
for (int i = 0; i < serializedObject.targetObjects.Length; ++i)
s_TypedTargets[i] = (ReflectionProxyVolumeComponent)serializedObject.targetObjects[i];
}

public override void OnInspectorGUI()
Expand All @@ -38,48 +47,56 @@ public override void OnInspectorGUI()
m_SerializedData.Apply();
}

void OnSceneGUI()
[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
static void DrawGizmosSelected(ReflectionProxyVolumeComponent proxyVolumeComponent, GizmoType gizmoType)
{
for (int i = 0; i < m_TypedTargets.Length; ++i)
{
var comp = m_TypedTargets[i];
var tr = comp.transform;
var prox = comp.proxyVolume;

using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, tr.rotation, Vector3.one)))
for (int i = 0; i < s_TypedTargets.Length; ++i)
{
switch (prox.shape)
var comp = s_TypedTargets[i];
var tr = comp.transform;
var prox = comp.proxyVolume;

var matrix = Matrix4x4.TRS(Vector3.zero, tr.rotation, Vector3.one);
if (matrix.ValidTRS())
{
case ProxyShape.Box:
m_BoxHandle.center = Quaternion.Inverse(tr.rotation) * tr.position;
m_BoxHandle.size = prox.boxSize;
EditorGUI.BeginChangeCheck();
m_BoxHandle.DrawHull(true);
m_BoxHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObjects(new Object[] { tr, comp }, "Update Proxy Volume Size");
tr.position = tr.rotation * m_BoxHandle.center;
prox.boxSize = m_BoxHandle.size;
}
break;
case ProxyShape.Sphere:
m_SphereHandle.center = Quaternion.Inverse(tr.rotation) * tr.position;
m_SphereHandle.radius = prox.sphereRadius;
EditorGUI.BeginChangeCheck();
m_SphereHandle.DrawHull(true);
m_SphereHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
using (new Handles.DrawingScope(matrix))
{
switch (prox.shape)
{
Undo.RecordObjects(new Object[] { tr, comp }, "Update Proxy Volume Size");
tr.position = tr.rotation * m_SphereHandle.center;
prox.sphereRadius = m_SphereHandle.radius;
case ProxyShape.Box:
s_BoxHandle.Value.center = Quaternion.Inverse(tr.rotation) * tr.position;
s_BoxHandle.Value.size = prox.boxSize;
EditorGUI.BeginChangeCheck();
s_BoxHandle.Value.DrawHull(true);
s_BoxHandle.Value.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObjects(new Object[] {tr, comp}, "Update Proxy Volume Size");
tr.position = tr.rotation * s_BoxHandle.Value.center;
prox.boxSize = s_BoxHandle.Value.size;
}

break;
case ProxyShape.Sphere:
s_SphereHandle.Value.center = Quaternion.Inverse(tr.rotation) * tr.position;
s_SphereHandle.Value.radius = prox.sphereRadius;
EditorGUI.BeginChangeCheck();
s_SphereHandle.Value.DrawHull(true);
s_SphereHandle.Value.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObjects(new Object[] {tr, comp}, "Update Proxy Volume Size");
tr.position = tr.rotation * s_SphereHandle.Value.center;
prox.sphereRadius = s_SphereHandle.Value.radius;
}

break;
case ProxyShape.Infinite:
break;
}
break;
case ProxyShape.Infinite:
break;
}
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_DrawDistanceProperty, k_DistanceContent);
if (EditorGUI.EndChangeCheck() && m_DrawDistanceProperty.floatValue < 0f)
m_DrawDistanceProperty.floatValue = 0f;
if (m_DrawDistanceProperty.floatValue > DecalSystem.instance.DrawDistance)
{
EditorGUILayout.HelpBox(String.Format(DecalSystem.s_GlobalDrawDistanceWarning, DecalSystem.instance.DrawDistance), MessageType.Warning);
}

EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent);
using (new EditorGUI.DisabledScope(!decalLayerEnabled))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public void UpdateNonDirectionalCachedRequests(LightType lightType,
{
// Handshake with the cached shadow manager to notify about the rendering.
// Technically the rendering has not happened yet, but it is scheduled.
cachedShadowAtlas.shadowsWithValidData.Add(cachedShadowID, cachedShadowID);
cachedShadowAtlas.shadowsWithValidData.TryAdd(cachedShadowID, cachedShadowID);
}
}

Expand Down
Loading

0 comments on commit ce6dbc5

Please sign in to comment.