Skip to content

Commit bd02728

Browse files
HDRenderPipeline; Add Pom test level
1 parent 9162537 commit bd02728

34 files changed

Lines changed: 1508 additions & 91 deletions

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ Shader "HDRenderPipeline/LayeredLit"
154154
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1
155155
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
156156
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
157+
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
158+
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
157159
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
158160
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
159161

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ Shader "HDRenderPipeline/LayeredLitTesselation"
154154
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1
155155
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
156156
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
157+
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
158+
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
157159
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
158160
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
159161

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ protected static class Styles
3333
public static GUIContent UVBaseDetailMappingText = new GUIContent("UV set for Base and Detail", "");
3434
public static GUIContent normalMapSpaceText = new GUIContent("Normal/Tangent Map space", "");
3535
public static GUIContent enablePerPixelDisplacementText = new GUIContent("Enable Per Pixel Displacement", "");
36+
public static GUIContent ppdMinSamplesText = new GUIContent("Minimum samples", "Minimun samples to use with per pixel displacement mapping");
37+
public static GUIContent ppdMaxSamplesText = new GUIContent("Maximum samples", "Maximum samples to use with per pxiel displacement mapping");
38+
3639
public static GUIContent detailMapModeText = new GUIContent("Detail Map with Normal", "Detail Map with AO / Height");
3740
public static GUIContent UVDetailMappingText = new GUIContent("UV set for Detail", "");
3841
public static GUIContent emissiveColorModeText = new GUIContent("Emissive Color Usage", "Use emissive color or emissive mask");

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public enum EmissiveColorMode
6565
protected const string kNormalMapSpace = "_NormalMapSpace";
6666
protected MaterialProperty enablePerPixelDisplacement = null;
6767
protected const string kEnablePerPixelDisplacement = "_EnablePerPixelDisplacement";
68+
protected MaterialProperty ppdMinSamples = null;
69+
protected const string kPpdMinSamples = "_PPDMinSamples";
70+
protected MaterialProperty ppdMaxSamples = null;
71+
protected const string kPpdMaxSamples = "_PPDMaxSamples";
6872
protected MaterialProperty detailMapMode = null;
6973
protected const string kDetailMapMode = "_DetailMapMode";
7074
protected MaterialProperty UVDetail = null;
@@ -136,6 +140,8 @@ protected void FindMaterialOptionProperties(MaterialProperty[] props)
136140
smoothnessMapChannel = FindProperty(kSmoothnessTextureChannel, props);
137141
normalMapSpace = FindProperty(kNormalMapSpace, props);
138142
enablePerPixelDisplacement = FindProperty(kEnablePerPixelDisplacement, props);
143+
ppdMinSamples = FindProperty(kPpdMinSamples, props);
144+
ppdMaxSamples = FindProperty(kPpdMaxSamples, props);
139145
detailMapMode = FindProperty(kDetailMapMode, props);
140146
emissiveColorMode = FindProperty(kEmissiveColorMode, props);
141147
}
@@ -214,6 +220,9 @@ override protected void ShaderInputOptionsGUI()
214220
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText.text);
215221
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText.text);
216222
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, Styles.enablePerPixelDisplacementText.text);
223+
m_MaterialEditor.ShaderProperty(ppdMinSamples, Styles.ppdMinSamplesText.text);
224+
m_MaterialEditor.ShaderProperty(ppdMaxSamples, Styles.ppdMaxSamplesText.text);
225+
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
217226
EditorGUI.indentLevel--;
218227
}
219228

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ Shader "HDRenderPipeline/Lit"
8484
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0
8585
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
8686
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
87+
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
88+
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
8789
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
8890
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
8991
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)
90-
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
92+
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
9193
}
9294

9395
HLSLINCLUDE

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord l
230230
float3 viewDirTS = TransformWorldToTangent(V, input.tangentToWorld);
231231
// Change the number of samples per ray depending on the viewing angle for the surface.
232232
// Oblique angles require smaller step sizes to achieve more accurate precision for computing displacement.
233-
// int numSteps = (int)lerp(_PPPMaxSamples, _PPPMinSamples, viewDirTS.z);
234-
int numSteps = (int)lerp(15, 15, viewDirTS.z); // TEMP
233+
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
235234

236235
ParallaxOcclusionMappingLayer(layerTexCoord, numSteps, viewDirTS);
237236

@@ -422,7 +421,7 @@ void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord l
422421
{
423422
#if defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)
424423
float3 viewDirTS = TransformWorldToTangent(V, input.tangentToWorld);
425-
int numSteps = (int)lerp(15, 15, viewDirTS.z);
424+
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
426425

427426
ParallaxOcclusionMappingLayer0(layerTexCoord, numSteps, viewDirTS);
428427
ParallaxOcclusionMappingLayer1(layerTexCoord, numSteps, viewDirTS);

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void ADD_IDX(ParallaxOcclusionMappingLayer)(inout LayerTexCoord layerTexCoord, i
7878

7979
float2 uv = ADD_IDX(layerTexCoord.base).uv;
8080

81-
// Compute lod as we will sample inside a lop (so can't use regular sampling)
81+
// Compute lod as we will sample inside a loop (so can't use regular sampling)
8282
float lod = CALCULATE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv);
8383

8484
// Do a first step before the loop to init all value correctly

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ float _UVMappingPlanar;
7575
float4 _UVMappingMask;
7676
float4 _UVDetailsMappingMask;
7777

78+
float _PPDMaxSamples;
79+
float _PPDMinSamples;
80+
7881
#else // LAYERED_LIT_SHADER
7982

8083
// Set of users variables
@@ -155,6 +158,9 @@ PROP_DECL(float4, _UVDetailsMappingMask);
155158

156159
float _AlphaCutoff;
157160

161+
float _PPDMaxSamples;
162+
float _PPDMinSamples;
163+
158164
#endif // LAYERED_LIT_SHADER
159165

160166
// Tessellation specific

Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Shader "HDRenderPipeline/LitTessellation"
8484
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0
8585
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
8686
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
87+
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
88+
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
8789
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
8890
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
8991
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)

Assets/TestScenes/HDTest/GraphicTest.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)