From eb390f7e9eaf517706751914347b23cd854eae63 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Tue, 6 Apr 2021 12:20:48 +0200 Subject: [PATCH 1/5] RT meshes now default to dbl-sided with mix of single/dbl materials. --- .../Raytracing/HDRaytracingManager.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs index 6ce9c8537f3..a959cfa63da 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs @@ -165,7 +165,7 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, // We need to build the instance flag for this renderer uint instanceFlag = 0x00; - bool singleSided = false; + bool doubleSided = false; bool materialIsOnlyTransparent = true; bool hasTransparentSubMaterial = false; @@ -207,9 +207,8 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, else if (transparentMaterial) subMeshFlagArray[meshIdx] |= RayTracingSubMeshFlags.UniqueAnyHitCalls; - // Force it to be non single sided if it has the keyword if there is a reason - bool doubleSided = currentMaterial.doubleSidedGI || currentMaterial.IsKeywordEnabled("_DOUBLESIDED_ON"); - singleSided |= !doubleSided; + // Check if we want double-sidedness for the mesh + doubleSided |= currentMaterial.doubleSidedGI || currentMaterial.IsKeywordEnabled("_DOUBLESIDED_ON"); // Check if the material has changed since last time we were here if (!m_MaterialsDirty) @@ -229,12 +228,9 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, } } - // If the mesh was not valid, exclude it + // If the mesh was not valid, exclude it (without affecting sidedness) if (!validMesh) - { subMeshFlagArray[meshIdx] = RayTracingSubMeshFlags.Disabled; - singleSided = true; - } } // If the material is considered opaque, every sub-mesh has to be enabled and with unique any hit calls @@ -301,7 +297,7 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, if (instanceFlag == 0) return AccelerationStructureStatus.Added; // Add it to the acceleration structure - m_CurrentRAS.AddInstance(currentRenderer, subMeshFlags: subMeshFlagArray, enableTriangleCulling: singleSided, mask: instanceFlag); + m_CurrentRAS.AddInstance(currentRenderer, subMeshFlags: subMeshFlagArray, enableTriangleCulling: !doubleSided, mask: instanceFlag); // Indicates that a transform has changed in our scene (mesh or light) m_TransformDirty |= currentRenderer.transform.hasChanged; From 0ee4a3831293d520c1f87a65dd199c72adc386dd Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Tue, 6 Apr 2021 12:25:32 +0200 Subject: [PATCH 2/5] Updated changelog. --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 81158c24c67..197da8beded 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -197,6 +197,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Updated Wizard to better handle RenderPipelineAsset in Quality Settings - Added Global settings check in Wizard - Added localization on Wizard window +- 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). ## [11.0.0] - 2020-10-21 From 2a560d89dd3f542e4028729349079e1d64ba3725 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Tue, 6 Apr 2021 14:17:06 +0200 Subject: [PATCH 3/5] More explicit comment. --- .../Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs index a959cfa63da..d1be080335f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs @@ -207,7 +207,8 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, else if (transparentMaterial) subMeshFlagArray[meshIdx] |= RayTracingSubMeshFlags.UniqueAnyHitCalls; - // Check if we want double-sidedness for the mesh + // Check if we want to enable double-sidedness for the mesh + // (note that a mix of single and double-sided materials will result in a double-sided mesh in the AS) doubleSided |= currentMaterial.doubleSidedGI || currentMaterial.IsKeywordEnabled("_DOUBLESIDED_ON"); // Check if the material has changed since last time we were here From 88cf83650fcb89e9dba2f6b39d5deac82e883d48 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 21 Apr 2021 00:04:05 +0200 Subject: [PATCH 4/5] Update CHANGELOG.md --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 931f1231090..00e637cb630 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -151,6 +151,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the camera controller in the template with the old input system (case 1326816). - Fixed broken Lanczos filter artifacts on ps4, caused by a very aggressive epsilon (case 1328904) - Fixed global Settings ignore the path set via Fix All in HDRP wizard (case 1327978) +- Fixed GBuffer clear option in FrameSettings not working +- Fixed usage of Panini Projection with floating point HDRP and Post Processing color buffers. ### Changed - Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard From 9964be09e189f484036ad52304f4b2ee95e4469c Mon Sep 17 00:00:00 2001 From: Vic-Cooper Date: Wed, 21 Apr 2021 16:04:55 +0100 Subject: [PATCH 5/5] Docs update Added information about ray tracing and meshes to Ray-Tracing-Getting-Started.md. Also mentioned the orthographic projection limitation. Added mesh rendering limitation to Ray-Tracing-Path-Tracing.md. --- .../Ray-Tracing-Getting-Started.md | 27 ++++++++++++++----- .../Ray-Tracing-Path-Tracing.md | 9 ++++--- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md index 7249b0ab5e3..b58ef3c301d 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md @@ -1,8 +1,6 @@ # Getting started with ray tracing -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. - -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. +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. This document covers: @@ -161,7 +159,7 @@ Now that your HDRP Project supports ray tracing, there are a few steps you must #### Frame Settings -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. +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. To enable ray tracing by default: @@ -188,6 +186,20 @@ To check whether it is possible to use ray tracing in a Scene, HDRP includes a m 1. Click **Edit > Rendering > Check Scene Content for HDRP Ray Tracing**. 2. In the Console window (menu: **Window > General > Console**), check if there are any warnings. + + +# Ray tracing and Meshes + +HDRP changes how it handles Meshes in your scene when you integrate a ray traced effect into your project. + +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. + +As a result, ray tracing can change how some Meshes appear in your scene in the following ways: + +- 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. +- 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. +- 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. + ## Ray tracing effects overview @@ -209,7 +221,7 @@ HDRP includes two ray tracing modes that define how it evaluates certain ray-tra * **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. * **Quality**: This mode targets technical demos and applications that want the best quality results. -Depending on which ray tracing mode you select, HDRP may expose difference properties for some ray-traced effects. +Depending on which ray tracing mode you select, HDRP may expose different properties for some ray-traced effects. You can change which ray tracing mode HDRP uses on either a Project level or effect level. To change it for your entire Project: @@ -224,7 +236,7 @@ If you select **Both**, you can change the ray tracing mode for each ray-traced ## Ray tracing project -You can find a small ray tracing project that contains all the effects mention above here: +You can find a small ray tracing project that contains all the effects mentioned above here: https://github.com/Unity-Technologies/SmallOfficeRayTracing This Project is already set up with ray tracing support. @@ -238,7 +250,7 @@ There is no support for ray tracing on platforms other than DX12 for now. HDRP ray tracing in Unity 2020.2 has the following limitations: - Does not support vertex animation. -- Does not supports decals. +- Does not support decals. - Does not support tessellation. - Does not support per pixel displacement (parallax occlusion mapping, height map, depth offset). - Does not support VFX and Terrain. @@ -247,6 +259,7 @@ HDRP ray tracing in Unity 2020.2 has the following limitations: - 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. - Does not support [Graphics.DrawMesh](https://docs.unity3d.com/ScriptReference/Graphics.DrawMesh.html). - Ray tracing is not supported when rendering [Reflection Probes](Reflection-Probe.md). +- 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. ### Unsupported shader graph nodes for ray tracing diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md index 1c2588aeef4..af422d47790 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md @@ -1,6 +1,6 @@ # Path tracing -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". +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". 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. @@ -14,7 +14,7 @@ Noisy image with **Maximum Samples** set to 1 Clean image with **Maximum Samples** set to 256 -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. +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. ## Setting up path tracing @@ -62,11 +62,12 @@ There is no support for path tracing on platforms other than DX12 for now. HDRP path tracing in Unity 2020.2 has the following limitations: +- 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). - Does not support 3D Text and TextMeshPro. -- Does not support Shader Graph nodes that use derivatives (ex : normal from textures). +- Does not support Shader Graph nodes that use derivatives (for example, a normal map that derives from a texture). - Does not support decals. - Does not support tessellation. -- Does not support Tube and Disc shaped Area Light. +- Does not support Tube and Disc-shaped Area Lights. - Does not support Translucent Opaque Materials. - Does not support several of HDRP's Materials. This includes Eye, StackLit, Hair, Decal. - Does not support per-pixel displacement (parallax occlusion mapping, height map, depth offset).