Skip to content

Commit 2930f0d

Browse files
remi-chapelainEvergreen
authored andcommitted
[HDRP] Adding SG custom refraction example to Transparency sample
This concludes the task of adding transparent samples to HDRP. The last needed part was the shader graph example which needed to include compute thickness and new nodes added by @soufiane-khiat a while ago. This adds 3 examples: - The gummy bears, which shows two ways of using compute thickness by rendering gummy bears and its x-ray using the same shader. - The lens effect which has been snatched from the dead Werner demo - And a full custom refraction shader which replicates the sphere refraction model in HDRP using an Unlit shader. Those should be good base for user to kickstart a custom refraction effect in HDRP ![image](https://media.github.cds.internal.unity3d.com/user/1764/files/0565c42d-b16d-4504-91a0-8056d440e8c4) this adds two new thing to check in the HDRP asset when importing a sample. ![image](https://media.github.cds.internal.unity3d.com/user/1764/files/09c823b1-39b6-46bc-94fc-226e071fcefc) Lastly, took the opportunity to reduce filesize by replacing the tif with png file which minimize the additional file needed for this addition. before: ![image](https://media.github.cds.internal.unity3d.com/user/1764/files/610bd172-ce4d-408a-a157-347ed9089b40) now: ![image](https://media.github.cds.internal.unity3d.com/user/1764/files/88c9e5e7-7241-472a-aabc-0f68b23730f4) Regarding the raytracing quality node. It's not really possible to have a migration / upgrade. But by default, if the user doesn't re-save their graph the result stay unchanged. Then, if they want to upgrade, they need to delete / re-add the keywords to be able to get the new behavior. Since, it's most probably not used a lot (we never had a report regarding this), it's probably acceptable to have this behavior.
1 parent 15dc399 commit 2930f0d

File tree

88 files changed

+31704
-3384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+31704
-3384
lines changed

Packages/com.unity.render-pipelines.core/Samples~/Common/Scripts/RequiredSettings/RequiredSettingBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public virtual bool state
8484
break;
8585
case ValueType.Int:
8686
floatValue = property.intValue;
87-
comparedValue = (int)comparedValue;
87+
comparedValue = (int)targetValue;
8888
break;
8989
default:
9090
return property.boolValue == (targetValue > 0f);
@@ -102,6 +102,10 @@ public virtual bool state
102102
return floatValue <= comparedValue;
103103
case ValidationType.Different:
104104
return floatValue != comparedValue;
105+
case ValidationType.LayermaskContains:
106+
var intValue = property.intValue;
107+
var intCompared = (int)targetValue;
108+
return (intValue & intCompared) == intCompared;
105109
default:
106110
return floatValue == comparedValue;
107111
}
@@ -123,7 +127,8 @@ public enum ValidationType
123127
Lower,
124128
GreaterEqual,
125129
LowerEqual,
126-
Different
130+
Different,
131+
LayermaskContains
127132
};
128133
}
129134
#endif
-57 KB
Loading

Packages/com.unity.render-pipelines.high-definition/Documentation~/SGNode-Raytracing-Quality.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Implement ray tracing with Shader Graph
22

3-
To use ray-traced effects with Shader Graph, use the **Raytracing Quality** Keyword node. This node exchanges accuracy for speed, except for [Path-Traced effects](Ray-Tracing-Path-Tracing.md) which aren't affected and use the default path.
3+
To use ray-traced effects with Shader Graph, use the **Raytracing Quality** Keyword node. This node exchanges accuracy for speed for ray-traced effects. It's also useful to prevent compilation error due to unsupported nodes when using [Path Tracing](Ray-Tracing-Path-Tracing.md).
44

55
## Add the Raytracing Quality Keyword node
66

@@ -21,6 +21,7 @@ To use this keyword in the graph, you need to create a [Keyword Node](https://do
2121

2222
| Name | Direction | Type | Description |
2323
| :------------ | :-------- | :------------- | :----------------------------------------------------------- |
24-
| **default** | Input | Vector4 | The value to use for the normal Shader Graph. This is the default path Unity uses to render this Shader Graph. |
25-
| **raytraced** | Input | Vector4 | The value to use for the fast Shader Graph to use with the ray-traced effects excepth the path traced one.|
26-
| **output** | Output | Vector4 | Outputs is the value which will be selected based on the context this shader graph is used. |
24+
| **default** | Input | Vector4 | The value to use for the normal Shader Graph. This is the default path Unity uses to render this Shader Graph. |
25+
| **raytraced** | Input | Vector4 | The value to use for the fast Shader Graph to use with the ray-traced effects.|
26+
| **pathtraced** | Input | Vector4 | The value to use for the Shader Graph when the path tracer is enabled. This is useful to prevent compilation error due to unsupported nodes in path tracing.|
27+
| **output** | Output | Vector4 | Outputs is the value which will be selected based on the context this shader graph is used. |

Packages/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2023.2-to-unity-6-preview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ With the introduction of the sky occlusion feature some asset data layout has ch
2222

2323
Path tracing now has a *Seed Mode* parameter. The default is the **non repeating** noise pattern, which is different from the previous behavior. To match behavior in the last version, select the **repeating** pattern.
2424

25+
The [Raytracing Quality Keyword](SGNode-Raytracing-Quality.md) has been updated to include a Pathtraced input.
26+
In previous versions, when Path tracing is enabled, the default input was used. Now, it uses the Pathtraced input. This is to prevent compilation error in graphs using unsupported nodes.
27+
If you had Shader Graph materials using the Raytracing Quality Keyword, the result will stay unchanged until you re-save them. To upgrade the behavior, you need to delete the keyword in the blackboard and re-add it manually.
28+
2529
## Enabling light sources in Path Tracing
2630

2731
In this version, the setting to include light sources in ray traced effects has been split in one checkbox for hybrid ray tracing effects (`include for Ray Tracing`) and one checkbox for inclusion in Path Tracing (`include for Path Tracing`). When upgrading, this last checkbox might need to be updated.

Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ IncludeCollection GenerateIncludes()
13061306
public static DefineCollection RaytracingPathTracingDefines = new DefineCollection
13071307
{
13081308
{ Defines.shadowLow },
1309-
{ Defines.raytracingDefault },
1309+
{ Defines.raytracingPathtraced },
13101310
{ Defines.pathtracingDisableLightCluster },
13111311
{ CoreKeywordDescriptors.HasLightloop, 1 },
13121312
};
@@ -1423,6 +1423,7 @@ public static class Defines
14231423
// Raytracing Quality
14241424
public static DefineCollection raytracingDefault = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 0 } };
14251425
public static DefineCollection raytracingRaytraced = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 1 } };
1426+
public static DefineCollection raytracingPathtraced = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 2 } };
14261427

14271428
// Path tracing specific defines
14281429
public static DefineCollection pathtracingDisableLightCluster = new DefineCollection { { CoreKeywordDescriptors.DisableLightloopTileAndCluster, 1 }, { CoreKeywordDescriptors.PathTracingclusteredDecals, 1 } };

Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/RayTracingQualityNode.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ class RayTracingQualityNode
1313
{
1414
private const string k_KeywordDefault = "RAYTRACING_SHADER_GRAPH_DEFAULT";
1515
private const string k_KeywordRaytraced = "RAYTRACING_SHADER_GRAPH_RAYTRACED";
16+
private const string k_KeywordPathtracer = "RAYTRACING_SHADER_GRAPH_PATHTRACED";
1617

1718
public enum RayTracingQualityVariant
1819
{
1920
Default,
20-
Raytraced
21+
Raytraced,
22+
Pathtraced
2123
}
2224

2325
public static string RaytracingVariantKeyword(RayTracingQualityVariant variant)
@@ -26,6 +28,7 @@ public static string RaytracingVariantKeyword(RayTracingQualityVariant variant)
2628
{
2729
case RayTracingQualityVariant.Default: return k_KeywordDefault;
2830
case RayTracingQualityVariant.Raytraced: return k_KeywordRaytraced;
31+
case RayTracingQualityVariant.Pathtraced: return k_KeywordPathtracer;
2932
default: throw new ArgumentOutOfRangeException(nameof(variant));
3033
}
3134
}
@@ -46,6 +49,7 @@ public static KeywordDescriptor GetRayTracingQualityKeyword()
4649
{
4750
new KeywordEntry("Default", "DEFAULT"),
4851
new KeywordEntry("Raytraced", "RAYTRACED"),
52+
new KeywordEntry("Pathtraced", "PATHTRACED"),
4953
},
5054
};
5155
}

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ internal enum ExpandableRendering
3737
DynamicResolution = 1 << 1,
3838
LowResTransparency = 1 << 2,
3939
Water = 1 << 3,
40-
ComputeThickness = 1 << 4,
41-
HighQualityLineRendering = 1 << 5
40+
// Illegal index 1 << 4 since parent Lighting section index is using it
41+
HighQualityLineRendering = 1 << 5,
42+
ComputeThickness = 1 << 6
4243
}
4344

4445
internal enum ExpandableDecal
@@ -53,8 +54,9 @@ internal enum ExpandableLighting
5354
Cookie = 1 << 2,
5455
Reflection = 1 << 3,
5556
Sky = 1 << 4,
56-
Shadow = 1 << 5,
57-
LightLoop = 1 << 6
57+
// Illegal index 1 << 5 since parent Lighting section index is using it
58+
LightLoop = 1 << 6,
59+
Shadow = 1 << 7
5860
}
5961

6062
internal enum ExpandableLightingQuality

Packages/com.unity.render-pipelines.high-definition/Samples~/TransparentSamples/Materials/Models/IceCube.mat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ Material:
9696
m_Scale: {x: 2, y: 2}
9797
m_Offset: {x: 0, y: 0}
9898
- _MaskMap:
99-
m_Texture: {fileID: 2800000, guid: decd59cf305ad964bb384d3e0a9bd4b6, type: 3}
99+
m_Texture: {fileID: 2800000, guid: 5ed4ee65b96332c489342cd3aa01d63c, type: 3}
100100
m_Scale: {x: 1, y: 1}
101101
m_Offset: {x: 0, y: 0}
102102
- _NormalMap:
103-
m_Texture: {fileID: 2800000, guid: 10be5dc71ddc43b41994c5b5d60dde4c, type: 3}
103+
m_Texture: {fileID: 2800000, guid: 68d089e25cf7c5e48bf86174b5d00074, type: 3}
104104
m_Scale: {x: 1, y: 1}
105105
m_Offset: {x: 0, y: 0}
106106
- _NormalMapOS:

Packages/com.unity.render-pipelines.high-definition/Samples~/TransparentSamples/Materials/Models/Marble Blue.mat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ Material:
9595
m_Scale: {x: 1, y: 1}
9696
m_Offset: {x: 0, y: 0}
9797
- _MaskMap:
98-
m_Texture: {fileID: 2800000, guid: decd59cf305ad964bb384d3e0a9bd4b6, type: 3}
98+
m_Texture: {fileID: 2800000, guid: 5ed4ee65b96332c489342cd3aa01d63c, type: 3}
9999
m_Scale: {x: 1, y: 1}
100100
m_Offset: {x: 0, y: 0}
101101
- _NormalMap:
102-
m_Texture: {fileID: 2800000, guid: 10be5dc71ddc43b41994c5b5d60dde4c, type: 3}
102+
m_Texture: {fileID: 2800000, guid: 68d089e25cf7c5e48bf86174b5d00074, type: 3}
103103
m_Scale: {x: 1, y: 1}
104104
m_Offset: {x: 0, y: 0}
105105
- _NormalMapOS:

Packages/com.unity.render-pipelines.high-definition/Samples~/TransparentSamples/Materials/Models/Marble High Absorption.mat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ Material:
9595
m_Scale: {x: 1, y: 1}
9696
m_Offset: {x: 0, y: 0}
9797
- _MaskMap:
98-
m_Texture: {fileID: 2800000, guid: decd59cf305ad964bb384d3e0a9bd4b6, type: 3}
98+
m_Texture: {fileID: 2800000, guid: 5ed4ee65b96332c489342cd3aa01d63c, type: 3}
9999
m_Scale: {x: 1, y: 1}
100100
m_Offset: {x: 0, y: 0}
101101
- _NormalMap:
102-
m_Texture: {fileID: 2800000, guid: 10be5dc71ddc43b41994c5b5d60dde4c, type: 3}
102+
m_Texture: {fileID: 2800000, guid: 68d089e25cf7c5e48bf86174b5d00074, type: 3}
103103
m_Scale: {x: 1, y: 1}
104104
m_Offset: {x: 0, y: 0}
105105
- _NormalMapOS:

0 commit comments

Comments
 (0)