Skip to content
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

Internal/2021.3/staging #8124

Merged
merged 10 commits into from
Jan 22, 2025
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 @@ -42,7 +42,7 @@ You can use AOVs to output the contribution from a selected list of [Lights](Lig
## Custom Pass AOVs
Finally, you can use AOVs to output the results of [custom passes](Custom-Pass.md). In particular, you can output the cumulative results of all custom passes that are active on every custom pass injection point. This can be useful to output arbitrary information that custom passes compute, such as the Object ID of the Scene GameObjects.

## Rendering Precission
## Rendering precision
By default AOVs are rendering at the precision and format selected in the HDRP asset. If the AOVRequest is configured with *SetOverrideRenderFormat* option set to true, then rendering will use the same precision as the user allocated AOV output buffer.

## Scripting API example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can use the **Volume Profiles** section to assign and edit a [Volume Profile

The **Default Volume Profile Asset** (A) references a Volume Profile in the HDRP package folder called `DefaultSettingsVolumeProfile` by default. Below it, you can add [Volume overrides](Volume-Components.md), and edit their properties. You can assign your own Volume Profile to this property field. Be aware that this property must always reference a Volume Profile. If you assign your own Volume Profile and then delete it, HDRP automatically re-assigns the `DefaultSettingsVolumeProfile` from the HDRP package folder.

The **LookDev Volume Profile Asset** (B) references the Volume Profile HDRP uses in the [LookDev window](Look-Dev.md). This Asset works in almost the same way as the Default Volume Profile Asset, except that it overrides [Visual Environment Components](Override-Visual-Environment.md) and sky components.![](Images/HDRPgs_Volume_Profiles.png)
The **LookDev Volume Profile Asset** (B) references the Volume Profile HDRP uses in the [LookDev window](Look-Dev.md). This Asset works in almost the same way as the Default Volume Profile Asset, except it overrides [Visual Environment Components](Override-Visual-Environment.md) and sky components.

## Diffusion Profile Assets

Expand Down Expand Up @@ -44,8 +44,6 @@ Use this section to select which custom post processing effect HDRP uses in the

HDRP provides one list for each post processing injection point. See the [Custom Post Process](Custom-Post-Process.md) documentation for more details.

![](Images/HDRPgs_Custom_PP.png)

## Miscellaneous

| **Property** | **Description** |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Forward and Deferred rendering both implement the same features, but the quality

## Differences between Forward and Deferred rendering in HDRP

| **Feature** | **Forward Rendering** | **Defferred** |
| **Feature** | **Forward Rendering** | **Deferred** |
|---|---|---|
| **Normal shadow bias** | HDRP uses the geometric normal (the vertex normal) of the Material for shadow bias, so Forward Rendering produces fewer shadow artifacts. | HDRP uses the pixel normal of the Material for shadow bias, so Deferred Rendering produces more shadow artifacts. |
| **Emissive Color** | Ambient Occlusion doesn't affect Emissive Color. | Ambient Occlusion affects Emissive Color due to technical constraints. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Frame Settings are settings HDRP uses to render Cameras, real-time, baked, and custom reflections. You can set the default values for Frame Settings for each of these three individually from within the [HDRP Global Settings](Default-Settings-Window.md) tab (menu: **Edit** > **Project Settings** > **Graphics** > **HDRP Global Settings**).

![](Images/FrameSettings1.png)

To make Cameras and Reflection Probes use their respective default values for Frame Settings, disable the **Custom Frame Settings** checkbox under the **General** settings of Cameras or under **Capture Settings** of Reflection Probes.

You can override the default value of a Frame Setting on a per component basis. Enable the **Custom Frame Settings** checkbox to set specific Frame Settings for individual Cameras and Reflection Probes. This exposes the Frame Settings Override which gives you access to the same settings as within the HDRP Global Settings. Edit the settings within the Frame Settings Override to create a Frame Settings profile for an individual component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ This section includes all the menu items under the **Edit > Rendering > Decal La

This section includes all the menu items under the **Edit > Rendering > Materials** menu fold-out.

For more information, refer to [Convert materials and shaders](convert-from-built-in-convert-materials-and-shaders).

| **Item** | **Description** |
| ----------------------------------------------- | ------------------------------------------------------------ |
| **Upgrade HDRP Materials to Latest Version** | Upgrades all HDRP Materials in the project to the latest version. This is useful if HDRP's automatic Material upgrade process fails to upgrade a Material. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ The property to enable in your Frame Settings is: **Lighting > Contact Shadows**

You can enable Contact Shadows on a per Light basis for Directional, Point, and Spot Lights. Tick the **Enable** checkbox under the **Contact Shadows** drop-down in the **Shadows** section of each Light to indicate that HDRP should calculate Contact Shadows for that Light.

Only one Light can cast Contact Shadows at a time. This means that, if you have more than one Light that casts Contact Shadows visible on the screen, only the dominant Light renders Contact Shadows. HDRP chooses the dominant Light using the screen space size of the Light’s bounding box. A Directional Light that casts Contact Shadows is always the dominant Light.

**Note**: A Light casts Contact Shadows for every Mesh Renderer that uses a Material that writes to the depth buffer. This is regardless of whether you enable or disable the **Cast Shadows** property on the Mesh Renderer. This means that you can disable **Cast Shadows** on small GameObjects/props and still have them cast Contact Shadows. This is good if you do not want HDRP to render these GameObjects in shadow maps. If you do not want this behavior, use Shader Graph to author a Material that does not write to the depth buffer.

[!include[](snippets/volume-override-api.md)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Micro Shadows

Micro shadows are shadows that the High Definition Render Pipeline (HDRP) simulates for small details embedded in the Material of a GameObject, but not in its Mesh geometry. HDRP uses the details from the normal map and the ambient occlusion map to estimate the shadows those maps would cast if they were Meshes.
Micro shadows are shadows that the High Definition Render Pipeline (HDRP) simulates for small details embedded in the Material of a GameObject, but not in its Mesh geometry.

HDRP uses the details from the normal map, the ambient occlusion map, and specular occlusion to estimate the shadows those details would cast if they were meshes.

In this image, the different layers of details in the Material shadow each other.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Using these three things, HDRP generates volumetric clouds in a two-step process

[!include[](snippets/Volume-Override-Enable-Override.md)]

* In your [HDRP Asset](HDRP Asset) go to **Lighting > Volumetrics > Volumetric Clouds**.
* In your [HDRP Asset](HDRP-Asset.md) go to **Lighting > Volumetrics > Volumetric Clouds**.

* In your [Frame Settings](Frame-Settings.md) go to **Lighting > Volumetric Clouds**.

Expand Down Expand Up @@ -126,6 +126,7 @@ When importing these two map Textures, disable **sRGB**. For best results, do no
| -------------------------------- | ------------------------------------------------------------ |
| **Temporal Accumulation Factor** | The amount of temporal accumulation to apply to the clouds. Temporal accumulation increases the visual quality of clouds by decreasing the noise. A higher value produces better quality clouds, but can create [ghosting](Glossary.md#ghosting). |
| **Ghosting Reduction** | When you enable this property, HDRP removes the ghosting caused by temporal accumulation. This effect might cause a flickering effect when the **Temporal Accumulation Factor** value is low. |
| **Perceptual Blending** | Blend the clouds with the environment. This might cause artifacts if the sky is overexposed. This setting only has an effect when you disable multi-sample antialiasing (MSAA). |
| **Num Primary Steps** | The number of steps to use to evaluate the clouds' transmittance. Higher values linearly increase the resource intensity of the effect. |
| **Num Light Steps** | The number of steps to use to evaluate the clouds' lighting. Higher values exponent increase the resource intensity of the effect. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ For more information, see [System requirements for Unity](https://docs.unity3d.c
HRDP is only compatible with the following platforms:

- Windows and Windows Store, with DirectX 11 or DirectX 12 and Shader Model 5.0
- Google
- Stadia
- Sony
- PlayStation 4
- PlayStation 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ To upgrade the Materials in your Scene to HDRP-compatible Materials:
The automatic upgrade options described above can't upgrade all Materials to HDRP correctly:

* You can't automatically upgrade custom Materials or Shaders to HDRP. You must [convert custom Materials and Shaders manually](#ManualConversion).
* HDRP can only convert materials from the **Assets** folder of your project. HDRP uses the [error shader](xref:shader-error) for GameObjects that use the default read-only material from the Built-In Render Pipeline, for example [primitives](xref:um-primitive-objects).
* Height mapped Materials might look incorrect. This is because HDRP supports more height map displacement techniques and decompression options than the Built-in Render Pipeline. To upgrade a Material that uses a heightmap, modify the Material's **Amplitude** and **Base** properties until the result more closely matches the Built-in Render Pipeline version.
* You can't upgrade particle shaders. HDRP doesn't support particle shaders, but it does provide Shader Graphs that are compatible with the [Built-in Particle System](https://docs.unity3d.com/Manual/Built-inParticleSystem.html). These Shader Graphs work in a similar way to the built-in particle shaders. To use these Shader Graphs, import the **Particle System Shader Samples** sample:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ You can also watch the presentation from Unite Copenhagen (October 2019) to lear
* **PC with DX11**:
* Oculus Rift & Rift S (Oculus XR Plugin, Windows 10, DirectX 11)
* Windows Mixed Reality (Windows XR Plugin, Windows 10, DirectX 11)
* Open VR
* **PS4**:
* PlayStationVR
* Open VR*

**Note**: Valve is currently developing their OpenVR Unity XR plugin for 2019.3 and beyond.
For more information, see [Unity XR platform updates](https://blogs.unity3d.com/2020/01/24/unity-xr-platform-updates/) on the Unity blog, and [XR Plugin Architecture](https://docs.unity3d.com/Manual/XRPluginArchitecture.html) in the Unity Manual.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,19 @@ SHADOW_TYPE EvaluateShadow_Directional( LightLoopContext lightLoopContext, Posit
shadow = lightLoopContext.shadowValue;

#ifdef SHADOWS_SHADOWMASK
float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition();
float distanceCamToPixel2 = dot(camToPixel, camToPixel);

int shadowSplitIndex = lightLoopContext.shadowContext.shadowSplitIndex;
if (shadowSplitIndex < 0)
{
shadow = shadowMask;
}
else if (shadowSplitIndex == int(_CascadeShadowCount) - 1)
{
float fade = lightLoopContext.shadowContext.fade;
// float fade = lightLoopContext.shadowContext.fade;
float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition();
float distanceCamToPixel2 = dot(camToPixel, camToPixel);

HDDirectionalShadowData dsd = lightLoopContext.shadowContext.directionalShadowData;
float fade = saturate(distanceCamToPixel2 * dsd.fadeScale + dsd.fadeBias);
// In the transition code (both dithering and blend) we use shadow = lerp( shadow, 1.0, fade ) for last transition
// mean if we expend the code we have (shadow * (1 - fade) + fade). Here to make transition with shadow mask
// we will remove fade and add fade * shadowMask which mean we do a lerp with shadow mask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, Vector2 historySiz
}
else
{
parameters.runningRes = new Vector2(Mathf.RoundToInt(camera.actualWidth * 0.5f), Mathf.RoundToInt(camera.actualHeight * 0.5f));
// Ceil is needed because we upsample the AO too, round would loose a pixel is the resolution is odd
parameters.runningRes = new Vector2(Mathf.CeilToInt(camera.actualWidth * 0.5f), Mathf.CeilToInt(camera.actualHeight * 0.5f));
cb._AOBufferSize = new Vector4(parameters.runningRes.x, parameters.runningRes.y, 1.0f / parameters.runningRes.x, 1.0f / parameters.runningRes.y);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ unsafe struct HDDirectionalShadowData
[HLSLArray(4, typeof(float))]
[SurfaceDataAttributes(precision = FieldPrecision.Real)]
public fixed float cascadeBorders[4];

public float fadeScale;
public float fadeBias;
}

class HDShadowRequest
Expand Down Expand Up @@ -754,7 +757,10 @@ unsafe public void PrepareGPUShadowDatas(CullingResults cullResults, HDCamera ca
else
m_DirectionalShadowData.cascadeDirection = Vector4.zero;

m_DirectionalShadowData.cascadeDirection.w = camera.volumeStack.GetComponent<HDShadowSettings>().cascadeShadowSplitCount.value;
HDShadowSettings shadowSettings = camera.volumeStack.GetComponent<HDShadowSettings>();
m_DirectionalShadowData.cascadeDirection.w = shadowSettings.cascadeShadowSplitCount.value;

GetShadowFadeScaleAndBias(shadowSettings, out m_DirectionalShadowData.fadeScale, out m_DirectionalShadowData.fadeBias);

if (m_ShadowRequestCount > 0)
{
Expand All @@ -765,6 +771,45 @@ unsafe public void PrepareGPUShadowDatas(CullingResults cullResults, HDCamera ca
}
}

void GetShadowFadeScaleAndBias(HDShadowSettings shadowSettings, out float scale, out float bias)
{
float maxShadowDistance = shadowSettings.maxShadowDistance.value;
float maxShadowDistanceSq = maxShadowDistance * maxShadowDistance;
float cascadeBorder;
int splitCount = shadowSettings.cascadeShadowSplitCount.value;
if (splitCount == 4)
cascadeBorder = shadowSettings.cascadeShadowBorder3.value;
else if (splitCount == 3)
cascadeBorder = shadowSettings.cascadeShadowBorder2.value;
else if (splitCount == 2)
cascadeBorder = shadowSettings.cascadeShadowBorder1.value;
else
cascadeBorder = shadowSettings.cascadeShadowBorder0.value;

GetScaleAndBiasForLinearDistanceFade(maxShadowDistanceSq, cascadeBorder, out scale, out bias);
}

void GetScaleAndBiasForLinearDistanceFade(float fadeDistance, float border, out float scale, out float bias)
{
// To avoid division from zero
// This values ensure that fade within cascade will be 0 and outside 1
if (border < 0.0001f)
{
float multiplier = 1000f; // To avoid blending if difference is in fractions
scale = multiplier;
bias = -fadeDistance * multiplier;
return;
}

border = 1 - border;
border *= border;

// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarily chosen but should work well enough.
float distanceFadeNear = border * fadeDistance;
scale = 1.0f / (fadeDistance - distanceFadeNear);
bias = -distanceFadeNear / (fadeDistance - distanceFadeNear);
}

public void PushGlobalParameters(CommandBuffer cmd)
{
// This code must be in sync with HDShadowContext.hlsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct HDDirectionalShadowData
float4 sphereCascades[4];
real4 cascadeDirection;
real cascadeBorders[4];
float fadeScale;
float fadeBias;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ IndirectLighting EvaluateBSDF_ScreenSpaceReflection(PositionInputs posInput,
//
// Note that the SSR with clear coat is a binary state, which means we should never enter the if condition if we don't have an active
// clear coat (which is not guaranteed by the HasFlag condition in deferred mode in some cases). We then need to make sure that coatMask is actually non zero.
if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) && bsdfData.coatMask > 0.0)
if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) && bsdfData.coatMask >= 0.0)
{
// We use the coat-traced light according to how similar the base lobe roughness is to the coat roughness
// (we can assume the coat is always smoother):
Expand Down
Loading
Loading