Skip to content

Commit 1099929

Browse files
Merge Hd/bugfix #4265
1 parent 84e5df4 commit 1099929

File tree

13 files changed

+65
-36
lines changed

13 files changed

+65
-36
lines changed

com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ public void Release()
141141
/// <returns>Input size scaled by the RTHandle scale factor.</returns>
142142
public Vector2Int GetScaledSize(Vector2Int refSize)
143143
{
144+
if (!useScaling)
145+
return refSize;
146+
144147
if (scaleFunc != null)
145148
{
146149
return scaleFunc(refSize);

com.unity.render-pipelines.core/ShaderLibrary/AreaLighting.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ real3 ComputeEdgeFactor(real3 V1, real3 V2)
2121
if (V1oV2 < 0)
2222
{
2323
// Undo range reduction.
24-
y = PI * rsqrt(saturate(1 - V1oV2 * V1oV2)) - y;
24+
const float epsilon = 1e-5f;
25+
y = PI * rsqrt(max(epsilon, saturate(1 - V1oV2 * V1oV2))) - y;
2526
}
2627

2728
return V1xV2 * y;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3737
- Fixed issue with the color space of AOVs (case 1324759)
3838
- Fixed issue with history buffers when using multiple AOVs (case 1323684).
3939
- Fixed camera preview with multi selection (case 1324126).
40+
- Fixed GBuffer clear option in FrameSettings not working
41+
- Fixed usage of Panini Projection with floating point HDRP and Post Processing color buffers.
42+
- Fixed a NaN generating in Area light code.
43+
- Fixed CustomPassUtils scaling issues when used with RTHandles allocated from a RenderTexture.
4044

4145
### Changed
4246
- Reduced the maximal number of bounces for both RTGI and RTR (case 1318876).
@@ -49,6 +53,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4953
- Increased path tracing max samples from 4K to 16K (case 1327729).
5054
- Changed ray tracing acceleration structure build, so that only meshes with HDRP materials are included (case 1322365).
5155
- Default black texture XR is now opaque (alpha = 1).
56+
- 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).
5257

5358
## [10.4.0] - 2021-03-11
5459

com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Getting started with ray tracing
22

3-
The High Definition Render Pipeline (HDRP) includes preview ray tracing support from Unity 2019.3. Ray tracing is a feature that allows you to access data that is not on screen. For example, you can use it to request position data, normal data, or lighting data, and then use this data to compute quantities that are hard to approximate using classic rasterization techniques.
4-
5-
While film production uses ray tracing extensively, its resource intensity has limited its use to offline rendering for a long time. Now, with recent advances in GPU hardware, you can make use of ray tracing effect in real time.
3+
The High Definition Render Pipeline (HDRP) includes preview ray tracing support from Unity 2019.3. Ray tracing allows you to access data that is not on screen. For example, you can use it to request position data, normal data, or lighting data, and then use this data to compute quantities that are hard to approximate using classic rasterization techniques.
64

75
This document covers:
86

@@ -161,7 +159,7 @@ Now that your HDRP Project supports ray tracing, there are a few steps you must
161159

162160
#### Frame Settings
163161

164-
To make HDRP calculates ray tracing effects for [Cameras](HDRP-Camera.md) in your Scene, make sure your Cameras use [Frame Settings](Frame-Settings.md) that have ray tracing enabled. You can enable ray tracing for all Cameras by default, or you can enable ray tracing for specific Cameras in your Scene.
162+
To make HDRP calculate ray tracing effects for [Cameras](HDRP-Camera.md) in your Scene, make sure your Cameras use [Frame Settings](Frame-Settings.md) that have ray tracing enabled. You can enable ray tracing for all Cameras by default, or you can enable ray tracing for specific Cameras in your Scene.
165163

166164
To enable ray tracing by default:
167165

@@ -188,6 +186,20 @@ To check whether it is possible to use ray tracing in a Scene, HDRP includes a m
188186
1. Click **Edit > Rendering > Check Scene Content for HDRP Ray Tracing**.
189187
2. In the Console window (menu: **Window > General > Console**), check if there are any warnings.
190188

189+
<a name="RayTracingMeshes"></a>
190+
191+
# Ray tracing and Meshes
192+
193+
HDRP changes how it handles Meshes in your scene when you integrate a ray traced effect into your project.
194+
195+
When you enable ray tracing, HDRP automatically creates a ray tracing acceleration structure. This structure allows Unity to calculate ray tracing for Meshes in your scene efficiently in real time.
196+
197+
As a result, ray tracing can change how some Meshes appear in your scene in the following ways:
198+
199+
- If your Mesh has a Material assigned that does not have the HDRenderPipeline tag, HDRP does not add it to the acceleration structure and does not apply any ray traced effects to the mesh as a result.
200+
- If your Mesh has a Decal Material assigned, HDRP does not add it to the acceleration structure and the Mesh does not appear in your scene.
201+
- If a Mesh has a combination of Materials that are single and double-sided, HDRP flags all Materials you have assigned to this mesh as double-sided.
202+
191203
<a name="RayTracingEffectsOverview"></a>
192204

193205
## Ray tracing effects overview
@@ -209,7 +221,7 @@ HDRP includes two ray tracing modes that define how it evaluates certain ray-tra
209221
* **Performance**: This mode targets real-time applications. If you select this mode, ray-traced effects include presets that you can change to balance performance with quality.
210222
* **Quality**: This mode targets technical demos and applications that want the best quality results.
211223

212-
Depending on which ray tracing mode you select, HDRP may expose difference properties for some ray-traced effects.
224+
Depending on which ray tracing mode you select, HDRP may expose different properties for some ray-traced effects.
213225

214226
You can change which ray tracing mode HDRP uses on either a Project level or effect level. To change it for your entire Project:
215227

@@ -224,7 +236,7 @@ If you select **Both**, you can change the ray tracing mode for each ray-traced
224236

225237
## Ray tracing project
226238

227-
You can find a small ray tracing project that contains all the effects mention above here:
239+
You can find a small ray tracing project that contains all the effects mentioned above here:
228240
https://github.com/Unity-Technologies/SmallOfficeRayTracing
229241
This Project is already set up with ray tracing support.
230242

@@ -238,7 +250,7 @@ There is no support for ray tracing on platforms other than DX12 for now.
238250

239251
HDRP ray tracing in Unity 2020.2 has the following limitations:
240252
- Does not support vertex animation.
241-
- Does not supports decals.
253+
- Does not support decals.
242254
- Does not support tessellation.
243255
- Does not support per pixel displacement (parallax occlusion mapping, height map, depth offset).
244256
- Does not support VFX and Terrain.
@@ -247,6 +259,7 @@ HDRP ray tracing in Unity 2020.2 has the following limitations:
247259
- For renderers that have [LODs](https://docs.unity3d.com/2019.3/Documentation/Manual/LevelOfDetail.html), the ray tracing acceleration structure only includes the highest level LOD and ignores the lower LODs.
248260
- Does not support [Graphics.DrawMesh](https://docs.unity3d.com/ScriptReference/Graphics.DrawMesh.html).
249261
- Ray tracing is not supported when rendering [Reflection Probes](Reflection-Probe.md).
262+
- HDRP does not support [orthographic projection](HDRP-Camera.md). If you enable orthographic projection mode, you might experience rendering problems for Transparent Materials, volumetrics and planar reflections.
250263

251264
### Unsupported shader graph nodes for ray tracing
252265

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Path tracing
22

3-
Path tracing is a ray tracing algorithm that sends rays from the Camera and, when a ray hits a reflective or refractive surface, recurses the process until it reaches a light source. The series of rays from the Camera to the Light forms a "path".
3+
Path tracing is a ray tracing algorithm that sends rays from the Camera and, when a ray hits a reflective or refractive surface, recurses the process until it reaches a light source. The series of rays from the Camera to the Light form a "path".
44

55
It enables HDRP to compute many different effects (such as hard or soft shadows, mirror or glossy reflections and refractions, and indirect illumination) in one single unified process.
66

@@ -14,7 +14,7 @@ Noisy image with **Maximum Samples** set to 1
1414

1515
Clean image with **Maximum Samples** set to 256
1616

17-
The current implementation for path tracing in the High Definition Render Pipeline (HDRP) accumulates paths for every pixel up to a maximum count, unless the Camera moves. If the Camera moves, HDRP restarts the path accumulation. Path tracing supports Lit, LayeredLit and Unlit materials, and area, point, directional and environment lights.
17+
The current implementation for path tracing in the High Definition Render Pipeline (HDRP) accumulates paths for every pixel up to a maximum count unless the Camera moves. If the Camera moves, HDRP restarts the path accumulation. Path tracing supports Lit, LayeredLit, and Unlit materials, and area, point, directional, and environment lights.
1818

1919
## Set up path tracing
2020

@@ -62,11 +62,12 @@ There is no support for path tracing on platforms other than DX12 for now.
6262

6363
HDRP path tracing in Unity 2020.2 has the following limitations:
6464

65+
- If a Mesh in your scene has a Material assigned that does not have the `HDRenderPipeline` tag, the mesh will not appear in your scene. For more information, see [Ray tracing and Meshes](Ray-Tracing-Getting-Started.md#RayTracingMeshes).
6566
- Does not support 3D Text and TextMeshPro.
66-
- Does not support Shader Graph nodes that use derivatives (ex : normal from textures).
67+
- Does not support Shader Graph nodes that use derivatives (for example, a normal map that derives from a texture).
6768
- Does not support decals.
6869
- Does not support tessellation.
69-
- Does not support Tube and Disc shaped Area Light.
70+
- Does not support Tube and Disc-shaped Area Lights.
7071
- Does not support Translucent Opaque Materials.
7172
- Does not support several of HDRP's Materials. This includes Fabric, Eye, StackLit, Hair, Decal.
7273
- Does not support per-pixel displacement (parallax occlusion mapping, height map, depth offset).

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Skin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ static partial class HDCameraUI
1515

1616
static readonly GUIContent clearModeContent = EditorGUIUtility.TrTextContent("Background Type", "Specifies the type of background the Camera applies when it clears the screen before rendering a frame. Be aware that when setting this to None, the background is never cleared and since HDRP shares render texture between cameras, you may end up with garbage from previous rendering.");
1717
static readonly GUIContent backgroundColorContent = EditorGUIUtility.TrTextContent("Background Color", "The Background Color used to clear the screen when selecting Background Color before rendering.");
18-
static readonly GUIContent cullingMaskContent = EditorGUIUtility.TrTextContent("Culling Mask");
18+
static readonly GUIContent cullingMaskContent = EditorGUIUtility.TrTextContent("Culling Mask", "Specifies the list of layers the camera should render.");
1919
static readonly GUIContent volumeLayerMaskContent = EditorGUIUtility.TrTextContent("Volume Layer Mask");
2020
static readonly GUIContent volumeAnchorOverrideContent = EditorGUIUtility.TrTextContent("Volume Anchor Override");
21-
static readonly GUIContent occlusionCullingContent = EditorGUIUtility.TrTextContent("Occlusion Culling");
21+
static readonly GUIContent occlusionCullingContent = EditorGUIUtility.TrTextContent("Occlusion Culling", "When enabled, the camera does not render objects that are being obscured by other geometry.");
2222

2323
static readonly GUIContent exposureTargetContent = EditorGUIUtility.TrTextContent("Exposure Target", "The object used as a target for centering the Exposure's Procedural Mask metering mode when target object option is set (See Exposure Volume Component).");
2424

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,9 @@ PaniniProjectionParameters PreparePaniniProjectionParameters(HDCamera camera)
30533053
parameters.paniniProjectionCS.EnableKeyword("UNITDISTANCE");
30543054
}
30553055

3056+
if (m_EnableAlpha)
3057+
passData.paniniProjectionCS.EnableKeyword("ENABLE_ALPHA");
3058+
30563059
parameters.paniniParams = new Vector4(viewExtents.x, viewExtents.y, paniniD, paniniS);
30573060
parameters.paniniProjectionKernel = parameters.paniniProjectionCS.FindKernel("KMain");
30583061

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
22
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
3+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/PostProcessDefines.hlsl"
34

45
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
56

67
#pragma kernel KMain
78

89
#pragma multi_compile GENERIC UNITDISTANCE
10+
#pragma multi_compile _ ENABLE_ALPHA
911

1012
TEXTURE2D_X(_InputTexture);
1113

12-
RW_TEXTURE2D_X(float3, _OutputTexture);
14+
RW_TEXTURE2D_X(CTYPE, _OutputTexture);
1315

1416
SAMPLER(sampler_LinearClamp);
1517

@@ -125,7 +127,7 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
125127
}
126128
else
127129
{
128-
float3 smp = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(coords), 0.0).xyz;
130+
CTYPE smp = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(coords), 0.0).CTYPE_SWIZZLE;
129131
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = smp;
130132
}
131133
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ void CleanupPrepass()
4545
CoreUtils.Destroy(m_DepthResolveMaterial);
4646
}
4747

48-
bool NeedClearGBuffer()
48+
bool NeedClearGBuffer(HDCamera hdCamera)
4949
{
50-
// TODO: Add an option to force clear
51-
return m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled();
50+
return m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() || hdCamera.frameSettings.IsEnabled(FrameSettingsField.ClearGBuffers);
5251
}
5352

5453
HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo()
@@ -108,7 +107,7 @@ TextureHandle CreateDepthBuffer(RenderGraph renderGraph, bool clear, bool msaa)
108107
return renderGraph.CreateTexture(depthDesc);
109108
}
110109

111-
TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa)
110+
TextureHandle CreateNormalBuffer(RenderGraph renderGraph, HDCamera hdCamera, bool msaa)
112111
{
113112
#if UNITY_2020_2_OR_NEWER
114113
FastMemoryDesc fastMemDesc;
@@ -118,7 +117,7 @@ TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa)
118117
#endif
119118

120119
TextureDesc normalDesc = new TextureDesc(Vector2.one, true, true)
121-
{ colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer"
120+
{ colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(hdCamera), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer"
122121
#if UNITY_2020_2_OR_NEWER
123122
, fastMemoryDesc = fastMemDesc
124123
#endif
@@ -327,7 +326,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
327326
decalBuffer = renderGraph.defaultResources.blackTextureXR;
328327
output.depthAsColor = renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
329328
{ colorFormat = GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, bindTextureMS = true, enableMSAA = true, name = "DepthAsColorMSAA" });
330-
output.normalBuffer = CreateNormalBuffer(renderGraph, msaa);
329+
output.normalBuffer = CreateNormalBuffer(renderGraph, hdCamera, msaa);
331330
return false;
332331
}
333332

@@ -464,7 +463,7 @@ struct GBufferOutput
464463

465464
void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, GBufferPassData passData, TextureHandle sssBuffer, TextureHandle vtFeedbackBuffer, ref PrepassOutput prepassOutput, FrameSettings frameSettings, RenderGraphBuilder builder)
466465
{
467-
bool clearGBuffer = NeedClearGBuffer();
466+
bool clearGBuffer = NeedClearGBuffer(hdCamera);
468467
bool lightLayers = frameSettings.IsEnabled(FrameSettingsField.LightLayers);
469468
bool shadowMasks = frameSettings.IsEnabled(FrameSettingsField.Shadowmask);
470469

@@ -630,7 +629,7 @@ void ResolvePrepassBuffers(RenderGraph renderGraph, HDCamera hdCamera, ref Prepa
630629

631630
passData.depthBuffer = builder.UseDepthBuffer(CreateDepthBuffer(renderGraph, true, false), DepthAccess.Write);
632631
passData.depthValuesBuffer = builder.UseColorBuffer(depthValuesBuffer, 0);
633-
passData.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, false), 1);
632+
passData.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, hdCamera, false), 1);
634633
if (passData.needMotionVectors)
635634
passData.motionVectorsBuffer = builder.UseColorBuffer(CreateMotionVectorBuffer(renderGraph, false, false), 2);
636635
else

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
5858

5959
LightingBuffers lightingBuffers = new LightingBuffers();
6060
lightingBuffers.diffuseLightingBuffer = CreateDiffuseLightingBuffer(m_RenderGraph, msaa);
61-
lightingBuffers.sssBuffer = CreateSSSBuffer(m_RenderGraph, msaa);
61+
lightingBuffers.sssBuffer = CreateSSSBuffer(m_RenderGraph, hdCamera, msaa);
6262

6363
var prepassOutput = RenderPrepass(m_RenderGraph, colorBuffer, lightingBuffers.sssBuffer, vtFeedbackBuffer, cullingResults, customPassCullingResults, hdCamera, aovRequest, aovBuffers);
6464

0 commit comments

Comments
 (0)