From 937e9c1c0b4bb0e90d3b15dab7d2cc4daa7d75e9 Mon Sep 17 00:00:00 2001
From: slunity <37302815+slunity@users.noreply.github.com>
Date: Fri, 12 Jun 2020 03:25:22 -0400
Subject: [PATCH 01/58] [10.x.x] Axf: add normal gradients and all mapping
modes (uv, planar, triplanar) #583
---
.../Direct3D11/None/1451_AxF_SVBRDF.png | 4 +-
.../Direct3D12/None/1451_AxF_SVBRDF.png | 3 +
.../Vulkan/None/1451_AxF_SVBRDF.png | 3 +
.../CHANGELOG.md | 1 +
.../Documentation~/AxF-Shader.md | 3 +-
.../Editor/Material/AxF/AxFGUI.cs | 67 +++
.../UIBlocks/AxfSurfaceInputsUIBlock.cs | 42 +-
.../Runtime/Material/AxF/AxF.cs | 53 +-
.../Runtime/Material/AxF/AxF.cs.hlsl | 162 +++++-
.../Runtime/Material/AxF/AxF.hlsl | 131 ++++-
.../Runtime/Material/AxF/AxF.shader | 11 +
.../Runtime/Material/AxF/AxFData.hlsl | 509 ++++++++++++++++--
.../Runtime/Material/AxF/AxFProperties.hlsl | 2 +
.../Material/AxF/ShaderPass/AxFDepthPass.hlsl | 49 +-
.../AxF/ShaderPass/AxFDistortionPass.hlsl | 12 -
.../ShaderPass/AxFDistortionPass.hlsl.meta | 9 -
16 files changed, 918 insertions(+), 143 deletions(-)
create mode 100644 TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png
create mode 100644 TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl
delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl.meta
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1451_AxF_SVBRDF.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1451_AxF_SVBRDF.png
index 88a60523d17..ff06ddbabcf 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1451_AxF_SVBRDF.png
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1451_AxF_SVBRDF.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:85c86928826be465c0f14d45a60544c42c0aba791a2ded36d550cadf02cec70e
-size 179315
+oid sha256:6c6581b8e33ab626b9808797111d008ac1600511ed76e9ca461b6ee396bb2e69
+size 158548
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png
new file mode 100644
index 00000000000..ff06ddbabcf
--- /dev/null
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6c6581b8e33ab626b9808797111d008ac1600511ed76e9ca461b6ee396bb2e69
+size 158548
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
new file mode 100644
index 00000000000..59a315367ee
--- /dev/null
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8bdf1ab6a1eadcb6d50029cae7e8099d64d50f777307b6298fd856c679abe7c0
+size 156437
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index e8c4916e821..1f0072bb9da 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added a function (HDRenderPipeline.ResetRTHandleReferenceSize) to reset the reference size of RTHandle systems.
- Added support for AxF measurements importing into texture resources tilings.
- Added Layer parameter on Area Light to modify Layer of generated Emissive Mesh
+- Added support for multiple mapping modes in AxF.
### Fixed
- Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047).
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md
index 116b81ce63b..795ed6788ab 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md
@@ -58,7 +58,8 @@ Note: The AxF Importer imports every Texture as half float, linear, sRGB gamut (
| **Property** | **Description** |
| --------------------- | ------------------------------------------------------------ |
-| **Main Tiling & Offset** | Sets the tiling rate (xy) and offsets (zw) for every Texture in the **Surface Inputs** section. HDRP uses these values to tile the Textures along the xy-axes of the Material’s surface, in the object's tangent space. Each texture property can also specify additional tiling and offset values that are applied on top of these main values (Texture property-specific tiling rates are multiplied and offsets are added to the main values set here) |
+| **Mapping Mode** | Controls the texture mapping mode of the material for all textures.
• **UV0..UV3**: Like in Lit, uses a UV set from UV0 to UV3 vertex attributes. Note that UV1 is used for baked lightmaps in Unity, so it isn't recommended to use this set.
• **PlanarXY,YZ,ZX**: Uses planar mapping along the specified plane.
• **Triplanar**: Uses triplanar mapping.
• **Planar Space**: When a planar or triplanar mapping mode is selected, you can select whether the coordinates used are world space or object space using the "planar space" option set to (respectively) "world" or "local". |
+| **Main Tiling & Offset** | Sets the tiling rate (xy) and offsets (zw) for every Texture in the **Surface Inputs** section. HDRP uses these values to tile the Textures along the xy-axes of the Material’s surface, in the object's tangent space. Each texture property can also specify additional tiling and offset values that are applied on top of these main values (Texture property-specific tiling rates are multiplied and offsets are added to the main values set here). These additional tiling and offsets appear next to each texture property on the same line. |
| **BRDF Type** | Controls the main AxF Material representation.
• **SVBRDF**: For information on the properties Unity makes visible when you select this option, see [BRDF Type - SVBRDF](#SVBRDF).
•**CAR_PAINT**: For information on the properties Unity makes visible when you select this option, see [BRDF Type - CAR_PAINT](#CAR_PAINT). |
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
index 51c0ab3c4a5..2f6a862523d 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
@@ -15,6 +15,18 @@ internal enum AxfBrdfType
BTF,
}
+ internal enum AxFMappingMode
+ {
+ UV0,
+ UV1,
+ UV2,
+ UV3,
+ PlanarXY,
+ PlanarYZ,
+ PlanarZX,
+ Triplanar,
+ }
+
///
/// GUI for HDRP AxF materials
///
@@ -50,6 +62,34 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
const string kEnableGeometricSpecularAA = "_EnableGeometricSpecularAA";
const string kSpecularOcclusionMode = "_SpecularOcclusionMode"; // match AdvancedOptionsUIBlock.kSpecularOcclusionMode : TODO move both to HDStringConstants.
+ const string kMappingMode = "_MappingMode";
+ const string kMappingMask = "_MappingMask";
+ const string kPlanarSpace = "_PlanarSpace";
+
+ static public Vector4 AxFMappingModeToMask(AxFMappingMode mappingMode)
+ {
+ Vector4 mask = Vector4.zero;
+ if (mappingMode <= AxFMappingMode.UV3)
+ {
+ float X,Y,Z,W;
+ X = (mappingMode == AxFMappingMode.UV0) ? 1.0f : 0.0f;
+ Y = (mappingMode == AxFMappingMode.UV1) ? 1.0f : 0.0f;
+ Z = (mappingMode == AxFMappingMode.UV2) ? 1.0f : 0.0f;
+ W = (mappingMode == AxFMappingMode.UV3) ? 1.0f : 0.0f;
+ mask = new Vector4(X, Y, Z, W);
+ }
+ else if (mappingMode < AxFMappingMode.Triplanar)
+ {
+ float X,Y,Z,W;
+ X = (mappingMode == AxFMappingMode.PlanarYZ) ? 1.0f : 0.0f;
+ Y = (mappingMode == AxFMappingMode.PlanarZX) ? 1.0f : 0.0f;
+ Z = (mappingMode == AxFMappingMode.PlanarXY) ? 1.0f : 0.0f;
+ W = 0.0f;
+ mask = new Vector4(X, Y, Z, W);
+ }
+ return mask;
+ }
+
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
static public void SetupMaterialKeywordsAndPass(Material material)
{
@@ -62,6 +102,33 @@ static public void SetupMaterialKeywordsAndPass(Material material)
CoreUtils.SetKeyword(material, "_AXF_BRDF_TYPE_CAR_PAINT", BRDFType == AxfBrdfType.CAR_PAINT);
CoreUtils.SetKeyword(material, "_AXF_BRDF_TYPE_BTF", BRDFType == AxfBrdfType.BTF);
+
+ // Mapping Modes:
+ AxFMappingMode mappingMode = (AxFMappingMode)material.GetFloat(kMappingMode);
+
+ // Make sure the mask is synched:
+ material.SetVector(kMappingMask, AxFMappingModeToMask(mappingMode));
+
+ bool mappingIsPlanar = (mappingMode >= AxFMappingMode.PlanarXY) && (mappingMode < AxFMappingMode.Triplanar);
+ bool planarIsLocal = (material.GetFloat(kPlanarSpace) > 0.0f);
+
+ CoreUtils.SetKeyword(material, "_MAPPING_PLANAR", mappingIsPlanar);
+ CoreUtils.SetKeyword(material, "_MAPPING_TRIPLANAR", mappingMode == AxFMappingMode.Triplanar);
+
+ if (mappingIsPlanar || mappingMode == AxFMappingMode.Triplanar)
+ {
+ CoreUtils.SetKeyword(material, "_PLANAR_LOCAL", planarIsLocal);
+ }
+
+ // Note: for ShaderPass defines for vertmesh/varyingmesh setup, we still use the same
+ // defines _REQUIRE_UV2 and _REQUIRE_UV3, and thus if eg _REQUIRE_UV3 is defined, _REQUIRE_UV2 will
+ // be assumed to be needed. But here in the AxFData sampling code, we use these to indicate precisely
+ // the single set used (if not using planar/triplanar) only and thus add _REQUIRE_UV1.
+ // Extra UVs might be transfered but we only need and support a single set at a time for the whole material.
+ CoreUtils.SetKeyword(material, "_REQUIRE_UV1", mappingMode == AxFMappingMode.UV1);
+ CoreUtils.SetKeyword(material, "_REQUIRE_UV2", mappingMode == AxFMappingMode.UV2);
+ CoreUtils.SetKeyword(material, "_REQUIRE_UV3", mappingMode == AxFMappingMode.UV3);
+
// Keywords for opt-out of decals and SSR:
bool decalsEnabled = material.HasProperty(kEnableDecals) && material.GetFloat(kEnableDecals) > 0.0f;
CoreUtils.SetKeyword(material, "_DISABLE_DECALS", decalsEnabled == false);
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AxfSurfaceInputsUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AxfSurfaceInputsUIBlock.cs
index 55b8ab0f75d..8037e361335 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AxfSurfaceInputsUIBlock.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AxfSurfaceInputsUIBlock.cs
@@ -20,6 +20,10 @@ public class Styles
{
public const string header = "Surface Inputs";
+ public static GUIContent mappingModeText = new GUIContent("Mapping Mode");
+ public static GUIContent planarSpaceText = new GUIContent("Planar Space");
+
+ public static GUIContent materialTilingOffsetText = new GUIContent("Main Tiling & Offset");
/////////////////////////////////////////////////////////////////////////////////////////////////
// SVBRDF Parameters
public static GUIContent diffuseColorMapText = new GUIContent("Diffuse Color");
@@ -110,10 +114,20 @@ enum SvbrdfFresnelVariant
SCHLICK, // Schlick's Approximation (1994)
}
static readonly string[] SvbrdfFresnelVariantNames = Enum.GetNames(typeof(SvbrdfFresnelVariant));
+ static readonly string[] MappingModeNames = Enum.GetNames(typeof(AxFMappingMode));
/////////////////////////////////////////////////////////////////////////////////////////////////
// Generic Parameters
-
+
+ static string m_MappingModeText = "_MappingMode";
+ MaterialProperty m_MappingMode = null;
+
+ static string m_MappingMaskText = "_MappingMask";
+ MaterialProperty m_MappingMask = null;
+
+ static string m_PlanarSpaceText = "_PlanarSpace";
+ MaterialProperty m_PlanarSpace = null;
+
MaterialProperty m_MaterialTilingOffset = null;
MaterialProperty m_DiffuseColorMapST = null;
MaterialProperty m_SpecularColorMapST = null;
@@ -234,6 +248,10 @@ public AxfSurfaceInputsUIBlock(Expandable expandableBit)
public override void LoadMaterialProperties()
{
+ m_MappingMode = FindProperty(m_MappingModeText);
+ m_MappingMask = FindProperty(m_MappingMaskText);
+ m_PlanarSpace = FindProperty(m_PlanarSpaceText);
+
m_MaterialTilingOffset = FindProperty(m_MaterialTilingOffsetText);
m_DiffuseColorMapST = FindProperty(m_DiffuseColorMapText + tilingOffsetPropNameSuffix);
@@ -344,7 +362,27 @@ public static void ExtractFlags(uint flags,
void DrawAxfSurfaceOptionsGUI()
{
- materialEditor.ShaderProperty(m_MaterialTilingOffset, "Main Tiling & Offset");
+ //materialEditor.ShaderProperty(m_MappingMode, Styles.mappingModeText);
+ EditorGUI.BeginChangeCheck();
+ float val = EditorGUILayout.Popup(Styles.mappingModeText, (int)m_MappingMode.floatValue, MappingModeNames);
+ if (EditorGUI.EndChangeCheck())
+ {
+ Material material = materialEditor.target as Material;
+ Undo.RecordObject(material, "Change Mapping Mode");
+ m_MappingMode.floatValue = val;
+ }
+
+ AxFMappingMode mappingMode = (AxFMappingMode)m_MappingMode.floatValue;
+ m_MappingMask.vectorValue = AxFGUI.AxFMappingModeToMask(mappingMode);
+
+ if (mappingMode >= AxFMappingMode.PlanarXY)
+ {
+ ++EditorGUI.indentLevel;
+ materialEditor.ShaderProperty(m_PlanarSpace, Styles.planarSpaceText);
+ --EditorGUI.indentLevel;
+ }
+
+ materialEditor.ShaderProperty(m_MaterialTilingOffset, Styles.materialTilingOffsetText);
AxfBrdfType AxF_BRDFType = (AxfBrdfType)m_AxF_BRDFType.floatValue;
AxF_BRDFType = (AxfBrdfType)EditorGUILayout.Popup("BRDF Type", (int)AxF_BRDFType, AxfBrdfTypeNames);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs
index 2d161eea64e..f72002d77cb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs
@@ -80,12 +80,35 @@ public struct SurfaceData
public float anisotropyAngle;
// Car Paint Variables
- [SurfaceDataAttributes("Flakes UV")]
- public Vector2 flakesUV;
-
- [SurfaceDataAttributes("Flakes Mip")]
- public float flakesMipLevel;
-
+ [SurfaceDataAttributes("Flakes UV (or PlanarZY)")]
+ public Vector2 flakesUVZY;
+ [SurfaceDataAttributes("Flakes PlanarXZ")]
+ public Vector2 flakesUVXZ;
+ [SurfaceDataAttributes("Flakes PlanarXY")]
+ public Vector2 flakesUVXY;
+
+ [SurfaceDataAttributes("Flakes Mip (and for PlanarZY)")]
+ public float flakesMipLevelZY;
+ [SurfaceDataAttributes("Flakes Mip for PlanarXZ")]
+ public float flakesMipLevelXZ;
+ [SurfaceDataAttributes("Flakes Mip for PlanarXY")]
+ public float flakesMipLevelXY;
+ [SurfaceDataAttributes("Flakes Triplanar Weights")]
+ public Vector3 flakesTriplanarWeights;
+
+ // if non null, we will prefer gradients (to be used statically only!)
+ [SurfaceDataAttributes("Flakes ddx (and for PlanarZY)")]
+ public Vector2 flakesDdxZY;
+ [SurfaceDataAttributes("Flakes ddy (and for PlanarZY)")]
+ public Vector2 flakesDdyZY;
+ [SurfaceDataAttributes("Flakes ddx for PlanarXZ")]
+ public Vector2 flakesDdxXZ;
+ [SurfaceDataAttributes("Flakes ddy for PlanarXZ")]
+ public Vector2 flakesDdyXZ;
+ [SurfaceDataAttributes("Flakes ddx for PlanarXY")]
+ public Vector2 flakesDdxXY;
+ [SurfaceDataAttributes("Flakes ddy for PlanarXY")]
+ public Vector2 flakesDdyXY;
// BTF Variables
// Clearcoat
@@ -127,11 +150,19 @@ public struct BSDFData
public float height_mm;
// Car Paint Variables
- [SurfaceDataAttributes("")]
- public Vector2 flakesUV;
-
- [SurfaceDataAttributes("Flakes Mip")]
- public float flakesMipLevel;
+ public Vector2 flakesUVZY;
+ public Vector2 flakesUVXZ;
+ public Vector2 flakesUVXY;
+ public float flakesMipLevelZY;
+ public float flakesMipLevelXZ;
+ public float flakesMipLevelXY;
+ public Vector3 flakesTriplanarWeights;
+ public Vector2 flakesDdxZY; // if non null, we will prefer gradients (to be used statically only!)
+ public Vector2 flakesDdyZY;
+ public Vector2 flakesDdxXZ;
+ public Vector2 flakesDdyXZ;
+ public Vector2 flakesDdxXY;
+ public Vector2 flakesDdyXY;
// BTF Variables
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs.hlsl
index 7362aefc55d..208c45de74c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs.hlsl
@@ -29,13 +29,24 @@
#define DEBUGVIEW_AXF_SURFACEDATA_SPECULAR_LOBE (1208)
#define DEBUGVIEW_AXF_SURFACEDATA_HEIGHT (1209)
#define DEBUGVIEW_AXF_SURFACEDATA_ANISOTROPIC_ANGLE (1210)
-#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_UV (1211)
-#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP (1212)
-#define DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_COLOR (1213)
-#define DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_NORMAL (1214)
-#define DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_IOR (1215)
-#define DEBUGVIEW_AXF_SURFACEDATA_GEOMETRIC_NORMAL (1216)
-#define DEBUGVIEW_AXF_SURFACEDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1217)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_UV_(OR_PLANAR_ZY) (1211)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_PLANAR_XZ (1212)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_PLANAR_XY (1213)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP_(AND_FOR_PLANAR_ZY) (1214)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP_FOR_PLANAR_XZ (1215)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP_FOR_PLANAR_XY (1216)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_TRIPLANAR_WEIGHTS (1217)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDX_(AND_FOR_PLANAR_ZY) (1218)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDY_(AND_FOR_PLANAR_ZY) (1219)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDX_FOR_PLANAR_XZ (1220)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDY_FOR_PLANAR_XZ (1221)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDX_FOR_PLANAR_XY (1222)
+#define DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDY_FOR_PLANAR_XY (1223)
+#define DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_COLOR (1224)
+#define DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_NORMAL (1225)
+#define DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_IOR (1226)
+#define DEBUGVIEW_AXF_SURFACEDATA_GEOMETRIC_NORMAL (1227)
+#define DEBUGVIEW_AXF_SURFACEDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1228)
//
// UnityEngine.Rendering.HighDefinition.AxF+BSDFData: static fields
@@ -51,13 +62,24 @@
#define DEBUGVIEW_AXF_BSDFDATA_FRESNEL_F0 (1258)
#define DEBUGVIEW_AXF_BSDFDATA_ROUGHNESS (1259)
#define DEBUGVIEW_AXF_BSDFDATA_HEIGHT_MM (1260)
-#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_UV (1261)
-#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP (1262)
-#define DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_COLOR (1263)
-#define DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_NORMAL_WS (1264)
-#define DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_IOR (1265)
-#define DEBUGVIEW_AXF_BSDFDATA_GEOMETRIC_NORMAL (1266)
-#define DEBUGVIEW_AXF_BSDFDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1267)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_UVZY (1261)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_UVXZ (1262)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_UVXY (1263)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP_LEVEL_ZY (1264)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP_LEVEL_XZ (1265)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP_LEVEL_XY (1266)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_TRIPLANAR_WEIGHTS (1267)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDX_ZY (1268)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDY_ZY (1269)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDX_XZ (1270)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDY_XZ (1271)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDX_XY (1272)
+#define DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDY_XY (1273)
+#define DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_COLOR (1274)
+#define DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_NORMAL_WS (1275)
+#define DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_IOR (1276)
+#define DEBUGVIEW_AXF_BSDFDATA_GEOMETRIC_NORMAL (1277)
+#define DEBUGVIEW_AXF_BSDFDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1278)
// Generated from UnityEngine.Rendering.HighDefinition.AxF+SurfaceData
// PackingRules = Exact
@@ -73,8 +95,19 @@ struct SurfaceData
float3 specularLobe;
float height_mm;
float anisotropyAngle;
- float2 flakesUV;
- float flakesMipLevel;
+ float2 flakesUVZY;
+ float2 flakesUVXZ;
+ float2 flakesUVXY;
+ float flakesMipLevelZY;
+ float flakesMipLevelXZ;
+ float flakesMipLevelXY;
+ float3 flakesTriplanarWeights;
+ float2 flakesDdxZY;
+ float2 flakesDdyZY;
+ float2 flakesDdxXZ;
+ float2 flakesDdyXZ;
+ float2 flakesDdxXY;
+ float2 flakesDdyXY;
float3 clearcoatColor;
float3 clearcoatNormalWS;
float clearcoatIOR;
@@ -95,8 +128,19 @@ struct BSDFData
float3 fresnelF0;
float3 roughness;
float height_mm;
- float2 flakesUV;
- float flakesMipLevel;
+ float2 flakesUVZY;
+ float2 flakesUVXZ;
+ float2 flakesUVXY;
+ float flakesMipLevelZY;
+ float flakesMipLevelXZ;
+ float flakesMipLevelXY;
+ float3 flakesTriplanarWeights;
+ float2 flakesDdxZY;
+ float2 flakesDdyZY;
+ float2 flakesDdxXZ;
+ float2 flakesDdyXZ;
+ float2 flakesDdxXY;
+ float2 flakesDdyXY;
float3 clearcoatColor;
float3 clearcoatNormalWS;
float clearcoatIOR;
@@ -145,11 +189,44 @@ void GetGeneratedSurfaceDataDebug(uint paramId, SurfaceData surfacedata, inout f
case DEBUGVIEW_AXF_SURFACEDATA_ANISOTROPIC_ANGLE:
result = surfacedata.anisotropyAngle.xxx;
break;
- case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_UV:
- result = float3(surfacedata.flakesUV, 0.0);
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_UV_(OR_PLANAR_ZY):
+ result = float3(surfacedata.flakesUVZY, 0.0);
break;
- case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP:
- result = surfacedata.flakesMipLevel.xxx;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_PLANAR_XZ:
+ result = float3(surfacedata.flakesUVXZ, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_PLANAR_XY:
+ result = float3(surfacedata.flakesUVXY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP_(AND_FOR_PLANAR_ZY):
+ result = surfacedata.flakesMipLevelZY.xxx;
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP_FOR_PLANAR_XZ:
+ result = surfacedata.flakesMipLevelXZ.xxx;
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_MIP_FOR_PLANAR_XY:
+ result = surfacedata.flakesMipLevelXY.xxx;
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_TRIPLANAR_WEIGHTS:
+ result = surfacedata.flakesTriplanarWeights;
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDX_(AND_FOR_PLANAR_ZY):
+ result = float3(surfacedata.flakesDdxZY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDY_(AND_FOR_PLANAR_ZY):
+ result = float3(surfacedata.flakesDdyZY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDX_FOR_PLANAR_XZ:
+ result = float3(surfacedata.flakesDdxXZ, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDY_FOR_PLANAR_XZ:
+ result = float3(surfacedata.flakesDdyXZ, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDX_FOR_PLANAR_XY:
+ result = float3(surfacedata.flakesDdxXY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_SURFACEDATA_FLAKES_DDY_FOR_PLANAR_XY:
+ result = float3(surfacedata.flakesDdyXY, 0.0);
break;
case DEBUGVIEW_AXF_SURFACEDATA_CLEARCOAT_COLOR:
result = surfacedata.clearcoatColor;
@@ -209,11 +286,44 @@ void GetGeneratedBSDFDataDebug(uint paramId, BSDFData bsdfdata, inout float3 res
case DEBUGVIEW_AXF_BSDFDATA_HEIGHT_MM:
result = bsdfdata.height_mm.xxx;
break;
- case DEBUGVIEW_AXF_BSDFDATA_FLAKES_UV:
- result = float3(bsdfdata.flakesUV, 0.0);
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_UVZY:
+ result = float3(bsdfdata.flakesUVZY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_UVXZ:
+ result = float3(bsdfdata.flakesUVXZ, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_UVXY:
+ result = float3(bsdfdata.flakesUVXY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP_LEVEL_ZY:
+ result = bsdfdata.flakesMipLevelZY.xxx;
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP_LEVEL_XZ:
+ result = bsdfdata.flakesMipLevelXZ.xxx;
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP_LEVEL_XY:
+ result = bsdfdata.flakesMipLevelXY.xxx;
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_TRIPLANAR_WEIGHTS:
+ result = bsdfdata.flakesTriplanarWeights;
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDX_ZY:
+ result = float3(bsdfdata.flakesDdxZY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDY_ZY:
+ result = float3(bsdfdata.flakesDdyZY, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDX_XZ:
+ result = float3(bsdfdata.flakesDdxXZ, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDY_XZ:
+ result = float3(bsdfdata.flakesDdyXZ, 0.0);
+ break;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDX_XY:
+ result = float3(bsdfdata.flakesDdxXY, 0.0);
break;
- case DEBUGVIEW_AXF_BSDFDATA_FLAKES_MIP:
- result = bsdfdata.flakesMipLevel.xxx;
+ case DEBUGVIEW_AXF_BSDFDATA_FLAKES_DDY_XY:
+ result = float3(bsdfdata.flakesDdyXY, 0.0);
break;
case DEBUGVIEW_AXF_BSDFDATA_CLEARCOAT_COLOR:
result = bsdfdata.clearcoatColor;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
index 96dd992632d..fb145c24cc0 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
@@ -71,6 +71,15 @@
# define IF_FLAKES_JUST_BTF(a) (a)
#endif
+#ifdef _MAPPING_TRIPLANAR
+# define NB_FLAKES_RND_SHIFTS 3
+# define FLAKES_SHIFT_IDX_PLANAR_ZY (0)
+# define FLAKES_SHIFT_IDX_PLANAR_XZ (1)
+# define FLAKES_SHIFT_IDX_PLANAR_XY (2)
+#else
+# define NB_FLAKES_RND_SHIFTS 1
+#endif
+
// Define this to sample the environment maps/LTC samples for each lobe, instead of a single sample with an average lobe
#define USE_COOK_TORRANCE_MULTI_LOBES 1
#define MAX_CT_LOBE_COUNT 3
@@ -81,6 +90,43 @@
// Helper functions/variable specific to this material
//-----------------------------------------------------------------------------
+void FillFlakesBSDFData(SurfaceData surfaceData, inout BSDFData bsdfData)
+{
+#ifdef _MAPPING_TRIPLANAR
+ bsdfData.flakesUVZY = surfaceData.flakesUVZY;
+ bsdfData.flakesUVXZ = surfaceData.flakesUVXZ;
+ bsdfData.flakesUVXY = surfaceData.flakesUVXY;
+ bsdfData.flakesMipLevelZY = surfaceData.flakesMipLevelZY;
+ bsdfData.flakesMipLevelXZ = surfaceData.flakesMipLevelXZ;
+ bsdfData.flakesMipLevelXY = surfaceData.flakesMipLevelXY;
+ bsdfData.flakesTriplanarWeights = surfaceData.flakesTriplanarWeights;
+
+ bsdfData.flakesDdxZY = surfaceData.flakesDdxZY;
+ bsdfData.flakesDdyZY = surfaceData.flakesDdyZY;
+ bsdfData.flakesDdxXZ = surfaceData.flakesDdxXZ;
+ bsdfData.flakesDdyXZ = surfaceData.flakesDdyXZ;
+ bsdfData.flakesDdxXY = surfaceData.flakesDdxXY;
+ bsdfData.flakesDdyXY = surfaceData.flakesDdyXY;
+#else
+ // NOTE: When not triplanar UVZY has one uv set or one planar coordinate set,
+ // and this planar coordinate set isn't necessarily ZY, we just reuse this field
+ // as a common one.
+ bsdfData.flakesUVZY = surfaceData.flakesUVZY;
+ bsdfData.flakesMipLevelZY = surfaceData.flakesMipLevelZY;
+ bsdfData.flakesDdxZY = surfaceData.flakesDdxZY;
+ bsdfData.flakesDdyZY = surfaceData.flakesDdyZY;
+ bsdfData.flakesUVXZ = 0;
+ bsdfData.flakesUVXY = 0;
+ bsdfData.flakesMipLevelXZ = 0;
+ bsdfData.flakesMipLevelXY = 0;
+ bsdfData.flakesTriplanarWeights = 0;
+ bsdfData.flakesDdxXZ = 0;
+ bsdfData.flakesDdyXZ = 0;
+ bsdfData.flakesDdxXY = 0;
+ bsdfData.flakesDdyXY = 0;
+#endif
+}
+
// AxF splits the chromaticity and f0 from the usual "SpecularColor" convention
// to just be a chromatic f0.
// CARPAINT2 has a different way to handle colors and must be accounted for too.
@@ -686,7 +732,7 @@ float OrenNayar(in float3 n, in float3 v, in float3 l, in float roughness)
BSDFData ConvertSurfaceDataToBSDFData(uint2 positionSS, SurfaceData surfaceData)
{
BSDFData bsdfData;
- // ZERO_INITIALIZE(BSDFData, data);
+ ZERO_INITIALIZE(BSDFData, bsdfData);
bsdfData.ambientOcclusion = surfaceData.ambientOcclusion;
bsdfData.specularOcclusion = surfaceData.specularOcclusion;
@@ -711,14 +757,12 @@ BSDFData ConvertSurfaceDataToBSDFData(uint2 positionSS, SurfaceData surfaceData)
bsdfData.clearcoatIOR = surfaceData.clearcoatIOR;
// Useless but pass along anyway
- bsdfData.flakesUV = surfaceData.flakesUV;
- bsdfData.flakesMipLevel = surfaceData.flakesMipLevel;
+ FillFlakesBSDFData(surfaceData, bsdfData);
//-----------------------------------------------------------------------------
#elif defined(_AXF_BRDF_TYPE_CAR_PAINT)
bsdfData.diffuseColor = surfaceData.diffuseColor;
- bsdfData.flakesUV = surfaceData.flakesUV;
- bsdfData.flakesMipLevel = surfaceData.flakesMipLevel;
+ FillFlakesBSDFData(surfaceData, bsdfData);
bsdfData.clearcoatColor = 1.0; // Not provided, assume white...
bsdfData.clearcoatIOR = surfaceData.clearcoatIOR;
bsdfData.clearcoatNormalWS = HasClearcoat() ? surfaceData.clearcoatNormalWS : surfaceData.normalWS;
@@ -810,9 +854,52 @@ uint SampleFlakesLUT(uint index)
// return pipoLUT[min(11, _index)];
}
-float3 SamplesFlakes(float2 UV, uint sliceIndex, float mipLevel)
-{
- return _CarPaint2_BTFFlakeMapScale * SAMPLE_TEXTURE2D_ARRAY_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap, UV, sliceIndex, mipLevel).xyz;
+float3 SamplesFlakes(float2 offsets[NB_FLAKES_RND_SHIFTS], uint sliceIndex, BSDFData bsdfData)
+{
+ // We can't use SAMPLE_TEXTURE2D_ARRAY, the compiler can't unroll in that case, and the lightloop is built with unroll
+ // That's why we calculate gradients or LOD earlier.
+ // TODO: The LOD code path (useFlakesMipLevel == true) is kept for a possible performance/appearance trade-off
+ // (less VGPR for LOD) and also for (future) raytracing, it is easier to substitute an approximate single LOD value
+ // than a full 2x2 Jacobian.
+ float3 val = 0;
+ bool useFlakesMipLevel = all(bsdfData.flakesDdxZY == (float2)0); // should be known statically!
+
+#ifdef _MAPPING_TRIPLANAR
+ val += bsdfData.flakesTriplanarWeights.x *
+ (useFlakesMipLevel ?
+ SAMPLE_TEXTURE2D_ARRAY_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVZY + offsets[FLAKES_SHIFT_IDX_PLANAR_ZY],
+ sliceIndex, bsdfData.flakesMipLevelZY).xyz
+ : SAMPLE_TEXTURE2D_ARRAY_GRAD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVZY + offsets[FLAKES_SHIFT_IDX_PLANAR_ZY],
+ sliceIndex, bsdfData.flakesDdxZY, bsdfData.flakesDdyZY).xyz );
+
+ val += bsdfData.flakesTriplanarWeights.y *
+ (useFlakesMipLevel ?
+ SAMPLE_TEXTURE2D_ARRAY_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVXZ + offsets[FLAKES_SHIFT_IDX_PLANAR_XZ],
+ sliceIndex, bsdfData.flakesMipLevelXZ).xyz
+ : SAMPLE_TEXTURE2D_ARRAY_GRAD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVXZ + offsets[FLAKES_SHIFT_IDX_PLANAR_XZ],
+ sliceIndex, bsdfData.flakesDdxXZ, bsdfData.flakesDdyXZ).xyz );
+ val += bsdfData.flakesTriplanarWeights.z *
+ (useFlakesMipLevel ?
+ SAMPLE_TEXTURE2D_ARRAY_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVXY + offsets[FLAKES_SHIFT_IDX_PLANAR_XY],
+ sliceIndex, bsdfData.flakesMipLevelXY).xyz
+ : SAMPLE_TEXTURE2D_ARRAY_GRAD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVXY + offsets[FLAKES_SHIFT_IDX_PLANAR_XY],
+ sliceIndex, bsdfData.flakesDdxXY, bsdfData.flakesDdyXY).xyz );
+ val *= _CarPaint2_BTFFlakeMapScale;
+#else
+ val = _CarPaint2_BTFFlakeMapScale *
+ (useFlakesMipLevel ?
+ SAMPLE_TEXTURE2D_ARRAY_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVZY + offsets[0], sliceIndex, bsdfData.flakesMipLevelZY).xyz
+ : SAMPLE_TEXTURE2D_ARRAY_GRAD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap,
+ bsdfData.flakesUVZY + offsets[0], sliceIndex, bsdfData.flakesDdxZY, bsdfData.flakesDdyZY).xyz );
+#endif
+ return val;
}
//
@@ -820,9 +907,6 @@ float3 SamplesFlakes(float2 UV, uint sliceIndex, float mipLevel)
//
float3 CarPaint_BTF(float thetaH, float thetaD, BSDFData bsdfData)
{
- float2 UV = bsdfData.flakesUV;
- float mipLevel = bsdfData.flakesMipLevel;
-
// thetaH sampling defines the angular sampling, i.e. angular flake lifetime
float binIndexH = _CarPaint2_FlakeNumThetaF * (2.0 * thetaH / PI) + 0.5; // TODO: doc says to use NumThetaF for both, check if this isn't a typo
float binIndexD = _CarPaint2_FlakeNumThetaF * (2.0 * thetaD / PI) + 0.5;
@@ -836,8 +920,9 @@ float3 CarPaint_BTF(float thetaH, float thetaD, BSDFData bsdfData)
float thetaD_weight = binIndexD - thetaD_low;
// To allow lower thetaD samplings while preserving flake lifetime, "virtual" thetaD patches are generated by shifting existing ones
- float2 offset_l = 0;
- float2 offset_h = 0;
+ // NB_FLAKES_RND_SHIFTS = 1 if not triplanar; otherwise this is in case we want a randomization that takes planar coordinate index into account
+ float2 offset_l[NB_FLAKES_RND_SHIFTS] = (float2[NB_FLAKES_RND_SHIFTS])0;
+ float2 offset_h[NB_FLAKES_RND_SHIFTS] = (float2[NB_FLAKES_RND_SHIFTS])0;
// Organization of the flake BTF slice array and LUT:
//
@@ -943,8 +1028,10 @@ float3 CarPaint_BTF(float thetaH, float thetaD, BSDFData bsdfData)
// Access flake texture - make sure to stay in the correct slices (no slip over)
if (thetaD_low < _CarPaint2_FlakeMaxThetaI)
{
- float2 UVl = UV + offset_l;
- float2 UVh = UV + offset_h;
+ // These are spatial UVs, we let SampleFlakes deal with them in case of triplanar,
+ // and just submit the random shift offsets (TODO "virtual" angular patches)
+ //float2 UVl = UV + offset_l;
+ //float2 UVh = UV + offset_h;
uint LUT0 = SampleFlakesLUT(thetaD_low);
uint LUT1 = SampleFlakesLUT(thetaD_high);
@@ -954,10 +1041,10 @@ float3 CarPaint_BTF(float thetaH, float thetaD, BSDFData bsdfData)
if (LUT0 + thetaH_low < LUT0_limit)
{
- H0_D0 = SamplesFlakes(UVl, LUT0 + thetaH_low, mipLevel);
+ H0_D0 = SamplesFlakes(offset_l, LUT0 + thetaH_low, bsdfData);
if (LUT0 + thetaH_high < LUT0_limit)
{
- H1_D0 = SamplesFlakes(UVl, LUT0 + thetaH_high, mipLevel);
+ H1_D0 = SamplesFlakes(offset_l, LUT0 + thetaH_high, bsdfData);
}
}
// else it means that the calculated index for that thetaD_low and the thetaH_low
@@ -974,10 +1061,10 @@ float3 CarPaint_BTF(float thetaH, float thetaD, BSDFData bsdfData)
{
if (LUT1 + thetaH_low < LUT2)
{
- H0_D1 = SamplesFlakes(UVh, LUT1 + thetaH_low, mipLevel);
+ H0_D1 = SamplesFlakes(offset_h, LUT1 + thetaH_low, bsdfData);
if (LUT1 + thetaH_high < LUT2)
{
- H1_D1 = SamplesFlakes(UVh, LUT1 + thetaH_high, mipLevel);
+ H1_D1 = SamplesFlakes(offset_h, LUT1 + thetaH_high, bsdfData);
}
}
// else, same thing as our comment above
@@ -2030,7 +2117,7 @@ DirectLighting EvaluateBSDF_Line( LightLoopContext lightLoopContext,
ltcValue = LTCEvaluate(P1, P2, B, preLightData.ltcTransformFlakes);
ltcValue *= lightData.specularDimmer;
- lighting.specular += ltcValue * preLightData.singleFlakesComponent; //preLightData.flakesFGD * CarPaint_BTF(thetaH, thetaD, bsdfData);
+ lighting.specular += ltcValue * preLightData.singleFlakesComponent;
#endif
@@ -2246,7 +2333,7 @@ DirectLighting EvaluateBSDF_Rect(LightLoopContext lightLoopContext,
ltcValue = PolygonIrradiance(mul(lightVerts, preLightData.ltcTransformFlakes));
ltcValue *= lightData.specularDimmer;
- lighting.specular += ltcValue * preLightData.singleFlakesComponent; //preLightData.flakesFGD * CarPaint_BTF(thetaH, thetaD, bsdfData);
+ lighting.specular += ltcValue * preLightData.singleFlakesComponent;
#endif
@@ -2523,7 +2610,6 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
// Sample flakes
//TODO_FLAKES
float flakesMipLevel = 0; // Flakes are supposed to be perfect mirrors
- //envLighting += preLightData.flakesFGD * CarPaint_BTF(thetaH, thetaD, bsdfData) * SampleEnv(lightLoopContext, lightData.envIndex, lightWS_UnderCoat, flakesMipLevel, lightData.rangeCompressionFactorCompensation).xyz;
envLighting += preLightData.singleFlakesComponent * SampleEnv(lightLoopContext, lightData.envIndex, envSamplingDirForBottomLayer, flakesMipLevel, lightData.rangeCompressionFactorCompensation).xyz;
#else // USE_COOK_TORRANCE_MULTI_LOBES
@@ -2539,7 +2625,6 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
envLighting = preLightData.specularCTFGDSingleLobe * GetSpecularIndirectDimmer();
//TODO_FLAKES
- //envLighting += preLightData.flakesFGD * CarPaint_BTF(thetaH, thetaD, bsdfData);
envLighting += preLightData.singleFlakesComponent;
envLighting *= preLD.xyz;
weight *= preLD.w; // Used by planar reflection to discard pixel
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
index a52d3de21c7..30748367cce 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
@@ -7,6 +7,13 @@ Shader "HDRP/AxF"
/////////////////////////////////////////////////////////////////////////////
// General Parameters
+ // UI Only: transfered to _MappingMask
+ // BUG! 6 values work, not 7 -_-
+ //[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, PlanarXY, 4, PlanarYZ, 5, PlanarZX, 6, Triplanar, 7)] _MappingMode("Mapping Mode", Float) = 0
+ [HideInInspector] _MappingMode("Mapping Mode", Float) = 0
+ [HideInInspector] _MappingMask("MappingMask", Vector) = (1, 0, 0, 0)
+ // UI Only:
+ [Enum(World, 0, Local, 1)] _PlanarSpace("Planar/Triplanar space", Float) = 0
// Tilings and offsets
_Material_SO( "Main Material Tiling & Offset", Vector) = (1, 1, 0, 0)
@@ -151,6 +158,10 @@ Shader "HDRP/AxF"
#pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE //_SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP
+ #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
+ #pragma shader_feature_local _ _REQUIRE_UV1 _REQUIRE_UV2 _REQUIRE_UV3
+ #pragma shader_feature_local _ _PLANAR_LOCAL
+
#pragma shader_feature_local _ALPHATEST_ON
#pragma shader_feature_local _DOUBLESIDED_ON
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl
index e1ee3e925bc..7a03a7f06a3 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl
@@ -1,12 +1,428 @@
+//-------------------------------------------------------------------------------------
+// Defines
+//-------------------------------------------------------------------------------------
+// Gradients are now required:
+#define SURFACE_GRADIENT // Note: this affects Material/MaterialUtilities.hlsl's GetNormalWS() and makes it expect a surface gradient.
+
+//to test #define FLAKES_TILE_BEFORE_SCALE
+#define AXF_REUSE_SCREEN_DDXDDY
+// ...ie use _GRAD sampling for everything and calculate those only one time:
+// offset doesn't change derivatives, and scales just scales them, so we can cache them.
+
+// The compiler can't unroll the lightloop if flakes are sampled inside it, so we need to cache either LOD
+// or derivatives. We prefer the later, as the CalculateLevelOfDetail will not work when anisotropic filtering
+// is used, and AxF materials textures often have trilinear filtering set.
+#define FLAKES_USE_DDXDDY
+
+#define AXF_USES_RG_NORMAL_MAPS // else, RGB
+
//-------------------------------------------------------------------------------------
// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
+#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Sampling/SampleUVMapping.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
+//-----------------------------------------------------------------------------
+// Texture Mapping
+//-----------------------------------------------------------------------------
+#ifdef AXF_USES_RG_NORMAL_MAPS
+#define AXF_DERIVATIVE_NORMAL UnpackDerivativeNormalRGorAG
+#else
+#define AXF_DERIVATIVE_NORMAL UnpackDerivativeNormalRGB
+#endif
+
// Note: the scaling _Material_SO.xy should already be in texuv, but NOT the bias.
-#define AXF_TRANSFORM_TEXUV(texuv, name) ((texuv.xy) * name##_SO.xy + name##_SO.zw + _Material_SO.zw)
+#define AXF_TRANSFORM_TEXUV_BYNAME(texuv, name) ((texuv.xy) * name##_SO.xy + name##_SO.zw + _Material_SO.zw)
+#define AXF_GET_SINGE_SCALE_OFFSET(name) (name##_SO)
+#define AXF_TRANSFORM_TEXUV(texuv, scaleOffset) ((texuv.xy) * scaleOffset.xy + scaleOffset.zw + _Material_SO.zw)
+
+// Note: the scaling _Material_SO.xy should already be in ddx and ddy:
+#define AXF_SCALE_DDXDDY_BYNAME(vddx, name) ((vddx) * (name##_SO.xy))
+
+#if 0
+#define DDX(param) ddx_fine(param)
+#define DDY(param) ddy_fine(param)
+#else
+#define DDX(param) ddx(param)
+#define DDY(param) ddy(param)
+#endif
+
+struct TextureUVMapping
+{
+#ifdef _MAPPING_TRIPLANAR
+ float2 uvZY;
+ float2 uvXZ;
+ float2 uvXY;
+ float3 triplanarWeights;
+ float2 ddxZY;
+ float2 ddyZY;
+ float2 ddxXZ;
+ float2 ddyXZ;
+ float2 ddxXY;
+ float2 ddyXY;
+#else
+ float2 uvBase; // uv0..uv3 or a planar set (ZY, XZ or XY)
+ float2 ddxBase;
+ float2 ddyBase;
+#endif
+
+ float3 vertexNormalWS;
+ float3 vertexTangentWS;
+ float3 vertexBitangentWS;
+};
+
+void InitTextureUVMapping(FragInputs input, out TextureUVMapping uvMapping)
+{
+ float2 uvZY;
+ float2 uvXZ;
+ float2 uvXY;
+ float2 uv3 = 0;
+
+ // Set uv* variables above: they will contain a set of uv0...3 or a planar set:
+#if (defined(_MAPPING_PLANAR) || defined(_MAPPING_TRIPLANAR))
+ // planar/triplanar
+ uv3 = 0;
+
+#ifdef _PLANAR_LOCAL
+ // If we use local planar mapping, convert to local space
+ GetTriplanarCoordinate(TransformWorldToObject(input.positionRWS), uvXZ, uvXY, uvZY);
+#else
+ GetTriplanarCoordinate(GetAbsolutePositionWS(input.positionRWS), uvXZ, uvXY, uvZY);
+#endif
+
+ // Note: if only planar mapping is selected, we don't apply AxF main material tiling scale here,
+ // we select one set with _MappingMask into the uvBase and scale that.
+
+#ifdef _MAPPING_TRIPLANAR
+ // In that case, we will need to store the 3 sets of planar coordinates:
+ // (Apply AxF's main material tiling scale also)
+ uvMapping.uvZY = uvZY * _Material_SO.xy;
+ uvMapping.uvXZ = uvXZ * _Material_SO.xy;
+ uvMapping.uvXY = uvXY * _Material_SO.xy;
+
+ uvMapping.ddxZY = DDX(uvMapping.uvZY);
+ uvMapping.ddyZY = DDY(uvMapping.uvZY);
+ uvMapping.ddxXZ = DDX(uvMapping.uvXZ);
+ uvMapping.ddyXZ = DDY(uvMapping.uvXZ);
+ uvMapping.ddxXY = DDX(uvMapping.uvXY);
+ uvMapping.ddyXY = DDY(uvMapping.uvXY);
+
+#endif
+
+#else // #if (defined(_MAPPING_PLANAR) || defined(_MAPPING_TRIPLANAR))
+
+ // No planar and no triplanar: uvZY will alias uv0, uvXZ uv1 and uvXY uv2 and _MappingMask will select one:
+ uv3 = input.texCoord3.xy;
+ uvZY = input.texCoord0.xy;
+ uvXZ = input.texCoord1.xy;
+ uvXY = input.texCoord2.xy;
+#endif // #if (defined(_MAPPING_PLANAR) || defined(_MAPPING_TRIPLANAR))
+
+ // Set uvBase if not triplanar from the uv* variables above
+#ifndef _MAPPING_TRIPLANAR
+ // No triplanar: uvBase will store the selected single uv or planar coordinate set using _MappingMask:
+ uvMapping.uvBase = _MappingMask.x * uvZY + // texCoord0 if no planar
+ _MappingMask.y * uvXZ + // texCoord1 if no planar
+ _MappingMask.z * uvXY + // texCoord2 if no planar
+ _MappingMask.w * uv3; // _MappingMask.w should be 0 anyway if planar, but we force uv3 to 0
+
+ // Apply AxF's main material tiling scale:
+ uvMapping.uvBase *= _Material_SO.xy;
+
+ uvMapping.ddxBase = DDX(uvMapping.uvBase);
+ uvMapping.ddyBase = DDY(uvMapping.uvBase);
+
+#endif
+
+ // Calculate triplanar weights, interpreting "local planar space" for coordinates
+ // as applying to the normal (used for weighting the samples fetched from those planar coords) also.
+#ifdef _MAPPING_TRIPLANAR
+ float3 vertexNormal = input.tangentToWorld[2].xyz;
+#ifdef _PLANAR_LOCAL
+ // If we use local planar mapping, convert to local space
+ vertexNormal = TransformWorldToObjectDir(vertexNormal);
+#endif
+ uvMapping.triplanarWeights = ComputeTriplanarWeights(vertexNormal);
+#endif
+
+ // Use surface gradients to build an extra TBN is using anything other than UV0
+ // Otherwise, use the vertex stage provided TBN as default:
+
+ float3 vertexNormalWS = input.tangentToWorld[2];
+ uvMapping.vertexNormalWS = vertexNormalWS;
+ uvMapping.vertexTangentWS = input.tangentToWorld[0];
+ uvMapping.vertexBitangentWS = input.tangentToWorld[1];
+
+#if (defined(_REQUIRE_UV1)||defined(_REQUIRE_UV2)||defined(_REQUIRE_UV3))
+ float3 dPdx = ddx_fine(input.positionRWS);
+ float3 dPdy = ddy_fine(input.positionRWS);
+
+ float3 sigmaX = dPdx - dot(dPdx, vertexNormalWS) * vertexNormalWS;
+ float3 sigmaY = dPdy - dot(dPdy, vertexNormalWS) * vertexNormalWS;
+ //float flipSign = dot(sigmaY, cross(vertexNormalWS, sigmaX) ) ? -1.0 : 1.0;
+ float flipSign = dot(dPdy, cross(vertexNormalWS, dPdx)) < 0.0 ? -1.0 : 1.0; // gives same as the commented out line above
+
+#if defined(_REQUIRE_UV1)
+ SurfaceGradientGenBasisTB(vertexNormalWS, sigmaX, sigmaY, flipSign, input.texCoord1.xy, uvMapping.vertexTangentWS, uvMapping.vertexBitangentWS);
+#elif defined(_REQUIRE_UV2)
+ SurfaceGradientGenBasisTB(vertexNormalWS, sigmaX, sigmaY, flipSign, input.texCoord2.xy, uvMapping.vertexTangentWS, uvMapping.vertexBitangentWS);
+#elif defined(_REQUIRE_UV3)
+ SurfaceGradientGenBasisTB(vertexNormalWS, sigmaX, sigmaY, flipSign, input.texCoord3.xy, uvMapping.vertexTangentWS, uvMapping.vertexBitangentWS);
+#endif
+#endif //#if (defined(_REQUIRE_UV1)||defined(_REQUIRE_UV2)||defined(_REQUIRE_UV3))
+}
+
+// Make sure lodBiasOrGrad is used statically!
+//
+#define AXF_SAMPLE_USE_LOD 1
+#define AXF_SAMPLE_USE_BIAS 2
+#define AXF_SAMPLE_USE_GRAD 3
+
+// Note that scaleOffset are the texture specific ones, not the main material ones!
+float4 AxfSampleTexture2D(TEXTURE2D_PARAM(textureName, samplerName), float4 scaleOffset, TextureUVMapping uvMapping,
+ int lodBiasOrGrad = 0, float3 lodOrBias = 0, float3x2 triDdx = (float3x2)0, float3x2 triDdy = (float3x2)0)
+{
+ bool useLod = lodBiasOrGrad == 1;
+ bool useBias = lodBiasOrGrad == 2;
+ bool useGrad = lodBiasOrGrad == 3;
+ bool useCachedDdxDdy = false;
+#ifdef AXF_REUSE_SCREEN_DDXDDY
+ useCachedDdxDdy = false;
+#endif
+
+#ifdef _MAPPING_TRIPLANAR
+ float4 val = 0;
+
+ val += uvMapping.triplanarWeights.x
+ * ( useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), lodOrBias.x)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), lodOrBias.x)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), triDdx[0], triDdy[0])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), scaleOffset.xy * uvMapping.ddxZY, scaleOffset.xy * uvMapping.ddyZY)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset)) );
+ val += uvMapping.triplanarWeights.y
+ * ( useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), lodOrBias.y)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), lodOrBias.y)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), triDdx[1], triDdy[1])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), scaleOffset.xy * uvMapping.ddxXZ, scaleOffset.xy * uvMapping.ddyXZ)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset)) );
+ val += uvMapping.triplanarWeights.z
+ * ( useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), lodOrBias.z)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), lodOrBias.z)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), triDdx[2], triDdy[2])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), scaleOffset.xy * uvMapping.ddxXY, scaleOffset.xy * uvMapping.ddyXY)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset)) );
+
+ return val;
+#else
+ return useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), lodOrBias.x)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), lodOrBias.x)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), triDdx[0], triDdy[0])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), scaleOffset.xy * uvMapping.ddxBase, scaleOffset.xy * uvMapping.ddyBase)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset));
+#endif
+}
+
+// Normal map sampling requires special care especially for triplanar, we will use gradients for that.
+// Also, AxF normal maps are encoded on 3 channels (xyz) but are still tangent space.
+// Make sure useLod is used statically!
+// Note that scaleOffset are the texture specific ones, not the main material ones!
+float3 AxFSampleTexture2DNormalAsSurfaceGrad(TEXTURE2D_PARAM(textureName, samplerName), float4 scaleOffset, TextureUVMapping uvMapping,
+ int lodBiasOrGrad = 0, float3 lodOrBias = 0, float3x2 triDdx = (float3x2)0, float3x2 triDdy = (float3x2)0)
+{
+ float scale = 1.0;
+ bool useLod = lodBiasOrGrad == 1;
+ bool useBias = lodBiasOrGrad == 2;
+ bool useGrad = lodBiasOrGrad == 3;
+ bool useCachedDdxDdy = false;
+#ifdef AXF_REUSE_SCREEN_DDXDDY
+ useCachedDdxDdy = true;
+#endif
+
+#ifdef _MAPPING_TRIPLANAR
+
+ float2 derivXplane;
+ float2 derivYPlane;
+ float2 derivZPlane;
+ float4 packedNormal;
+ derivXplane = derivYPlane = derivZPlane = float2(0.0, 0.0);
+
+ // UnpackDerivativeNormalRGB will unpack an RGB tangent space normal map and output a corresponding height map gradient
+ // (We will sum those to get a volume gradient and from it a surface gradient (and/or a final normal). Both have 3 coordinates)
+
+ packedNormal = useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), lodOrBias.x)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), lodOrBias.x)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), triDdx[0], triDdy[0])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset), scaleOffset.xy * uvMapping.ddxZY, scaleOffset.xy * uvMapping.ddyZY)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvZY, scaleOffset));
+ derivXplane = uvMapping.triplanarWeights.x * AXF_DERIVATIVE_NORMAL(packedNormal, scale);
+
+ packedNormal = useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), lodOrBias.y)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), lodOrBias.y)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), triDdx[1], triDdy[1])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset), scaleOffset.xy * uvMapping.ddxXZ, scaleOffset.xy * uvMapping.ddyXZ)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXZ, scaleOffset));
+ derivYPlane = uvMapping.triplanarWeights.y * AXF_DERIVATIVE_NORMAL(packedNormal, scale);
+
+ packedNormal = useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), lodOrBias.z)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), lodOrBias.z)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), triDdx[2], triDdy[2])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset), scaleOffset.xy * uvMapping.ddxXY, scaleOffset.xy * uvMapping.ddyXY)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvXY, scaleOffset));
+ derivZPlane = uvMapping.triplanarWeights.z * AXF_DERIVATIVE_NORMAL(packedNormal, scale);
+
+ // Important note! See SurfaceGradientFromTriplanarProjection:
+ // Tiling scales should NOT be negative!
+
+ // Assume derivXplane, derivYPlane and derivZPlane sampled using (z,y), (z,x) and (x,y) respectively.
+ float3 volumeGrad = float3(derivZPlane.x + derivYPlane.y, derivZPlane.y + derivXplane.y, derivXplane.x + derivYPlane.x);
+ float3 surfaceGrad = SurfaceGradientFromVolumeGradient(uvMapping.vertexNormalWS, volumeGrad);
+
+ // We don't need to process further operation on the gradient, but we dont resolve it to a normal immediately:
+ // ie by doing return SurfaceGradientResolveNormal(uvMapping.vertexNormalWS, surfaceGrad);
+ // This is because we use GetNormalWS() later which with #define SURFACE_GRADIENT, expects a surface gradient.
+ return surfaceGrad;
+
+#else
+ // No triplanar: in that case, just sample the texture, but also unpacks it as a surface gradient! See comment above
+
+ float4 packedNormal = useLod ? SAMPLE_TEXTURE2D_LOD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), lodOrBias.x)
+ : useBias ? SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), lodOrBias.x)
+ : useGrad ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), triDdx[0], triDdy[0])
+ : useCachedDdxDdy ? SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset), scaleOffset.xy * uvMapping.ddxBase, scaleOffset.xy * uvMapping.ddyBase)
+ : SAMPLE_TEXTURE2D(textureName, samplerName, AXF_TRANSFORM_TEXUV(uvMapping.uvBase, scaleOffset));
+ float2 deriv = AXF_DERIVATIVE_NORMAL(packedNormal, scale);
+
+#ifndef _MAPPING_PLANAR
+ // No planar mapping, in that case, just use the generated (or simply cached if using uv0) TBN:
+ return SurfaceGradientFromTBN(deriv, uvMapping.vertexTangentWS, uvMapping.vertexBitangentWS);
+#else
+ float3 volumeGrad;
+
+ // We will use the mapping selector mask to know which plane we used.
+ // This allows us to properly build the volume gradient:
+ if (_MappingMask.x == 1.0) // uvZY
+ volumeGrad = float3(0.0, deriv.y, deriv.x);
+ else if (_MappingMask.y == 1.0) // uvXZ
+ volumeGrad = float3(deriv.y, 0.0, deriv.x);
+ else if (_MappingMask.z == 1.0) // uvXY
+ volumeGrad = float3(deriv.x, deriv.y, 0.0);
+
+ return SurfaceGradientFromVolumeGradient(uvMapping.vertexNormalWS, volumeGrad);
+#endif // if not _MAPPING_PLANAR
+#endif // if triplanar.
+}
+
+#define AXF_SAMPLE_TEXTURE2D(name, uvMapping) AxfSampleTexture2D(name, sampler##name, name##_SO, uvMapping)
+#define AXF_SAMPLE_SMP_TEXTURE2D(name, samplername, uvMapping) AxfSampleTexture2D(name, samplername, name##_SO, uvMapping)
+#define AXF_SAMPLE_SMP_TEXTURE2D_LOD(name, samplername, lod, uvMapping) AxfSampleTexture2D(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_LOD, lod)
+#define AXF_SAMPLE_SMP_TEXTURE2D_BIAS(name, samplername, bias, uvMapping) AxfSampleTexture2D(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_BIAS, bias)
+
+#ifdef _MAPPING_TRIPLANAR
+#define AXF_SAMPLE_SMP_TEXTURE2D_GRAD(name, samplername, triddx, triddy, uvMapping) AxfSampleTexture2D(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_GRAD, /*unused*/(float3)0, triddx, triddy)
+#else
+#define AXF_SAMPLE_SMP_TEXTURE2D_GRAD(name, samplername, vddx, vddy, uvMapping) AxfSampleTexture2D(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_GRAD, /*unused*/(float3)0, float3x2(vddx, (float2)0, (float2)0), float3x2(vddy, (float2)0, (float2)0))
+#endif
+
+#define AXF_SAMPLE_TEXTURE2D_NORMAL_AS_GRAD(name, uvMapping) AxFSampleTexture2DNormalAsSurfaceGrad(name, sampler##name, name##_SO, uvMapping)
+#define AXF_SAMPLE_SMP_TEXTURE2D_NORMAL_AS_GRAD(name, samplername, uvMapping) AxFSampleTexture2DNormalAsSurfaceGrad(name, samplername, name##_SO, uvMapping)
+#define AXF_SAMPLE_SMP_TEXTURE2D_LOD_NORMAL_AS_GRAD(name, samplername, lod, uvMapping) AxFSampleTexture2DNormalAsSurfaceGrad(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_LOD, lod)
+#define AXF_SAMPLE_SMP_TEXTURE2D_BIAS_NORMAL_AS_GRAD(name, samplername, bias, uvMapping) AxFSampleTexture2DNormalAsSurfaceGrad(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_BIAS, bias)
+
+#ifdef _MAPPING_TRIPLANAR
+#define AXF_SAMPLE_SMP_TEXTURE2D_GRAD_NORMAL_AS_GRAD(name, samplername, triddx, triddy, uvMapping) AxFSampleTexture2DNormalAsSurfaceGrad(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_GRAD, /*unused*/(float3)0, triddx, triddy)
+#else
+#define AXF_SAMPLE_SMP_TEXTURE2D_GRAD_NORMAL_AS_GRAD(name, samplername, vddx, vddy, uvMapping) AxFSampleTexture2DNormalAsSurfaceGrad(name, samplername, name##_SO, uvMapping, /*lodBiasOrGrad*/ AXF_SAMPLE_USE_GRAD, /*unused*/(float3)0, float3x2(vddx, (float2)0, (float2)0), float3x2(vddy, (float2)0, (float2)0))
+#endif
+
+
+float2 TileFlakesUV(float2 flakesUV)
+{
+ // Create mirrored UVs to hide flakes tiling
+ // TODO_FLAKES: this isn't tiling!
+ if ((int(flakesUV.y) & 1) == 0)
+ flakesUV.x += 0.5;
+ else if ((uint(1000.0 + flakesUV.x) % 3) == 0)
+ flakesUV.y = 1.0 - flakesUV.y;
+ else
+ flakesUV.x = 1.0 - flakesUV.x;
+
+ return flakesUV;
+}
+
+
+void SetFlakesSurfaceData(TextureUVMapping uvMapping, inout SurfaceData surfaceData)
+{
+ surfaceData.flakesDdxZY = surfaceData.flakesDdyZY = surfaceData.flakesDdxXZ = surfaceData.flakesDdyXZ =
+ surfaceData.flakesDdxXY = surfaceData.flakesDdyXY = 0;
+
+#ifdef _MAPPING_TRIPLANAR
+ float2 uv;
+
+ uv = AXF_TRANSFORM_TEXUV_BYNAME(uvMapping.uvZY, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesMipLevelZY = CALCULATE_TEXTURE2D_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap, uv);
+#ifndef FLAKES_TILE_BEFORE_SCALE
+ surfaceData.flakesUVZY = TileFlakesUV(uv);
+#else
+ surfaceData.flakesUVZY = AXF_TRANSFORM_TEXUV_BYNAME(TileFlakesUV(uvMapping.uvZY), _CarPaint2_BTFFlakeMap);
+#endif
+
+ uv = AXF_TRANSFORM_TEXUV_BYNAME(uvMapping.uvXZ, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesMipLevelXZ = CALCULATE_TEXTURE2D_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap, uv);
+#ifndef FLAKES_TILE_BEFORE_SCALE
+ surfaceData.flakesUVXZ = TileFlakesUV(uv);
+#else
+ surfaceData.flakesUVXZ = AXF_TRANSFORM_TEXUV_BYNAME(TileFlakesUV(uvMapping.uvXZ), _CarPaint2_BTFFlakeMap);
+#endif
+
+ uv = AXF_TRANSFORM_TEXUV_BYNAME(uvMapping.uvXY, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesMipLevelXY = CALCULATE_TEXTURE2D_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap, uv);
+#ifndef FLAKES_TILE_BEFORE_SCALE
+ surfaceData.flakesUVXY = TileFlakesUV(uv);
+#else
+ surfaceData.flakesUVXY = AXF_TRANSFORM_TEXUV_BYNAME(TileFlakesUV(uvMapping.uvXY), _CarPaint2_BTFFlakeMap);
+#endif
+
+ surfaceData.flakesTriplanarWeights = uvMapping.triplanarWeights;
+
+#ifdef FLAKES_USE_DDXDDY
+ // Filling surfaceData.flakesDdx* to nonzero values will automatically ignore surfaceData.flakesMipLevel*
+ // and the compiler will optimize them out (see SampleFlakes in AxF.hlsl)
+ surfaceData.flakesDdxZY = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddxZY, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesDdyZY = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddyZY, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesDdxXZ = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddxXZ, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesDdyXZ = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddyXZ, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesDdxXY = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddxXY, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesDdyXY = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddyXY, _CarPaint2_BTFFlakeMap);
+#endif
+
+#else // TRIPLANAR
+
+ float2 uv;
+ // NOTE: When not triplanar UVZY has one uv set or one planar coordinate set,
+ // and this planar coordinate set isn't necessarily ZY, we just reuse this field
+ // as a common one.
+ uv = AXF_TRANSFORM_TEXUV_BYNAME(uvMapping.uvBase, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesMipLevelZY = CALCULATE_TEXTURE2D_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap, uv);
+#ifndef FLAKES_TILE_BEFORE_SCALE
+ surfaceData.flakesUVZY = TileFlakesUV(uv);
+#else
+ surfaceData.flakesUVZY = AXF_TRANSFORM_TEXUV_BYNAME(TileFlakesUV(uvMapping.uvBase), _CarPaint2_BTFFlakeMap);
+#endif
+
+#ifdef FLAKES_USE_DDXDDY
+ // Filling surfaceData.flakesDdx* to nonzero values will automatically ignore surfaceData.flakesMipLevel*
+ // and the compiler will optimize them out (see SampleFlakes in AxF.hlsl)
+ surfaceData.flakesDdxZY = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddxBase, _CarPaint2_BTFFlakeMap);
+ surfaceData.flakesDdyZY = AXF_SCALE_DDXDDY_BYNAME(uvMapping.ddyBase, _CarPaint2_BTFFlakeMap);
+#endif
+
+ surfaceData.flakesUVXZ = surfaceData.flakesUVXY = 0;
+ surfaceData.flakesMipLevelXZ = surfaceData.flakesMipLevelXY = 0;
+ surfaceData.flakesTriplanarWeights = 0;
+#endif
+}
void ApplyDecalToSurfaceData(DecalSurfaceData decalSurfaceData, inout SurfaceData surfaceData)
{
@@ -58,11 +474,11 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
ApplyDoubleSidedFlipOrMirror(input, doubleSidedConstants); // Apply double sided flip on the vertex normal
- float2 UV0 = input.texCoord0.xy * _Material_SO.xy;
+ // Note that in uvMapping, the main scaling _Material_SO.xy has been applied:
+ TextureUVMapping uvMapping;
+ InitTextureUVMapping(input, uvMapping);
+ ZERO_INITIALIZE(SurfaceData, surfaceData);
- //-----------------------------------------------------------------------------
- // _AXF_BRDF_TYPE_SVBRDF
- //-----------------------------------------------------------------------------
float alpha = 1.0;
@@ -70,50 +486,45 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
surfaceData.specularOcclusion = 1.0;
surfaceData.specularLobe = 0;
+ //-----------------------------------------------------------------------------
+ // _AXF_BRDF_TYPE_SVBRDF
+ //-----------------------------------------------------------------------------
+
#ifdef _AXF_BRDF_TYPE_SVBRDF
- surfaceData.diffuseColor =
- SAMPLE_TEXTURE2D(_SVBRDF_DiffuseColorMap, sampler_SVBRDF_DiffuseColorMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_DiffuseColorMap)).xyz;
- surfaceData.specularColor =
- SAMPLE_TEXTURE2D(_SVBRDF_SpecularColorMap, sampler_SVBRDF_SpecularColorMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_SpecularColorMap)).xyz;
- surfaceData.specularLobe.xy =
- _SVBRDF_SpecularLobeMapScale * SAMPLE_TEXTURE2D(_SVBRDF_SpecularLobeMap, sampler_SVBRDF_SpecularLobeMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_SpecularLobeMap)).xy;
+ surfaceData.diffuseColor = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_DiffuseColorMap, sampler_SVBRDF_DiffuseColorMap, uvMapping).xyz;
+ surfaceData.specularColor = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_SpecularColorMap, sampler_SVBRDF_SpecularColorMap, uvMapping).xyz;
+ surfaceData.specularLobe.xy = _SVBRDF_SpecularLobeMapScale * AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_SpecularLobeMap, sampler_SVBRDF_SpecularLobeMap, uvMapping).xy;
// The AxF models include both a general coloring term that they call "specular color" while the f0 is actually another term,
// seemingly always scalar:
- surfaceData.fresnelF0 = SAMPLE_TEXTURE2D(_SVBRDF_FresnelMap, sampler_SVBRDF_FresnelMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_FresnelMap)).x;
- surfaceData.height_mm = SAMPLE_TEXTURE2D(_SVBRDF_HeightMap, sampler_SVBRDF_HeightMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_HeightMap)).x * _SVBRDF_HeightMapMaxMM;
+ surfaceData.fresnelF0 = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_FresnelMap, sampler_SVBRDF_FresnelMap, uvMapping).x;
+ surfaceData.height_mm = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_HeightMap, sampler_SVBRDF_HeightMap, uvMapping).x * _SVBRDF_HeightMapMaxMM;
// Our importer range remaps the [-HALF_PI, HALF_PI) range to [0,1). We map back here:
surfaceData.anisotropyAngle =
- HALF_PI * (2.0 * SAMPLE_TEXTURE2D(_SVBRDF_AnisoRotationMap, sampler_SVBRDF_AnisoRotationMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_AnisoRotationMap)).x - 1.0);
- surfaceData.clearcoatColor =
- SAMPLE_TEXTURE2D(_SVBRDF_ClearcoatColorMap, sampler_SVBRDF_ClearcoatColorMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_ClearcoatColorMap)).xyz;
+ HALF_PI * (2.0 * AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_AnisoRotationMap, sampler_SVBRDF_AnisoRotationMap, uvMapping).x - 1.0);
+ surfaceData.clearcoatColor = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_ClearcoatColorMap, sampler_SVBRDF_ClearcoatColorMap, uvMapping).xyz;
// The importer transforms the IOR to an f0, we map it back here as an IOR clamped under at 1.0
// TODO: if we're reusing float textures anyway, we shouldn't need the normalization that transforming to an f0 provides.
- float clearcoatF0 = SAMPLE_TEXTURE2D(_SVBRDF_ClearcoatIORMap, sampler_SVBRDF_ClearcoatIORMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_ClearcoatIORMap)).x;
+ float clearcoatF0 = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_ClearcoatIORMap, sampler_SVBRDF_ClearcoatIORMap, uvMapping).x;
float sqrtF0 = sqrt(clearcoatF0);
surfaceData.clearcoatIOR = max(1.0, (1.0 + sqrtF0) / (1.00001 - sqrtF0)); // We make sure it's working for F0=1
+ //
// TBN
- GetNormalWS(
- input,
- 2.0 * SAMPLE_TEXTURE2D(_SVBRDF_NormalMap, sampler_SVBRDF_NormalMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_NormalMap)).xyz - 1.0,
- surfaceData.normalWS,
- doubleSidedConstants
- );
- GetNormalWS(
- input,
- 2.0 * SAMPLE_TEXTURE2D(_ClearcoatNormalMap, sampler_ClearcoatNormalMap, AXF_TRANSFORM_TEXUV(UV0, _ClearcoatNormalMap)).xyz - 1.0,
- surfaceData.clearcoatNormalWS,
- doubleSidedConstants
- );
-
- alpha = SAMPLE_TEXTURE2D(_SVBRDF_AlphaMap, sampler_SVBRDF_AlphaMap, AXF_TRANSFORM_TEXUV(UV0, _SVBRDF_AlphaMap)).x;
-
- // Useless for SVBRDF
- surfaceData.flakesUV = input.texCoord0.xy;
- surfaceData.flakesMipLevel = 0.0;
+ //
+ // Note: since SURFACE_GRADIENT is enabled, resolve is done with input.tangentToWorld[2] in GetNormalWS(),
+ // and uvMapping uses that as vertexNormalWS.
+
+ //Normal sampling:
+ GetNormalWS(input, AXF_SAMPLE_SMP_TEXTURE2D_NORMAL_AS_GRAD(_SVBRDF_NormalMap, sampler_SVBRDF_NormalMap, uvMapping).xyz, surfaceData.normalWS, doubleSidedConstants);
+ GetNormalWS(input, AXF_SAMPLE_SMP_TEXTURE2D_NORMAL_AS_GRAD(_ClearcoatNormalMap, sampler_ClearcoatNormalMap, uvMapping).xyz, surfaceData.clearcoatNormalWS, doubleSidedConstants);
+
+ // Useless for SVBRDF, will be optimized out
+ //SetFlakesSurfaceData(uvMapping, surfaceData);
+
+ alpha = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_AlphaMap, sampler_SVBRDF_AlphaMap, uvMapping).x;
//-----------------------------------------------------------------------------
// _AXF_BRDF_TYPE_CAR_PAINT
@@ -127,24 +538,9 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
surfaceData.specularLobe = _CarPaint2_CTSpreads.xyz; // We may want to modify these (eg for Specular AA)
surfaceData.normalWS = input.tangentToWorld[2].xyz;
- GetNormalWS(
- input,
- 2.0 * SAMPLE_TEXTURE2D(_ClearcoatNormalMap, sampler_ClearcoatNormalMap, AXF_TRANSFORM_TEXUV(UV0, _ClearcoatNormalMap)).xyz - 1.0,
- surfaceData.clearcoatNormalWS,
- doubleSidedConstants
- );
+ GetNormalWS(input, AXF_SAMPLE_SMP_TEXTURE2D_NORMAL_AS_GRAD(_ClearcoatNormalMap, sampler_ClearcoatNormalMap, uvMapping).xyz, surfaceData.clearcoatNormalWS, doubleSidedConstants);
- surfaceData.flakesUV = AXF_TRANSFORM_TEXUV(UV0, _CarPaint2_BTFFlakeMap);
- surfaceData.flakesMipLevel = CALCULATE_TEXTURE2D_LOD(_CarPaint2_BTFFlakeMap, sampler_CarPaint2_BTFFlakeMap, surfaceData.flakesUV);
-
- // Create mirrored UVs to hide flakes tiling
- // TODO_FLAKES: this isn't really tiling
- if ((int(surfaceData.flakesUV.y) & 1) == 0)
- surfaceData.flakesUV.x += 0.5;
- else if ((uint(1000.0 + surfaceData.flakesUV.x) % 3) == 0)
- surfaceData.flakesUV.y = 1.0 - surfaceData.flakesUV.y;
- else
- surfaceData.flakesUV.x = 1.0 - surfaceData.flakesUV.x;
+ SetFlakesSurfaceData(uvMapping, surfaceData);
// Useless for car paint BSDF
surfaceData.specularColor = 0;
@@ -175,13 +571,18 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
surfaceData.geomNormalWS = input.tangentToWorld[2];
// Finalize tangent space
- surfaceData.tangentWS = input.tangentToWorld[0];
+ surfaceData.tangentWS = uvMapping.vertexTangentWS;
+ // TODOTODO:
+ // This is crappy: anisotropy rotation don't mix triplanar style like scalar values because of what it represents. That's why in HDRP we use
+ // tangent space tangent vector maps and triplanar sample those as we do normals in the surface gradients framework!
+ // Better to rebuild a gradient in the proper space from each rotation, combine those gradients as normals and resolve here.
if (HasAnisotropy())
{
float3 tangentTS = float3(1, 0, 0);
// We will keep anisotropyAngle in surfaceData for now for debug info, register will be freed
// anyway by the compiler (never used again after this)
sincos(surfaceData.anisotropyAngle, tangentTS.y, tangentTS.x);
+ float3x3 tbn = float3x3(uvMapping.vertexTangentWS, uvMapping.vertexBitangentWS, uvMapping.vertexNormalWS);
surfaceData.tangentWS = TransformTangentToWorld(tangentTS, input.tangentToWorld);
}
@@ -204,7 +605,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
// Unity's WS is left handed, so this makes a difference here).
#ifdef _ALPHATEST_ON
- // TODO: Move alpha test earlier and test.
+ // TODOTODO: Move alpha test earlier and test.
float alphaCutoff = _AlphaCutoff;
#if SHADERPASS == SHADERPASS_SHADOWS
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFProperties.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFProperties.hlsl
index d19ba0e0cad..59d7ab2b016 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFProperties.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFProperties.hlsl
@@ -51,6 +51,8 @@ SAMPLER(sampler_SVBRDF_ClearcoatIORMap);
CBUFFER_START(UnityPerMaterial)
+ float4 _MappingMask;
+
// Scale/Offsets:
float4 _Material_SO; // Main scale, TODO: scale - but not offset - could be moved to vertex shader and applied to uv0
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDepthPass.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDepthPass.hlsl
index 41073524c16..54d1d63f832 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDepthPass.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDepthPass.hlsl
@@ -2,17 +2,60 @@
#error Undefine_SHADERPASS
#endif
-#ifdef _ALPHATEST_ON
+// Attributes
+#define REQUIRE_TANGENT_TO_WORLD defined(_PIXEL_DISPLACEMENT)
+#define REQUIRE_NORMAL defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD || defined(_VERTEX_DISPLACEMENT)
+#define REQUIRE_VERTEX_COLOR (defined(_VERTEX_DISPLACEMENT) || defined(_TESSELLATION_DISPLACEMENT) || (defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))))
+
+// This first set of define allow to say which attributes will be use by the mesh in the vertex and domain shader (for tesselation)
+
+// Tesselation require normal
+#if REQUIRE_NORMAL
+#define ATTRIBUTES_NEED_NORMAL
+#endif
+#if REQUIRE_TANGENT_TO_WORLD
+#define ATTRIBUTES_NEED_TANGENT
+#endif
+#if REQUIRE_VERTEX_COLOR
+#define ATTRIBUTES_NEED_COLOR
+#endif
+
+// About UV
+// When UVX is present, we assume that UVX - 1 ... UV0 is present
+
+#if defined(_VERTEX_DISPLACEMENT) || REQUIRE_TANGENT_TO_WORLD || defined(_ALPHATEST_ON) || defined(_TESSELLATION_DISPLACEMENT)
#define ATTRIBUTES_NEED_TEXCOORD0
#define ATTRIBUTES_NEED_TEXCOORD1
+ #if defined(_REQUIRE_UV2) || defined(_REQUIRE_UV3)
+ #define ATTRIBUTES_NEED_TEXCOORD2
+ #endif
+ #if defined(_REQUIRE_UV3)
+ #define ATTRIBUTES_NEED_TEXCOORD3
+ #endif
+#endif
+// Varying - Use for pixel shader
+// This second set of define allow to say which varyings will be output in the vertex (no more tesselation)
+#if REQUIRE_TANGENT_TO_WORLD
+#define VARYINGS_NEED_TANGENT_TO_WORLD
+#endif
+
+#if REQUIRE_TANGENT_TO_WORLD || defined(_ALPHATEST_ON)
#define VARYINGS_NEED_POSITION_WS // Required to get view vector and to get planar/triplanar mapping working
#define VARYINGS_NEED_TEXCOORD0
#define VARYINGS_NEED_TEXCOORD1
-
+ #ifdef ATTRIBUTES_NEED_TEXCOORD2
+ #define VARYINGS_NEED_TEXCOORD2
+ #endif
+ #ifdef ATTRIBUTES_NEED_TEXCOORD3
+ #define VARYINGS_NEED_TEXCOORD3
+ #endif
+ #ifdef ATTRIBUTES_NEED_COLOR
+ #define VARYINGS_NEED_COLOR
+ #endif
#elif defined(LOD_FADE_CROSSFADE)
#define VARYINGS_NEED_POSITION_WS // Required to get view vector use in cross fade effect
-#endif //..._ALPHATEST_ON
+#endif
// This include will define the various Attributes/Varyings structure
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VaryingMesh.hlsl"
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl
deleted file mode 100644
index 12a2bc95f54..00000000000
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef SHADERPASS
-#error Undefine_SHADERPASS
-#endif
-
-// NEWLITTODO : Handling of TESSELATION, DISPLACEMENT, HEIGHTMAP, WIND
-
-#define ATTRIBUTES_NEED_TEXCOORD0
-
-#define VARYINGS_NEED_TEXCOORD0
-
-// This include will define the various Attributes/Varyings structure
-#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VaryingMesh.hlsl"
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl.meta
deleted file mode 100644
index b32a9b2863e..00000000000
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFDistortionPass.hlsl.meta
+++ /dev/null
@@ -1,9 +0,0 @@
-fileFormatVersion: 2
-guid: 7d97a7af62e578b4fa1b4a687f9c91a1
-ShaderImporter:
- externalObjects: {}
- defaultTextures: []
- nonModifiableTextures: []
- userData:
- assetBundleName:
- assetBundleVariant:
From d094c5a38012508e1fa623c9809d1a25ad2d2755 Mon Sep 17 00:00:00 2001
From: slunity <37302815+slunity@users.noreply.github.com>
Date: Fri, 12 Jun 2020 05:45:53 -0400
Subject: [PATCH 02/58] [10.x.x] Axf fix shininess exp to roughness, ssr
transparent and alpha test #587
---
.../Vulkan/None/1451_AxF_SVBRDF.png | 4 +-
.../CHANGELOG.md | 2 +
.../Editor/Material/AxF/AxFGUI.cs | 9 +++-
.../Runtime/Material/AxF/AxF.hlsl | 16 ++----
.../Runtime/Material/AxF/AxF.shader | 3 +-
.../Runtime/Material/AxF/AxFData.hlsl | 51 +++++++++++++------
6 files changed, 53 insertions(+), 32 deletions(-)
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
index 59a315367ee..ee8f0d73692 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:8bdf1ab6a1eadcb6d50029cae7e8099d64d50f777307b6298fd856c679abe7c0
-size 156437
+oid sha256:6bba19dc68f61b58aae5de4d46cb82e260c9eed2483851d9cf0d7456233e4c99
+size 261
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 1f0072bb9da..e57900c0743 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -59,6 +59,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Tentative fix for missing include in depth of field shaders.
- Fixed Wizard check on default volume profile to also check it is not the default one in package.
- Fixed light layers not correctly disabled when the lightlayers is set to Nothing and Lightlayers isn't enabled in HDRP Asset
+- Fixed AxF handling of roughness for Blinn-Phong type materials
+- Fixed AxF UI errors when surface type is switched to transparent
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
index 2f6a862523d..6b8320c8a02 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
@@ -132,8 +132,13 @@ static public void SetupMaterialKeywordsAndPass(Material material)
// Keywords for opt-out of decals and SSR:
bool decalsEnabled = material.HasProperty(kEnableDecals) && material.GetFloat(kEnableDecals) > 0.0f;
CoreUtils.SetKeyword(material, "_DISABLE_DECALS", decalsEnabled == false);
- bool ssrEnabled = material.HasProperty(kEnableSSR) && material.GetFloat(kEnableSSR) > 0.0f;
- CoreUtils.SetKeyword(material, "_DISABLE_SSR", ssrEnabled == false);
+ bool ssrEnabled = false;
+ if (material.GetSurfaceType() == SurfaceType.Transparent)
+ ssrEnabled = material.HasProperty(kReceivesSSRTransparent) ? material.GetFloat(kReceivesSSRTransparent) != 0 : false;
+ else
+ ssrEnabled = material.HasProperty(kReceivesSSR) ? material.GetFloat(kReceivesSSR) != 0 : false;
+ CoreUtils.SetKeyword(material, "_DISABLE_SSR", material.HasProperty(kReceivesSSR) && material.GetFloat(kReceivesSSR) == 0.0f);
+ CoreUtils.SetKeyword(material, "_DISABLE_SSR_TRANSPARENT", material.HasProperty(kReceivesSSRTransparent) && material.GetFloat(kReceivesSSRTransparent) == 0.0);
CoreUtils.SetKeyword(material, "_ENABLE_GEOMETRIC_SPECULAR_AA", material.HasProperty(kEnableGeometricSpecularAA) && material.GetFloat(kEnableGeometricSpecularAA) > 0.0f);
CoreUtils.SetKeyword(material, "_SPECULAR_OCCLUSION_NONE", material.HasProperty(kSpecularOcclusionMode) && material.GetFloat(kSpecularOcclusionMode) == 0.0f);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
index fb145c24cc0..29a7ad28cef 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
@@ -1175,7 +1175,8 @@ PreLightData GetPreLightData(float3 viewWS_Clearcoat, PositionInputs posInput
preLightData.iblPerceptualRoughness = PerceptualRoughnessBeckmannToGGX(preLightData.iblPerceptualRoughness);
break;
- // case 1: // @TODO: Support Blinn-Phong FGD?
+ case 1: //Phong
+ case 4: //Blinn-Phong : just approximate with Cook-Torrance which uses a Beckmann distribution
case 2:
GetPreIntegratedFGDCookTorranceAndLambert(NdotV_UnderCoat, preLightData.iblPerceptualRoughness, tempF0, preLightData.specularFGD, preLightData.diffuseFGD, specularReflectivity);
preLightData.specularFGD *= GetPreIntegratedFGDCookTorranceSampleMutiplier();
@@ -1186,8 +1187,6 @@ PreLightData GetPreLightData(float3 viewWS_Clearcoat, PositionInputs posInput
GetPreIntegratedFGDGGXAndLambert(NdotV_UnderCoat, preLightData.iblPerceptualRoughness, tempF0, preLightData.specularFGD, preLightData.diffuseFGD, specularReflectivity);
break;
- // case 4: // @TODO: Support Blinn-Phong FGD?
-
default: // Use GGX by default
GetPreIntegratedFGDGGXAndLambert(NdotV_UnderCoat, preLightData.iblPerceptualRoughness, tempF0, preLightData.specularFGD, preLightData.diffuseFGD, specularReflectivity);
break;
@@ -1356,14 +1355,6 @@ PreLightData GetPreLightData(float3 viewWS_Clearcoat, PositionInputs posInput
case 1: // BLINN-PHONG
case 4: // PHONG;
{
- // According to https://computergraphics.stackexchange.com/questions/1515/what-is-the-accepted-method-of-converting-shininess-to-roughness-and-vice-versa
- // float exponent = 2/roughness^4 - 2;
- //
- float exponent = PerceptualRoughnessToRoughness(preLightData.iblPerceptualRoughness);
- float roughness = pow(max(0.0, 2.0 / (exponent + 2)), 1.0 / 4.0);
- // todo_modes todo_pseudorefract: cant use undercoat like that
- //float2 UV = LTCGetSamplingUV(NdotV_UnderCoat, RoughnessToPerceptualRoughness(roughness));
- float2 UV = LTCGetSamplingUV(NdotV_Clearcoat, RoughnessToPerceptualRoughness(roughness));
preLightData.ltcTransformSpecular = LTCSampleMatrix(UV, LTC_MATRIX_INDEX_COOK_TORRANCE);
break;
}
@@ -1576,7 +1567,8 @@ float3 ComputeWard(float3 H, float LdotH, float NdotL, float NdotV, PreLightData
float3 ComputeBlinnPhong(float3 H, float LdotH, float NdotL, float NdotV, PreLightData preLightData, BSDFData bsdfData)
{
- float2 exponents = exp2(bsdfData.roughness.xy);
+ // See AxFGetRoughnessFromSpecularLobeTexture in AxFData
+ float2 exponents = 2 * rcp(max(0.0001,(bsdfData.roughness.xy*bsdfData.roughness.xy))) - 2;
// Evaluate normal distribution function
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.biTangentWS), dot(H, bsdfData.normalWS));
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
index 30748367cce..e5814dc28d7 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
@@ -141,7 +141,7 @@ Shader "HDRP/AxF"
[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0
-
+ [ToggleUI] _ReceivesSSRTransparent("Receives SSR Transparent", Float) = 0.0
[ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0
}
@@ -167,6 +167,7 @@ Shader "HDRP/AxF"
#pragma shader_feature_local _DISABLE_DECALS
#pragma shader_feature_local _DISABLE_SSR
+ #pragma shader_feature_local _DISABLE_SSR_TRANSPARENT
#pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA
#pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl
index 7a03a7f06a3..8c603b0017a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl
@@ -464,6 +464,29 @@ void ApplyDecalToSurfaceData(DecalSurfaceData decalSurfaceData, inout SurfaceDat
#endif
}
+bool HasPhongTypeBRDF()
+{
+ uint type = ((_SVBRDF_BRDFType >> 1) & 7);
+ return type == 1 || type == 4;
+}
+
+float2 AxFGetRoughnessFromSpecularLobeTexture(float2 specularLobe)
+{
+ // For Blinn-Phong, AxF encodes specularLobe.xy as log2(shiniExp_xy) so
+ // shiniExp = exp2(abs(specularLobe.xy))
+ // A good fit for a corresponding Beckmann roughness is
+ // roughnessBeckmann^2 = 2 /(shiniExp + 2)
+ // See eg
+ // http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
+ // http://simonstechblog.blogspot.com/2011/12/microfacet-brdf.html
+
+ // We thus have
+ // roughnessBeckmann = sqrt(2) * rsqrt(exp2(abs(specularLobe.xy)) + 2);
+ // shiniExp = 2 * rcp(max(0.0001,(roughnessBeckmann*roughnessBeckmann))) - 2;
+
+ return (HasPhongTypeBRDF() ? (sqrt(2) * rsqrt(exp2(abs(specularLobe)) + 2)) : specularLobe);
+}
+
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
#ifdef _DOUBLESIDED_ON
@@ -479,8 +502,18 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
InitTextureUVMapping(input, uvMapping);
ZERO_INITIALIZE(SurfaceData, surfaceData);
+ float alpha = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_AlphaMap, sampler_SVBRDF_AlphaMap, uvMapping).x;
+
+#ifdef _ALPHATEST_ON
+ // TODOTODO: Move alpha test earlier and test.
+ float alphaCutoff = _AlphaCutoff;
- float alpha = 1.0;
+ #if SHADERPASS == SHADERPASS_SHADOWS
+ GENERIC_ALPHA_TEST(alpha, _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff);
+ #else
+ GENERIC_ALPHA_TEST(alpha, alphaCutoff);
+ #endif
+#endif
surfaceData.ambientOcclusion = 1.0;
surfaceData.specularOcclusion = 1.0;
@@ -494,7 +527,8 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
surfaceData.diffuseColor = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_DiffuseColorMap, sampler_SVBRDF_DiffuseColorMap, uvMapping).xyz;
surfaceData.specularColor = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_SpecularColorMap, sampler_SVBRDF_SpecularColorMap, uvMapping).xyz;
- surfaceData.specularLobe.xy = _SVBRDF_SpecularLobeMapScale * AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_SpecularLobeMap, sampler_SVBRDF_SpecularLobeMap, uvMapping).xy;
+ surfaceData.specularLobe.xy = _SVBRDF_SpecularLobeMapScale * AxFGetRoughnessFromSpecularLobeTexture(
+ AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_SpecularLobeMap, sampler_SVBRDF_SpecularLobeMap, uvMapping).xy);
// The AxF models include both a general coloring term that they call "specular color" while the f0 is actually another term,
// seemingly always scalar:
@@ -524,8 +558,6 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
// Useless for SVBRDF, will be optimized out
//SetFlakesSurfaceData(uvMapping, surfaceData);
- alpha = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_AlphaMap, sampler_SVBRDF_AlphaMap, uvMapping).x;
-
//-----------------------------------------------------------------------------
// _AXF_BRDF_TYPE_CAR_PAINT
//-----------------------------------------------------------------------------
@@ -604,17 +636,6 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
// the handedness of the world space (tangentToWorld can be passed right handed while
// Unity's WS is left handed, so this makes a difference here).
-#ifdef _ALPHATEST_ON
- // TODOTODO: Move alpha test earlier and test.
- float alphaCutoff = _AlphaCutoff;
-
- #if SHADERPASS == SHADERPASS_SHADOWS
- GENERIC_ALPHA_TEST(alpha, _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff);
- #else
- GENERIC_ALPHA_TEST(alpha, alphaCutoff);
- #endif
-#endif
-
#if defined(_ENABLE_GEOMETRIC_SPECULAR_AA)
// Specular AA for geometric curvature
From 5f86be48ac33195abfd77f2fcd90603a90666638 Mon Sep 17 00:00:00 2001
From: JordanL8
Date: Sat, 6 Jun 2020 01:40:03 +0100
Subject: [PATCH 03/58] Update Light-Component.md (#682)
---
.../Documentation~/Light-Component.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md b/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md
index cc7d7669fea..a889989aa30 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md
@@ -216,7 +216,7 @@ This section is only available in Realtime or Mixed light **Mode**.
| **Blur Passes** | Use the slider to set the number of blur passes HDRP performs on this shadow map. Increasing this value softens shadows, but impacts performance. This property only appears if you select **Rectangle** from the **Type** drop-down and enable [more options](More-Options.html) for this section. |
| **Dimmer** | Dims the shadows this Light casts so they become more faded and transparent.
This property only appears when you enable [more options](More-Options.html) for this section. |
| **Tint** | Specifies whether HDRP should tint the shadows this Light casts. This option affects dynamic shadows, [Contact Shadows](Override-Contact-Shadows.md), and [ShadowMask](Lighting-Mode-Shadowmask.md). It does not affect baked shadows. You can use this behavior to change the color and transparency of shadows.
This property only appears when you enable the [more options](More-Options.html) for this section. |
-| **Penumbra Tint** | Specifies whether the tint should only affect the shadow's penumbra.
This property only appears when you enable the [more options](More-Options.htmlMore-Options.html) for this section. |
+| **Penumbra Tint** | Specifies whether the tint should only affect the shadow's penumbra. If you enable this property, HDRP only applies the color tint to the shadow's penumbra. If you disable this property, HDRP applies the color tint to the entire shadow including the penumbra. To change the color HDRP tints the shadow to, see the above **Tint** property.
This property only appears when you enable the [more options](More-Options.htmlMore-Options.html) for this section. |
| **Fade Distance** | The distance, in meters, between the Camera and the Light at which shadows fade out. This property is available for **Spot** and **Point** Lights.
This property only appears when you enable [more options](More-Options.html) for this section. |
| **Link Light Layer** | Enable the checkbox to use the same [Light Layer](Light-Layers.html) for shadows and lighting. If you enable this feature, then HDRP uses the Light Layer from the **Light Layer** drop-down in the **General** section for shadowing. If you disable this feature, then HDRP uses the **Light Layer** drop-down in this section for shadowing.
This property only appears if you enable [more options](More-Options.html) for this section.To access this property, enable **Light Layers** in your [HDRP Asset](HDRP-Asset.html). |
| **Light Layer** | Use the drop-down to set the Light Layer HDRP uses for shadowing. This Light therefore only casts shadows for GameObjects that use a matching Light Layer. For more information about using Light Layers for shadowing, see [Shadow Light Layers](Light-Layers.html#ShadowLightLayers).
This property only appears if you enable [more options](More-Options.html) for this section.To access this property, disable the **Link Light Layer** checkbox. |
From 16f71619419375516e6c13df90e46faeaf411e65 Mon Sep 17 00:00:00 2001
From: Sebastien Lagarde
Date: Tue, 7 Jul 2020 07:56:17 +0200
Subject: [PATCH 04/58] push meta
---
.../Linear/WindowsEditor/Direct3D12.meta | 8 ++
.../Linear/WindowsEditor/Direct3D12/None.meta | 8 ++
.../Direct3D12/None/1451_AxF_SVBRDF.png.meta | 94 +++++++++++++++++++
.../Vulkan/None/1451_AxF_SVBRDF.png.meta | 82 ++++++++++++++++
4 files changed, 192 insertions(+)
create mode 100644 TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12.meta
create mode 100644 TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None.meta
create mode 100644 TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png.meta
create mode 100644 TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png.meta
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12.meta
new file mode 100644
index 00000000000..163d16d9624
--- /dev/null
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 520fe8bf281dd6747b1a8df0d539b76b
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None.meta
new file mode 100644
index 00000000000..b402b1fcec9
--- /dev/null
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 56ab4814f629eca479bbb6fdbf194e78
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png.meta
new file mode 100644
index 00000000000..eacf8bbcba3
--- /dev/null
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1451_AxF_SVBRDF.png.meta
@@ -0,0 +1,94 @@
+fileFormatVersion: 2
+guid: c96f19160b2639e418cd03aa8babe6bb
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 11
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ vTOnly: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: -1
+ aniso: -1
+ mipBias: -100
+ wrapU: -1
+ wrapV: -1
+ wrapW: -1
+ nPOTScale: 1
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 0
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 0
+ spriteTessellationDetail: -1
+ textureType: 0
+ textureShape: 1
+ singleChannelComponent: 0
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
+ platformSettings:
+ - serializedVersion: 3
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID:
+ internalID: 0
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ secondaryTextures: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png.meta
new file mode 100644
index 00000000000..32c947df3df
--- /dev/null
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png.meta
@@ -0,0 +1,82 @@
+fileFormatVersion: 2
+guid: 5d53d2fd92d1b39459b7121ef54d0136
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 11
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ vTOnly: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: -1
+ aniso: -1
+ mipBias: -100
+ wrapU: -1
+ wrapV: -1
+ wrapW: -1
+ nPOTScale: 1
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 0
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 0
+ spriteTessellationDetail: -1
+ textureType: 0
+ textureShape: 1
+ singleChannelComponent: 0
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
+ platformSettings: []
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID:
+ internalID: 0
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ secondaryTextures: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
From 7baef3515e442cbe3f2df285df3046282adb1bcc Mon Sep 17 00:00:00 2001
From: Sebastien Lagarde
Date: Tue, 7 Jul 2020 07:58:51 +0200
Subject: [PATCH 05/58] removed undesired change in AXF
---
.../Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png | 4 ++--
.../Editor/Material/AxF/AxFGUI.cs | 9 ++-------
.../Runtime/Material/AxF/AxF.shader | 3 +--
3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
index ee8f0d73692..59a315367ee 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/1451_AxF_SVBRDF.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:6bba19dc68f61b58aae5de4d46cb82e260c9eed2483851d9cf0d7456233e4c99
-size 261
+oid sha256:8bdf1ab6a1eadcb6d50029cae7e8099d64d50f777307b6298fd856c679abe7c0
+size 156437
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
index 6b8320c8a02..2f6a862523d 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/AxF/AxFGUI.cs
@@ -132,13 +132,8 @@ static public void SetupMaterialKeywordsAndPass(Material material)
// Keywords for opt-out of decals and SSR:
bool decalsEnabled = material.HasProperty(kEnableDecals) && material.GetFloat(kEnableDecals) > 0.0f;
CoreUtils.SetKeyword(material, "_DISABLE_DECALS", decalsEnabled == false);
- bool ssrEnabled = false;
- if (material.GetSurfaceType() == SurfaceType.Transparent)
- ssrEnabled = material.HasProperty(kReceivesSSRTransparent) ? material.GetFloat(kReceivesSSRTransparent) != 0 : false;
- else
- ssrEnabled = material.HasProperty(kReceivesSSR) ? material.GetFloat(kReceivesSSR) != 0 : false;
- CoreUtils.SetKeyword(material, "_DISABLE_SSR", material.HasProperty(kReceivesSSR) && material.GetFloat(kReceivesSSR) == 0.0f);
- CoreUtils.SetKeyword(material, "_DISABLE_SSR_TRANSPARENT", material.HasProperty(kReceivesSSRTransparent) && material.GetFloat(kReceivesSSRTransparent) == 0.0);
+ bool ssrEnabled = material.HasProperty(kEnableSSR) && material.GetFloat(kEnableSSR) > 0.0f;
+ CoreUtils.SetKeyword(material, "_DISABLE_SSR", ssrEnabled == false);
CoreUtils.SetKeyword(material, "_ENABLE_GEOMETRIC_SPECULAR_AA", material.HasProperty(kEnableGeometricSpecularAA) && material.GetFloat(kEnableGeometricSpecularAA) > 0.0f);
CoreUtils.SetKeyword(material, "_SPECULAR_OCCLUSION_NONE", material.HasProperty(kSpecularOcclusionMode) && material.GetFloat(kSpecularOcclusionMode) == 0.0f);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
index e5814dc28d7..30748367cce 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader
@@ -141,7 +141,7 @@ Shader "HDRP/AxF"
[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0
- [ToggleUI] _ReceivesSSRTransparent("Receives SSR Transparent", Float) = 0.0
+
[ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0
}
@@ -167,7 +167,6 @@ Shader "HDRP/AxF"
#pragma shader_feature_local _DISABLE_DECALS
#pragma shader_feature_local _DISABLE_SSR
- #pragma shader_feature_local _DISABLE_SSR_TRANSPARENT
#pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA
#pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY
From fb33c794277002ddcac89f475bb62b8c5046bd9f Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Tue, 2 Jun 2020 16:41:48 +0200
Subject: [PATCH 06/58] Fix transparent movec scene view #698
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index e57900c0743..199995a3a29 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -136,6 +136,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed scalarization code for contact shadows
- Fix MaterialBalls having same guid issue
- Fix spelling and grammatical errors in material samples
+- Fixed issues with scene view and transparent motion vectors.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index e0b5fe2d06b..39abf37314f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -3563,7 +3563,7 @@ void RenderForwardOpaque(CullingResults cullResults, HDCamera hdCamera, Scriptab
static bool NeedMotionVectorForTransparent(FrameSettings frameSettings)
{
- return frameSettings.IsEnabled(FrameSettingsField.MotionVectors) && frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector);
+ return frameSettings.IsEnabled(FrameSettingsField.MotionVectors) && frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector) && frameSettings.IsEnabled(FrameSettingsField.ObjectMotionVectors);
}
RendererListDesc PrepareForwardTransparentRendererList(CullingResults cullResults, HDCamera hdCamera, bool preRefraction)
From 4ce96aa9b6972abd6e2ff1fac962a63a56331038 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Thu, 4 Jun 2020 16:09:28 +0200
Subject: [PATCH 07/58] Porting console fixes to staging (#699)
---
.../Runtime/Lighting/LightCookieManager.cs | 15 +++++++++++++++
.../Reflection/PlanarReflectionProbeCache.cs | 11 ++++++++++-
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 7 ++++++-
.../RenderPipeline/RenderPass/MipGenerator.cs | 3 +++
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
index d551020e17c..0d020b648f2 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
@@ -139,6 +139,13 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
name = cacheName + "TempAreaLightRT0"
};
+ // Clear the textures to avoid filtering with NaNs on consoles.
+ for (int mipIdx = 0; mipIdx < mipMapCount; ++mipIdx)
+ {
+ cmd.SetRenderTarget(m_TempRenderTexture0, mipIdx);
+ cmd.ClearRenderTarget(false, true, Color.clear);
+ }
+
// We start by a horizontal gaussian into mip 1 that reduces the width by a factor 2 but keeps the same height
m_TempRenderTexture1 = new RenderTexture(sourceWidth >> 1, sourceHeight, 1, cookieFormat)
{
@@ -147,6 +154,14 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
autoGenerateMips = false,
name = cacheName + "TempAreaLightRT1"
};
+
+ // Clear the textures to avoid filtering with NaNs on consoles.
+ for (int mipIdx = 0; mipIdx < mipMapCount - 1; ++mipIdx)
+ {
+ cmd.SetRenderTarget(m_TempRenderTexture1, mipIdx);
+ cmd.ClearRenderTarget(false, true, Color.clear);
+ }
+
}
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.AreaLightCookieConvolution)))
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs
index c53d79a2e7c..3981a28f34b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs
@@ -39,7 +39,7 @@ public PlanarReflectionProbeCache(RenderPipelineResources defaultResources, IBLF
Debug.Assert(probeFormat == GraphicsFormat.RGB_BC6H_SFloat || probeFormat == GraphicsFormat.R16G16B16A16_SFloat, "Reflection Probe Cache format for HDRP can only be BC6H or FP16.");
m_ProbeSize = atlasResolution;
- m_TextureAtlas = new PowerOfTwoTextureAtlas(atlasResolution, 0, probeFormat, useMipMap: isMipmaped, name: "PlanarReflectionProbe Atlas");
+ m_TextureAtlas = new PowerOfTwoTextureAtlas(atlasResolution, 1, probeFormat, useMipMap: isMipmaped, name: "PlanarReflectionProbe Atlas");
m_IBLFilterGGX = iblFilter;
m_PerformBC6HCompression = probeFormat == GraphicsFormat.RGB_BC6H_SFloat;
@@ -69,6 +69,15 @@ void Initialize()
m_ConvolutionTargetTexture.name = CoreUtils.GetRenderTargetAutoName(m_ProbeSize, m_ProbeSize, 0, RenderTextureFormat.ARGBHalf, "PlanarReflectionConvolution", mips: true);
m_ConvolutionTargetTexture.enableRandomWrite = true;
m_ConvolutionTargetTexture.Create();
+
+ // Clear to avoid garbage in the convolution texture.
+ int mipCount = Mathf.FloorToInt(Mathf.Log(m_ProbeSize, 2)) + 1;
+ for (int mipIdx = 0; mipIdx < mipCount; ++mipIdx)
+ {
+ Graphics.SetRenderTarget(m_ConvolutionTargetTexture, mipIdx, CubemapFace.Unknown);
+ GL.Clear(false, true, Color.clear);
+ }
+
}
m_FrameProbeIndex = 0;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 39abf37314f..5f89d11636b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -1460,7 +1460,12 @@ void AddVisibleProbeVisibleIndexIfUpdateIsRequired(HDProbe probe, int visibleInI
return;
// Notify that we render the probe at this frame
- probe.SetIsRendered(m_FrameCount);
+ // NOTE: If the probe was rendered on the very first frame, we could have some data that was used and it wasn't in a fully initialized state, which is fine on PC, but on console
+ // might lead to NaNs due to lack of complete initialization. To circumvent this, we force the probe to render again only if it was rendered on the first frame. Note that the problem
+ // doesn't apply if probe is enable any frame other than the very first. Also note that we are likely to be re-rendering the probe anyway due to the issue on sky ambient probe
+ // (see m_SkyManager.HasSetValidAmbientProbe in this function).
+ if (m_FrameCount > 1)
+ probe.SetIsRendered(m_FrameCount);
float visibility = ComputeVisibility(visibleInIndex, probe);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs
index f413e1df6ad..d5596dba52e 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs
@@ -146,6 +146,9 @@ public int RenderColorGaussianPyramid(CommandBuffer cmd, Vector2Int size, Textur
useDynamicScale: true,
name: "Temporary Downsampled Pyramid"
);
+
+ cmd.SetRenderTarget(m_TempDownsamplePyramid[rtIndex]);
+ cmd.ClearRenderTarget(false, true, Color.black);
}
float sourceScaleX = (float)size.x / source.width;
From fda10a83fa6fc9cfab4f4f74b0bcb61a8f4bb2a6 Mon Sep 17 00:00:00 2001
From: JordanL8
Date: Sat, 6 Jun 2020 01:40:36 +0100
Subject: [PATCH 08/58] Update HDRP-Camera.md (#706)
---
.../Documentation~/HDRP-Camera.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md
index e12c7cbeacd..81dcbd21614 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md
@@ -19,7 +19,7 @@ The HDRP Camera shares many properties with the [Standard Unity Camera](https://
| **Volume Anchor Override** | Assign a Transform that the [Volume](Volumes.html) system uses to handle the position of this Camera. For example, if your application uses a third person view of a character, set this property to the character's Transform. The Camera then uses the post-processing and Scene settings for Volumes that the character enters.If you do not assign a Transform, the Camera uses its own Transform instead. |
| **Probe Layer Mask** | Use the drop-down to set the Layer Mask that the Camera uses to exclude environment lights (light from Planar Reflection Probes and Reflection Probes). The Camera only uses Reflection Probes on Layers that you include in this Layer Mask. |
| **Occlusion Culling** | Enable the checkbox to make this Camera not render GameObjects that are not currently visible. For more information, see the [Occlusion Culling documentation](). |
-| **Projection** | Use the drop-down to select the projection mode for the Camera.
• **Perspective**: The Camera simulates perspective when it renders GameObjects. This means that GameObjects further from the Camera appear smaller than GameObjects that are closer.
• **Orthographic**: The Camera renders GameObjects uniformly with no perspective. This means that GameObjects further from the Camera appear to be the same size as GameObjects that are closer. |
+| **Projection** | Use the drop-down to select the projection mode for the Camera.
• **Perspective**: The Camera simulates perspective when it renders GameObjects. This means that GameObjects further from the Camera appear smaller than GameObjects that are closer.
• **Orthographic**: The Camera renders GameObjects uniformly with no perspective. This means that GameObjects further from the Camera appear to be the same size as GameObjects that are closer. Currently, HDRP does not support this projection mode. If you select this projection mode, any HDRP feature that requires lighting does not work consistently. However, this projection mode does work consistently with [Unlit](Unlit-Shader.md) Materials. |
| **FOV Axis** | Use the drop-down to select the axis that you want the field of view to relate to.
• **Vertical**: Allows you to set the **Field of View** using the vertical axis.
• **Horizontal**: Allows you to set the **Field of View** using the horizontal axis.This property only appears when you select **Perspective** from the **Projection** drop-down. |
| **Field of View** | Use the slider to set the viewing angle for the Camera, in degrees.
This property only appears when you select **Perspective** from the **Projection** drop-down. |
| **Link FOV to Physical Camera** | Enable the checkbox to make the Camera use its **Physical Settings** to calculate its viewing angle.This property only appears when you select **Perspective** from the **Projection** drop-down. |
From dbad64ac9c2006923a3c009bec4b46c9181b215f Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Sat, 6 Jun 2020 14:46:38 +0200
Subject: [PATCH 09/58] Pre warm RT Handle system so that reallocations are
reduced. #713
---
.../RenderGraphResourceRegistry.cs | 3 ++-
.../CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/Camera/HDCamera.cs | 5 ----
.../RenderPipeline/HDRenderPipeline.cs | 27 +++++++++++++++++--
4 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
index f8b5fc64097..96eb881f654 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
@@ -324,7 +324,8 @@ private RenderGraphResourceRegistry()
internal RenderGraphResourceRegistry(bool supportMSAA, MSAASamples initialSampleCount, RenderGraphDebugParams renderGraphDebug, RenderGraphLogger logger)
{
- m_RTHandleSystem.Initialize(1, 1, supportMSAA, initialSampleCount);
+ // We initialize to screen width/height to avoid multiple realloc that can lead to inflated memory usage (as releasing of memory is delayed).
+ m_RTHandleSystem.Initialize(Screen.width, Screen.height, supportMSAA, initialSampleCount);
m_RenderGraphDebug = renderGraphDebug;
m_Logger = logger;
}
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 199995a3a29..bb09ad34bed 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -137,6 +137,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix MaterialBalls having same guid issue
- Fix spelling and grammatical errors in material samples
- Fixed issues with scene view and transparent motion vectors.
+- Pre-warm the RTHandle system to reduce the amount of memory allocations and the total memory needed at all points.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index d59f6cc0911..ea103c3970f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -477,11 +477,6 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
cameraFrameCount++;
hdrp.UpdateVolumetricBufferParams(this);
-
- // Here we use the non scaled resolution for the RTHandleSystem ref size because we assume that at some point we will need full resolution anyway.
- // This is necessary because we assume that after post processes, we have the full size render target for debug rendering
- // The only point of calling this here is to grow the render targets. The call in BeginRender will setup the current RTHandle viewport size.
- RTHandles.SetReferenceSize(nonScaledViewport.x, nonScaledViewport.y, msaaSamples);
}
// Updating RTHandle needs to be done at the beginning of rendering (not during update of HDCamera which happens in batches)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 5f89d11636b..0239373547e 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -377,8 +377,8 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau
// Initial state of the RTHandle system.
// Tells the system that we will require MSAA or not so that we can avoid wasteful render texture allocation.
- // TODO: Might want to initialize to at least the window resolution to avoid un-necessary re-alloc in the player
- RTHandles.Initialize(1, 1, m_Asset.currentPlatformRenderPipelineSettings.supportMSAA, m_Asset.currentPlatformRenderPipelineSettings.msaaSampleCount);
+ // We initialize to screen width/height to avoid multiple realloc that can lead to inflated memory usage (as releasing of memory is delayed).
+ RTHandles.Initialize(Screen.width, Screen.height, m_Asset.currentPlatformRenderPipelineSettings.supportMSAA, m_Asset.currentPlatformRenderPipelineSettings.msaaSampleCount);
m_XRSystem = new XRSystem(asset.renderPipelineResources.shaders);
m_GPUCopy = new GPUCopy(defaultResources.shaders.copyChannelCS);
@@ -1811,6 +1811,29 @@ ref _cullingResults
using (new ProfilingScope(null, ProfilingSampler.Get(HDProfileId.HDRenderPipelineAllRenderRequest)))
{
+
+ // Warm up the RTHandle system so that it gets init to the maximum resolution available (avoiding to call multiple resizes
+ // that can lead to high memory spike as the memory release is delayed while the creation is immediate).
+ {
+ Vector2Int maxSize = new Vector2Int(1, 1);
+
+ for (int i = renderRequestIndicesToRender.Count - 1; i >= 0; --i)
+ {
+ var renderRequestIndex = renderRequestIndicesToRender[i];
+ var renderRequest = renderRequests[renderRequestIndex];
+ var hdCamera = renderRequest.hdCamera;
+
+ maxSize.x = Math.Max((int)hdCamera.finalViewport.size.x, maxSize.x);
+ maxSize.y = Math.Max((int)hdCamera.finalViewport.size.y, maxSize.y);
+ }
+
+ // Here we use the non scaled resolution for the RTHandleSystem ref size because we assume that at some point we will need full resolution anyway.
+ // This is necessary because we assume that after post processes, we have the full size render target for debug rendering
+ // The only point of calling this here is to grow the render targets. The call in BeginRender will setup the current RTHandle viewport size.
+ RTHandles.SetReferenceSize(maxSize.x, maxSize.y, m_MSAASamples);
+ }
+
+
// Execute render request graph, in reverse order
for (int i = renderRequestIndicesToRender.Count - 1; i >= 0; --i)
{
From 80ed29addbd6e1de8da456e0b7d11c6a4b2c00e0 Mon Sep 17 00:00:00 2001
From: Sebastien Lagarde
Date: Tue, 7 Jul 2020 08:09:16 +0200
Subject: [PATCH 10/58] Update PlanarReflectionProbeCache.cs
---
.../Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs
index 3981a28f34b..e9e37cceb4a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/PlanarReflectionProbeCache.cs
@@ -39,7 +39,7 @@ public PlanarReflectionProbeCache(RenderPipelineResources defaultResources, IBLF
Debug.Assert(probeFormat == GraphicsFormat.RGB_BC6H_SFloat || probeFormat == GraphicsFormat.R16G16B16A16_SFloat, "Reflection Probe Cache format for HDRP can only be BC6H or FP16.");
m_ProbeSize = atlasResolution;
- m_TextureAtlas = new PowerOfTwoTextureAtlas(atlasResolution, 1, probeFormat, useMipMap: isMipmaped, name: "PlanarReflectionProbe Atlas");
+ m_TextureAtlas = new PowerOfTwoTextureAtlas(atlasResolution, 0, probeFormat, useMipMap: isMipmaped, name: "PlanarReflectionProbe Atlas");
m_IBLFilterGGX = iblFilter;
m_PerformBC6HCompression = probeFormat == GraphicsFormat.RGB_BC6H_SFloat;
From cc93c2de3161b300be0c0764518dded53e009a49 Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Mon, 8 Jun 2020 01:07:11 +0200
Subject: [PATCH 11/58] Update preview naming in raytrace component #753
---
.../Documentation~/Volume-Components.md | 4 ++--
.../Editor/Lighting/AmbientOcclusionEditor.cs | 2 +-
.../Editor/Lighting/HDLightUI.Skin.cs | 4 ++--
.../Lighting/Reflection/HDScreenSpaceReflectionEditor.cs | 2 +-
.../RenderPipeline/Raytracing/GlobalIlluminationEditor.cs | 2 +-
.../Runtime/Lighting/AtmosphericScattering/Fog.cs | 2 +-
.../Material/SubsurfaceScattering/SubSurfaceScattering.cs | 5 +++++
.../Runtime/RenderPipeline/PathTracing/PathTracing.cs | 5 +++++
.../Runtime/RenderPipeline/Raytracing/LightCluster.cs | 5 +++++
.../RenderPipeline/Raytracing/RayTracingSettings.cs | 7 ++++++-
.../RenderPipeline/Raytracing/RecursiveRendering.cs | 5 +++++
11 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Volume-Components.md b/com.unity.render-pipelines.high-definition/Documentation~/Volume-Components.md
index d51aacf85d2..df59a9e1038 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Volume-Components.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Volume-Components.md
@@ -16,8 +16,8 @@ To render a different fog color in a certain area of your Scene:
1. Create a global Volume (menu: __GameObject > Volume > Global Volume__).
2. Click the **New** button next to the **Profile** property to add a new Volume Profile to the Volume.
-3. Select **Add Override > Fog > Fog** and leave it with the default settings.
+3. Select **Add Override > Fog** and leave it with the default settings.
4. Create a local Volume. To add a **Local** Volume with a box boundary, select __GameObject > Volume > Box Volume__.
-5. Select **Add Override > Fog > Fog** then in the **Fog** Inspector, override the properties with your preferred values.
+5. Select **Add Override > Fog** then in the **Fog** Inspector, override the properties with your preferred values.
Now, whenever your Camera is within the bounds of the local Volume's Collider, HDRP uses the Fog values from that Volume. Whenever your Camera is outside the bounds of the local Volume's Collider, HDRP uses the Fog values from the global Volume
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs
index 0c4347c2084..8b59cf7910e 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs
@@ -71,7 +71,7 @@ public override void OnInspectorGUI()
}
if (HDRenderPipeline.pipelineSupportsRayTracing)
- PropertyField(m_RayTracing, EditorGUIUtility.TrTextContent("Ray Tracing", "Enable ray traced ambient occlusion."));
+ PropertyField(m_RayTracing, EditorGUIUtility.TrTextContent("Ray Tracing (Preview)", "Enable ray traced ambient occlusion."));
// Shared attributes
PropertyField(m_Intensity, EditorGUIUtility.TrTextContent("Intensity", "Controls the strength of the ambient occlusion effect. Increase this value to produce darker areas."));
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs
index 2dcef35355b..e761994c929 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs
@@ -113,7 +113,7 @@ sealed class Styles
public readonly GUIContent shadowTint = new GUIContent("Tint", "Specifies the color and transparency that HDRP tints this Light's shadows to. The tint affects dynamic shadows, Contact Shadows, and ShadowMask. It does not affect baked shadows.");
public readonly GUIContent penumbraTint = new GUIContent("Penumbra Tint", "When enabled, the tint only affects the shadow's penumbra.");
public readonly GUIContent contactShadows = new GUIContent("Enable", "Enable support for Contact Shadows on this Light. This is better for lights with a lot of visible shadows.");
- public readonly GUIContent rayTracedContactShadow = new GUIContent("Ray Tracing", "Uses ray tracing to compute the contact shadow for a light.");
+ public readonly GUIContent rayTracedContactShadow = new GUIContent("Ray Tracing (Preview)", "Uses ray tracing to compute the contact shadow for a light.");
public readonly GUIContent shadowUpdateMode = new GUIContent("Update Mode", "Specifies when HDRP updates the shadow map.");
public readonly GUIContent useCustomSpotLightShadowCone = new GUIContent("Custom Spot Angle", "When enabled, this Spot Light uses the custom angle for shadow map rendering.");
public readonly GUIContent customSpotLightShadowCone = new GUIContent("Shadow Angle", "Controls the custom angle this Spot Light uses for shadow map rendering.");
@@ -131,7 +131,7 @@ sealed class Styles
public readonly GUIContent diameterScaleForSoftness = new GUIContent("Angular Diameter Scale for Softness", "Scale the angular diameter for the sake of softness calculation. Higher scales will result in higher softness.");
public readonly GUIContent areaLightShadowCone = new GUIContent("Shadow Cone", "Aperture of the cone used for shadowing the area light.");
public readonly GUIContent useScreenSpaceShadows = new GUIContent("Screen Space Shadows", "Render screen space shadow.");
- public readonly GUIContent useRayTracedShadows = new GUIContent("Ray Traced Shadows", "If selected, ray traced shadows are used in place of rasterized ones.");
+ public readonly GUIContent useRayTracedShadows = new GUIContent("Ray Traced Shadows (Preview)", "If selected, ray traced shadows are used in place of rasterized ones.");
public readonly GUIContent numRayTracingSamples = new GUIContent("Sample Count", "This defines the number of samples that will be used to evaluate this shadow.");
public readonly GUIContent denoiseTracedShadow = new GUIContent("Denoise", "This defines if the ray traced shadow should be filtered.");
public readonly GUIContent denoiserRadius = new GUIContent("Denoiser Radius", "This defines the denoiser's radius used for filtering ray traced shadows.");
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs
index f41d2bd5458..67087161187 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs
@@ -86,7 +86,7 @@ public override void OnInspectorGUI()
bool rayTracingSupported = HDRenderPipeline.pipelineSupportsRayTracing;
if (rayTracingSupported)
- PropertyField(m_RayTracing, EditorGUIUtility.TrTextContent("Ray Tracing", "Enable ray traced reflections."));
+ PropertyField(m_RayTracing, EditorGUIUtility.TrTextContent("Ray Tracing (Preview)", "Enable ray traced reflections."));
// Shared Data
PropertyField(m_MinSmoothness, EditorGUIUtility.TrTextContent("Minimum Smoothness", "Controls the smoothness value at which HDRP activates SSR and the smoothness-controlled fade out stops."));
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs
index 29d549abe84..47a76d8aca6 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs
@@ -68,7 +68,7 @@ public override void OnInspectorGUI()
// If ray tracing is supported display the content of the volume component
if (HDRenderPipeline.pipelineSupportsRayTracing)
{
- PropertyField(m_RayTracing);
+ PropertyField(m_RayTracing, EditorGUIUtility.TrTextContent("Ray Tracing (Preview)", "Enable ray traced global illumination."));
if (m_RayTracing.overrideState.boolValue && m_RayTracing.value.boolValue)
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs
index 733c81fa19b..6bd99833755 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs
@@ -6,7 +6,7 @@ namespace UnityEngine.Rendering.HighDefinition
///
/// Fog Volume Component.
///
- [Serializable, VolumeComponentMenu("Fog/Fog")]
+ [Serializable, VolumeComponentMenu("Fog")]
public class Fog : VolumeComponent
{
// Fog Color
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs
index 08aa2b6bae5..98a81be6ebc 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs
@@ -20,5 +20,10 @@ public sealed class SubSurfaceScattering : VolumeComponent
///
[Tooltip("Number of samples for sub-surface scattering.")]
public ClampedIntParameter sampleCount = new ClampedIntParameter(1, 1, 32);
+
+ SubSurfaceScattering()
+ {
+ displayName = "SubSurface Scattering (Preview)";
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs
index 324fe90b6fb..f977403c17a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs
@@ -48,6 +48,11 @@ public sealed class PathTracing : VolumeComponent
///
[Tooltip("Defines the maximum intensity value computed for a path segment.")]
public ClampedFloatParameter maximumIntensity = new ClampedFloatParameter(10f, 0f, 100f);
+
+ PathTracing()
+ {
+ displayName = "Path Tracing (Preview)";
+ }
}
public partial class HDRenderPipeline
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
index 15770d49ee7..6a1676a2601 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
@@ -19,5 +19,10 @@ public sealed class LightCluster : VolumeComponent
///
[Tooltip("Controls the range of the cluster around the camera.")]
public ClampedFloatParameter cameraClusterRange = new ClampedFloatParameter(10f, 0.001f, 50f);
+
+ LightCluster()
+ {
+ displayName = "Light Cluster (Preview)";
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs
index f15a5f100c3..87d82e7a8d9 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs
@@ -5,7 +5,7 @@ namespace UnityEngine.Rendering.HighDefinition
///
/// A volume component that holds the general settings for ray traced effects.
///
- [Serializable, VolumeComponentMenu("Ray Tracing/Settings (Preview)")]
+ [Serializable, VolumeComponentMenu("Ray Tracing/Ray Tracing Settings (Preview)")]
public sealed class RayTracingSettings : VolumeComponent
{
///
@@ -13,5 +13,10 @@ public sealed class RayTracingSettings : VolumeComponent
///
[Tooltip("Controls the bias for all real-time ray tracing effects.")]
public ClampedFloatParameter rayBias = new ClampedFloatParameter(0.001f, 0.0f, 0.1f);
+
+ RayTracingSettings()
+ {
+ displayName = "Ray Tracing Settings (Preview)";
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs
index d5afc8c21f7..a56219666c0 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs
@@ -33,5 +33,10 @@ public sealed class RecursiveRendering : VolumeComponent
///
[Tooltip("Ray Length. This defines the maximal travel distance of rays.")]
public ClampedFloatParameter rayLength = new ClampedFloatParameter(10f, 0f, 50f);
+
+ RecursiveRendering()
+ {
+ displayName = "Recursive Rendering (Preview)";
+ }
}
}
From 644061cdd623076886817e4b025d48afc103297a Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Tue, 9 Jun 2020 10:11:33 +0200
Subject: [PATCH 12/58] Workaround for GetKernelThreadGroupSizes returning
wrong data #760
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/PostProcessing/PostProcessSystem.cs | 6 +++++-
.../Runtime/PostProcessing/Shaders/LutBuilder3D.compute | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index bb09ad34bed..c81e4f51feb 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -138,6 +138,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix spelling and grammatical errors in material samples
- Fixed issues with scene view and transparent motion vectors.
- Pre-warm the RTHandle system to reduce the amount of memory allocations and the total memory needed at all points.
+- Workaround an issue caused by GetKernelThreadGroupSizes failing to retrieve correct group size.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs
index 1682871fdf8..9a13f6b81b3 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs
@@ -2228,7 +2228,11 @@ void DoColorGrading(CommandBuffer cmd, ComputeShader cs, int kernel)
// Generate the lut
// See the note about Metal & Intel in LutBuilder3D.compute
- builderCS.GetKernelThreadGroupSizes(builderKernel, out uint threadX, out uint threadY, out uint threadZ);
+ // GetKernelThreadGroupSizes is currently broken on some binary versions.
+ //builderCS.GetKernelThreadGroupSizes(builderKernel, out uint threadX, out uint threadY, out uint threadZ);
+ uint threadX = 4;
+ uint threadY = 4;
+ uint threadZ = 4;
cmd.DispatchCompute(builderCS, builderKernel,
(int)((m_LutSize + threadX - 1u) / threadX),
(int)((m_LutSize + threadY - 1u) / threadY),
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/LutBuilder3D.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/LutBuilder3D.compute
index da9ab06c2f6..439e191d660 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/LutBuilder3D.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/LutBuilder3D.compute
@@ -234,6 +234,7 @@ float3 Tonemap(float3 colorLinear)
// allow anything higher than 256 threads. We'll use 4x4x4 then.
// Ultimately it would nice to expose `maxTotalThreadsPerThreadgroup` for Metal...
// Source: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
+// It is important to keep this in sync with the group-size declared in PostProcessSystem.cs
[numthreads(4,4,4)]
void MAIN(uint3 dispatchThreadId : SV_DispatchThreadID)
{
From 81f925df533df71adcf07ec694defa082c3b0c29 Mon Sep 17 00:00:00 2001
From: Adrien de Tocqueville
Date: Tue, 9 Jun 2020 13:11:54 +0000
Subject: [PATCH 13/58] Sanitize transparent motion vectors setting #761
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs | 1 +
.../Runtime/RenderPipeline/Settings/FrameSettings.cs | 2 ++
3 files changed, 4 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index c81e4f51feb..b828377a5e2 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -139,6 +139,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issues with scene view and transparent motion vectors.
- Pre-warm the RTHandle system to reduce the amount of memory allocations and the total memory needed at all points.
- Workaround an issue caused by GetKernelThreadGroupSizes failing to retrieve correct group size.
+- Fixed transparent motion vector framesetting not sanitized.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs
index 38e6edc192a..dec98ca62f9 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs
@@ -214,6 +214,7 @@ static void Drawer_SectionRenderingSettings(SerializedFrameSettings serialized,
area.AmmendInfo(FrameSettingsField.RayTracing, overrideable: () => hdrpSettings.supportRayTracing);
area.AmmendInfo(FrameSettingsField.MotionVectors, overrideable: () => hdrpSettings.supportMotionVectors);
area.AmmendInfo(FrameSettingsField.ObjectMotionVectors, overrideable: () => hdrpSettings.supportMotionVectors);
+ area.AmmendInfo(FrameSettingsField.TransparentsWriteMotionVector, overrideable: () => hdrpSettings.supportMotionVectors);
area.AmmendInfo(FrameSettingsField.Decals, overrideable: () => hdrpSettings.supportDecals);
area.AmmendInfo(FrameSettingsField.Distortion, overrideable: () => hdrpSettings.supportDistortion);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs
index 3c1d84f7ea6..28645caa886 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs
@@ -679,6 +679,8 @@ internal static void Sanitize(ref FrameSettings sanitizedFrameSettings, Camera c
// Object motion vector are disabled if motion vector are disabled
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.ObjectMotionVectors] &= motionVector && !preview;
+ sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.TransparentsWriteMotionVector] &= motionVector && !preview;
+
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.Decals] &= renderPipelineSettings.supportDecals && !preview;
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.TransparentPostpass] &= renderPipelineSettings.supportTransparentDepthPostpass && !preview;
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.Distortion] &= renderPipelineSettings.supportDistortion && !msaa && !preview;
From 51ea72a67441eac0d6151167d0d7d4e560dd50cd Mon Sep 17 00:00:00 2001
From: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com>
Date: Tue, 9 Jun 2020 09:48:30 +0200
Subject: [PATCH 14/58] Standard terrain upgrader (#762)
---
.../StandardsTerrainToHDTerrainLitUpgrader.cs | 21 +++++++++++++++++++
...dardsTerrainToHDTerrainLitUpgrader.cs.meta | 11 ++++++++++
.../UpgradeStandardShaderMaterials.cs | 3 +++
3 files changed, 35 insertions(+)
create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs
create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs.meta
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs b/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs
new file mode 100644
index 00000000000..91d4812cf55
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs
@@ -0,0 +1,21 @@
+using UnityEngine;
+using UnityEngine.Rendering.HighDefinition;
+
+namespace UnityEditor.Rendering.HighDefinition
+{
+ class StandardsTerrainToHDTerrainLitUpgrader : MaterialUpgrader
+ {
+
+ public StandardsTerrainToHDTerrainLitUpgrader(string sourceShaderName, string destShaderName, MaterialFinalizer finalizer = null)
+ {
+ RenameShader(sourceShaderName, destShaderName, finalizer);
+ }
+
+ public override void Convert(Material srcMaterial, Material dstMaterial)
+ {
+ base.Convert(srcMaterial, dstMaterial);
+
+ HDShaderUtils.ResetMaterialKeywords(dstMaterial);
+ }
+ }
+}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs.meta
new file mode 100644
index 00000000000..5b33cc09037
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/StandardsTerrainToHDTerrainLitUpgrader.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6d3e54e3dd1c6c249a59f788380085b1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs
index d07e9d15459..3caefc2fd49 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs
@@ -18,6 +18,9 @@ static List GetHDUpgraders()
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Texture", "HDRP/Unlit"));
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Transparent", "HDRP/Unlit"));
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Transparent Cutout", "HDRP/Unlit"));
+
+ upgraders.Add(new StandardsTerrainToHDTerrainLitUpgrader("Nature/Terrain/Standard", "HDRP/TerrainLit"));
+
return upgraders;
}
From aedd7ba6ab48915b7f185d20e556f6f1f7e3da0e Mon Sep 17 00:00:00 2001
From: JordanL8
Date: Tue, 9 Jun 2020 13:41:35 +0100
Subject: [PATCH 15/58] Update Reflection-Probe (#790)
* Update Reflection-Probe.md
* Update Reflection-Probe.md
Co-authored-by: sebastienlagarde
---
.../Documentation~/Reflection-Probe.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Reflection-Probe.md b/com.unity.render-pipelines.high-definition/Documentation~/Reflection-Probe.md
index 89ba30667fd..5a4d08eb63e 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Reflection-Probe.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Reflection-Probe.md
@@ -12,7 +12,7 @@ The HDRP Reflection Probe uses the [built-in render pipeline Reflection Probe](h
| **Property** | **Description** |
| ----------------- | ------------------------------------------------------------ |
-| **Type** | Use the drop-down to select the mode this Reflection Probe uses to capture a view of the Scene. Reflective Materials query this capture to process reflections for their surface.
• **Realtime**: Makes the Reflection Probe capture a view of the Scene in real time. Use the **Realtime Mode** property to set the time period.
• **Custom**: Allows you to assign a cubemap Texture to act as the Reflection Probe's captured view of the Scene. Use the **Texture** property to assign the cubemap.
• **Baked**: Makes the Reflection Probe use a static cubemap Texture at runtime. You must bake this Texture before you build your Unity Project. |
+| **Type** | Use the drop-down to select the mode this Reflection Probe uses to capture a view of the Scene. Reflective Materials query this capture to process reflections for their surface.
• **Realtime**: Makes the Reflection Probe capture a view of the Scene in real time. Use the **Realtime Mode** property to set the time period.
• **Custom**: Allows you to assign a cubemap Texture to act as the Reflection Probe's captured view of the Scene. Use the **Texture** property to assign the cubemap.
• **Baked**: Makes the Reflection Probe use a static cubemap Texture at runtime. You must bake this Texture before you build your Unity Project. In this mode, the Reflection Probe does not capture GameObjects have their Reflection Probe Static flag disabled. |
| **Realtime Mode** | Use the drop-down to select how often the Reflection Probe should capture a view of the Scene.
•**Every Frame**: Updates the Probe’s capture data every frame.
• **On Enable**: Updates the Probe’s capture data each time Unity calls the component’s `OnEnable()` function. This occurs whenever you enable the component in the Inspector or activate the GameObject that the component attaches to.
This property only appears when you select **Realtime** from the **Type** drop-down. |
| **Texture** | Assign a Texture for the Reflection Probe to use as its captured view of the Scene.
This property only appears when you select **Custom** from the **Type** drop-down. |
@@ -86,4 +86,4 @@ You can use Scene view gizmos to visually customize specific properties.
|  | **Influence Volume boundary**. | Provides Scene view handles that allow you to resize the boundaries of the [Influence Volume](#InfluenceVolume), which defines the area this Reflection Probe affects reflective Materials. Edits the **Box Size** or **Radius** value, depending on the **Shape** you select. |
|  | **Blend Distance boundary**. | Provides Scene view handles that allows you to alter the inward distance from the **Box Size** or **Radius** at which this Reflection Probe blends with other Reflection Probes. Its behavior depends on the [workflow mode](#Workflows) you are using. It scales all sides equally in **Normal** mode, scales just the side with the handle you control in **Advanced** mode. |
|  | **Blend Normal Distance boundary**. | Provides Scene view handles that allow you to resize the boundary where pixels with a normal pointing away from the **Capture Position** don’t receive any influence from this Probe. |
-|  | **Capture Position**. | Changes the behavior of the Move Tool so that it alters the **Capture Position** property, rather than the **Position** of the **Transform**. |
\ No newline at end of file
+|  | **Capture Position**. | Changes the behavior of the Move Tool so that it alters the **Capture Position** property, rather than the **Position** of the **Transform**. |
From c8e4097e87aa23e412d4e9caf93462992eb3dd32 Mon Sep 17 00:00:00 2001
From: Adrien de Tocqueville
Date: Wed, 10 Jun 2020 13:04:20 +0000
Subject: [PATCH 16/58] Fix reflection probe framesettings override #796
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/Utilities/ProbeSettingsUtilities.cs | 7 -------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index b828377a5e2..4640bc27c5d 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -140,6 +140,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Pre-warm the RTHandle system to reduce the amount of memory allocations and the total memory needed at all points.
- Workaround an issue caused by GetKernelThreadGroupSizes failing to retrieve correct group size.
- Fixed transparent motion vector framesetting not sanitized.
+- Fix reflection probe frame settings override
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettingsUtilities.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettingsUtilities.cs
index a9767063151..6eba9bda004 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettingsUtilities.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettingsUtilities.cs
@@ -108,13 +108,6 @@ public static void ApplySettings(
cameraSettings.defaultFrameSettings = FrameSettingsRenderType.CustomOrBakedReflection;
break;
}
-
- switch (settings.type)
- {
- case ProbeSettings.ProbeType.ReflectionProbe:
- cameraSettings.customRenderingSettings = true;
- break;
- }
}
internal static void ApplyMirroredReferenceTransform(
From 88bde234bcf51d190c8766647f26a170c16d8d0f Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Tue, 9 Jun 2020 17:19:28 +0200
Subject: [PATCH 17/58] Force post process parent setting to be before child
settings #799
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/Settings/FrameSettings.cs | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 4640bc27c5d..5a49ed38ecf 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -141,6 +141,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Workaround an issue caused by GetKernelThreadGroupSizes failing to retrieve correct group size.
- Fixed transparent motion vector framesetting not sanitized.
- Fix reflection probe frame settings override
+- Fixed wrong order of post process frame settings.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs
index 28645caa886..5c007ed8c98 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs
@@ -138,7 +138,7 @@ public enum FrameSettingsField
[FrameSettingsField(0, autoName: Distortion, tooltip: "When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings (Depends on \"Distortion\" in current HDRP Asset).")]
Distortion = 14,
/// When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.
- [FrameSettingsField(0, displayedName: "Post-process", tooltip: "When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.")]
+ [FrameSettingsField(0, displayedName: "Post-process", customOrderInGroup: 17, tooltip: "When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.")]
Postprocess = 15,
/// When enabled, HDRP render user written post processes.
[FrameSettingsField(0, displayedName: "Custom Post-process", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP render user written post processes.")]
From 320605e51504a11a481eca8e667c25346e76bd64 Mon Sep 17 00:00:00 2001
From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com>
Date: Sun, 21 Jun 2020 16:08:46 +0200
Subject: [PATCH 18/58] Fixed 1253367 by rebaking probe with missing baked
texture. #818
---
.../Runtime/Common/ListBuffer.cs | 163 ++++++++++++++++++
.../Runtime/Common/ListBuffer.cs.meta | 3 +
.../CHANGELOG.md | 1 +
.../Reflection/HDBakedReflectionSystem.cs | 85 +++++++--
4 files changed, 237 insertions(+), 15 deletions(-)
create mode 100644 com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs
create mode 100644 com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs.meta
diff --git a/com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs b/com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs
new file mode 100644
index 00000000000..594313c44f8
--- /dev/null
+++ b/com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs
@@ -0,0 +1,163 @@
+using System;
+using Unity.Collections.LowLevel.Unsafe;
+
+namespace UnityEngine.Rendering
+{
+ ///
+ /// A list that stores value on a provided memory buffer.
+ ///
+ /// Usually use this to have a list on stack allocated memory.
+ ///
+ /// The type of the data stored in the list.
+ public unsafe struct ListBuffer
+ where T: unmanaged
+ {
+ private T* m_BufferPtr;
+ private int m_Capacity;
+ private int* m_CountPtr;
+
+ ///
+ /// The pointer to the memory storage.
+ ///
+ internal T* BufferPtr => m_BufferPtr;
+
+ ///
+ /// The number of item in the list.
+ ///
+ public int Count => *m_CountPtr;
+
+ ///
+ /// The maximum number of item stored in this list.
+ ///
+ public int Capacity => m_Capacity;
+
+ ///
+ /// Instantiate a new list.
+ ///
+ /// The address in memory to store the data.
+ /// The address in memory to store the number of item of this list..
+ /// The number of that can be stored in the buffer.
+ public ListBuffer(T* bufferPtr, int* countPtr, int capacity)
+ {
+ m_BufferPtr = bufferPtr;
+ m_Capacity = capacity;
+ m_CountPtr = countPtr;
+ }
+
+ ///
+ /// Get an item from the list.
+ ///
+ /// The index of the item to get.
+ /// A reference to the item.
+ /// If the index is invalid.
+ public ref T this[in int index]
+ {
+ get
+ {
+ if (index < 0 || index >= Count)
+ throw new IndexOutOfRangeException(
+ $"Expected a value between 0 and {Count}, but received {index}.");
+ return ref m_BufferPtr[index];
+ }
+ }
+
+ ///
+ /// Get an item from the list.
+ ///
+ /// Safety: index must be inside the bounds of the list.
+ ///
+ /// The index of the item to get.
+ /// A reference to the item.
+ public unsafe ref T GetUnchecked(in int index) => ref m_BufferPtr[index];
+
+ ///
+ /// Try to add a value in the list.
+ ///
+ /// A reference to the value to add.
+ ///
+ /// true
when the value was added,
+ /// false
when the value was not added because the capacity was reached.
+ ///
+ public bool TryAdd(in T value)
+ {
+ if (Count >= m_Capacity)
+ return false;
+
+ m_BufferPtr[Count] = value;
+ ++*m_CountPtr;
+ return true;
+ }
+
+ ///
+ /// Copy the content of this list into another buffer in memory.
+ ///
+ /// Safety:
+ /// * The destination must have enough memory to receive the copied data.
+ ///
+ /// The destination buffer of the copy operation.
+ /// The index of the first element that will be copied in the destination buffer.
+ /// The number of item to copy.
+ public unsafe void CopyTo(T* dstBuffer, int startDstIndex, int copyCount)
+ {
+ UnsafeUtility.MemCpy( dstBuffer + startDstIndex, m_BufferPtr,
+ UnsafeUtility.SizeOf() * copyCount);
+ }
+
+ ///
+ /// Try to copy the list into another list.
+ ///
+ /// The destination of the copy.
+ ///
+ /// * true
when the copy was performed.
+ /// * false
when the copy was aborted because the destination have a capacity too small.
+ ///
+ public bool TryCopyTo(ListBuffer other)
+ {
+ if (other.Count + Count >= other.m_Capacity)
+ return false;
+
+ UnsafeUtility.MemCpy( other.m_BufferPtr + other.Count, m_BufferPtr, UnsafeUtility.SizeOf() * Count);
+ *other.m_CountPtr += Count;
+ return true;
+ }
+
+ ///
+ /// Try to copy the data from a buffer in this list.
+ ///
+ /// The pointer of the source memory to copy.
+ /// The number of item to copy from the source buffer.
+ ///
+ /// * true
when the copy was performed.
+ /// * false
when the copy was aborted because the capacity of this list is too small.
+ ///
+ public bool TryCopyFrom(T* srcPtr, int count)
+ {
+ if (count + Count > m_Capacity)
+ return false;
+
+ UnsafeUtility.MemCpy( m_BufferPtr + Count, srcPtr, UnsafeUtility.SizeOf() * count);
+ *m_CountPtr += count;
+ return true;
+ }
+ }
+
+ ///
+ /// Extensions for .
+ ///
+ public static class ListBufferExtensions
+ {
+ ///
+ /// Perform a quick sort on a .
+ ///
+ /// The list to sort.
+ /// The type of the element in the list.
+ public static void QuickSort(this ListBuffer self)
+ where T : unmanaged, IComparable
+ {
+ unsafe
+ {
+ CoreUnsafeUtils.QuickSort(self.Count, self.BufferPtr);
+ }
+ }
+ }
+}
diff --git a/com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs.meta b/com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs.meta
new file mode 100644
index 00000000000..1259d25752c
--- /dev/null
+++ b/com.unity.render-pipelines.core/Runtime/Common/ListBuffer.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 188d5dc897b64646b3757571725337ce
+timeCreated: 1591792904
\ No newline at end of file
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 5a49ed38ecf..59f4a288cf0 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -142,6 +142,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed transparent motion vector framesetting not sanitized.
- Fix reflection probe frame settings override
- Fixed wrong order of post process frame settings.
+- Force to rebake probe with missing baked texture. (1253367)
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs
index a72d37ea47e..f173f379020 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs
@@ -119,6 +119,8 @@ IScriptableBakedReflectionSystemStageNotifier handle
// a. If we have to remove a baked data
// b. If we have to bake a probe
// 4. Bake all required probes
+ // a. Bake probe that were added or modified
+ // b. Bake probe with a missing baked texture
// 5. Remove unused baked data
// 6. Update probe assets
@@ -135,11 +137,31 @@ IScriptableBakedReflectionSystemStageNotifier handle
// == 2. ==
var states = stackalloc HDProbeBakingState[bakedProbeCount];
+ // A list of indices of probe we may want to force to rebake, even if the hashes matches.
+ // Usually, add a probe when something external to its state or the world state forces the bake.
+ var probeForcedToBakeIndices = stackalloc int[bakedProbeCount];
+ var probeForcedToBakeIndicesCount = 0;
+ var probeForcedToBakeIndicesList = new ListBuffer(
+ probeForcedToBakeIndices,
+ &probeForcedToBakeIndicesCount,
+ bakedProbeCount
+ );
+
ComputeProbeInstanceID(bakedProbes, states);
ComputeProbeSettingsHashes(bakedProbes, states);
// TODO: Handle bounce dependency here
ComputeProbeBakingHashes(bakedProbeCount, allProbeDependencyHash, states);
+ // Force to rebake probe with missing baked texture
+ for (var i = 0; i < bakedProbeCount; ++i)
+ {
+ var instanceId = states[i].instanceID;
+ var probe = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
+ if (probe.bakedTexture != null && !probe.bakedTexture.Equals(null)) continue;
+
+ probeForcedToBakeIndicesList.TryAdd(i);
+ }
+
CoreUnsafeUtils.QuickSort(
bakedProbeCount, states
);
@@ -173,7 +195,7 @@ IScriptableBakedReflectionSystemStageNotifier handle
}
}
- if (operationCount > 0)
+ if (operationCount > 0 || probeForcedToBakeIndicesList.Count > 0)
{
// == 4. ==
var cubemapSize = (int)hdPipeline.currentPlatformRenderPipelineSettings.lightLoopSettings.reflectionCubemapSize;
@@ -185,33 +207,66 @@ IScriptableBakedReflectionSystemStageNotifier handle
0
);
- // Render probes
- for (int i = 0; i < addCount; ++i)
+ // Compute indices of probes to bake: added, modified probe or with a missing baked texture.
+ var toBakeIndices = stackalloc int[bakedProbeCount];
+ var toBakeIndicesCount = 0;
+ var toBakeIndicesList = new ListBuffer(toBakeIndices, &toBakeIndicesCount, bakedProbeCount);
+ {
+ // Note: we will add probes from change check and baked texture missing check.
+ // So we can add at most 2 time the probe in the list.
+ var toBakeIndicesTmp = stackalloc int[bakedProbeCount * 2];
+ var toBakeIndicesTmpCount = 0;
+ var toBakeIndicesTmpList =
+ new ListBuffer(toBakeIndicesTmp, &toBakeIndicesTmpCount, bakedProbeCount * 2);
+
+ // Add the indices from the added or modified detection check
+ toBakeIndicesTmpList.TryCopyFrom(addIndices, addCount);
+ // Add the probe with missing baked texture check
+ probeForcedToBakeIndicesList.TryCopyTo(toBakeIndicesTmpList);
+
+ // Sort indices
+ toBakeIndicesTmpList.QuickSort();
+ // Add to final list without the duplicates
+ var lastValue = int.MaxValue;
+ for (var i = 0; i < toBakeIndicesTmpList.Count; ++i)
+ {
+ if (lastValue == toBakeIndicesTmpList.GetUnchecked(i))
+ // Skip duplicates
+ continue;
+
+ lastValue = toBakeIndicesTmpList.GetUnchecked(i);
+ toBakeIndicesList.TryAdd(lastValue);
+ }
+ }
+
+ // Render probes that were added or modified
+ for (int i = 0; i < toBakeIndicesList.Count; ++i)
{
handle.EnterStage(
(int)BakingStages.ReflectionProbes,
string.Format("Reflection Probes | {0} jobs", addCount),
- i / (float)addCount
+ i / (float)toBakeIndicesCount
);
- var index = addIndices[i];
+ var index = toBakeIndicesList.GetUnchecked(i);
var instanceId = states[index].instanceID;
var probe = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
var cacheFile = GetGICacheFileForHDProbe(states[index].probeBakingHash);
- var planarRT = HDRenderUtilities.CreatePlanarProbeRenderTarget((int)probe.resolution);
// Get from cache or render the probe
if (!File.Exists(cacheFile))
+ {
+ var planarRT = HDRenderUtilities.CreatePlanarProbeRenderTarget((int)probe.resolution);
RenderAndWriteToFile(probe, cacheFile, cubeRT, planarRT);
-
- planarRT.Release();
+ planarRT.Release();
+ }
}
cubeRT.Release();
// Copy texture from cache
- for (int i = 0; i < addCount; ++i)
+ for (int i = 0; i < toBakeIndicesList.Count; ++i)
{
- var index = addIndices[i];
+ var index = toBakeIndicesList.GetUnchecked(i);
var instanceId = states[index].instanceID;
var probe = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
var cacheFile = GetGICacheFileForHDProbe(states[index].probeBakingHash);
@@ -235,7 +290,7 @@ IScriptableBakedReflectionSystemStageNotifier handle
AssetDatabase.StartAssetEditing();
for (int i = 0; i < bakedProbeCount; ++i)
{
- var index = addIndices[i];
+ var index = toBakeIndicesList.GetUnchecked(i);
var instanceId = states[index].instanceID;
var probe = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
@@ -246,9 +301,9 @@ IScriptableBakedReflectionSystemStageNotifier handle
}
// Import assets
AssetDatabase.StartAssetEditing();
- for (int i = 0; i < addCount; ++i)
+ for (int i = 0; i < toBakeIndicesList.Count; ++i)
{
- var index = addIndices[i];
+ var index = toBakeIndicesList.GetUnchecked(i);
var instanceId = states[index].instanceID;
var probe = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
@@ -275,9 +330,9 @@ IScriptableBakedReflectionSystemStageNotifier handle
targetBakedStates[targetI++] = m_HDProbeBakedStates[i];
}
// Add new baked states
- for (int i = 0; i < addCount; ++i)
+ for (int i = 0; i < toBakeIndicesList.Count; ++i)
{
- var state = states[addIndices[i]];
+ var state = states[toBakeIndicesList.GetUnchecked(i)];
targetBakedStates[targetI++] = new HDProbeBakedState
{
instanceID = state.instanceID,
From f23a6f78c31270d7a09c1018278af20890d71f13 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Wed, 10 Jun 2020 19:46:49 +0200
Subject: [PATCH 19/58] Fix issue with blocky artifacts when decals affecting
metallic are applied on specular color workflow #823
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/Material/Lit/LitDecalData.hlsl | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 59f4a288cf0..6af3c77231d 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -143,6 +143,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix reflection probe frame settings override
- Fixed wrong order of post process frame settings.
- Force to rebake probe with missing baked texture. (1253367)
+- Fix issue causing blocky artifacts when decals affect metallic and are applied on material with specular color workflow.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl
index 06951a7e204..eff35477336 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl
@@ -16,7 +16,7 @@ void ApplyDecalToSurfaceData(DecalSurfaceData decalSurfaceData, inout SurfaceDat
#ifdef DECALS_4RT // only smoothness in 3RT mode
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
float3 decalSpecularColor = ComputeFresnel0((decalSurfaceData.HTileMask & DBUFFERHTILEBIT_DIFFUSE) ? decalSurfaceData.baseColor.xyz : float3(1.0, 1.0, 1.0), decalSurfaceData.mask.x, DEFAULT_SPECULAR_VALUE);
- surfaceData.specularColor = surfaceData.specularColor * decalSurfaceData.MAOSBlend.x + decalSpecularColor;
+ surfaceData.specularColor = surfaceData.specularColor * decalSurfaceData.MAOSBlend.x + decalSpecularColor * (1.0f - decalSurfaceData.MAOSBlend.x);
#else
surfaceData.metallic = surfaceData.metallic * decalSurfaceData.MAOSBlend.x + decalSurfaceData.mask.x;
#endif
From b94861347c0af50ea593a3be167bd966a439ba8d Mon Sep 17 00:00:00 2001
From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com>
Date: Fri, 12 Jun 2020 10:43:57 +0200
Subject: [PATCH 20/58] Fixed blend distance editing (1248931) #838
---
.../CHANGELOG.md | 1 +
.../Lighting/Reflection/HDProbeUI.Drawers.cs | 1 -
.../Volume/InfluenceVolumeUI.Drawers.cs | 16 ++++------------
3 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 6af3c77231d..9d1aa032d3a 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -144,6 +144,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed wrong order of post process frame settings.
- Force to rebake probe with missing baked texture. (1253367)
- Fix issue causing blocky artifacts when decals affect metallic and are applied on material with specular color workflow.
+- Appropriately constraint blend distance of reflection probe while editing with the inspector (case 1248931)
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
index 3cba949c92c..81286155f03 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
@@ -233,7 +233,6 @@ public static void DrawCustomSettings(SerializedHDProbe serialized, Editor owner
public static void DrawInfluenceSettings(SerializedHDProbe serialized, Editor owner)
{
- var provider = new TProvider();
InfluenceVolumeUI.Draw(serialized.probeSettings.influence, owner);
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
index 9e4443bbc2e..f1f9eb3f08e 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
@@ -173,18 +173,10 @@ static void Drawer_AdvancedBlendDistance(SerializedInfluenceVolume serialized, b
}
else
{
- float scalar = editorSimplifiedModeBlendDistance.floatValue;
- if (!(Mathf.Approximately(blendDistancePositive.vector3Value.x, scalar)
- && Mathf.Approximately(blendDistancePositive.vector3Value.y, scalar)
- && Mathf.Approximately(blendDistancePositive.vector3Value.z, scalar)
- && Mathf.Approximately(blendDistanceNegative.vector3Value.x, scalar)
- && Mathf.Approximately(blendDistanceNegative.vector3Value.y, scalar)
- && Mathf.Approximately(blendDistanceNegative.vector3Value.z, scalar)))
- {
- blendDistancePositive.vector3Value = blendDistanceNegative.vector3Value = new Vector3(scalar, scalar, scalar);
- serialized.Apply();
- SceneView.RepaintAll(); //update gizmo
- }
+ var scalar = Mathf.Min(editorSimplifiedModeBlendDistance.floatValue, Mathf.Min(maxBlendDistance.x, maxBlendDistance.y, maxBlendDistance.z));
+ blendDistancePositive.vector3Value = blendDistanceNegative.vector3Value = new Vector3(scalar, scalar, scalar);
+ serialized.Apply();
+ SceneView.RepaintAll(); //update gizmo
}
if (serialized.editorAdvancedModeEnabled.boolValue)
From 4fc752118c77c51821b3df20ff48688739174956 Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Tue, 7 Jul 2020 14:29:45 +0200
Subject: [PATCH 21/58] Fix API breaking change: Add Public quality to
Raytracing volume effect
---
.../Material/SubsurfaceScattering/SubSurfaceScattering.cs | 2 +-
.../Runtime/RenderPipeline/PathTracing/PathTracing.cs | 2 +-
.../Runtime/RenderPipeline/Raytracing/LightCluster.cs | 2 +-
.../Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs
index 98a81be6ebc..587d57fb53e 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubSurfaceScattering.cs
@@ -21,7 +21,7 @@ public sealed class SubSurfaceScattering : VolumeComponent
[Tooltip("Number of samples for sub-surface scattering.")]
public ClampedIntParameter sampleCount = new ClampedIntParameter(1, 1, 32);
- SubSurfaceScattering()
+ public SubSurfaceScattering()
{
displayName = "SubSurface Scattering (Preview)";
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs
index f977403c17a..5d821413c6d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs
@@ -49,7 +49,7 @@ public sealed class PathTracing : VolumeComponent
[Tooltip("Defines the maximum intensity value computed for a path segment.")]
public ClampedFloatParameter maximumIntensity = new ClampedFloatParameter(10f, 0f, 100f);
- PathTracing()
+ public PathTracing()
{
displayName = "Path Tracing (Preview)";
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
index 6a1676a2601..bd5c5bd63b6 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
@@ -20,7 +20,7 @@ public sealed class LightCluster : VolumeComponent
[Tooltip("Controls the range of the cluster around the camera.")]
public ClampedFloatParameter cameraClusterRange = new ClampedFloatParameter(10f, 0.001f, 50f);
- LightCluster()
+ public LightCluster()
{
displayName = "Light Cluster (Preview)";
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs
index 87d82e7a8d9..7a3c07316a3 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs
@@ -14,7 +14,7 @@ public sealed class RayTracingSettings : VolumeComponent
[Tooltip("Controls the bias for all real-time ray tracing effects.")]
public ClampedFloatParameter rayBias = new ClampedFloatParameter(0.001f, 0.0f, 0.1f);
- RayTracingSettings()
+ public RayTracingSettings()
{
displayName = "Ray Tracing Settings (Preview)";
}
From f8fc08a504a8fa8fc298a401707bb382365ad339 Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Tue, 7 Jul 2020 15:18:44 +0200
Subject: [PATCH 22/58] Fix API breaking change: Add Public quality to
Raytracing volume effect - RR
---
.../Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs
index a56219666c0..9790c8d4763 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RecursiveRendering.cs
@@ -34,7 +34,7 @@ public sealed class RecursiveRendering : VolumeComponent
[Tooltip("Ray Length. This defines the maximal travel distance of rays.")]
public ClampedFloatParameter rayLength = new ClampedFloatParameter(10f, 0f, 50f);
- RecursiveRendering()
+ public RecursiveRendering()
{
displayName = "Recursive Rendering (Preview)";
}
From 02f56c7810fbe849aa56a14fa8fffda5c51869ce Mon Sep 17 00:00:00 2001
From: JordanL8
Date: Thu, 11 Jun 2020 14:58:48 +0100
Subject: [PATCH 23/58] Update HDR information. Also updated format and links.
(#853)
---
.../Documentation~/Feature-Comparison.md | 41 ++++++++++---------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md
index b07508e96a1..ce0c7033b8d 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md
@@ -4,11 +4,12 @@ The tables that follow provide an overview of the **Features** that the High Def
## Camera
-| **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** (HDRP) |
+| **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** |
| ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| HDR | Yes. The Built-in Renderer uses an HDR Texture Format. | Yes. |
-| Anti-Aliasing | Yes. The Built-in Renderer supports multi-sample anti-aliasing (MSAA) for the Forward Renderer.
If you use the Post-processing v2 package, this Render Pipeline also supports:
•Temporal anti-aliasing (TAA).
•Fast approximate anti-aliasing(FXAA).
•Subpixel morphological anti-aliasing (SMAA). | Yes. HDRP supports:
•MSAA, for the Forward Renderer.
•TAA.
•FXAA.
•SMAA. |
-| Physical Camera | Yes. The **Built-in Render Pipeline** only uses physical camera properties to calculate the Camera's field of view. | Yes. HDRP uses physical camera properties to:
•Calculate the Camera's field of view.
•Calculate the exposure of the Scene.
•Calculate the result of certain post-processing effects.. |
+| HDR rendering | Yes. The Built-in Renderer uses an HDR Texture Format. | Yes |
+| HDR output | Yes | No, however this feature is in research for HDRP. For more information, see [High dynamic range](https://docs.unity3d.com/Manual/HDR.html). |
+| Anti-Aliasing | Yes. The Built-in Renderer supports multi-sample anti-aliasing (MSAA) for the Forward Renderer.
If you use the Post-processing v2 package, this Render Pipeline also supports:
• Temporal anti-aliasing (TAA).
• Fast approximate anti-aliasing(FXAA).
• Subpixel morphological anti-aliasing (SMAA). | Yes. HDRP supports:
• MSAA, for the Forward Renderer.
• TAA.
• FXAA.
• SMAA. |
+| Physical Camera | Yes. The **Built-in Render Pipeline** only uses physical camera properties to calculate the Camera's field of view. | Yes. HDRP uses physical camera properties to:
• Calculate the Camera's field of view.
• Calculate the exposure of the Scene.
• Calculate the result of certain post-processing effects.. |
| Dynamic Resolution | | |
| Hardware | Not supported | Yes but only for consoles. |
| Software | Yes. Limited. | Yes. On all platforms. |
@@ -26,9 +27,9 @@ The tables that follow provide an overview of the **Features** that the High Def
| ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Light Types | | |
| Directional | Yes | Yes |
-| Spot | Yes | Yes. Supports the following shapes:
•Cone.
•Pyramid.
•Box. |
+| Spot | Yes | Yes. Supports the following shapes:
• Cone.
• Pyramid.
• Box. |
| Point | Yes | Yes |
-| Area | Yes. Supports the following shapes:
•Rectangle.
•Disk (baked only). | Yes. Supports the following shapes:
•Rectangle.
•Tube.
•Disk (baked only). |
+| Area | Yes. Supports the following shapes:
• Rectangle.
• Disk (baked only). | Yes. Supports the following shapes:
• Rectangle.
• Tube.
• Disk (baked only). |
| Inner Spot Angle | Not supported | Yes |
| Shading | Multiple Passes | Tiled/Clustered |
| Culling | | |
@@ -61,7 +62,7 @@ The tables that follow provide an overview of the **Features** that the High Def
| Shadow Resolve Type | | |
| Lighting Pass | Yes | Yes |
| Screen Space Pass | Yes | Yes |
-| Shadow Bias | Yes. Supports the following types:
•Constant clip space offset.
•Normal bias. | Yes. Supports the following types:
•Slope bias.
•Normal bias. |
+| Shadow Bias | Yes. Supports the following types:
• Constant clip space offset.
• Normal bias. | Yes. Supports the following types:
• Slope bias.
• Normal bias. |
## Batching
@@ -115,14 +116,14 @@ The tables that follow provide an overview of the **Features** that the High Def
| Realtime | Yes | yes |
| Baked | Yes | Yes |
| Sampling | | |
-| Simple | Yes | See [Reflection Hierarchy](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Reflection-in-HDRP.html). |
-| Blend Probes | Yes | See [Reflection Hierarchy](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Reflection-in-HDRP.html). |
-| Blend Probes and Skybox | Yes | See [Reflection Hierarchy](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Reflection-in-HDRP.html). |
+| Simple | Yes | See [Reflection Hierarchy](Reflection-in-HDRP.md). |
+| Blend Probes | Yes | See [Reflection Hierarchy](Reflection-in-HDRP.md). |
+| Blend Probes and Skybox | Yes | See [Reflection Hierarchy](Reflection-in-HDRP.md). |
| Projection | | |
| Box | Yes | Yes |
| Sphere | No | Yes |
| Proxy Volume | Not supported | Yes |
-| Other Reflections | The **Built-in Render Pipeline** also supports screen space reflection. | HDRP supports the following other reflection methods:
•Planar Reflection Probes.
•Screen space reflection.
•Ray-traced reflection. |
+| Other Reflections | The **Built-in Render Pipeline** also supports screen space reflection. | HDRP supports the following other reflection methods:
• Planar Reflection Probes.
• Screen space reflection.
• Ray-traced reflection. |
## Global Illumination (Lightmap Modes)
@@ -136,9 +137,9 @@ The tables that follow provide an overview of the **Features** that the High Def
| **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** |
| ------------ | ------------------------ | ------------------------------------------------------------ |
| Source | | |
-| Skybox | Yes | Uses a single sky to bake global illumination, otherwise uses sky settings per Volume. You can [create own sky via script](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@7.1/manual/Creating-a-Custom-Sky.html) and Material. |
-| Gradient | Yes | Uses a single sky to bake global illumination, otherwise uses sky settings per Volume. You can [create own sky via script](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@7.1/manual/Creating-a-Custom-Sky.html) and Material. |
-| Color | Yes | Uses a single sky to bake global illumination, otherwise uses sky settings per Volume. You can [create own sky via script](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@7.1/manual/Creating-a-Custom-Sky.html) and Material. |
+| Skybox | Yes | Uses a single sky to bake global illumination, otherwise uses sky settings per Volume. You can [create own sky via script](Creating-a-Custom-Sky.md) and Material. |
+| Gradient | Yes | Uses a single sky to bake global illumination, otherwise uses sky settings per Volume. You can [create own sky via script](Creating-a-Custom-Sky.md) and Material. |
+| Color | Yes | Uses a single sky to bake global illumination, otherwise uses sky settings per Volume. You can [create own sky via script](Creating-a-Custom-Sky.md) and Material. |
| Ambient Mode | | |
| Realtime | Yes | Yes |
| Baked | Yes | Yes |
@@ -159,7 +160,7 @@ The tables that follow provide an overview of the **Features** that the High Def
| **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** |
| ------------------- | ------------------------ | ------------------------------------------------------------ |
| Linear | Yes | Not supported |
-| Exponential | Yes | Yes. The [Fog Override](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Override-Fog.html) uses exponential fog. |
+| Exponential | Yes | Yes. The [Fog Override](Override-Fog.md) uses exponential fog. |
| Exponential Squared | Yes | Not supported |
| Local Volumetric | No | Yes |
@@ -169,7 +170,7 @@ The tables that follow provide an overview of the **Features** that the High Def
| --------------------------- | --------------------------------------------- | ------------------------------------------------------------ |
| Shader Graph | Not supported | Yes |
| Surface Shaders | Yes | Not supported |
-| Camera-relative Rendering | Not supported | Yes. See [Camera Relative Rendering](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Camera-Relative-Rendering.html). |
+| Camera-relative Rendering | Not supported | Yes. See [Camera Relative Rendering](Camera-Relative-Rendering.md). |
| Standard Lit Shader | | |
| Metallic Workflow | Yes | Yes |
| Specular Workflow | Yes | Yes |
@@ -181,8 +182,8 @@ The tables that follow provide an overview of the **Features** that the High Def
| Additive | Not supported | Yes |
| Multiply | Not supported | Not supported |
| Decals | Not supported | Yes. To create decals in HDRP, you can use a decal Mesh or a decal projector. |
-| Detail Maps | Yes. You can assigned albedo and normal maps. | Yes. HDRP uses the [mask and detail maps]() to combine maps such ask albedo, normals, and smoothness |
-| Advanced Material Options | None | HDRP supports the following advanced Materials:
•Anisotropic.
•Subsurface Scattering.
•Iridescence.
•Translucence. |
+| Detail Maps | Yes. You can assigned albedo and normal maps. | Yes. HDRP uses the [mask and detail maps](Mask-Map-and-Detail-Map.md) to combine maps such ask albedo, normals, and smoothness |
+| Advanced Material Options | None | HDRP supports the following advanced Materials:
• Anisotropic.
• Subsurface Scattering.
• Iridescence.
• Translucence. |
| Surface Inputs | | |
| Albedo (Base Map) | Yes | Yes |
| Specular | Yes | Yes |
@@ -241,8 +242,8 @@ The tables that follow provide an overview of the **Features** that the High Def
| **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** |
| --------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Implementation | Uses Post-Processing Version 2 package. | Native Post-Processing solution embedded in HDRP package |
-| Ambient Occlusion | Yes. The **Built-in Render Pipeline** supports:
•Multi-scale ambient occlusion. | Yes. HDRP supports:
•Ground truth ambient occlusion.
•[Ray-traced ambient occlusion](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@7.1/manual/Ray-Traced-Ambient-Occlusion.html). |
-| Exposure | Yes. The **Built-in Render Pipeline** supports:
•Fixed exposure.
•Automatic exposure. | Yes. HDRP supports:
•Fixed exposure.
•Automatic (Eye adaptation).
•Curve Mapping.
•Physical Camera settings |
+| Ambient Occlusion | Yes. The **Built-in Render Pipeline** supports:
• Multi-scale ambient occlusion. | Yes. HDRP supports:
• Ground truth ambient occlusion.
• [Ray-traced ambient occlusion](Ray-Traced-Ambient-Occlusion.md). |
+| Exposure | Yes. The **Built-in Render Pipeline** supports:
• Fixed exposure.
• Automatic exposure. | Yes. HDRP supports:
• Fixed exposure.
• Automatic (Eye adaptation).
• Curve Mapping.
• Physical Camera settings |
| Bloom | Yes | Yes |
| Chromatic Aberration | Yes | Yes |
| Color Grading / Tonemapping | Yes | Yes |
From 8c920f4f78a1870d62d93cc25cc21af745910d7a Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Thu, 11 Jun 2020 20:21:22 +0200
Subject: [PATCH 24/58] Fix message for metal and ao (#859)
---
.../Material/UIBlocks/DecalSurfaceInputsUIBlock.cs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs
index 23f9f91c38f..81ae763ee74 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs
@@ -323,11 +323,12 @@ void DrawDecalGUI()
materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText);
}
- EditorGUILayout.HelpBox(
- "Enable 'Metal and AO properties' in your HDRP Asset if you want to control the Metal and AO properties of decals.\nThere is a performance cost of enabling this option.",
- MessageType.Info);
+ if (!perChannelMask)
+ {
+ EditorGUILayout.HelpBox("Enable 'Metal and AO properties' in your HDRP Asset if you want to control the Metal and AO properties of decals.\nThere is a performance cost of enabling this option.",
+ MessageType.Info);
+ }
}
-
}
}
}
From 0e04f7676b005afd3275eef467af2f5740960fd6 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Thu, 11 Jun 2020 20:36:58 +0200
Subject: [PATCH 25/58] d Fix issue with the blue line of prefab modifications
for Volume mode #860
---
com.unity.render-pipelines.core/CHANGELOG.md | 1 +
com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md
index fd2d3bec35e..bf490f1fdef 100644
--- a/com.unity.render-pipelines.core/CHANGELOG.md
+++ b/com.unity.render-pipelines.core/CHANGELOG.md
@@ -22,6 +22,7 @@ The version number for this package has increased due to a version update of a r
- Fixed null reference exception in LookDev when setting the SRP to one not implementing LookDev (case 1245086)
- Fix LookDev's undo/redo on EnvironmentLibrary (case 1234725)
- Fixed a wrong condition in CameraSwitcher, potentially causing out of bound exceptions.
+- Fixed issue with blue line in prefabs for volume mode.
## [8.0.1] - 2020-02-25
diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs
index 274016aa54a..b29db2c33b6 100644
--- a/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs
+++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs
@@ -59,7 +59,7 @@ public override void OnInspectorGUI()
EditorGUI.BeginProperty(lineRect, label, m_IsGlobal);
{
EditorGUI.BeginChangeCheck();
- isGlobal = EditorGUILayout.Popup(label, isGlobal, m_Modes);
+ isGlobal = EditorGUI.Popup(lineRect, label, isGlobal, m_Modes);
if (EditorGUI.EndChangeCheck())
m_IsGlobal.boolValue = isGlobal == 0;
}
From 9de5cb2f3fe28fc22245f66873443cb7f656a9ce Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Thu, 11 Jun 2020 20:49:07 +0200
Subject: [PATCH 26/58] Recompute FOV when generating PixelCoord To WorldSpace
View Direction Matrix #865
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/Camera/HDCamera.cs | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 9d1aa032d3a..90f26f93b42 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed light layers not correctly disabled when the lightlayers is set to Nothing and Lightlayers isn't enabled in HDRP Asset
- Fixed AxF handling of roughness for Blinn-Phong type materials
- Fixed AxF UI errors when surface type is switched to transparent
+- Fix issue that caused sky to incorrectly render when using a custom projection matrix.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index ea103c3970f..39af292dc49 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -1221,6 +1221,10 @@ Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(ViewConstants viewCon
}
float verticalFoV = camera.GetGateFittedFieldOfView() * Mathf.Deg2Rad;
+ if (!camera.usePhysicalProperties)
+ {
+ verticalFoV = Mathf.Atan(-1.0f / viewConstants.projMatrix[1, 1]) * 2;
+ }
Vector2 lensShift = camera.GetGateFittedLensShift();
return HDUtils.ComputePixelCoordToWorldSpaceViewDirectionMatrix(verticalFoV, lensShift, resolution, viewConstants.viewMatrix, false, aspect);
From 08b7f9ebc87dabc6f91ee00d86bca9b35cc3a05f Mon Sep 17 00:00:00 2001
From: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com>
Date: Fri, 12 Jun 2020 18:11:52 +0200
Subject: [PATCH 27/58] Upgrade default legacy terrain to HDRP default
TerrainLit (#883)
---
.../UpgradeStandardShaderMaterials.cs | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs
index 3caefc2fd49..e474ad3aa5c 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs
@@ -35,6 +35,29 @@ internal static void UpgradeMaterialsSelection()
{
MaterialUpgrader.UpgradeSelection(GetHDUpgraders(), "Upgrade to HD Material");
}
+
+ [MenuItem("Edit/Render Pipeline/Upgrade Scene Terrains to High Definition Terrains", priority = CoreUtils.editMenuPriority2)]
+ static void UpgradeSceneTerrainsToHighDefinitionTerrains(MenuCommand menuCommand)
+ {
+ var LegacyDefaultTerrainMat = AssetDatabase.GetBuiltinExtraResource("Default-Terrain-Standard.mat");
+ var HDRPTerrainMat = AssetDatabase.LoadAssetAtPath("Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat");
+ var terrainArray = UnityEngine.GameObject.FindObjectsOfType();
+
+ if(terrainArray.Length == 0)
+ {
+ Debug.LogWarning("No terrains were found in the scene.");
+ return;
+ }
+
+ foreach (Terrain currentTerrain in terrainArray)
+ {
+ if(currentTerrain.materialTemplate == LegacyDefaultTerrainMat)
+ {
+ currentTerrain.materialTemplate = HDRPTerrainMat;
+ }
+ }
+ }
+
[MenuItem("Edit/Render Pipeline/Multiply Unity Builtin Directional Light Intensity to match High Definition", priority = CoreUtils.editMenuPriority2)]
internal static void UpgradeLights()
From 8f01531610f429dac7293a1491cd441a9e49f6d6 Mon Sep 17 00:00:00 2001
From: JordanL8
Date: Mon, 15 Jun 2020 10:35:34 +0100
Subject: [PATCH 28/58] Editing volumes via script doc (#884)
* Added Volumes API doc
* Update Volumes-API.md
* Changed terminology back to Volume Override
* Added terminology disclaimer
---
.../Documentation~/Volumes-API.md | 85 +++++++++++++++++++
1 file changed, 85 insertions(+)
create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Volumes-API.md
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Volumes-API.md b/com.unity.render-pipelines.high-definition/Documentation~/Volumes-API.md
new file mode 100644
index 00000000000..71246fd0049
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Volumes-API.md
@@ -0,0 +1,85 @@
+# Volume Scripting API
+
+In the High Definition Render Pipeline (HDRP), [Volumes](Volumes.md) control environment settings in a scene. To give you control over Volumes at runtime, HDRP provides API that you can use to create, access, and edit Volumes via C# scripting. This page describes how to use the scripting API and provides examples to help you get started. You may notice that Volume Overrides, such as [Fog](Override-Fog.md), actually inherit from the VolumeComponent class. The documentation calls these Volume Overrides and not Volume Components to be consistent with the user interface and to avoid confusion with the [Volume](Volumes.md) component.
+
+## Modifying an existing Volume
+
+Volumes store their [Volume Overrides](Volume-Components.md) in a [Volume Profile](Volume-Profile.md). So, to modify the properties of a Volume Override, you need to first retrieve the Volume Profile. There are two ways to do this:
+
+### Shared Volume Profile access
+
+One method is to access the Volume's shared Profile. You do this via the Volume's `sharedProfile` property. This gives you a reference to the instance of the Volume Profile asset. If you modify this Volume Profile:
+
+- HDRP applies any changes you make to every Volume that uses this Volume Profile asset.
+
+- The modifications you make affect the actual Volume Profile asset which means they do not reset when you exit Play mode
+
+Note the `sharedProfile` property can return `null` if the Volume does not reference a Volume Profile asset.
+
+### Owned Volume Profile access
+
+The other method is to clone the Volume Profile asset. The advantage of this is that your modifications only affect the Volume component you clone the Volume Profile from and don't affect any other Volumes that use the same Volume Profile asset. To do this, use the Volume's `profile` property. This returns a reference to a new instance of a Volume Profile (if not already created). If you were already modifying the Volume's `sharedProfile`, any changes you made are copied over to the new instance. If you modify this Volume Profile:
+
+- HDRP only applies changes to the particular Volume.
+- The modification you make reset when you exit Play mode.
+- It is your responsibility to destroy the duplicate Volume Profile when you no longer need it.
+
+Note that you can use this property to assign a different Volume Profile to the Volume.
+
+## Changing Volume Profile properties
+
+When you have a reference to the Volume Profile, you can change the properties of any Volume Overrides in it. This works in a similar way as changing properties in the Inspector.
+
+First, you need to retrieve the particular Volume Override using the generic `TryGet<>` function on the profile. If the Volume Profile does not contain that particular Volume Override and the `TryGet<>` function returns false, you can use the `Add<>` function to add the Volume Override.
+
+When you have a reference to the Volume Override, you can access and modify its public properties. For a property to have an effect on the scene, you need to specify that it has been overridden. This makes HDRP use the value you specify, rather than using the default value. Every property in a Volume Override is made up of two parts:
+
+- A bool that contains the override state. This is `overrideState`.
+- The property's value itself. This is `value`.
+
+After you set a property's `overrideState` to true, you can then change the `value`.
+
+The following example changes the `enabled` property of the [Fog](Override-Fog.md) Volume Override:
+
+```
+using UnityEngine.Rendering;
+using UnityEngine.Rendering.HighDefinition;
+
+
+public Volume m_Volume;
+public bool enableFog;
+public bool overrideFog;
+
+
+VolumeProfile profile = m_Volume.sharedProfile;
+if (!profile.TryGet(out var fog))
+{
+ fog = profile.Add(false);
+}
+
+fog.enabled.overrideState = overrideFog;
+fog.enabled.value = enableFog;
+```
+
+
+
+## Fading Volumes
+
+Distance-based Volume blending is useful for many design use-cases, but you may want to manually trigger a fade in/out effect based on an event in your application. To do this, update the `weight` property of the Volume. The example below changes the weight property over time in the `Update` method of a `MonoBehaviour`. It fades the Volume in and out based on the Sin of the time since the application started, but you can use any method to update the `weight`:
+
+```
+using UnityEngine;
+using UnityEngine.Rendering;
+
+public class VolumeWeightSin : MonoBehaviour
+{
+ Volume m_Volume;
+ void Update()
+ {
+ if (m_Volume != null)
+ {
+ m_Volume.weight = Mathf.Sin(Time.realtimeSinceStartup);
+ }
+ }
+}
+```
\ No newline at end of file
From f4e391d4852cf3b20ffa73b88161989875c328b4 Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Fri, 19 Jun 2020 19:32:31 +0200
Subject: [PATCH 29/58] Update HDRenderPipeline.cs (#994)
---
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 0239373547e..ec1d30d6c31 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -717,6 +717,7 @@ void SetRenderingFeatures()
, overridesMaximumLODLevel = true
, terrainDetailUnsupported = true
, overridesShadowmask = true // Don't display the shadow mask UI in Quality Settings
+ , overrideShadowmaskMessage = "\nThe Shadowmask Mode used at run time can be found in the Shadows section of Light component."
, overridesRealtimeReflectionProbes = true // Don't display the real time reflection probes checkbox UI in Quality Settings
};
From bf8937748a01a2e6a54392de3bf5e5f79f80db8c Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Fri, 19 Jun 2020 19:32:31 +0200
Subject: [PATCH 30/58] Delete 9713_VirtualTexturing.meta
---
.../Scenes/9x_Other/9713_VirtualTexturing.meta | 8 --------
1 file changed, 8 deletions(-)
delete mode 100644 TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9713_VirtualTexturing.meta
diff --git a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9713_VirtualTexturing.meta b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9713_VirtualTexturing.meta
deleted file mode 100644
index 735cd34ee74..00000000000
--- a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9713_VirtualTexturing.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 2559987e9b9bc30428f6e337ec811b1c
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
From 3b7f7fbb1064c61c20f22f09223f18f85791567f Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Fri, 3 Jul 2020 15:40:21 +0200
Subject: [PATCH 31/58] Fix SSAO with double sided material and normal mode to
none #1043
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/Lighting/ScreenSpaceLighting/GTAO.compute | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 90f26f93b42..f0daeb6ceee 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed AxF handling of roughness for Blinn-Phong type materials
- Fixed AxF UI errors when surface type is switched to transparent
- Fix issue that caused sky to incorrectly render when using a custom projection matrix.
+- Fixed issue with completely black AO on double sided materials when normal mode is set to None.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAO.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAO.compute
index 5bf31c7a038..6ac477b19fe 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAO.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAO.compute
@@ -214,7 +214,7 @@ void GTAO_KERNEL_NAME(uint3 dispatchThreadId : SV_DispatchThreadID)
integral /= dirCount;
- if (currDepth == UNITY_RAW_FAR_CLIP_VALUE)
+ if (currDepth == UNITY_RAW_FAR_CLIP_VALUE || integral < -1e-2f)
{
integral = 1;
}
From deacc88912760d12f34a7063c48c6450de72445c Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Thu, 2 Jul 2020 18:16:15 +0200
Subject: [PATCH 32/58] Fix emissive mesh layer mask behaviour #1062
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/Lighting/Light/HDAdditionalLightData.cs | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index f0daeb6ceee..59d8084fa85 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed AxF UI errors when surface type is switched to transparent
- Fix issue that caused sky to incorrectly render when using a custom projection matrix.
- Fixed issue with completely black AO on double sided materials when normal mode is set to None.
+- Fixed issue with culling layer mask of area light's emissive mesh
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
index 091c61be589..5873404b72c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
@@ -2362,6 +2362,11 @@ void OnValidate()
DisableCachedShadowSlot();
m_ShadowMapRenderedSinceLastRequest = false;
+ if (emissiveMeshRenderer != null && !emissiveMeshRenderer.Equals(null))
+ {
+ emissiveMeshRenderer.gameObject.layer = m_AreaLightEmissiveMeshLayer;
+ }
+
#if UNITY_EDITOR
// If modification are due to change on prefab asset that are non overridden on this prefab instance
if (PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false))
From e5e102fc8b916e2f1dc2d5d15020f4efb4639f10 Mon Sep 17 00:00:00 2001
From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com>
Date: Fri, 3 Jul 2020 15:49:07 +0200
Subject: [PATCH 33/58] Use the wide mode to force the UI drawing on a single
line (1251235) #1064
---
.../Editor/QuaternionPropertyDrawer.cs | 3 +++
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
2 files changed, 4 insertions(+)
diff --git a/com.unity.render-pipelines.core/Editor/QuaternionPropertyDrawer.cs b/com.unity.render-pipelines.core/Editor/QuaternionPropertyDrawer.cs
index b6096a16210..3bbe0fb103a 100644
--- a/com.unity.render-pipelines.core/Editor/QuaternionPropertyDrawer.cs
+++ b/com.unity.render-pipelines.core/Editor/QuaternionPropertyDrawer.cs
@@ -9,7 +9,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
{
var euler = property.quaternionValue.eulerAngles;
EditorGUI.BeginChangeCheck();
+ var w = EditorGUIUtility.wideMode;
+ EditorGUIUtility.wideMode = true;
euler = EditorGUI.Vector3Field(position, label, euler);
+ EditorGUIUtility.wideMode = w;
if (EditorGUI.EndChangeCheck())
property.quaternionValue = Quaternion.Euler(euler);
}
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 59d8084fa85..e89cfac58df 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix issue that caused sky to incorrectly render when using a custom projection matrix.
- Fixed issue with completely black AO on double sided materials when normal mode is set to None.
- Fixed issue with culling layer mask of area light's emissive mesh
+- Fixed UI drawing of the quaternion (1251235)
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
From 805e51c618dc4145c83b3fa50acfecfb7ba4127d Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Tue, 7 Jul 2020 18:41:05 +0200
Subject: [PATCH 34/58] Fix custom pass after post process buffer #1072
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Documentation~/Custom-Pass.md | 3 ++-
.../CustomPass/DrawRenderersCustomPassDrawer.cs | 3 ++-
.../Runtime/RenderPipeline/HDStringConstants.cs | 1 +
.../RenderPass/CustomPass/CustomPassCommon.hlsl | 6 ++++++
.../RenderPass/CustomPass/CustomPassVolume.cs | 2 ++
6 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index e89cfac58df..ae951254674 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with completely black AO on double sided materials when normal mode is set to None.
- Fixed issue with culling layer mask of area light's emissive mesh
- Fixed UI drawing of the quaternion (1251235)
+- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md b/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md
index 2e8d98ed523..586dfc9a9bb 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md
@@ -79,7 +79,7 @@ float4 FullScreenPass(Varyings varyings) : SV_Target
// Load the camera color buffer at the mip 0 if we're not at the before rendering injection point
if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING)
- color = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1);
+ color = float4(CustomPassLoadCameraColor(varyings.positionCS.xy, 0), 1);
// Add your custom pass code here
@@ -98,6 +98,7 @@ In this snippet, we fetch a lot of useful input data that you might need in your
| **Sampling the camera color with lods is only available in after and before post process passes**. Calling `CustomPassSampleCameraColor` at before rendering will only return black. |
| **DrawRenderers Pass chained with FullScreen Pass**: In multi-pass setups where you draw objects in the camera color buffer and then read it from a fullscreen custom pass, you'll not see the objects you've drawn in the passes before your fullscreen pass (unless you are in Before Transparent). |
| **MSAA**: When dealing with MSAA, you must check that the `Fetch color buffer` boolean is correctly setup because it will determine whether or not you'll be able to fetch the color buffer in this pass or not. |
+| **Before Pre-Refraction and After post-process**: On these injection points, the camera color buffer set as the target for the fullscreen pass is the same as the one you can access inside the shader. Because the camera color buffer is the target, and because of read/write restrictions on certain platforms, you cannot directly sample from the camera color buffer inside the shader. Instead, you need to split your effect into two passes and use the custom color buffer as an intermediate buffer. This avoids reading and writing simultaneously to the same buffer. |
### DrawRenderers Custom Pass
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs
index 5759a22323c..c6dc1f8b41c 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs
@@ -161,7 +161,8 @@ protected override void DoPassGUI(SerializedProperty customPass, Rect rect)
#endif
// TODO: remove all this code when the fix for SerializedReference lands
- EditorGUI.PropertyField(rect, m_SortingCriteria, Styles.sortingCriteria);
+ m_SortingCriteria.intValue = (int)(SortingCriteria)EditorGUI.EnumFlagsField(rect, Styles.sortingCriteria, (SortingCriteria)m_SortingCriteria.intValue);
+ // EditorGUI.PropertyField(rect, m_SortingCriteria, Styles.sortingCriteria);
rect.y += Styles.defaultLineSpace;
EditorGUI.indentLevel--;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
index ef300ef3a6b..0414b52ecca 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
@@ -445,6 +445,7 @@ static class HDShaderIDs
public static readonly int _CustomDepthTexture = Shader.PropertyToID("_CustomDepthTexture");
public static readonly int _CustomColorTexture = Shader.PropertyToID("_CustomColorTexture");
public static readonly int _CustomPassInjectionPoint = Shader.PropertyToID("_CustomPassInjectionPoint");
+ public static readonly int _AfterPostProcessColorBuffer = Shader.PropertyToID("_AfterPostProcessColorBuffer");
public static readonly int _InputCubemap = Shader.PropertyToID("_InputCubemap");
public static readonly int _Mipmap = Shader.PropertyToID("_Mipmap");
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl
index 00f86e02957..fb5e97ceed7 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl
@@ -10,6 +10,10 @@
float _CustomPassInjectionPoint;
float _FadeValue;
+// This texture is only available in after post process and contains the result of post processing effects.
+// While SampleCameraColor still returns the color pyramid without post processes
+TEXTURE2D_X(_AfterPostProcessColorBuffer);
+
float3 CustomPassSampleCameraColor(float2 uv, float lod, bool uvGuards = true)
{
if (uvGuards)
@@ -22,6 +26,7 @@ float3 CustomPassSampleCameraColor(float2 uv, float lod, bool uvGuards = true)
// Also, we don't use _RTHandleScaleHistory to sample because the color pyramid bound is the actual camera color buffer which is at the resolution of the camera
case CUSTOMPASSINJECTIONPOINT_BEFORE_TRANSPARENT:
case CUSTOMPASSINJECTIONPOINT_BEFORE_PRE_REFRACTION: return SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, uv * _RTHandleScaleHistory.xy, 0).rgb;
+ case CUSTOMPASSINJECTIONPOINT_AFTER_POST_PROCESS: return SAMPLE_TEXTURE2D_X_LOD(_AfterPostProcessColorBuffer, s_trilinear_clamp_sampler, uv * _RTHandleScaleHistory.xy, 0).rgb;
default: return SampleCameraColor(uv, lod);
}
}
@@ -34,6 +39,7 @@ float3 CustomPassLoadCameraColor(uint2 pixelCoords, float lod)
// there is no color pyramid yet for before transparent so we can't sample with mips.
case CUSTOMPASSINJECTIONPOINT_BEFORE_TRANSPARENT:
case CUSTOMPASSINJECTIONPOINT_BEFORE_PRE_REFRACTION: return LOAD_TEXTURE2D_X_LOD(_ColorPyramidTexture, pixelCoords, 0).rgb;
+ case CUSTOMPASSINJECTIONPOINT_AFTER_POST_PROCESS: return LOAD_TEXTURE2D_X_LOD(_AfterPostProcessColorBuffer, pixelCoords, 0).rgb;
default: return LoadCameraColor(pixelCoords, lod);
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs
index 6cb40883a61..cc4c290ca32 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs
@@ -88,6 +88,8 @@ internal bool Execute(ScriptableRenderContext renderContext, CommandBuffer cmd,
return false;
Shader.SetGlobalFloat(HDShaderIDs._CustomPassInjectionPoint, (float)injectionPoint);
+ if (injectionPoint == CustomPassInjectionPoint.AfterPostProcess)
+ Shader.SetGlobalTexture(HDShaderIDs._AfterPostProcessColorBuffer, targets.cameraColorBuffer);
foreach (var pass in customPasses)
{
From c9574da73f441cb008e10e2c04bde49a9783c1a0 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Sat, 4 Jul 2020 21:08:35 +0200
Subject: [PATCH 35/58] Fix for area light baked data not updating when
changing the gizmo #1075
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/Lighting/Light/HDAdditionalLightData.cs | 2 ++
2 files changed, 3 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index ae951254674..08b7e02d01d 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with culling layer mask of area light's emissive mesh
- Fixed UI drawing of the quaternion (1251235)
- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
+- Fixed for area light not updating baked light result when modifying with gizmo.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
index 5873404b72c..1d2c4ab48eb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
@@ -2677,6 +2677,8 @@ void UpdateShapeSize()
// Force to clamp the shape if we changed the type of the light
shapeWidth = m_ShapeWidth;
shapeHeight = m_ShapeHeight;
+
+ legacyLight.areaSize = new Vector2(shapeWidth, shapeHeight);
}
///
From 3d88d6b627ba38bccffa0a5e06131742835a9f40 Mon Sep 17 00:00:00 2001
From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com>
Date: Fri, 3 Jul 2020 11:18:58 +0200
Subject: [PATCH 36/58] =?UTF-8?q?=20Fixed=20an=20error=20when=20switch=20a?=
=?UTF-8?q?rea=20light=20shape=20to=20disk=20while=20an=20emissive?=
=?UTF-8?q?=E2=80=A6=20#1112?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CHANGELOG.md | 1 +
.../Editor/Lighting/SerializedHDLight.cs | 12 ++++++++----
.../Editor/RenderPipeline/HDEditorUtils.cs | 4 ++++
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 08b7e02d01d..1ea5b0ee33c 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -151,6 +151,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Force to rebake probe with missing baked texture. (1253367)
- Fix issue causing blocky artifacts when decals affect metallic and are applied on material with specular color workflow.
- Appropriately constraint blend distance of reflection probe while editing with the inspector (case 1248931)
+- Fixed errors when switching area light to disk shape while an area emissive mesh was displayed.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs
index b9cfcea5681..022584863f1 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs
@@ -464,8 +464,10 @@ public void Update()
settings.Update();
lightGameObject.Update();
- deportedAreaLightEmissiveMeshMotionVector?.serializedObject.Update();
- deportedAreaLightEmissiveMeshLayer?.serializedObject.Update();
+ if (deportedAreaLightEmissiveMeshMotionVector.IsTargetAlive())
+ deportedAreaLightEmissiveMeshMotionVector?.serializedObject.Update();
+ if (deportedAreaLightEmissiveMeshLayer.IsTargetAlive())
+ deportedAreaLightEmissiveMeshLayer?.serializedObject.Update();
}
void ApplyInternal(bool withDeportedEmissiveMeshData)
@@ -474,8 +476,10 @@ void ApplyInternal(bool withDeportedEmissiveMeshData)
settings.ApplyModifiedProperties();
if (withDeportedEmissiveMeshData)
{
- deportedAreaLightEmissiveMeshMotionVector?.serializedObject.ApplyModifiedProperties();
- deportedAreaLightEmissiveMeshLayer?.serializedObject.ApplyModifiedProperties();
+ if (deportedAreaLightEmissiveMeshMotionVector.IsTargetAlive())
+ deportedAreaLightEmissiveMeshMotionVector?.serializedObject.ApplyModifiedProperties();
+ if (deportedAreaLightEmissiveMeshLayer.IsTargetAlive())
+ deportedAreaLightEmissiveMeshLayer?.serializedObject.ApplyModifiedProperties();
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs
index 29c7745ea9b..1ef64600f1f 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs
@@ -287,6 +287,10 @@ public static IEnumerable EnumerateDisplayName(this SerializedProperty p
yield return property.displayName;
}
+ public static bool IsTargetAlive(this SerializedProperty property)
+ => property != null && property.serializedObject.targetObject != null &&
+ !property.serializedObject.targetObject.Equals(null);
+
///
/// Helper to get an enum value from a SerializedProperty.
/// This handle case where index do not correspond to enum value.
From bf6e812aa4526a436e47b8252f125469775abd6f Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Fri, 3 Jul 2020 17:50:04 +0200
Subject: [PATCH 37/58] Have the PBR Sky not render black when below horizon
#1116
---
.../CHANGELOG.md | 1 +
.../PhysicallyBasedSkyRenderer.cs | 14 ++++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 1ea5b0ee33c..7bff13d2882 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -152,6 +152,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix issue causing blocky artifacts when decals affect metallic and are applied on material with specular color workflow.
- Appropriately constraint blend distance of reflection probe while editing with the inspector (case 1248931)
- Fixed errors when switching area light to disk shape while an area emissive mesh was displayed.
+- PBR Sky now doesn't go black when going below sea level, but it instead freezes calculation as if on the horizon.
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs
index 03767aec550..d02d94ab26d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs
@@ -446,11 +446,13 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo
var pbrSky = builtinParams.skySettings as PhysicallyBasedSky;
// TODO: the following expression is somewhat inefficient, but good enough for now.
- Vector3 X = builtinParams.worldSpaceCameraPos;
- float r = Vector3.Distance(X, pbrSky.GetPlanetCenterPosition(X));
- float R = pbrSky.GetPlanetaryRadius();
+ Vector3 cameraPos = builtinParams.worldSpaceCameraPos;
+ Vector3 planetCenter = pbrSky.GetPlanetCenterPosition(cameraPos);
+ float R = pbrSky.GetPlanetaryRadius();
- bool isPbrSkyActive = r > R; // Disable sky rendering below the ground
+ Vector3 cameraToPlanetCenter = planetCenter - cameraPos;
+ float r = cameraToPlanetCenter.magnitude;
+ cameraPos = planetCenter - Mathf.Max(R, r) * cameraToPlanetCenter.normalized;
CommandBuffer cmd = builtinParams.commandBuffer;
@@ -464,7 +466,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo
pbrSky.spaceRotation.value.z);
s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, builtinParams.pixelCoordToViewDirMatrix);
- s_PbrSkyMaterialProperties.SetVector(HDShaderIDs._WorldSpaceCameraPos1, builtinParams.worldSpaceCameraPos);
+ s_PbrSkyMaterialProperties.SetVector(HDShaderIDs._WorldSpaceCameraPos1, cameraPos);
s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._ViewMatrix1, builtinParams.viewMatrix);
s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._PlanetRotation, Matrix4x4.Rotate(planetRotation));
s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._SpaceRotation, Matrix4x4.Rotate(spaceRotation));
@@ -502,7 +504,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo
s_PbrSkyMaterialProperties.SetInt(HDShaderIDs._RenderSunDisk, renderSunDisk ? 1 : 0);
- int pass = (renderForCubemap ? 0 : 2) + (isPbrSkyActive ? 0 : 1);
+ int pass = (renderForCubemap ? 0 : 2);
CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_PbrSkyMaterial, s_PbrSkyMaterialProperties, pass);
}
From cc8ba573f24cb27a222f6deec92f92198d88b130 Mon Sep 17 00:00:00 2001
From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com>
Date: Fri, 3 Jul 2020 19:18:38 +0200
Subject: [PATCH 38/58] Find the appropriate default frame settings per editor
(case 1247631) #1129
---
.../CHANGELOG.md | 1 +
.../Lighting/Reflection/HDProbeEditor.cs | 7 +++++-
.../Settings/DefaultSettingsPanel.cs | 24 ++++++++++++++++---
.../Settings/FrameSettingsUI.Drawers.cs | 16 ++++++-------
4 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 7bff13d2882..6f7860e509c 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -153,6 +153,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Appropriately constraint blend distance of reflection probe while editing with the inspector (case 1248931)
- Fixed errors when switching area light to disk shape while an area emissive mesh was displayed.
- PBR Sky now doesn't go black when going below sea level, but it instead freezes calculation as if on the horizon.
+- Fixed UI drawing of the quaternion (1251235)
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeEditor.cs
index 81abdeaca4a..2d1625dcc18 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeEditor.cs
@@ -16,7 +16,7 @@ interface IHDProbeEditor
bool showChromeGizmo { get; set; }
}
- abstract class HDProbeEditor : Editor, IHDProbeEditor
+ abstract class HDProbeEditor : Editor, IHDProbeEditor, IDefaultFrameSettingsType
where TProvider : struct, HDProbeUI.IProbeUISettingsProvider, InfluenceVolumeUI.IInfluenceUISettingsProvider
where TSerialized : SerializedHDProbe
{
@@ -142,5 +142,10 @@ static Func ComputeCapturePointPreviewSizeGetter()
}
internal static float capturePointPreviewSize
{ get { return s_CapturePointPreviewSizeGetter(); } }
+
+ public FrameSettingsRenderType GetFrameSettingsType()
+ => GetTarget(target).mode == ProbeSettings.Mode.Realtime
+ ? FrameSettingsRenderType.RealtimeReflection
+ : FrameSettingsRenderType.CustomOrBakedReflection;
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs
index 35167715150..f6e6d6084f3 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs
@@ -22,12 +22,27 @@ public static SettingsProvider CreateSettingsProvider()
keywords = SettingsProvider.GetSearchKeywordsFromGUIContentProperties()
.Concat(SettingsProvider.GetSearchKeywordsFromGUIContentProperties())
.Concat(OverridableFrameSettingsArea.frameSettingsKeywords).ToArray(),
- guiHandler = s_IMGUIImpl.OnGUI,
+ guiHandler = s_IMGUIImpl.DoGUI,
};
}
class DefaultSettingsPanelIMGUI
{
+ // A wrapper for CoreEditorDrawers
+ class CoreEditorDrawerEditorWrapper : Editor, IDefaultFrameSettingsType
+ {
+ public FrameSettingsRenderType GetFrameSettingsType()
+ {
+ switch (HDRenderPipelineUI.selectedFrameSettings)
+ {
+ case HDRenderPipelineUI.SelectedFrameSettings.Camera: return FrameSettingsRenderType.Camera;
+ case HDRenderPipelineUI.SelectedFrameSettings.RealtimeReflection: return FrameSettingsRenderType.RealtimeReflection;
+ case HDRenderPipelineUI.SelectedFrameSettings.BakedOrCustomReflection: return FrameSettingsRenderType.CustomOrBakedReflection;
+ }
+ throw new Exception("unreachable");
+ }
+ }
+
public class Styles
{
public const int labelWidth = 220;
@@ -46,8 +61,9 @@ public class Styles
ReorderableList m_BeforePostProcessCustomPostProcesses;
ReorderableList m_AfterPostProcessCustomPostProcesses;
int m_CurrentVolumeProfileInstanceID;
+ private Editor m_Cache;
- public void OnGUI(string searchContext)
+ public void DoGUI(string searchContext)
{
m_ScrollViewPosition = GUILayout.BeginScrollView(m_ScrollViewPosition, EditorStyles.largeLabel);
Draw_GeneralSettings();
@@ -268,7 +284,9 @@ void Draw_DefaultFrameSettings()
var serializedObject = new SerializedObject(hdrpAsset);
var serializedHDRPAsset = new SerializedHDRenderPipelineAsset(serializedObject);
- HDRenderPipelineUI.FrameSettingsSection.Draw(serializedHDRPAsset, null);
+ Editor.CreateCachedEditor(hdrpAsset, typeof(CoreEditorDrawerEditorWrapper), ref m_Cache);
+
+ HDRenderPipelineUI.FrameSettingsSection.Draw(serializedHDRPAsset, m_Cache);
serializedObject.ApplyModifiedProperties();
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs
index dec98ca62f9..2e379bcedd1 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs
@@ -45,6 +45,11 @@ public static MaterialQualityMode Into(this MaterialQuality quality)
}
}
+ interface IDefaultFrameSettingsType
+ {
+ FrameSettingsRenderType GetFrameSettingsType();
+ }
+
partial class FrameSettingsUI
{
enum Expandable
@@ -132,14 +137,9 @@ static HDRenderPipelineAsset GetHDRPAssetFor(Editor owner)
static FrameSettings GetDefaultFrameSettingsFor(Editor owner)
{
HDRenderPipelineAsset hdrpAsset = GetHDRPAssetFor(owner);
- if (owner is IHDProbeEditor)
- {
- if ((owner as IHDProbeEditor).GetTarget(owner.target).mode == ProbeSettings.Mode.Realtime)
- return hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.RealtimeReflection);
- else
- return hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.CustomOrBakedReflection);
- }
- return hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera);
+ return owner is IDefaultFrameSettingsType getType
+ ? hdrpAsset.GetDefaultFrameSettings(getType.GetFrameSettingsType())
+ : hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera);
}
static void Drawer_SectionRenderingSettings(SerializedFrameSettings serialized, Editor owner, bool withOverride)
From c122273c0e891ced65528003ac5b52827cce3048 Mon Sep 17 00:00:00 2001
From: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com>
Date: Mon, 18 May 2020 11:11:24 -0400
Subject: [PATCH 39/58] Fix taaFrameIndex and restore TAA tests for XR #534
---
.../Scenes/4x_PostProcessing/4052_TAA.unity | 6 +-
.../4053_TAA-FP16Alpha.unity | 95 ++++++++++++++++---
.../Direct3D11/None/2316_ShadowTint.png | 4 +-
.../Direct3D11/None/2316_ShadowTint.png.meta | 19 +++-
.../Direct3D11/None/4052_TAA.png | 4 +-
.../Direct3D11/None/4052_TAA.png.meta | 17 +++-
.../Direct3D11/None/4053_TAA-FP16Alpha.png | 4 +-
.../None/4053_TAA-FP16Alpha.png.meta | 23 ++++-
.../CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/Camera/HDCamera.cs | 10 +-
.../RP_Assets/HDRP_Test_Def.asset | 1 +
.../HDRP_Test_Def_FP16_PPAlpha.asset | 1 +
.../TestRunner/HDRP_GraphicTestRunner.cs | 3 +
13 files changed, 152 insertions(+), 36 deletions(-)
diff --git a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity
index be528f3b965..a9175d91f8a 100644
--- a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity
+++ b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity
@@ -4387,7 +4387,7 @@ PrefabInstance:
- target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
type: 3}
propertyPath: waitFrames
- value: 16
+ value: 64
objectReference: {fileID: 0}
- target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
type: 3}
@@ -4397,8 +4397,8 @@ PrefabInstance:
type: 2}
- target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
type: 3}
- propertyPath: xrCompatible
- value: 0
+ propertyPath: xrThresholdMultiplier
+ value: 1.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
diff --git a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4053_TAA-FP16Alpha.unity b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4053_TAA-FP16Alpha.unity
index 9eba779d282..3be75735d92 100644
--- a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4053_TAA-FP16Alpha.unity
+++ b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4053_TAA-FP16Alpha.unity
@@ -97,10 +97,9 @@ LightmapSettings:
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
- m_LightingDataAsset: {fileID: 112000002, guid: abac67019f3687e48bfb3b0ad2040282,
- type: 2}
- m_LightingSettings: {fileID: 4890085278179872738, guid: 37d5c6f5a3a191940be8a1392afab696,
+ m_LightingDataAsset: {fileID: 112000002, guid: 8c37a70c4f7006c45bd37ffd23852c5c,
type: 2}
+ m_LightingSettings: {fileID: 1014242297}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
@@ -120,6 +119,8 @@ NavMeshSettings:
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
+ maxJobWorkers: 0
+ preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
@@ -873,7 +874,7 @@ MeshCollider:
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
- serializedVersion: 3
+ serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
@@ -1039,6 +1040,7 @@ MonoBehaviour:
m_BarrelClipping: 0.25
m_Anamorphism: 0
flipYMode: 0
+ xrRendering: 1
fullscreenPassthrough: 0
allowDynamicResolution: 0
customRenderingSettings: 0
@@ -2012,9 +2014,9 @@ MeshCollider:
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
- serializedVersion: 3
+ serializedVersion: 4
m_Convex: 0
- m_CookingOptions: 14
+ m_CookingOptions: 30
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &552920927
MeshRenderer:
@@ -3599,6 +3601,67 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 973608314}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!850595691 &1014242297
+LightingSettings:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name:
+ serializedVersion: 2
+ m_GIWorkflowMode: 1
+ m_EnableBakedLightmaps: 1
+ m_EnableRealtimeLightmaps: 0
+ m_RealtimeEnvironmentLighting: 1
+ m_BounceScale: 1
+ m_AlbedoBoost: 1
+ m_IndirectOutputScale: 1
+ m_UsingShadowmask: 1
+ m_BakeBackend: 1
+ m_LightmapMaxSize: 1024
+ m_BakeResolution: 40
+ m_Padding: 2
+ m_TextureCompression: 1
+ m_AO: 0
+ m_AOMaxDistance: 1
+ m_CompAOExponent: 1
+ m_CompAOExponentDirect: 0
+ m_ExtractAO: 0
+ m_MixedBakeMode: 2
+ m_LightmapsBakeMode: 1
+ m_FilterMode: 1
+ m_LightmapParameters: {fileID: 0}
+ m_ExportTrainingData: 0
+ m_TrainingDataDestination: TrainingData
+ m_RealtimeResolution: 2
+ m_ForceWhiteAlbedo: 0
+ m_ForceUpdates: 0
+ m_FinalGather: 0
+ m_FinalGatherRayCount: 256
+ m_FinalGatherFiltering: 1
+ m_PVRCulling: 1
+ m_PVRSampling: 1
+ m_PVRDirectSampleCount: 32
+ m_PVRSampleCount: 512
+ m_PVREnvironmentSampleCount: 256
+ m_PVREnvironmentReferencePointCount: 2048
+ m_LightProbeSampleCountMultiplier: 4
+ m_PVRBounces: 2
+ m_PVRRussianRouletteStartBounce: 2
+ m_PVREnvironmentMIS: 1
+ m_PVRFilteringMode: 1
+ m_PVRDenoiserTypeDirect: 1
+ m_PVRDenoiserTypeIndirect: 1
+ m_PVRDenoiserTypeAO: 1
+ m_PVRFilterTypeDirect: 0
+ m_PVRFilterTypeIndirect: 0
+ m_PVRFilterTypeAO: 0
+ m_PVRFilteringGaussRadiusDirect: 1
+ m_PVRFilteringGaussRadiusIndirect: 5
+ m_PVRFilteringGaussRadiusAO: 2
+ m_PVRFilteringAtrousPositionSigmaDirect: 0.5
+ m_PVRFilteringAtrousPositionSigmaIndirect: 2
+ m_PVRFilteringAtrousPositionSigmaAO: 1
--- !u!1 &1017656384
GameObject:
m_ObjectHideFlags: 0
@@ -3914,7 +3977,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
- m_Version: 9
+ m_Version: 11
m_ObsoleteShadowResolutionTier: 1
m_ObsoleteUseShadowQualitySettings: 0
m_ObsoleteCustomShadowResolution: 512
@@ -3960,6 +4023,7 @@ MonoBehaviour:
m_FilterSizeTraced: 16
m_SunLightConeAngle: 0.5
m_LightShadowRadius: 0.5
+ m_SemiTransparentShadow: 0
m_ColorShadow: 1
m_EvsmExponent: 15
m_EvsmLightLeakBias: 0
@@ -4009,6 +4073,9 @@ MonoBehaviour:
useVolumetric: 0
featuresFoldout: 1
showAdditionalSettings: 0
+ m_AreaLightEmissiveMeshShadowCastingMode: 0
+ m_AreaLightEmissiveMeshMotionVectorGenerationMode: 0
+ m_AreaLightEmissiveMeshLayer: -1
--- !u!108 &1079224356
Light:
m_ObjectHideFlags: 0
@@ -4384,11 +4451,6 @@ PrefabInstance:
propertyPath: ImageComparisonSettings.TargetHeight
value: 512
objectReference: {fileID: 0}
- - target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
- type: 3}
- propertyPath: waitFrames
- value: 16
- objectReference: {fileID: 0}
- target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
type: 3}
propertyPath: renderPipelineAsset
@@ -4397,8 +4459,13 @@ PrefabInstance:
type: 2}
- target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
type: 3}
- propertyPath: xrCompatible
- value: 0
+ propertyPath: waitFrames
+ value: 64
+ objectReference: {fileID: 0}
+ - target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7,
+ type: 3}
+ propertyPath: xrThresholdMultiplier
+ value: 1.2
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png
index 719eab3a10a..f3142f45920 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:556bc8905ef1f0f78382707adf52761e3d0a2a1b4e04185f255fdb8e7c72a7b4
-size 132133
+oid sha256:527845054366304abd3886fdea40e8b2a88ccc1b4909df83386d83b518fc9f33
+size 132856
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png.meta
index c3ce6fad141..890afaf420c 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png.meta
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png.meta
@@ -1,9 +1,9 @@
fileFormatVersion: 2
-guid: 256fa63bde57c784ea54812a54dd32f9
+guid: f0c0d20ad6ea280438c5fa84b6f19dcd
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
- serializedVersion: 10
+ serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
@@ -23,6 +23,7 @@ TextureImporter:
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
+ vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@@ -57,6 +58,8 @@ TextureImporter:
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
@@ -70,6 +73,18 @@ TextureImporter:
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 3
+ buildTarget: Standalone
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 0
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png
index 29015fff8e2..169c974f853 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:e293a01b72ac593c538be1e0d6db9fcf095f9447c297a1123d27373e3d57445d
-size 183316
+oid sha256:81372ce6ea129dda8d7dc5002da0609591ff416d12e895ad54f9f8c660a66955
+size 186222
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png.meta
index bea91ec713c..f8c41d9450a 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png.meta
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png.meta
@@ -1,9 +1,9 @@
fileFormatVersion: 2
-guid: 0ed9215b293e4cf46892abf617b9facf
+guid: 98d6ed50af680494f96fead35d76ace5
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
- serializedVersion: 10
+ serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
@@ -59,6 +59,7 @@ TextureImporter:
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
+ applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
@@ -72,6 +73,18 @@ TextureImporter:
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 3
+ buildTarget: Standalone
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 0
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png
index c26c649282f..911d6663bf9 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:35bfaabe20c17251cff955c89334d02eeca38087670aa474b40536d1ff1dfd3c
-size 191253
+oid sha256:e00c5d3d1f6c1a2681c4de43b1f41c467cda77868ade98ac3971c3af16f99d88
+size 194223
diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png.meta b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png.meta
index 07bbfa82f30..70f413213ac 100644
--- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png.meta
+++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png.meta
@@ -1,12 +1,12 @@
fileFormatVersion: 2
-guid: 9ef0394c92d6ca24dadc2ce0b0581d22
+guid: b4d9f596c39a6904199dfac0c348e455
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
- serializedVersion: 10
+ serializedVersion: 11
mipmaps:
mipMapMode: 0
- enableMipMap: 0
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@@ -20,7 +20,7 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
- isReadable: 1
+ isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
@@ -38,7 +38,7 @@ TextureImporter:
wrapU: -1
wrapV: -1
wrapW: -1
- nPOTScale: 0
+ nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
@@ -59,6 +59,7 @@ TextureImporter:
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
+ applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
@@ -72,6 +73,18 @@ TextureImporter:
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 3
+ buildTarget: Standalone
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 0
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 6f7860e509c..eafaf308e2d 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -154,6 +154,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed errors when switching area light to disk shape while an area emissive mesh was displayed.
- PBR Sky now doesn't go black when going below sea level, but it instead freezes calculation as if on the horizon.
- Fixed UI drawing of the quaternion (1251235)
+- Fixed taaFrameIndex and XR tests 4052 and 4053
### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index 39af292dc49..1fea101bd79 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -472,6 +472,10 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
screenSize = new Vector4(screenWidth, screenHeight, 1.0f / screenWidth, 1.0f / screenHeight);
screenParams = new Vector4(screenSize.x, screenSize.y, 1 + screenSize.z, 1 + screenSize.w);
+ const int kMaxSampleCount = 8;
+ if (++taaFrameIndex >= kMaxSampleCount)
+ taaFrameIndex = 0;
+
UpdateAllViewConstants();
isFirstFrame = false;
cameraFrameCount++;
@@ -899,6 +903,8 @@ void UpdateAllViewConstants()
if (m_XRViewConstants == null || m_XRViewConstants.Length != viewCount)
{
m_XRViewConstants = new ViewConstants[viewCount];
+ resetPostProcessingHistory = true;
+ isFirstFrame = true;
}
UpdateAllViewConstants(IsTAAEnabled(), true);
@@ -1148,10 +1154,6 @@ Matrix4x4 GetJitteredProjectionMatrix(Matrix4x4 origProj)
float jitterY = HaltonSequence.Get((taaFrameIndex & 1023) + 1, 3) - 0.5f;
taaJitter = new Vector4(jitterX, jitterY, jitterX / actualWidth, jitterY / actualHeight);
- const int kMaxSampleCount = 8;
- if (++taaFrameIndex >= kMaxSampleCount)
- taaFrameIndex = 0;
-
Matrix4x4 proj;
if (camera.orthographic)
diff --git a/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def.asset b/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def.asset
index 21fe7fe11c5..024d2a2d5ab 100644
--- a/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def.asset
+++ b/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def.asset
@@ -296,6 +296,7 @@ MonoBehaviour:
xrSettings:
singlePass: 1
occlusionMesh: 1
+ cameraJitter: 1
postProcessQualitySettings:
NearBlurSampleCount: 030000000500000008000000
NearBlurMaxRadius:
diff --git a/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def_FP16_PPAlpha.asset b/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def_FP16_PPAlpha.asset
index f3747f6fa00..c9c8224e226 100644
--- a/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def_FP16_PPAlpha.asset
+++ b/com.unity.testing.hdrp/RP_Assets/HDRP_Test_Def_FP16_PPAlpha.asset
@@ -295,6 +295,7 @@ MonoBehaviour:
xrSettings:
singlePass: 1
occlusionMesh: 1
+ cameraJitter: 1
postProcessQualitySettings:
NearBlurSampleCount: 030000000500000008000000
NearBlurMaxRadius:
diff --git a/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs b/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs
index 0b0113342ac..e6e73a3fe40 100644
--- a/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs
+++ b/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs
@@ -58,6 +58,9 @@ public IEnumerator Run(GraphicsTestCase testCase)
yield return null;
}
+ // Reset temporal effects on hdCamera
+ HDCamera.GetOrCreate(camera).Reset();
+
for (int i=0 ; i
Date: Mon, 29 Jun 2020 12:22:37 -0400
Subject: [PATCH 40/58] fix typo in the Render Pipeline Wizard #1037
---
.../Editor/DefaultScene/HDWizard.Window.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs
index e1f451f0171..bbec85fd3eb 100644
--- a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs
@@ -125,7 +125,7 @@ public ConfigStyle(string label, string error, string button = resolve, MessageT
messageType: MessageType.Info);
public static readonly ConfigStyle vrSinglePassInstancing = new ConfigStyle(
label: "Single-Pass Instancing",
- error: "Single-Pass Instancing must be enabled in Occulus Pluggin.\nGo in Edit > Project Settings > XR Plugin Manager > Oculus and change Stereo Rendering Mode to Single Pass Instanced.\n(This can't be verified by the Wizard)",
+ error: "Single-Pass Instancing must be enabled in Oculus Pluggin.\nGo in Edit > Project Settings > XR Plugin Manager > Oculus and change Stereo Rendering Mode to Single Pass Instanced.\n(This can't be verified by the Wizard)",
messageType: MessageType.Info);
public static readonly ConfigStyle vrLegacyHelpersPackage = new ConfigStyle(
label: "XR Legacy Helpers Package",
From cb7e9add48033d0d0abdf66c80c7b2efe0f69137 Mon Sep 17 00:00:00 2001
From: Evgenii Golubev
Date: Tue, 16 Jun 2020 05:34:35 -0700
Subject: [PATCH 41/58] Add light layer on indirect lighting controller #777
---
.../CHANGELOG.md | 1 +
.../Override-Indirect-Lighting-Controller.md | 9 ++--
.../IndirectLightingControllerEditor.cs | 33 +++++++++---
.../Editor/Wizard.meta | 8 +++
.../Lighting/IndirectLightingController.cs | 54 +++++++++++++++++--
.../Runtime/Lighting/LightLoop/LightLoop.cs | 2 +-
.../Runtime/Lighting/LightLoop/LightLoop.hlsl | 4 ++
.../ShaderVariablesScreenSpaceLighting.cs | 5 +-
...ShaderVariablesScreenSpaceLighting.cs.hlsl | 5 +-
.../Runtime/Material/BuiltinUtilities.hlsl | 5 +-
.../RenderPipeline/HDRenderPipeline.cs | 6 ++-
.../RenderPipeline/HDStringConstants.cs | 5 +-
.../Raytracing/HDRaytracingIndirectDiffuse.cs | 7 ++-
.../RaytracingIndirectDiffuse.compute | 3 +-
.../ShaderLibrary/ShaderVariables.hlsl | 11 ++++
15 files changed, 135 insertions(+), 23 deletions(-)
create mode 100644 com.unity.render-pipelines.high-definition/Editor/Wizard.meta
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index eafaf308e2d..d3f395f0387 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added support for AxF measurements importing into texture resources tilings.
- Added Layer parameter on Area Light to modify Layer of generated Emissive Mesh
- Added support for multiple mapping modes in AxF.
+- Add support of lightlayers on indirect lighting controller
### Fixed
- Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047).
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md
index fe2646f9438..0688b528c12 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md
@@ -17,10 +17,11 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework,
| Property | Description |
| ------------------------------- | ------------------------------------------------------------ |
-| **Indirect Diffuse Intensity** | A multiplier for baked and realtime Global Illumination lightmaps and Light Probes. HDRP multiplies the lightmap and Light Probe data by this value. |
-| **Indirect Specular Intensity** | A multiplier for baked, realtime, and custom Reflection Probes. HDRP multiplies the Reflection Probe data by this value. |
-
-
+| **Indirect Diffuse Lighting Multiplier** | A multiplier for lightmaps, Light Probes, Light Probe Volumes, Screen-Space Global Illumination, and [Ray-Traced Global Illumination](Ray-Traced-Global-Illumination.md). HDRP multiplies the light data from all of these by this value. |
+| **Indirect Diffuse Lighting Layers** | Specifies the [Light Layers](Light-Layers.md) for indirect diffuse lighting. If you enable Light Layers, you can use them to decouple Meshes in your Scene from the above multiplier. |
+| **Reflection Lighting Multiplier** | A multiplier for baked, realtime, custom [Reflection Probes](Reflection-Probe.md) and [Planar Probes](Planar-Reflection-Probe.md), [Screen-Space Reflection](Override-Screen-Space-Reflection.md), [Ray-Traced Reflection](Ray-Traced-Reflections.md), and Sky Reflection. HDRP multiplies the light data from all of these by this value. |
+| **Reflection Lighting Layers** | LSpecifies the [Light Layers](Light-Layers.md) for reflection lighting. If you enable Light Layers, you can use them to decouple Meshes in your Scene from the above multiplier. |
+| **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom [Reflection Probes](Reflection-Probe.md) and [Planar Probes](Planar-Reflection-Probe.md). HDRP multiplies the Reflection Probe data by this value. |
## Details
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs
index b0319d491fa..d2a61a5e247 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs
@@ -1,4 +1,6 @@
+using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
+using UnityEngine.Rendering;
namespace UnityEditor.Rendering.HighDefinition
{
@@ -6,21 +8,40 @@ namespace UnityEditor.Rendering.HighDefinition
[VolumeComponentEditor(typeof(IndirectLightingController))]
class IndirectLightingControllerEditor : VolumeComponentEditor
{
- SerializedDataParameter m_IndirectDiffuseIntensity;
- SerializedDataParameter m_IndirectSpecularIntensity;
+ SerializedDataParameter m_IndirectDiffuseLightingMultiplier;
+ SerializedDataParameter m_IndirectDiffuseLightingLayers;
+
+ SerializedDataParameter m_ReflectionLightingMultiplier;
+ SerializedDataParameter m_ReflectionLightingLayers;
+
+ SerializedDataParameter m_ReflectionProbeIntensityMultiplier;
public override void OnEnable()
{
var o = new PropertyFetcher(serializedObject);
- m_IndirectSpecularIntensity = Unpack(o.Find(x => x.indirectSpecularIntensity));
- m_IndirectDiffuseIntensity = Unpack(o.Find(x => x.indirectDiffuseIntensity));
+ m_IndirectDiffuseLightingMultiplier = Unpack(o.Find(x => x.indirectDiffuseLightingMultiplier));
+ m_IndirectDiffuseLightingLayers = Unpack(o.Find(x => x.indirectDiffuseLightingLayers));
+
+ m_ReflectionLightingMultiplier = Unpack(o.Find(x => x.reflectionLightingMultiplier));
+ m_ReflectionLightingLayers = Unpack(o.Find(x => x.reflectionLightingLayers));
+
+ m_ReflectionProbeIntensityMultiplier = Unpack(o.Find(x => x.reflectionProbeIntensityMultiplier));
}
public override void OnInspectorGUI()
{
- PropertyField(m_IndirectDiffuseIntensity, EditorGUIUtility.TrTextContent("Indirect Diffuse Intensity", "Sets the multiplier for baked diffuse lighting."));
- PropertyField(m_IndirectSpecularIntensity, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting."));
+ PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier", "Sets the multiplier for indirect diffuse lighting.\nIt affect Ambient Probe, Light Probes, Lightmaps, Light Probe Volumes, Screen Space Global Illumination, Raytrace Global Illumination."));
+ GUI.enabled = HDUtils.hdrpSettings.supportLightLayers;
+ PropertyField(m_IndirectDiffuseLightingLayers, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Layers", "Sets the light layer mask for indirect diffuse lighting. Only matching RenderingLayers on Mesh will get affected by the multiplier."));
+ GUI.enabled = true;
+
+ PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier", "Sets the multiplier for reflected specular lighting.\nIt affect Sky Reflection, Reflection Probes, Planar Probes, Screen Space Reflection, Raytrace Reflection."));
+ GUI.enabled = HDUtils.hdrpSettings.supportLightLayers;
+ PropertyField(m_ReflectionLightingLayers, EditorGUIUtility.TrTextContent("Reflection Lighting Layers", "Sets the light layer mask for reflected specular lighting. Only matching RenderingLayers on Mesh will get affected by the multiplier."));
+ GUI.enabled = true;
+
+ PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection/Planar Probe Intensity Multiplier", "Sets the intensity multiplier for Reflection/Planar Probes."));
}
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Wizard.meta b/com.unity.render-pipelines.high-definition/Editor/Wizard.meta
new file mode 100644
index 00000000000..2ad6042451d
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Editor/Wizard.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e14125a9cbe5bc246a3e488b7d518cb7
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
index 6ea09df9fd1..b982b9e71dd 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
namespace UnityEngine.Rendering.HighDefinition
{
@@ -8,9 +9,54 @@ namespace UnityEngine.Rendering.HighDefinition
[Serializable, VolumeComponentMenu("Lighting/Indirect Lighting Controller")]
public class IndirectLightingController : VolumeComponent
{
- /// Indirect specular intensity multiplier, between 0 and 1
- public MinFloatParameter indirectSpecularIntensity = new MinFloatParameter(1.0f, 0.0f);
- /// Indirect diffuse intensity multiplier, between 0 and 1
- public MinFloatParameter indirectDiffuseIntensity = new MinFloatParameter(1.0f, 0.0f);
+ [UnityEngine.Serialization.FormerlySerializedAs("indirectDiffuseIntensity")]
+ /// Indirect diffuse lighting multiplier, between 0 and 1
+ public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f);
+ /// Controls which layer will be affected by the indirect diffuse lighting multiplier
+ public LightLayerEnumParameter indirectDiffuseLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault);
+
+ /// Reflection lighting multiplier, between 0 and 1
+ public MinFloatParameter reflectionLightingMultiplier = new MinFloatParameter(1.0f, 0.0f);
+ /// Controls which layer will be affected by the reflection lighting multiplier
+ public LightLayerEnumParameter reflectionLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault);
+
+ [UnityEngine.Serialization.FormerlySerializedAs("indirectSpecularIntensity")]
+ /// Reflection probe intensity multiplier, between 0 and 1
+ public MinFloatParameter reflectionProbeIntensityMultiplier = new MinFloatParameter(1.0f, 0.0f);
+
+ ///
+ /// Returns a mask of reflection lighting layers as uint and handle the case of Everything as being 0xFF and not -1
+ ///
+ ///
+ public uint GetReflectionLightingLayers()
+ {
+ int value = (int)reflectionLightingLayers.GetValue();
+ return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value;
+ }
+
+ ///
+ /// Returns a mask of indirect diffuse lighting layers as uint and handle the case of Everything as being 0xFF and not -1
+ ///
+ ///
+ public uint GetIndirectDiffuseLightingLayers()
+ {
+ int value = (int)indirectDiffuseLightingLayers.GetValue();
+ return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value;
+ }
+
+ ///
+ /// Sky Ambient Mode volume parameter.
+ ///
+ [Serializable, DebuggerDisplay(k_DebuggerDisplay)]
+ public sealed class LightLayerEnumParameter : VolumeParameter
+ {
+ ///
+ /// Light Layer Enum parameterconstructor.
+ ///
+ /// Light Layer Enum parameter.
+ /// Initial override value.
+ public LightLayerEnumParameter(LightLayerEnum value, bool overrideState = false)
+ : base(value, overrideState) { }
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
index 1ca6843ed51..cb8978209fa 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
@@ -1816,7 +1816,7 @@ internal bool GetEnvLightData(CommandBuffer cmd, HDCamera hdCamera, in Processed
envLightData.lightLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? probe.lightLayersAsUInt : uint.MaxValue;
envLightData.influenceShapeType = influence.envShape;
envLightData.weight = processedProbe.weight;
- envLightData.multiplier = probe.multiplier * m_indirectLightingController.indirectSpecularIntensity.value;
+ envLightData.multiplier = probe.multiplier * m_indirectLightingController.reflectionProbeIntensityMultiplier.value;
envLightData.rangeCompressionFactorCompensation = Mathf.Max(probe.rangeCompressionFactor, 1e-6f);
envLightData.influenceExtents = influence.extents;
switch (influence.envShape)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl
index 8e239401b43..546dd0b1992 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl
@@ -466,6 +466,10 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS
ApplyDebugToLighting(context, builtinData, aggregateLighting);
+ // Note: We can't apply the IndirectDiffuseMultiplier here as with GBuffer, Emissive is part of the bakeDiffuseLighting.
+ // so IndirectDiffuseMultiplier is apply in PostInitBuiltinData or related location (like for probe volume)
+ aggregateLighting.indirect.specularReflected *= GetIndirectSpecularMultiplier(builtinData.renderingLayers);
+
// Also Apply indiret diffuse (GI)
// PostEvaluateBSDF will perform any operation wanted by the material and sum everything into diffuseLighting and specularLighting
PostEvaluateBSDF( context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting,
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs
index 8a9f1498c50..8c7bdc1d7a1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs
@@ -12,7 +12,10 @@ struct ShaderVariablesScreenSpaceLighting
// Ambient occlusion
public Vector4 _AmbientOcclusionParam; // xyz occlusion color, w directLightStrenght
- public Vector4 _IndirectLightingMultiplier; // .x indirect diffuse multiplier (use with indirect lighting volume controler)
+ public float _IndirectDiffuseLightingMultiplier;
+ public uint _IndirectDiffuseLightingLayers;
+ public float _ReflectionLightingMultiplier;
+ public uint _ReflectionLightingLayers;
// Screen space refraction
public float _SSRefractionInvScreenWeightDistance; // Distance for screen space smoothstep with fallback
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs.hlsl
index 7e004dbb0d3..392cd37952a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.cs.hlsl
@@ -11,7 +11,10 @@
float4 _DepthPyramidScale;
float4 _CameraMotionVectorsScale;
float4 _AmbientOcclusionParam;
- float4 _IndirectLightingMultiplier;
+ float _IndirectDiffuseLightingMultiplier;
+ uint _IndirectDiffuseLightingLayers;
+ float _ReflectionLightingMultiplier;
+ uint _ReflectionLightingLayers;
float _SSRefractionInvScreenWeightDistance;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl
index 9bb08a2a93f..f7aa4f6ae4a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl
@@ -105,8 +105,9 @@ void PostInitBuiltinData( float3 V, PositionInputs posInput, SurfaceData surfa
{
// Apply control from the indirect lighting volume settings - This is apply here so we don't affect emissive
// color in case of lit deferred for example and avoid material to have to deal with it
- builtinData.bakeDiffuseLighting *= _IndirectLightingMultiplier.x;
- builtinData.backBakeDiffuseLighting *= _IndirectLightingMultiplier.x;
+ float multiplier = GetIndirectDiffuseMultiplier(builtinData.renderingLayers);
+ builtinData.bakeDiffuseLighting *= multiplier;
+ builtinData.backBakeDiffuseLighting *= multiplier;
#ifdef MODIFY_BAKED_DIFFUSE_LIGHTING
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index ec1d30d6c31..16762ac39f3 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -1047,7 +1047,11 @@ void PushGlobalParams(HDCamera hdCamera, CommandBuffer cmd)
// Set up UnityPerView CBuffer.
hdCamera.SetupGlobalParams(cmd, m_FrameCount);
- cmd.SetGlobalVector(HDShaderIDs._IndirectLightingMultiplier, new Vector4(hdCamera.volumeStack.GetComponent().indirectDiffuseIntensity.value, 0, 0, 0));
+ IndirectLightingController indirectLightingController = hdCamera.volumeStack.GetComponent();
+ cmd.SetGlobalFloat(HDShaderIDs._IndirectDiffuseLightingMultiplier, indirectLightingController.indirectDiffuseLightingMultiplier.value);
+ cmd.SetGlobalInt(HDShaderIDs._IndirectDiffuseLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetIndirectDiffuseLightingLayers() : -1);
+ cmd.SetGlobalFloat(HDShaderIDs._ReflectionLightingMultiplier, indirectLightingController.reflectionLightingMultiplier.value);
+ cmd.SetGlobalInt(HDShaderIDs._ReflectionLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetReflectionLightingLayers() : -1);
// It will be overridden for transparent pass.
cmd.SetGlobalInt(HDShaderIDs._ColorMaskTransparentVel, (int)UnityEngine.Rendering.ColorWriteMask.All);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
index 0414b52ecca..739c7489005 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
@@ -166,7 +166,10 @@ static class HDShaderIDs
public static readonly int _NumTileClusteredX = Shader.PropertyToID("_NumTileClusteredX");
public static readonly int _NumTileClusteredY = Shader.PropertyToID("_NumTileClusteredY");
- public static readonly int _IndirectLightingMultiplier = Shader.PropertyToID("_IndirectLightingMultiplier");
+ public static readonly int _IndirectDiffuseLightingMultiplier = Shader.PropertyToID("_IndirectDiffuseLightingMultiplier");
+ public static readonly int _IndirectDiffuseLightingLayers = Shader.PropertyToID("_IndirectDiffuseLightingLayers");
+ public static readonly int _ReflectionLightingMultiplier = Shader.PropertyToID("_ReflectionLightingMultiplier");
+ public static readonly int _ReflectionLightingLayers = Shader.PropertyToID("_ReflectionLightingLayers");
public static readonly int g_isLogBaseBufferEnabled = Shader.PropertyToID("g_isLogBaseBufferEnabled");
public static readonly int g_vLayeredOffsetsBuffer = Shader.PropertyToID("g_vLayeredOffsetsBuffer");
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs
index 541e2e6a399..abe470480b2 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs
@@ -87,7 +87,12 @@ void RenderIndirectDiffuse(HDCamera hdCamera, CommandBuffer cmd, ScriptableRende
// Bind the output texture
cmd.SetComputeTextureParam(indirectDiffuseCS, indirectDiffuseKernel, HDShaderIDs._GBufferTexture[0], m_GbufferManager.GetBuffer(0));
cmd.SetComputeTextureParam(indirectDiffuseCS, indirectDiffuseKernel, HDShaderIDs._GBufferTexture[3], m_GbufferManager.GetBuffer(3));
- cmd.SetComputeVectorParam(indirectDiffuseCS, HDShaderIDs._IndirectLightingMultiplier, new Vector4(hdCamera.volumeStack.GetComponent().indirectDiffuseIntensity.value, 0, 0, 0));
+
+ IndirectLightingController indirectLightingController = hdCamera.volumeStack.GetComponent();
+ cmd.SetComputeFloatParam(indirectDiffuseCS, HDShaderIDs._IndirectDiffuseLightingMultiplier, indirectLightingController.indirectDiffuseLightingMultiplier.value);
+ cmd.SetComputeIntParam(indirectDiffuseCS, HDShaderIDs._IndirectDiffuseLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetIndirectDiffuseLightingLayers() : -1);
+ cmd.SetComputeFloatParam(indirectDiffuseCS, HDShaderIDs._ReflectionLightingMultiplier, indirectLightingController.reflectionLightingMultiplier.value);
+ cmd.SetComputeIntParam(indirectDiffuseCS, HDShaderIDs._ReflectionLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetReflectionLightingLayers() : -1);
// Evaluate the dispatch parameters
int areaTileSize = 8;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute
index ad2d408fd25..e4aee2550a0 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute
@@ -255,6 +255,7 @@ void IndirectDiffuseAccumulation(uint3 dispatchThreadId : SV_DispatchThreadID, u
uint2 currentPixelCoordinate = groupId * RAYTRACING_INDIRECT_DIFFUSE_TILE_SIZE + groupThreadId;
// Add the indirect diffuse to the buffer (while pre-multiplying by the base color)
- _GBufferTexture3[COORD_TEXTURE2D_X(currentPixelCoordinate)] += LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, currentPixelCoordinate) * LOAD_TEXTURE2D_X(_GBufferTexture0, currentPixelCoordinate) * _IndirectLightingMultiplier.x;
+ float indirectDiffuseMultiplier = GetIndirectDiffuseMultiplier(0xFF); // We don't have renderinglayer here
+ _GBufferTexture3[COORD_TEXTURE2D_X(currentPixelCoordinate)] += LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, currentPixelCoordinate) * LOAD_TEXTURE2D_X(_GBufferTexture0, currentPixelCoordinate) * indirectDiffuseMultiplier;
#endif
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
index 3ae291f141e..0d52656c4c9 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
@@ -434,6 +434,17 @@ float GetInversePreviousExposureMultiplier()
return rcp(exposure + (exposure == 0.0)); // zero-div guard
}
+// Helper function for indirect control volume
+float GetIndirectDiffuseMultiplier(uint renderingLayers)
+{
+ return (_IndirectDiffuseLightingLayers & renderingLayers) ? _IndirectDiffuseLightingMultiplier : 1.0f;
+}
+
+float GetIndirectSpecularMultiplier(uint renderingLayers)
+{
+ return (_ReflectionLightingLayers & renderingLayers) ? _ReflectionLightingMultiplier : 1.0f;
+}
+
// Functions to clamp UVs to use when RTHandle system is used.
float2 ClampAndScaleUV(float2 UV, float2 texelSize, float numberOfTexels)
From 3a00afad72cc79c2d0ca0aa01403476b41d212f8 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Tue, 7 Jul 2020 19:49:27 +0200
Subject: [PATCH 42/58] [8.x.x Backport] Fix exposure white flash when
enabling SSR (#842)
* fix white flash
* changelog
Co-authored-by: sebastienlagarde
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/Camera/HDCamera.cs | 2 ++
2 files changed, 3 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index d3f395f0387..cbb2460591b 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed UI drawing of the quaternion (1251235)
- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
- Fixed for area light not updating baked light result when modifying with gizmo.
+- Fixed issue with white flash when enabling SSR.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index 1fea101bd79..c2edc240a2c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -420,6 +420,8 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
// Reinit the system.
colorPyramidHistoryIsValid = false;
volumetricHistoryIsValid = false;
+ // Since we nuke all history we must inform the post process system too.
+ resetPostProcessingHistory = true;
// The history system only supports the "nuke all" option.
m_HistoryRTSystem.Dispose();
From ffdc83e37e08d4e9294b626272b4e8eadbe5a181 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Tue, 7 Jul 2020 19:52:35 +0200
Subject: [PATCH 43/58] [8.x.x Backport] Fix transparent/opaque motion vector
inconsistencies by allowing camera-only transparent motion vectors (#837)
* port
* changelog
* Update HDRenderPipeline.cs
Co-authored-by: sebastienlagarde
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/Camera/HDCamera.cs | 1 +
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 3 ++-
.../Runtime/RenderPipeline/HDStringConstants.cs | 2 ++
.../ShaderPass/MotionVectorVertexShaderCommon.hlsl | 7 +++++++
.../Runtime/ShaderLibrary/ShaderVariables.hlsl | 3 +++
6 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index cbb2460591b..283ec65c174 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
- Fixed for area light not updating baked light result when modifying with gizmo.
- Fixed issue with white flash when enabling SSR.
+- Fix inconsistencies with transparent motion vectors and opaque by allowing camera only transparent motion vectors.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index c2edc240a2c..4ba309b942b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -662,6 +662,7 @@ internal void SetupGlobalParams(CommandBuffer cmd, int frameCount)
cmd.SetGlobalVectorArray(HDShaderIDs._XRPrevWorldSpaceCameraPos, m_XRPrevWorldSpaceCameraPos);
}
+ cmd.SetGlobalInt(HDShaderIDs._TransparentCameraOnlyMotionVectors, (frameSettings.IsEnabled(FrameSettingsField.MotionVectors) && !frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) ? 1 : 0);
}
internal void AllocateAmbientOcclusionHistoryBuffer(float scaleFactor)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 16762ac39f3..f2622bfb2ea 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -2728,6 +2728,7 @@ out ScriptableCullingParameters cullingParams
if (camera.cameraType != CameraType.Game)
{
currentFrameSettings.SetEnabled(FrameSettingsField.ObjectMotionVectors, false);
+ currentFrameSettings.SetEnabled(FrameSettingsField.TransparentsWriteMotionVector, false);
}
hdCamera = HDCamera.GetOrCreate(camera, xrPass.multipassId);
@@ -3596,7 +3597,7 @@ void RenderForwardOpaque(CullingResults cullResults, HDCamera hdCamera, Scriptab
static bool NeedMotionVectorForTransparent(FrameSettings frameSettings)
{
- return frameSettings.IsEnabled(FrameSettingsField.MotionVectors) && frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector) && frameSettings.IsEnabled(FrameSettingsField.ObjectMotionVectors);
+ return frameSettings.IsEnabled(FrameSettingsField.MotionVectors);
}
RendererListDesc PrepareForwardTransparentRendererList(CullingResults cullResults, HDCamera hdCamera, bool preRefraction)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
index 739c7489005..d56b76aabaa 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
@@ -310,6 +310,8 @@ static class HDShaderIDs
public static readonly int _TaaFrameInfo = Shader.PropertyToID("_TaaFrameInfo");
public static readonly int _TaaJitterStrength = Shader.PropertyToID("_TaaJitterStrength");
+ public static readonly int _TransparentCameraOnlyMotionVectors = Shader.PropertyToID("_TransparentCameraOnlyMotionVectors ");
+
public static readonly int _WorldSpaceCameraPos1 = Shader.PropertyToID("_WorldSpaceCameraPos1");
public static readonly int _ViewMatrix1 = Shader.PropertyToID("_ViewMatrix1");
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl
index 60903b412d6..d96713326dc 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl
@@ -133,6 +133,13 @@ PackedVaryingsType MotionVectorVS(inout VaryingsType varyingsType, AttributesMes
ApplyVertexModification(inputMesh, normalWS, previousPositionRWS, _LastTimeParameters.xyz);
#endif
+#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
+ if (_TransparentCameraOnlyMotionVectors > 0)
+ {
+ previousPositionRWS = varyingsType.vmesh.positionRWS.xyz;
+ }
+#endif
+
varyingsType.vpass.previousPositionCS = mul(UNITY_MATRIX_PREV_VP, float4(previousPositionRWS, 1.0));
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
index 0d52656c4c9..34f12255833 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
@@ -283,6 +283,9 @@ CBUFFER_START(UnityGlobal)
float4 _CoarseStencilBufferSize;
+ int _TransparentCameraOnlyMotionVectors;
+ float3 _Pad;
+
CBUFFER_END
// Custom generated by HDRP, not from Unity Engine (passed in via HDCamera)
From 4ab3b4f463af99cc12145b897a16d936e52b7ec7 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Tue, 7 Jul 2020 19:54:35 +0200
Subject: [PATCH 44/58] [8.x.x Backport] Fix depth pyramid issues with dynamic
resolution (#847)
* Port
* changelog
Co-authored-by: sebastienlagarde
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 1 +
.../Runtime/RenderPipeline/Utility/HDUtils.cs | 4 ++++
3 files changed, 6 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 283ec65c174..d1826d9112c 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed for area light not updating baked light result when modifying with gizmo.
- Fixed issue with white flash when enabling SSR.
- Fix inconsistencies with transparent motion vectors and opaque by allowing camera only transparent motion vectors.
+- Fixed issue with depth pyramid generation and dynamic resolution.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index f2622bfb2ea..e62b8f9ec46 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -4047,6 +4047,7 @@ void GenerateDepthPyramid(HDCamera hdCamera, CommandBuffer cmd, FullScreenDebugM
{
CopyDepthBufferIfNeeded(hdCamera, cmd);
+ m_SharedRTManager.GetDepthBufferMipChainInfo().ComputePackedMipChainInfo(new Vector2Int(hdCamera.actualWidth, hdCamera.actualHeight));
int mipCount = m_SharedRTManager.GetDepthBufferMipChainInfo().mipLevelCount;
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DepthPyramid)))
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs
index e47e1c84cc7..d4e871d8411 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs
@@ -508,6 +508,10 @@ public void Allocate()
// This function is NOT fast, but it is illustrative, and can be optimized later.
public void ComputePackedMipChainInfo(Vector2Int viewportSize)
{
+ // No work needed.
+ if (viewportSize == mipLevelSizes[0])
+ return;
+
textureSize = viewportSize;
mipLevelSizes[0] = viewportSize;
mipLevelOffsets[0] = Vector2Int.zero;
From c87a2382c76e5b47dadcd404219c66a5d6b99577 Mon Sep 17 00:00:00 2001
From: JulienIgnace-Unity
Date: Tue, 7 Jul 2020 19:57:30 +0200
Subject: [PATCH 45/58] [Backport 8.x.x] Fixed a serialization issue,
preventing quality level parameters to undo/redo and update scene view on
change. (#1105)
* Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
* Fixed issue when using Custom
* Update changelog
Co-authored-by: sebastienlagarde
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../RenderPipeline/ScalableSettingLevelParameterEditor.cs | 3 ++-
.../RenderPipeline/GlobalPostProcessingQualitySettings.cs | 7 ++++++-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index d1826d9112c..82913a7987c 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -71,6 +71,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with white flash when enabling SSR.
- Fix inconsistencies with transparent motion vectors and opaque by allowing camera only transparent motion vectors.
- Fixed issue with depth pyramid generation and dynamic resolution.
+- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/ScalableSettingLevelParameterEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/ScalableSettingLevelParameterEditor.cs
index a41b0d596e9..de006eccc07 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/ScalableSettingLevelParameterEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/ScalableSettingLevelParameterEditor.cs
@@ -22,13 +22,14 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
rect.y += 2;
rect.width -= 3;
- o.levelAndOverride = SerializedScalableSettingValueUI.LevelFieldGUI(
+ var levelAndOverride = SerializedScalableSettingValueUI.LevelFieldGUI(
rect,
title,
ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels),
level,
useOverride
);
+ value.intValue = ScalableSettingLevelParameter.GetScalableSettingLevelParameterValue(levelAndOverride.level, levelAndOverride.useOverride);
return true;
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs
index 5bee02315d9..f77d6923019 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs
@@ -33,6 +33,11 @@ public ScalableSettingLevelParameter(int level, bool useOverride, bool overrideS
}
+ internal static int GetScalableSettingLevelParameterValue(int level, bool useOverride)
+ {
+ return useOverride ? LevelCount : (int)level;
+ }
+
///
/// Level and Override.
///
@@ -42,7 +47,7 @@ public ScalableSettingLevelParameter(int level, bool useOverride, bool overrideS
set
{
var (level, useOverride) = value;
- this.value = useOverride ? LevelCount : (int)level;
+ this.value = GetScalableSettingLevelParameterValue(level, useOverride);
}
}
}
From 571976379062519951072d324ac678354005fd19 Mon Sep 17 00:00:00 2001
From: JulienIgnace-Unity
Date: Tue, 7 Jul 2020 19:58:29 +0200
Subject: [PATCH 46/58] [Backport 8.x.x] Fixed Look Dev with Light Theme
(#1106)
* Fixed an issue where opening the look dev window with the light theme would make the window blink and eventually crash unity.
# Conflicts:
# com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs
* Update changelog
Co-authored-by: sebastienlagarde
---
.../Editor/LookDev/DisplayWindow.cs | 26 ++++++++++---------
.../CHANGELOG.md | 1 +
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs
index 12b7368fccc..fd1a725f16a 100644
--- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs
+++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs
@@ -42,7 +42,7 @@ public interface IViewDisplayer
/// Callback on update requested
event Action OnUpdateRequested;
}
-
+
partial class DisplayWindow : EditorWindow, IViewDisplayer
{
static partial class Style
@@ -82,7 +82,7 @@ internal static readonly (Texture2D icon, string tooltip) k_LayoutStackIcon =
internal const string k_CameraMenuSync1On2 = "Align Camera 1 with Camera 2";
internal const string k_CameraMenuSync2On1 = "Align Camera 2 with Camera 1";
internal const string k_CameraMenuReset = "Reset Cameras";
-
+
internal const string k_EnvironmentSidePanelName = "Environment";
internal const string k_DebugSidePanelName = "Debug";
@@ -127,7 +127,7 @@ internal static readonly (Texture2D icon, string tooltip) k_LayoutStackIcon =
Label m_NoEnvironment2;
Image[] m_Views = new Image[2];
-
+
LayoutContext layout
=> LookDev.currentContext.layout;
@@ -143,7 +143,7 @@ Layout viewLayout
}
}
}
-
+
SidePanel sidePanel
{
get => layout.showedSidePanel;
@@ -218,7 +218,7 @@ event Action IViewDisplayer.OnUpdateRequested
void OnEnable()
{
- //Stylesheet
+ //Stylesheet
// Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692).
// In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets.
// Waiting for filter on stylesheet (case 1228706) to remove last error.
@@ -486,7 +486,7 @@ Rect IViewDisplayer.GetRect(ViewCompositionIndex index)
throw new ArgumentException("Unknown ViewCompositionIndex: " + index);
}
}
-
+
Vector2 m_LastFirstViewSize = new Vector2();
Vector2 m_LastSecondViewSize = new Vector2();
void IViewDisplayer.SetTexture(ViewCompositionIndex index, Texture texture)
@@ -532,7 +532,7 @@ void IViewDisplayer.SetTexture(ViewCompositionIndex index, Texture texture)
throw new ArgumentException("Unknown ViewCompositionIndex: " + index);
}
}
-
+
void IViewDisplayer.Repaint() => Repaint();
void ApplyLayout(Layout value)
@@ -627,19 +627,21 @@ IStyle GetEnvironmentContenairDraggerStyle()
void OnGUI()
{
- //Stylesheet
+ //Stylesheet
// [case 1219692] if LookDev is open while reimporting CoreRP package,
// stylesheet can be null. In this case, we can have a null stylesheet
- // registered as it got destroyed. Reloading it. As we cannot just
+ // registered as it got destroyed. Reloading it. As we cannot just
// remove a null entry, we must filter and reconstruct the while list.
if (styleSheet == null || styleSheet.Equals(null)
|| (!EditorGUIUtility.isProSkin && (styleSheetLight == null || styleSheetLight.Equals(null))))
{
// While (case 1228706) is still on going, we sill close and reopen the look dev.
// This will prevent spawning error at frame.
- LookDev.Close();
- LookDev.Open();
- return;
+ // Note 2: This actually causes the lookdev to break completely with light theme.
+ // Until the actual issue is fixed, we'll comment this fix out as it only concerns an upgrade problem.
+ //LookDev.Close();
+ //LookDev.Open();
+ //return;
// Following lines is the correct fix if UIElement filter garbage collected Stylesheet.
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 82913a7987c..76433cef418 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -72,6 +72,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix inconsistencies with transparent motion vectors and opaque by allowing camera only transparent motion vectors.
- Fixed issue with depth pyramid generation and dynamic resolution.
- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
+- Fixed an issue where opening the look dev window with the light theme would make the window blink and eventually crash unity.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
From da56fbd05c3c9b72be17d7cb4f67ea6a56eca531 Mon Sep 17 00:00:00 2001
From: JulienIgnace-Unity
Date: Tue, 7 Jul 2020 20:01:42 +0200
Subject: [PATCH 47/58] [Backport 8.x.x] Fixed decal duplication when editing a
prefab in context (#1107)
* Implemented proper culling for decals when used in prefabs and edited in context.
* Compilation fix
* Update changelog
Co-authored-by: sebastienlagarde
---
.../CHANGELOG.md | 1 +
.../Material/Decal/DecalProjectorEditor.cs | 2 +-
.../Material/Decal/DecalProjector.Migration.cs | 4 ++--
.../Runtime/Material/Decal/DecalProjector.cs | 18 ++++++++++++------
.../Runtime/Material/Decal/DecalSystem.cs | 1 +
.../Runtime/RenderPipeline/Utility/HDUtils.cs | 9 ---------
6 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 76433cef418..e41d923f40b 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -73,6 +73,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with depth pyramid generation and dynamic resolution.
- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
- Fixed an issue where opening the look dev window with the light theme would make the window blink and eventually crash unity.
+- Fixed culling for decals when used in prefabs and edited in context.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs
index 2d3e741f9e6..8bad7221051 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs
@@ -259,7 +259,7 @@ void DrawHandles()
{
// Smoothly update the decal image projected
Matrix4x4 sizeOffset = Matrix4x4.Translate(decalProjector.decalOffset) * Matrix4x4.Scale(decalProjector.decalSize);
- DecalSystem.instance.UpdateCachedData(decalProjector.position, decalProjector.rotation, sizeOffset, decalProjector.drawDistance, decalProjector.fadeScale, decalProjector.uvScaleBias, decalProjector.affectsTransparency, decalProjector.Handle, decalProjector.gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(decalProjector.gameObject), decalProjector.fadeFactor);
+ DecalSystem.instance.UpdateCachedData(decalProjector.position, decalProjector.rotation, sizeOffset, decalProjector.drawDistance, decalProjector.fadeScale, decalProjector.uvScaleBias, decalProjector.affectsTransparency, decalProjector.Handle, decalProjector.gameObject.layer, decalProjector.gameObject.sceneCullingMask, decalProjector.fadeFactor);
}
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.Migration.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.Migration.cs
index 8c1ef20a3f2..4c7a4ede36a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.Migration.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.Migration.cs
@@ -37,7 +37,7 @@ enum Version
if (decal.m_Handle != null)
DecalSystem.instance.RemoveDecal(decal.m_Handle);
Matrix4x4 sizeOffset = Matrix4x4.Translate(decal.decalOffset) * Matrix4x4.Scale(decal.decalSize);
- decal.m_Handle = DecalSystem.instance.AddDecal(decal.position, decal.rotation, Vector3.one, sizeOffset, decal.m_DrawDistance, decal.m_FadeScale, decal.uvScaleBias, decal.m_AffectsTransparency, decal.m_Material, decal.gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(decal.gameObject), decal.m_FadeFactor);
+ decal.m_Handle = DecalSystem.instance.AddDecal(decal.position, decal.rotation, Vector3.one, sizeOffset, decal.m_DrawDistance, decal.m_FadeScale, decal.uvScaleBias, decal.m_AffectsTransparency, decal.m_Material, decal.gameObject.layer, decal.gameObject.sceneCullingMask, decal.m_FadeFactor);
}),
MigrationStep.New(Version.FixPivotPosition, (DecalProjector decal) =>
{
@@ -69,7 +69,7 @@ enum Version
if (decal.m_Handle != null)
DecalSystem.instance.RemoveDecal(decal.m_Handle);
Matrix4x4 sizeOffset = Matrix4x4.Translate(decal.decalOffset) * Matrix4x4.Scale(decal.decalSize);
- decal.m_Handle = DecalSystem.instance.AddDecal(decal.position, decal.rotation, Vector3.one, sizeOffset, decal.m_DrawDistance, decal.m_FadeScale, decal.uvScaleBias, decal.m_AffectsTransparency, decal.m_Material, decal.gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(decal.gameObject), decal.m_FadeFactor);
+ decal.m_Handle = DecalSystem.instance.AddDecal(decal.position, decal.rotation, Vector3.one, sizeOffset, decal.m_DrawDistance, decal.m_FadeScale, decal.uvScaleBias, decal.m_AffectsTransparency, decal.m_Material, decal.gameObject.layer, decal.gameObject.sceneCullingMask, decal.m_FadeFactor);
})
);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs
index 3706ba9ff0e..fd399890cbf 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs
@@ -238,7 +238,7 @@ void OnEnable()
}
Matrix4x4 sizeOffset = Matrix4x4.Translate(decalOffset) * Matrix4x4.Scale(decalSize);
- m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(gameObject), m_FadeFactor);
+ m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
m_OldMaterial = m_Material;
#if UNITY_EDITOR
@@ -260,7 +260,13 @@ void UpdateDecalVisibility()
else if (m_Handle == null)
{
Matrix4x4 sizeOffset = Matrix4x4.Translate(decalOffset) * Matrix4x4.Scale(decalSize);
- m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(gameObject), m_FadeFactor);
+ m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
+ }
+ else
+ {
+ // Scene culling mask may have changed.
+ Matrix4x4 sizeOffset = Matrix4x4.Translate(decalOffset) * Matrix4x4.Scale(decalSize);
+ DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
}
}
#endif
@@ -299,7 +305,7 @@ internal void OnValidate()
if (m_Material != null)
{
- m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(gameObject), m_FadeFactor);
+ m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
if (!DecalSystem.IsHDRenderPipelineDecal(m_Material.shader)) // non HDRP/decal shaders such as shader graph decal do not affect transparency
{
@@ -317,7 +323,7 @@ internal void OnValidate()
}
else // no material change, just update whatever else changed
{
- DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(gameObject), m_FadeFactor);
+ DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
}
}
}
@@ -329,7 +335,7 @@ void Update() // only run in editor
{
Matrix4x4 sizeOffset = Matrix4x4.Translate(decalOffset) * Matrix4x4.Scale(decalSize);
m_Layer = gameObject.layer;
- DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(gameObject), m_FadeFactor);
+ DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
}
}
#endif
@@ -341,7 +347,7 @@ void LateUpdate()
if (transform.hasChanged == true)
{
Matrix4x4 sizeOffset = Matrix4x4.Translate(decalOffset) * Matrix4x4.Scale(decalSize);
- DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, HDUtils.GetSceneCullingMaskFromGameObject(gameObject), m_FadeFactor);
+ DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, gameObject.sceneCullingMask, m_FadeFactor);
transform.hasChanged = false;
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs
index edcdac53c7b..55c80ef43a1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs
@@ -496,6 +496,7 @@ public DecalHandle AddDecal(Matrix4x4 localToWorld, Quaternion rotation, Matrix4
m_CachedDrawDistances = newCachedDrawDistances;
m_CachedUVScaleBias = newCachedUVScaleBias;
m_CachedAffectsTransparency = newCachedAffectsTransparency;
+ m_CachedLayerMask = newCachedLayerMask;
m_CachedSceneLayerMask = newCachedSceneLayerMask;
m_CachedFadeFactor = newCachedFadeFactor;
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs
index d4e871d8411..f58dc38c772 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs
@@ -942,15 +942,6 @@ internal static UInt64 GetSceneCullingMaskFromCamera(Camera camera)
}
- internal static ulong GetSceneCullingMaskFromGameObject(GameObject go)
- {
-#if UNITY_EDITOR
- return (go.scene == null) ? ~(ulong)0 : EditorSceneManager.GetSceneCullingMask(go.scene);
-#else
- return 0;
-#endif
- }
-
internal static HDAdditionalCameraData TryGetAdditionalCameraDataOrDefault(Camera camera)
{
if (camera == null || camera.Equals(null))
From 04ad6e92a650ccfd8da3287557c452de79bfc51e Mon Sep 17 00:00:00 2001
From: sebastienlagarde
Date: Tue, 7 Jul 2020 21:06:38 +0200
Subject: [PATCH 48/58] Fix API breaking change in indirect controller
---
.../Editor/Lighting/IndirectLightingControllerEditor.cs | 4 ++--
.../Runtime/Lighting/IndirectLightingController.cs | 6 ++----
.../Runtime/Lighting/LightLoop/LightLoop.cs | 2 +-
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 +-
.../Raytracing/HDRaytracingIndirectDiffuse.cs | 2 +-
5 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs
index d2a61a5e247..594775d66d9 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs
@@ -20,13 +20,13 @@ public override void OnEnable()
{
var o = new PropertyFetcher(serializedObject);
- m_IndirectDiffuseLightingMultiplier = Unpack(o.Find(x => x.indirectDiffuseLightingMultiplier));
+ m_IndirectDiffuseLightingMultiplier = Unpack(o.Find(x => x.indirectDiffuseIntensity));
m_IndirectDiffuseLightingLayers = Unpack(o.Find(x => x.indirectDiffuseLightingLayers));
m_ReflectionLightingMultiplier = Unpack(o.Find(x => x.reflectionLightingMultiplier));
m_ReflectionLightingLayers = Unpack(o.Find(x => x.reflectionLightingLayers));
- m_ReflectionProbeIntensityMultiplier = Unpack(o.Find(x => x.reflectionProbeIntensityMultiplier));
+ m_ReflectionProbeIntensityMultiplier = Unpack(o.Find(x => x.indirectSpecularIntensity));
}
public override void OnInspectorGUI()
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
index b982b9e71dd..42fa95df506 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
@@ -9,9 +9,8 @@ namespace UnityEngine.Rendering.HighDefinition
[Serializable, VolumeComponentMenu("Lighting/Indirect Lighting Controller")]
public class IndirectLightingController : VolumeComponent
{
- [UnityEngine.Serialization.FormerlySerializedAs("indirectDiffuseIntensity")]
/// Indirect diffuse lighting multiplier, between 0 and 1
- public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f);
+ public MinFloatParameter indirectDiffuseIntensity = new MinFloatParameter(1.0f, 0.0f);
/// Controls which layer will be affected by the indirect diffuse lighting multiplier
public LightLayerEnumParameter indirectDiffuseLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault);
@@ -20,9 +19,8 @@ public class IndirectLightingController : VolumeComponent
/// Controls which layer will be affected by the reflection lighting multiplier
public LightLayerEnumParameter reflectionLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault);
- [UnityEngine.Serialization.FormerlySerializedAs("indirectSpecularIntensity")]
/// Reflection probe intensity multiplier, between 0 and 1
- public MinFloatParameter reflectionProbeIntensityMultiplier = new MinFloatParameter(1.0f, 0.0f);
+ public MinFloatParameter indirectSpecularIntensity = new MinFloatParameter(1.0f, 0.0f);
///
/// Returns a mask of reflection lighting layers as uint and handle the case of Everything as being 0xFF and not -1
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
index cb8978209fa..1ca6843ed51 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
@@ -1816,7 +1816,7 @@ internal bool GetEnvLightData(CommandBuffer cmd, HDCamera hdCamera, in Processed
envLightData.lightLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? probe.lightLayersAsUInt : uint.MaxValue;
envLightData.influenceShapeType = influence.envShape;
envLightData.weight = processedProbe.weight;
- envLightData.multiplier = probe.multiplier * m_indirectLightingController.reflectionProbeIntensityMultiplier.value;
+ envLightData.multiplier = probe.multiplier * m_indirectLightingController.indirectSpecularIntensity.value;
envLightData.rangeCompressionFactorCompensation = Mathf.Max(probe.rangeCompressionFactor, 1e-6f);
envLightData.influenceExtents = influence.extents;
switch (influence.envShape)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index e62b8f9ec46..a89b4ef6df4 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -1048,7 +1048,7 @@ void PushGlobalParams(HDCamera hdCamera, CommandBuffer cmd)
hdCamera.SetupGlobalParams(cmd, m_FrameCount);
IndirectLightingController indirectLightingController = hdCamera.volumeStack.GetComponent();
- cmd.SetGlobalFloat(HDShaderIDs._IndirectDiffuseLightingMultiplier, indirectLightingController.indirectDiffuseLightingMultiplier.value);
+ cmd.SetGlobalFloat(HDShaderIDs._IndirectDiffuseLightingMultiplier, indirectLightingController.indirectDiffuseIntensity.value);
cmd.SetGlobalInt(HDShaderIDs._IndirectDiffuseLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetIndirectDiffuseLightingLayers() : -1);
cmd.SetGlobalFloat(HDShaderIDs._ReflectionLightingMultiplier, indirectLightingController.reflectionLightingMultiplier.value);
cmd.SetGlobalInt(HDShaderIDs._ReflectionLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetReflectionLightingLayers() : -1);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs
index abe470480b2..4c9fe99b703 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs
@@ -89,7 +89,7 @@ void RenderIndirectDiffuse(HDCamera hdCamera, CommandBuffer cmd, ScriptableRende
cmd.SetComputeTextureParam(indirectDiffuseCS, indirectDiffuseKernel, HDShaderIDs._GBufferTexture[3], m_GbufferManager.GetBuffer(3));
IndirectLightingController indirectLightingController = hdCamera.volumeStack.GetComponent();
- cmd.SetComputeFloatParam(indirectDiffuseCS, HDShaderIDs._IndirectDiffuseLightingMultiplier, indirectLightingController.indirectDiffuseLightingMultiplier.value);
+ cmd.SetComputeFloatParam(indirectDiffuseCS, HDShaderIDs._IndirectDiffuseLightingMultiplier, indirectLightingController.indirectDiffuseIntensity.value);
cmd.SetComputeIntParam(indirectDiffuseCS, HDShaderIDs._IndirectDiffuseLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetIndirectDiffuseLightingLayers() : -1);
cmd.SetComputeFloatParam(indirectDiffuseCS, HDShaderIDs._ReflectionLightingMultiplier, indirectLightingController.reflectionLightingMultiplier.value);
cmd.SetComputeIntParam(indirectDiffuseCS, HDShaderIDs._ReflectionLightingLayers, hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? (int)indirectLightingController.GetReflectionLightingLayers() : -1);
From 40cd33bd239e16ef967fa457948b16864e369672 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Mon, 6 Jul 2020 18:02:13 +0200
Subject: [PATCH 49/58] Fix area light gizmo not updating engine side light v2
#1156
---
.../Runtime/Lighting/Light/HDAdditionalLightData.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
index 1d2c4ab48eb..18463cf9f72 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs
@@ -2678,7 +2678,9 @@ void UpdateShapeSize()
shapeWidth = m_ShapeWidth;
shapeHeight = m_ShapeHeight;
+#if UNITY_EDITOR
legacyLight.areaSize = new Vector2(shapeWidth, shapeHeight);
+#endif
}
///
From f6cbe2842b1f28f4026ed9991aaa77fd5d6d0549 Mon Sep 17 00:00:00 2001
From: Sebastien Lagarde
Date: Wed, 8 Jul 2020 20:28:40 +0200
Subject: [PATCH 50/58] Add missing ClothObj.
---
.../Samples~/MaterialSamples/Meshes/Cloth.obj | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 com.unity.render-pipelines.high-definition/Samples~/MaterialSamples/Meshes/Cloth.obj
diff --git a/com.unity.render-pipelines.high-definition/Samples~/MaterialSamples/Meshes/Cloth.obj b/com.unity.render-pipelines.high-definition/Samples~/MaterialSamples/Meshes/Cloth.obj
new file mode 100644
index 00000000000..1d552e24199
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Samples~/MaterialSamples/Meshes/Cloth.obj
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:790febdb58b02862c0def673c1cb13b1610b6c4b1b79a5d195abb1f6cdc1d153
+size 2224438
From 9e4b93623dca7867b5f735b1e66d4b765bd7a637 Mon Sep 17 00:00:00 2001
From: Sebastien Lagarde
Date: Wed, 8 Jul 2020 20:32:59 +0200
Subject: [PATCH 51/58] HDRP: Default indirect Lighting controller Layers to
Everything to ease the migration
---
.../Runtime/Lighting/IndirectLightingController.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
index 42fa95df506..ee1ac5ffbbe 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs
@@ -12,12 +12,12 @@ public class IndirectLightingController : VolumeComponent
/// Indirect diffuse lighting multiplier, between 0 and 1
public MinFloatParameter indirectDiffuseIntensity = new MinFloatParameter(1.0f, 0.0f);
/// Controls which layer will be affected by the indirect diffuse lighting multiplier
- public LightLayerEnumParameter indirectDiffuseLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault);
+ public LightLayerEnumParameter indirectDiffuseLightingLayers = new LightLayerEnumParameter(LightLayerEnum.Everything); // Default to everything to not have migration issue
/// Reflection lighting multiplier, between 0 and 1
public MinFloatParameter reflectionLightingMultiplier = new MinFloatParameter(1.0f, 0.0f);
/// Controls which layer will be affected by the reflection lighting multiplier
- public LightLayerEnumParameter reflectionLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault);
+ public LightLayerEnumParameter reflectionLightingLayers = new LightLayerEnumParameter(LightLayerEnum.Everything); // Default to everything to not have migration issue
/// Reflection probe intensity multiplier, between 0 and 1
public MinFloatParameter indirectSpecularIntensity = new MinFloatParameter(1.0f, 0.0f);
From c52ab116da6647b5f3adfdadbe6e6d8bd1d1a6b6 Mon Sep 17 00:00:00 2001
From: Sebastien Lagarde
Date: Wed, 8 Jul 2020 20:33:51 +0200
Subject: [PATCH 52/58] Update HDRenderPipelineResources.asset
---
.../RenderPipelineResources/HDRenderPipelineResources.asset | 2 ++
1 file changed, 2 insertions(+)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset
index 1ee7f12cd2b..d44e76338af 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset
@@ -128,6 +128,8 @@ MonoBehaviour:
type: 3}
depthValuesPS: {fileID: 4800000, guid: 6e6a4a3dbb788234594aa74f2d6aeb6f, type: 3}
colorResolvePS: {fileID: 4800000, guid: dd7047092f3c82b40b3a07868f9c4de2, type: 3}
+ resolveMotionVecPS: {fileID: 4800000, guid: ea18ca9826385e943979c46cf98968cc,
+ type: 3}
copyAlphaCS: {fileID: 7200000, guid: c2c7eb6611725264187721ef9df0354b, type: 3}
nanKillerCS: {fileID: 7200000, guid: 83982f199acf927499576a99abc9bea9, type: 3}
exposureCS: {fileID: 7200000, guid: 976d7bce54fae534fb9ec67e9c18570c, type: 3}
From d0b7f952bd2bd27ffdb1305a0ef748d6335eff4b Mon Sep 17 00:00:00 2001
From: Emmanuel Turquin
Date: Wed, 10 Jun 2020 19:40:59 +0200
Subject: [PATCH 53/58] Fixed logic of test on presence of HDRP asset that
would wrongly trigger (#824)
a warning message when not in batch mode.
---
.../BuildProcessors/HDRPPreprocessShaders.cs | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs
index fddb336616d..c2f32cc523d 100644
--- a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs
@@ -394,14 +394,17 @@ static void GetAllValidHDRPAssets()
}
// Prompt a warning if we find 0 HDRP Assets.
- if (_hdrpAssets.Count == 0 && !Application.isBatchMode)
+ if (_hdrpAssets.Count == 0)
{
- if (EditorUtility.DisplayDialog("HDRP Asset missing", "No HDRP Asset has been set in the Graphic Settings, and no potential used in the build HDRP Asset has been found. If you want to continue compiling, this might lead to VERY long compilation time.", "Ok", "Cancel"))
- throw new UnityEditor.Build.BuildFailedException("Build canceled");
- }
- else
- {
- Debug.LogWarning("There is no HDRP Asset provided in GraphicsSettings. Build time can be extremely long without it.");
+ if (!Application.isBatchMode)
+ {
+ if (EditorUtility.DisplayDialog("HDRP Asset missing", "No HDRP Asset has been set in the Graphic Settings, and no potential used in the build HDRP Asset has been found. If you want to continue compiling, this might lead to VERY long compilation time.", "Ok", "Cancel"))
+ throw new UnityEditor.Build.BuildFailedException("Build canceled");
+ }
+ else
+ {
+ Debug.LogWarning("There is no HDRP Asset provided in GraphicsSettings. Build time can be extremely long without it.");
+ }
}
/*
From a294a189f98af86592a1327414f4ccfe67899d60 Mon Sep 17 00:00:00 2001
From: FrancescoC-Unity
Date: Thu, 18 Jun 2020 09:27:56 +0200
Subject: [PATCH 54/58] Rename h to hlsl
---
.../Shaders/ContrastAdaptiveSharpen.compute | 6 ++---
.../PostProcessing/Shaders/ffx_a.h.meta | 27 -------------------
.../Shaders/{ffx_a.h => ffx_a.hlsl} | 0
.../PostProcessing/Shaders/ffx_a.hlsl.meta | 10 +++++++
.../PostProcessing/Shaders/ffx_cas.h.meta | 27 -------------------
.../Shaders/{ffx_cas.h => ffx_cas.hlsl} | 0
.../PostProcessing/Shaders/ffx_cas.hlsl.meta | 10 +++++++
.../PostProcessing/Shaders/ffx_lpm.h.meta | 27 -------------------
.../Shaders/{ffx_lpm.h => ffx_lpm.hlsl} | 0
.../PostProcessing/Shaders/ffx_lpm.hlsl.meta | 10 +++++++
10 files changed, 33 insertions(+), 84 deletions(-)
delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.h.meta
rename com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/{ffx_a.h => ffx_a.hlsl} (100%)
create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl.meta
delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.h.meta
rename com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/{ffx_cas.h => ffx_cas.hlsl} (100%)
create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl.meta
delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.h.meta
rename com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/{ffx_lpm.h => ffx_lpm.hlsl} (100%)
create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.hlsl.meta
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute
index 7e29259723d..a505189c9c6 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute
@@ -1,4 +1,4 @@
-#pragma kernel KMain
+#pragma kernel KMain
#pragma kernel KInitialize
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
@@ -7,7 +7,7 @@
#define A_GPU 1
#define A_HLSL 1
-#include "ffx_a.h"
+#include "ffx_a.hlsl"
// two elements:
// [0] = const0
// [1] = const1
@@ -42,7 +42,7 @@ void WritePix(AU2 gxy, AF4 casPix)
_OutputTexture[COORD_TEXTURE2D_X(gxy)] = casPix;
}
-#include "ffx_cas.h"
+#include "ffx_cas.hlsl"
[numthreads(64, 1, 1)]
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.h.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.h.meta
deleted file mode 100644
index 5e8da5eaa28..00000000000
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.h.meta
+++ /dev/null
@@ -1,27 +0,0 @@
-fileFormatVersion: 2
-guid: 8fa88e06d4412864faafeccb0dd1f265
-PluginImporter:
- externalObjects: {}
- serializedVersion: 2
- iconMap: {}
- executionOrder: {}
- defineConstraints: []
- isPreloaded: 0
- isOverridable: 1
- isExplicitlyReferenced: 0
- validateReferences: 1
- platformData:
- - first:
- Any:
- second:
- enabled: 1
- settings: {}
- - first:
- Editor: Editor
- second:
- enabled: 0
- settings:
- DefaultValueInitialized: true
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.h b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl
similarity index 100%
rename from com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.h
rename to com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl.meta
new file mode 100644
index 00000000000..21ef14dc855
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 09d6b4dd7349d95459ccc412508450cb
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ preprocessorOverride: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.h.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.h.meta
deleted file mode 100644
index c047659b3d6..00000000000
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.h.meta
+++ /dev/null
@@ -1,27 +0,0 @@
-fileFormatVersion: 2
-guid: 17dee6c96085bcf44bc645a7fb003797
-PluginImporter:
- externalObjects: {}
- serializedVersion: 2
- iconMap: {}
- executionOrder: {}
- defineConstraints: []
- isPreloaded: 0
- isOverridable: 1
- isExplicitlyReferenced: 0
- validateReferences: 1
- platformData:
- - first:
- Any:
- second:
- enabled: 1
- settings: {}
- - first:
- Editor: Editor
- second:
- enabled: 0
- settings:
- DefaultValueInitialized: true
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.h b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl
similarity index 100%
rename from com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.h
rename to com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl.meta
new file mode 100644
index 00000000000..6094016656c
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: c6604d0ef3ffab64089f9c5f537442c0
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ preprocessorOverride: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.h.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.h.meta
deleted file mode 100644
index 7c08e1ba715..00000000000
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.h.meta
+++ /dev/null
@@ -1,27 +0,0 @@
-fileFormatVersion: 2
-guid: 010ce9ea342d9824a95a715800cc8a60
-PluginImporter:
- externalObjects: {}
- serializedVersion: 2
- iconMap: {}
- executionOrder: {}
- defineConstraints: []
- isPreloaded: 0
- isOverridable: 1
- isExplicitlyReferenced: 0
- validateReferences: 1
- platformData:
- - first:
- Any:
- second:
- enabled: 1
- settings: {}
- - first:
- Editor: Editor
- second:
- enabled: 0
- settings:
- DefaultValueInitialized: true
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.h b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.hlsl
similarity index 100%
rename from com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.h
rename to com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.hlsl
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.hlsl.meta
new file mode 100644
index 00000000000..c2e467885dd
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_lpm.hlsl.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 806df549cbaf41649a171cda59950cce
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ preprocessorOverride: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
From 64b4aa04409de19802f6e7d13d4d657badbdb497 Mon Sep 17 00:00:00 2001
From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Date: Thu, 9 Jul 2020 18:36:16 +0200
Subject: [PATCH 55/58] Update cas include paths (#1227)
---
.../PostProcessing/Shaders/ContrastAdaptiveSharpen.compute | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute
index a505189c9c6..2d64cd54246 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ContrastAdaptiveSharpen.compute
@@ -7,7 +7,7 @@
#define A_GPU 1
#define A_HLSL 1
-#include "ffx_a.hlsl"
+#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_a.hlsl"
// two elements:
// [0] = const0
// [1] = const1
@@ -42,7 +42,7 @@ void WritePix(AU2 gxy, AF4 casPix)
_OutputTexture[COORD_TEXTURE2D_X(gxy)] = casPix;
}
-#include "ffx_cas.hlsl"
+#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ffx_cas.hlsl"
[numthreads(64, 1, 1)]
From 1046768d2cd4fd1d600282e007934440d11513ea Mon Sep 17 00:00:00 2001
From: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com>
Date: Thu, 9 Jul 2020 17:22:43 -0400
Subject: [PATCH 56/58] Fix XR single-pass macros in tessellation shaders #1160
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl | 3 ---
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 9fc890272df..bfb88413dc1 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
- Fixed an issue where opening the look dev window with the light theme would make the window blink and eventually crash unity.
- Fixed culling for decals when used in prefabs and edited in context.
+- Fixed XR single-pass macros in tessellation shaders.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl
index 208a00e9e0f..7e90f7fbb78 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl
@@ -45,8 +45,6 @@ struct PackedVaryingsToDS
#ifdef VARYINGS_NEED_PASS
PackedVaryingsPassToDS vpass;
#endif
-
- UNITY_VERTEX_OUTPUT_STEREO
};
PackedVaryingsToDS PackVaryingsToDS(VaryingsToDS input)
@@ -57,7 +55,6 @@ PackedVaryingsToDS PackVaryingsToDS(VaryingsToDS input)
output.vpass = PackVaryingsPassToDS(input.vpass);
#endif
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
return output;
}
From a9351accc54aaddc99df7a303ebfa039b8800654 Mon Sep 17 00:00:00 2001
From: Remi Slysz <40034005+RSlysz@users.noreply.github.com>
Date: Thu, 9 Jul 2020 23:15:24 +0200
Subject: [PATCH 57/58] Hdrp/fix hierarchicalbox gizmo symetry and homothety
mode ensuring face faces outside #1228
---
com.unity.render-pipelines.core/CHANGELOG.md | 1 +
.../Editor/Gizmo/HierarchicalBox.cs | 99 ++++++++++++++++---
.../CHANGELOG.md | 1 +
.../Volume/InfluenceVolumeUI.Handles.cs | 8 +-
4 files changed, 96 insertions(+), 13 deletions(-)
diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md
index 3d3a2368771..6a8972253fb 100644
--- a/com.unity.render-pipelines.core/CHANGELOG.md
+++ b/com.unity.render-pipelines.core/CHANGELOG.md
@@ -23,6 +23,7 @@ The version number for this package has increased due to a version update of a r
- Fix LookDev's undo/redo on EnvironmentLibrary (case 1234725)
- Fixed a wrong condition in CameraSwitcher, potentially causing out of bound exceptions.
- Fixed issue with blue line in prefabs for volume mode.
+- Fix hierarchicalbox gizmo outside facing check in symetry or homothety mode no longer move the center
## [8.0.1] - 2020-02-25
diff --git a/com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs b/com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs
index be4761682b8..26b9250d279 100644
--- a/com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs
+++ b/com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs
@@ -244,9 +244,7 @@ public void DrawHandle()
for (int i = 0, count = m_ControlIDs.Length; i < count; ++i)
m_ControlIDs[i] = GUIUtility.GetControlID("HierarchicalBox".GetHashCode() + i, FocusType.Passive);
-
- EditorGUI.BeginChangeCheck();
-
+
var leftPosition = center + size.x * .5f * Vector3.left;
var rightPosition = center + size.x * .5f * Vector3.right;
var topPosition = center + size.y * .5f * Vector3.up;
@@ -256,6 +254,8 @@ public void DrawHandle()
var theChangedFace = NamedFace.None;
+ EditorGUI.BeginChangeCheck();
+
EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Left], ref leftPosition, Vector3.left, EditorSnapSettings.scale, GetHandleColor(NamedFace.Left));
if (EditorGUI.EndChangeCheck())
@@ -338,6 +338,27 @@ public void DrawHandle()
case NamedFace.Front: backPosition.z += delta; break;
case NamedFace.Back: frontPosition.z -= delta; break;
}
+
+ //ensure that the box face are still facing outside
+ switch (theChangedFace)
+ {
+ case NamedFace.Left:
+ case NamedFace.Right:
+ if (rightPosition.x < leftPosition.x)
+ rightPosition.x = leftPosition.x = center.x;
+ break;
+ case NamedFace.Top:
+ case NamedFace.Bottom:
+ if (topPosition.y < bottomPosition.y)
+ topPosition.y = bottomPosition.y = center.y;
+ break;
+ case NamedFace.Front:
+ case NamedFace.Back:
+ if (frontPosition.z < backPosition.z)
+ frontPosition.z = backPosition.z = center.z;
+ break;
+ }
+
}
if (useHomothety)
@@ -367,21 +388,77 @@ public void DrawHandle()
topPosition.y -= halfDelta;
break;
}
+
+ //ensure that the box face are still facing outside
+ switch (theChangedFace)
+ {
+ case NamedFace.Left:
+ if (rightPosition.x < leftPosition.x)
+ leftPosition.x = rightPosition.x;
+ if (topPosition.y < bottomPosition.y)
+ topPosition.y = bottomPosition.y = center.y;
+ if (frontPosition.z < backPosition.z)
+ frontPosition.z = backPosition.z = center.z;
+ break;
+ case NamedFace.Right:
+ if (rightPosition.x < leftPosition.x)
+ rightPosition.x = leftPosition.x;
+ if (topPosition.y < bottomPosition.y)
+ topPosition.y = bottomPosition.y = center.y;
+ if (frontPosition.z < backPosition.z)
+ frontPosition.z = backPosition.z = center.z;
+ break;
+ case NamedFace.Top:
+ if (topPosition.y < bottomPosition.y)
+ topPosition.y = bottomPosition.y;
+ if (rightPosition.x < leftPosition.x)
+ rightPosition.x = leftPosition.x = center.x;
+ if (frontPosition.z < backPosition.z)
+ frontPosition.z = backPosition.z = center.z;
+ break;
+ case NamedFace.Bottom:
+ if (topPosition.y < bottomPosition.y)
+ bottomPosition.y = topPosition.y;
+ if (rightPosition.x < leftPosition.x)
+ rightPosition.x = leftPosition.x = center.x;
+ if (frontPosition.z < backPosition.z)
+ frontPosition.z = backPosition.z = center.z;
+ break;
+ case NamedFace.Front:
+ if (frontPosition.z < backPosition.z)
+ frontPosition.z = backPosition.z;
+ if (rightPosition.x < leftPosition.x)
+ rightPosition.x = leftPosition.x = center.x;
+ if (topPosition.y < bottomPosition.y)
+ topPosition.y = bottomPosition.y = center.y;
+ break;
+ case NamedFace.Back:
+ if (frontPosition.z < backPosition.z)
+ backPosition.z = frontPosition.z;
+ if (rightPosition.x < leftPosition.x)
+ rightPosition.x = leftPosition.x = center.x;
+ if (topPosition.y < bottomPosition.y)
+ topPosition.y = bottomPosition.y = center.y;
+ break;
+ }
}
var max = new Vector3(rightPosition.x, topPosition.y, frontPosition.z);
var min = new Vector3(leftPosition.x, bottomPosition.y, backPosition.z);
- //ensure that the box face are still facing outside
- for (int axis = 0; axis < 3; ++axis)
+ if (!useSymetry && !useHomothety)
{
- if (min[axis] > max[axis])
+ //ensure that the box face are still facing outside
+ for (int axis = 0; axis < 3; ++axis)
{
- // Control IDs in m_ControlIDs[0-3[ are for positive axes
- if (GUIUtility.hotControl == m_ControlIDs[axis])
- max[axis] = min[axis];
- else
- min[axis] = max[axis];
+ if (min[axis] > max[axis])
+ {
+ // Control IDs in m_ControlIDs[0-3[ are for positive axes
+ if (GUIUtility.hotControl == m_ControlIDs[axis])
+ max[axis] = min[axis];
+ else
+ min[axis] = max[axis];
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index bfb88413dc1..bfe6afdacd9 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed an issue where opening the look dev window with the light theme would make the window blink and eventually crash unity.
- Fixed culling for decals when used in prefabs and edited in context.
- Fixed XR single-pass macros in tessellation shaders.
+- Fixed regression where moving face of the probe gizmo was not moving its position anymore.
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
index 6591265fc2d..644e16383a4 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
@@ -102,12 +102,12 @@ public static void DrawHandles_EditInfluenceNormal(SerializedInfluenceVolume ser
break;
}
}
-
+
static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box)
{
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one)))
{
- box.center = Quaternion.Inverse(transform.rotation)*transform.position;
+ box.center = Quaternion.Inverse(transform.rotation) * transform.position;
box.size = serialized.boxSize.vector3Value;
EditorGUI.BeginChangeCheck();
@@ -115,6 +115,10 @@ static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Tr
box.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
+ var newPosition = transform.rotation * box.center;
+ Undo.RecordObject(transform, "Moving Influence");
+ transform.position = newPosition;
+
// Clamp blend distances
var blendPositive = serialized.boxBlendDistancePositive.vector3Value;
var blendNegative = serialized.boxBlendDistanceNegative.vector3Value;
From c3938e4aa82c4b80c36ca5ca5531e1db1f52d662 Mon Sep 17 00:00:00 2001
From: Adrien de Tocqueville
Date: Thu, 16 Jul 2020 19:19:23 +0000
Subject: [PATCH 58/58] Remove MSAA debug mode when renderpipeline asset has no
MSAA (#1289)
---
com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 +
.../Runtime/Debug/DebugDisplay.cs | 9 ++++++---
.../Runtime/RenderPipeline/HDRenderPipeline.cs | 8 ++++----
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index bfe6afdacd9..92b9f796db1 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed culling for decals when used in prefabs and edited in context.
- Fixed XR single-pass macros in tessellation shaders.
- Fixed regression where moving face of the probe gizmo was not moving its position anymore.
+- Remove MSAA debug mode when renderpipeline asset has no MSAA
### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
index a8e6baff563..34c414e3309 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
@@ -1027,10 +1027,13 @@ void RegisterRenderingDebug()
});
}
- widgetList.AddRange(new DebugUI.Widget[]
+ if (HDRenderPipeline.currentAsset?.currentPlatformRenderPipelineSettings.supportMSAA ?? true)
{
- new DebugUI.EnumField { displayName = "MSAA Samples", getter = () => (int)data.msaaSamples, setter = value => data.msaaSamples = (MSAASamples)value, enumNames = s_MsaaSamplesDebugStrings, enumValues = s_MsaaSamplesDebugValues, getIndex = () => data.msaaSampleDebugModeEnumIndex, setIndex = value => data.msaaSampleDebugModeEnumIndex = value },
- });
+ widgetList.AddRange(new DebugUI.Widget[]
+ {
+ new DebugUI.EnumField { displayName = "MSAA Samples", getter = () => (int)data.msaaSamples, setter = value => data.msaaSamples = (MSAASamples)value, enumNames = s_MsaaSamplesDebugStrings, enumValues = s_MsaaSamplesDebugValues, getIndex = () => data.msaaSampleDebugModeEnumIndex, setIndex = value => data.msaaSampleDebugModeEnumIndex = value },
+ });
+ }
widgetList.AddRange(new DebugUI.Widget[]
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index a89b4ef6df4..ed5ec21add7 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -477,9 +477,6 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau
// TODO : Bind this directly to the debug menu instead of having an intermediate value
m_MSAASamples = m_Asset ? m_Asset.currentPlatformRenderPipelineSettings.msaaSampleCount : MSAASamples.None;
- // Propagate it to the debug menu
- m_DebugDisplaySettings.data.msaaSamples = m_MSAASamples;
-
m_MRTTransparentMotionVec = new RenderTargetIdentifier[2];
if (m_RayTracingSupported)
@@ -1994,7 +1991,10 @@ AOVRequestData aovRequest
else
{
// Make sure we are in sync with the debug menu for the msaa count
- m_MSAASamples = m_DebugDisplaySettings.data.msaaSamples;
+ m_MSAASamples = (m_DebugDisplaySettings.data.msaaSamples != MSAASamples.None) ?
+ m_DebugDisplaySettings.data.msaaSamples :
+ m_Asset.currentPlatformRenderPipelineSettings.msaaSampleCount;
+
m_SharedRTManager.SetNumMSAASamples(m_MSAASamples);
m_DebugDisplaySettings.UpdateCameraFreezeOptions();