浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into postfx-temp

/Branch_Batching2
Chman 8 年前
当前提交
1d022582
共有 62 个文件被更改,包括 2274 次插入1598 次删除
  1. 59
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs
  2. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader
  3. 257
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  4. 220
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  5. 1
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs
  6. 29
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
  7. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs
  8. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute
  9. 62
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  10. 11
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  11. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  12. 31
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  13. 66
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  14. 73
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  15. 48
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  16. 63
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  17. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  18. 33
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  19. 84
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  20. 624
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  21. 142
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  22. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  23. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
  24. 67
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
  25. 96
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader
  26. 25
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/SampleLayer.hlsl
  27. 60
      Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/SubsurfaceScatteringParameters.cs
  28. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/TessellationShare.hlsl
  29. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
  30. 46
      Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
  31. 29
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  32. 17
      Assets/TestScenes/HDTest/GraphicTest/LayeredTessellation/Layer-2-woord-rock.mat
  33. 920
      Assets/TestScenes/HDTest/LayeredLitTest.unity
  34. 64
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat
  35. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat.meta
  36. 53
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat
  37. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat.meta
  38. 49
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
  39. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat.meta
  40. 53
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
  41. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat.meta
  42. 49
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
  43. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat.meta
  44. 53
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat
  45. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat.meta
  46. 51
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat
  47. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat.meta
  48. 55
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat
  49. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat.meta
  50. 63
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat
  51. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat.meta
  52. 2
      ProjectSettings/QualitySettings.asset
  53. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl
  54. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl.meta
  55. 15
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl
  56. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl.meta
  57. 105
      Assets/ScriptableRenderLoop/ShaderLibrary/PerPixelDisplacement.hlsl
  58. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/PerPixelDisplacement.hlsl.meta
  59. 19
      Assets/TestScenes/HDTest/CascadedShadowsTest/CommonSettings_Cascaded.asset
  60. 9
      Assets/TestScenes/HDTest/CascadedShadowsTest/CommonSettings_Cascaded.asset.meta
  61. 20
      Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset
  62. 9
      Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset.meta

59
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs


public class GlobalDebugParameters
{
public float debugOverlayRatio = 0.33f;
public bool displayDebug = false;
public bool displayShadowDebug = false;
public bool displayMaterialDebug = false;
public bool displayRenderingDebug = false;
public bool displayLightingDebug = false;
public MaterialDebugParameters materialDebugParameters = new MaterialDebugParameters();
public LightingDebugParameters lightingDebugParameters = new LightingDebugParameters();
public RenderingDebugParameters renderingDebugParametrs = new RenderingDebugParameters();
public ShadowDebugParameters shadowDebugParameters = new ShadowDebugParameters();
public void OnValidate()
{
lightingDebugParameters.OnValidate();
}
public class DebugParameters
[Serializable]
public class MaterialDebugParameters
// Material Debugging
}
// Rendering debugging
[Serializable]
public class RenderingDebugParameters
{
public bool useForwardRenderingOnly = false; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepass = false;
public bool useDistortion = true;
// we have to fallback to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together
public bool ShouldUseForwardRenderingOnly() { return useForwardRenderingOnly || GL.wireframe; }
public bool enableDistortion = true;
}
public enum ShadowDebugMode

VisualizeShadowMap
}
[GenerateHLSL]
public enum LightingDebugMode
{
None,
DiffuseLighting,
SpecularLighting
}
public class ShadowDebugParameters
public class LightingDebugParameters
public bool enableShadows = true;
public ShadowDebugMode visualizationMode = ShadowDebugMode.None;
public uint visualizeShadowMapIndex = 0;
public bool enableShadows = true;
public ShadowDebugMode shadowDebugMode = ShadowDebugMode.None;
public uint shadowMapIndex = 0;
public LightingDebugMode lightingDebugMode = LightingDebugMode.None;
public bool overrideSmoothness = false;
public float overrideSmoothnessValue = 0.5f;
public Color debugLightingAlbedo = new Color(0.5f, 0.5f, 0.5f);
public void OnValidate()
{
overrideSmoothnessValue = Mathf.Clamp(overrideSmoothnessValue, 0.0f, 1.0f);
}
}
}

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader


#include "Common.hlsl"
TEXTURE2D(g_tShadowBuffer);
TEXTURE2D_FLOAT(g_tShadowBuffer);
TEXTURE2D(_DummyTexture);
SAMPLER2D(sampler_DummyTexture);

Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullscreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullscreenTriangleTexcoord(input.vertexID) * _TextureScaleBias.xy + _TextureScaleBias.zw;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullScreenTriangleTexcoord(input.vertexID) * _TextureScaleBias.xy + _TextureScaleBias.zw;
return output;
}

257
Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


{
private class Styles
{
// Global debug parameters
public readonly GUIContent debugging = new GUIContent("Debugging");
public readonly GUIContent debugOverlayRatio = new GUIContent("Overlay Ratio");
public readonly GUIContent settingsLabel = new GUIContent("Settings");
public readonly GUIContent debugParameters = new GUIContent("Debug Parameters");
public readonly GUIContent debugViewMaterial = new GUIContent("DebugView Material", "Display various properties of Materials.");
public readonly GUIContent displayOpaqueObjects = new GUIContent("Display Opaque Objects", "Toggle opaque objects rendering on and off.");
public readonly GUIContent displayTransparentObjects = new GUIContent("Display Transparent Objects", "Toggle transparent objects rendering on and off.");
// Rendering Settings
public readonly GUIContent renderingSettingsLabel = new GUIContent("Rendering Settings");
public readonly GUIContent useDistortion = new GUIContent("Use Distortion");
public bool isDebugViewMaterialInit = false;
public GUIContent[] debugViewMaterialStrings = null;
public int[] debugViewMaterialValues = null;
// Texture Settings
public readonly GUIContent textureSettings = new GUIContent("Texture Settings");
public readonly GUIContent spotCookieSize = new GUIContent("Spot cookie size");
public readonly GUIContent pointCookieSize = new GUIContent("Point cookie size");
public readonly GUIContent reflectionCubemapSize = new GUIContent("Reflection cubemap size");
public readonly GUIContent skyParams = new GUIContent("Sky Settings");
// Shadow Debug
public readonly GUIContent shadowDebugParameters = new GUIContent("Shadow Debug");
public readonly GUIContent shadowDebugEnable = new GUIContent("Enable Shadows");
public readonly GUIContent shadowDebugVisualizationMode = new GUIContent("Visualize");
public readonly GUIContent shadowDebugVisualizeShadowIndex = new GUIContent("Visualize Shadow Index");
// Shadow Settings
// Tile pass Settings
public readonly GUIContent tileLightLoopSettings = new GUIContent("Tile Light Loop Settings");
public readonly string[] tileLightLoopDebugTileFlagStrings = new string[] { "Punctual Light", "Area Light", "Env Light"};
public readonly GUIContent splitLightEvaluation = new GUIContent("Split light and reflection evaluation", "Toggle");

public readonly GUIContent disableDeferredShadingInCompute = new GUIContent("Disable deferred shading in compute", "Toggle");
public readonly GUIContent textureSettings = new GUIContent("Texture Settings");
// Sky Settings
public readonly GUIContent skyParams = new GUIContent("Sky Settings");
// Global debug parameters
public readonly GUIContent debugging = new GUIContent("Debugging");
public readonly GUIContent debugOverlayRatio = new GUIContent("Overlay Ratio");
public readonly GUIContent spotCookieSize = new GUIContent("Spot cookie size");
public readonly GUIContent pointCookieSize = new GUIContent("Point cookie size");
public readonly GUIContent reflectionCubemapSize = new GUIContent("Reflection cubemap size");
// Material debug
public readonly GUIContent materialDebugLabel = new GUIContent("Material Debug");
public readonly GUIContent debugViewMaterial = new GUIContent("DebugView Material", "Display various properties of Materials.");
public bool isDebugViewMaterialInit = false;
public GUIContent[] debugViewMaterialStrings = null;
public int[] debugViewMaterialValues = null;
// Rendering Debug
public readonly GUIContent renderingDebugParameters = new GUIContent("Rendering Debug");
public readonly GUIContent displayOpaqueObjects = new GUIContent("Display Opaque Objects", "Toggle opaque objects rendering on and off.");
public readonly GUIContent displayTransparentObjects = new GUIContent("Display Transparent Objects", "Toggle transparent objects rendering on and off.");
public readonly GUIContent enableDistortion = new GUIContent("Enable Distortion");
// Lighting Debug
public readonly GUIContent lightingDebugParameters = new GUIContent("Lighting Debug");
public readonly GUIContent shadowDebugEnable = new GUIContent("Enable Shadows");
public readonly GUIContent shadowDebugVisualizationMode = new GUIContent("Shadow Debug Mode");
public readonly GUIContent shadowDebugVisualizeShadowIndex = new GUIContent("Visualize Shadow Index");
public readonly GUIContent lightingDebugMode = new GUIContent("Lighting Debug Mode");
public readonly GUIContent lightingDebugOverrideSmoothness = new GUIContent("Override Smoothness");
public readonly GUIContent lightingDebugOverrideSmoothnessValue = new GUIContent("Smoothness Value");
public readonly GUIContent lightingDebugAlbedo = new GUIContent("Lighting Debug Albedo");
}
private static Styles s_Styles = null;

}
}
SerializedProperty m_ShowDebug = null;
SerializedProperty m_ShowDebugShadow = null;
// Global debug
SerializedProperty m_ShowMaterialDebug = null;
SerializedProperty m_ShowLightingDebug = null;
SerializedProperty m_ShowRenderingDebug = null;
// Rendering Debug
SerializedProperty m_MaterialDebugMode = null;
// Rendering Debug
SerializedProperty m_DisplayOpaqueObjects = null;
SerializedProperty m_DisplayTransparentObjects = null;
SerializedProperty m_EnableDistortion = null;
// Lighting debug
SerializedProperty m_DebugShadowVisualizationMode = null;
SerializedProperty m_DebugShadowVisualizeShadowIndex = null;
SerializedProperty m_ShadowDebugMode = null;
SerializedProperty m_ShadowDebugShadowMapIndex = null;
SerializedProperty m_LightingDebugMode = null;
SerializedProperty m_LightingDebugOverrideSmoothness = null;
SerializedProperty m_LightingDebugOverrideSmoothnessValue = null;
SerializedProperty m_LightingDebugAlbedo = null;
// Rendering Parameters
SerializedProperty m_RenderingUseForwardOnly = null;
SerializedProperty m_RenderingUseDepthPrepass = null;
// Global debug
m_ShowDebugShadow = FindProperty(x => x.globalDebugParameters.displayShadowDebug);
m_ShowDebug = FindProperty(x => x.globalDebugParameters.displayDebug);
m_ShowLightingDebug = FindProperty(x => x.globalDebugParameters.displayLightingDebug);
m_ShowRenderingDebug = FindProperty(x => x.globalDebugParameters.displayRenderingDebug);
m_ShowMaterialDebug = FindProperty(x => x.globalDebugParameters.displayMaterialDebug);
m_DebugShadowEnabled = FindProperty(x => x.globalDebugParameters.shadowDebugParameters.enableShadows);
m_DebugShadowVisualizationMode = FindProperty(x => x.globalDebugParameters.shadowDebugParameters.visualizationMode);
m_DebugShadowVisualizeShadowIndex = FindProperty(x => x.globalDebugParameters.shadowDebugParameters.visualizeShadowMapIndex);
// Material debug
m_MaterialDebugMode = FindProperty(x => x.globalDebugParameters.materialDebugParameters.debugViewMaterial);
// Rendering debug
m_DisplayOpaqueObjects = FindProperty(x => x.globalDebugParameters.renderingDebugParametrs.displayOpaqueObjects);
m_DisplayTransparentObjects = FindProperty(x => x.globalDebugParameters.renderingDebugParametrs.displayTransparentObjects);
m_EnableDistortion = FindProperty(x => x.globalDebugParameters.renderingDebugParametrs.enableDistortion);
// Lighting debug
m_DebugShadowEnabled = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.enableShadows);
m_ShadowDebugMode = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.shadowDebugMode);
m_ShadowDebugShadowMapIndex = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.shadowMapIndex);
m_LightingDebugMode = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.lightingDebugMode);
m_LightingDebugOverrideSmoothness = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.overrideSmoothness);
m_LightingDebugOverrideSmoothnessValue = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.overrideSmoothnessValue);
m_LightingDebugAlbedo = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.debugLightingAlbedo);
// Rendering settings
m_RenderingUseForwardOnly = FindProperty(x => x.renderingParameters.useForwardRenderingOnly);
m_RenderingUseDepthPrepass = FindProperty(x => x.renderingParameters.useDepthPrepass);
}
SerializedProperty FindProperty<TValue>(Expression<Func<HDRenderPipeline, TValue>> expr)

m_DebugOverlayRatio.floatValue = EditorGUILayout.Slider(styles.debugOverlayRatio, m_DebugOverlayRatio.floatValue, 0.1f, 1.0f);
EditorGUILayout.Space();
DebugParametersUI(renderContext);
MaterialDebugParametersUI(renderContext);
RenderingDebugParametersUI(renderContext);
LightingDebugParametersUI(renderContext, renderpipelineInstance);
ShadowDebugParametersUI(renderContext, renderpipelineInstance);
private void DebugParametersUI(HDRenderPipeline renderContext)
private void MaterialDebugParametersUI(HDRenderPipeline renderContext)
m_ShowDebug.boolValue = EditorGUILayout.Foldout(m_ShowDebug.boolValue, styles.debugParameters);
if (!m_ShowDebug.boolValue)
m_ShowMaterialDebug.boolValue = EditorGUILayout.Foldout(m_ShowMaterialDebug.boolValue, styles.materialDebugLabel);
if (!m_ShowMaterialDebug.boolValue)
var debugParameters = renderContext.debugParameters;
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();

styles.isDebugViewMaterialInit = true;
}
debugParameters.debugViewMaterial = EditorGUILayout.IntPopup(styles.debugViewMaterial, (int)debugParameters.debugViewMaterial, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
EditorGUILayout.Space();
debugParameters.displayOpaqueObjects = EditorGUILayout.Toggle(styles.displayOpaqueObjects, debugParameters.displayOpaqueObjects);
debugParameters.displayTransparentObjects = EditorGUILayout.Toggle(styles.displayTransparentObjects, debugParameters.displayTransparentObjects);
debugParameters.useForwardRenderingOnly = EditorGUILayout.Toggle(styles.useForwardRenderingOnly, debugParameters.useForwardRenderingOnly);
debugParameters.useDepthPrepass = EditorGUILayout.Toggle(styles.useDepthPrepass, debugParameters.useDepthPrepass);
debugParameters.useDistortion = EditorGUILayout.Toggle(styles.useDistortion, debugParameters.useDistortion);
EditorGUI.showMixedValue = m_MaterialDebugMode.hasMultipleDifferentValues;
m_MaterialDebugMode.intValue = EditorGUILayout.IntPopup(styles.debugViewMaterial, m_MaterialDebugMode.intValue, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
{

}
private void SkySettingsUI(HDRenderPipeline pipe)
private void RenderingDebugParametersUI(HDRenderPipeline renderContext)
EditorGUILayout.Space();
m_ShowRenderingDebug.boolValue = EditorGUILayout.Foldout(m_ShowRenderingDebug.boolValue, styles.renderingDebugParameters);
if (!m_ShowRenderingDebug.boolValue)
return;
EditorGUILayout.LabelField(styles.skyParams);
EditorGUI.BeginChangeCheck();
pipe.skyParameters = (SkyParameters) EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), pipe.skyParameters, typeof(SkyParameters), false);
pipe.lightLoopProducer = (LightLoopProducer) EditorGUILayout.ObjectField(new GUIContent("Light Loop"), pipe.lightLoopProducer, typeof(LightLoopProducer), false);
EditorGUILayout.PropertyField(m_DisplayOpaqueObjects, styles.displayOpaqueObjects);
EditorGUILayout.PropertyField(m_DisplayTransparentObjects, styles.displayTransparentObjects);
EditorGUILayout.PropertyField(m_EnableDistortion, styles.enableDistortion);
if (EditorGUI.EndChangeCheck())
{
HackSetDirty(pipe); // Repaint
}
}
private void SssSettingsUI(HDRenderPipeline pipe)

}
}
private void ShadowDebugParametersUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
private void LightingDebugParametersUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
m_ShowDebugShadow.boolValue = EditorGUILayout.Foldout(m_ShowDebugShadow.boolValue, styles.shadowDebugParameters);
if (!m_ShowDebugShadow.boolValue)
m_ShowLightingDebug.boolValue = EditorGUILayout.Foldout(m_ShowLightingDebug.boolValue, styles.lightingDebugParameters);
if (!m_ShowLightingDebug.boolValue)
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_DebugShadowVisualizationMode, styles.shadowDebugVisualizationMode);
if (!m_DebugShadowVisualizationMode.hasMultipleDifferentValues)
EditorGUILayout.PropertyField(m_ShadowDebugMode, styles.shadowDebugVisualizationMode);
if (!m_ShadowDebugMode.hasMultipleDifferentValues)
if ((ShadowDebugMode)m_DebugShadowVisualizationMode.intValue == ShadowDebugMode.VisualizeShadowMap)
if ((ShadowDebugMode)m_ShadowDebugMode.intValue == ShadowDebugMode.VisualizeShadowMap)
EditorGUILayout.IntSlider(m_DebugShadowVisualizeShadowIndex, 0, renderpipelineInstance.GetCurrentShadowCount() - 1, styles.shadowDebugVisualizeShadowIndex);
EditorGUILayout.IntSlider(m_ShadowDebugShadowMapIndex, 0, renderpipelineInstance.GetCurrentShadowCount() - 1, styles.shadowDebugVisualizeShadowIndex);
}
}
EditorGUILayout.PropertyField(m_LightingDebugMode, styles.lightingDebugMode);
if (!m_LightingDebugMode.hasMultipleDifferentValues)
{
if ((LightingDebugMode)m_LightingDebugMode.intValue != LightingDebugMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_LightingDebugAlbedo, styles.lightingDebugAlbedo);
EditorGUILayout.PropertyField(m_LightingDebugOverrideSmoothness, styles.lightingDebugOverrideSmoothness);
if (!m_LightingDebugOverrideSmoothness.hasMultipleDifferentValues && m_LightingDebugOverrideSmoothness.boolValue == true)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_LightingDebugOverrideSmoothnessValue, styles.lightingDebugOverrideSmoothnessValue);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
if (EditorGUI.EndChangeCheck())
{
HackSetDirty(renderContext);
}
}
private void SettingsUI(HDRenderPipeline renderContext)
{
EditorGUILayout.LabelField(styles.settingsLabel);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
renderContext.lightLoopProducer = (LightLoopProducer)EditorGUILayout.ObjectField(new GUIContent("Light Loop"), renderContext.lightLoopProducer, typeof(LightLoopProducer), false);
if (EditorGUI.EndChangeCheck())
{
HackSetDirty(renderContext); // Repaint
}
SkySettingsUI(renderContext);
SssSettingsUI(renderContext);
ShadowParametersUI(renderContext);
TextureParametersUI(renderContext);
RendereringParametersUI(renderContext);
//TilePassUI(renderContext);
EditorGUI.indentLevel--;
}
private void SkySettingsUI(HDRenderPipeline pipe)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.skyParams);
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel++;
pipe.skyParameters = (SkyParameters)EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), pipe.skyParameters, typeof(SkyParameters), false);
EditorGUI.indentLevel--;
if (EditorGUI.EndChangeCheck())
{
HackSetDirty(pipe); // Repaint
}
}
private void ShadowParametersUI(HDRenderPipeline renderContext)

{
HackSetDirty(renderContext); // Repaint
}
EditorGUI.indentLevel--;
}
private void RendereringParametersUI(HDRenderPipeline renderContext)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.renderingSettingsLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_RenderingUseDepthPrepass, styles.useDepthPrepass);
EditorGUILayout.PropertyField(m_RenderingUseForwardOnly, styles.useForwardRenderingOnly);
EditorGUI.indentLevel--;
}

serializedObject.Update();
DebuggingUI(renderContext, renderpipelineInstance);
SkySettingsUI(renderContext);
SssSettingsUI(renderContext);
ShadowParametersUI(renderContext);
TextureParametersUI(renderContext);
//TilePassUI(renderContext);
SettingsUI(renderContext);
serializedObject.ApplyModifiedProperties();
}

220
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


private HDRenderPipeline()
{}
[SerializeField]
private LightLoopProducer m_LightLoopProducer;
public LightLoopProducer lightLoopProducer
{
get { return m_LightLoopProducer; }
set { m_LightLoopProducer = value; }
}
[SerializeField]
private CommonSettings.Settings m_CommonSettings = CommonSettings.Settings.s_Defaultsettings;
protected override IRenderPipeline InternalCreatePipeline()
{
return new HDRenderPipelineInstance(this);
}
// NOTE:
// All those properties are public because of how HDRenderPipelineInspector retrieve those properties via serialization/reflection
// Debugging
public GlobalDebugParameters globalDebugParameters = new GlobalDebugParameters();
// Renderer Settings (per project)
public RenderingParameters renderingParameters = new RenderingParameters();
[SerializeField] ShadowSettings m_ShadowSettings = ShadowSettings.Default;
public SubsurfaceScatteringParameters localSssParameters;
[SerializeField] TextureSettings m_TextureSettings = TextureSettings.Default;
public ShadowSettings shadowSettings { get { return m_ShadowSettings; } }
public TextureSettings textureSettings { get { return m_TextureSettings; } set { m_TextureSettings = value; } }
// Renderer Settings (per "scene")
[SerializeField] private CommonSettings.Settings m_CommonSettings = CommonSettings.Settings.s_Defaultsettings;
[SerializeField] private SkyParameters m_SkyParameters;
public CommonSettings.Settings commonSettingsToUse
{

return m_CommonSettings;
}
}
[SerializeField]
private SkyParameters m_SkyParameters;
public SkyParameters skyParameters
{

}
}
[SerializeField]
public SubsurfaceScatteringParameters localSssParameters;
public SubsurfaceScatteringParameters sssParameters
{
get

if (localSssParameters == null)
{
localSssParameters = new SubsurfaceScatteringParameters();
localSssParameters = CreateInstance<SubsurfaceScatteringParameters>();
[SerializeField]
private LightLoopProducer m_LightLoopProducer;
public LightLoopProducer lightLoopProducer
public void ApplyDebugParameters()
get { return m_LightLoopProducer; }
set { m_LightLoopProducer = value; }
}
m_ShadowSettings.enabled = globalDebugParameters.lightingDebugParameters.enableShadows;
protected override IRenderPipeline InternalCreatePipeline()
{
return new HDRenderPipelineInstance(this);
}
// Debugging
public GlobalDebugParameters globalDebugParameters = new GlobalDebugParameters();
readonly DebugParameters m_DebugParameters = new DebugParameters();
LightingDebugParameters lightDebugParameters = globalDebugParameters.lightingDebugParameters;
Vector4 debugModeAndAlbedo = new Vector4((float)lightDebugParameters.lightingDebugMode, lightDebugParameters.debugLightingAlbedo.r, lightDebugParameters.debugLightingAlbedo.g, lightDebugParameters.debugLightingAlbedo.b);
Vector4 debugSmoothness = new Vector4(lightDebugParameters.overrideSmoothness ? 1.0f : 0.0f, lightDebugParameters.overrideSmoothnessValue, 0.0f, 0.0f);
Shader.SetGlobalVector("_DebugLightModeAndAlbedo", debugModeAndAlbedo);
Shader.SetGlobalVector("_DebugLightingSmoothness", debugSmoothness);
public DebugParameters debugParameters
{
get { return m_DebugParameters; }
[SerializeField]
ShadowSettings m_ShadowSettings = ShadowSettings.Default;
public ShadowSettings shadowSettings
public void UpdateCommonSettings()
get { return m_ShadowSettings; }
}
var commonSettings = commonSettingsToUse;
[SerializeField]
TextureSettings m_TextureSettings = TextureSettings.Default;
m_ShadowSettings.directionalLightCascadeCount = commonSettings.shadowCascadeCount;
m_ShadowSettings.directionalLightCascades = new Vector3(commonSettings.shadowCascadeSplit0, commonSettings.shadowCascadeSplit1, commonSettings.shadowCascadeSplit2);
m_ShadowSettings.maxShadowDistance = commonSettings.shadowMaxDistance;
}
public TextureSettings textureSettings
public void OnValidate()
get { return m_TextureSettings; }
set { m_TextureSettings = value; }
globalDebugParameters.OnValidate();
}
public void ApplyDebugParameters()
{
m_ShadowSettings.enabled = globalDebugParameters.shadowDebugParameters.enableShadows;
}
[Serializable]
public class RenderingParameters
{
public bool useForwardRenderingOnly = false; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepass = false;
public void UpdateCommonSettings()
// we have to fallback to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together
public bool ShouldUseForwardRenderingOnly()
var commonSettings = commonSettingsToUse;
m_ShadowSettings.directionalLightCascadeCount = commonSettings.shadowCascadeCount;
m_ShadowSettings.directionalLightCascades = new Vector3(commonSettings.shadowCascadeSplit0, commonSettings.shadowCascadeSplit1, commonSettings.shadowCascadeSplit2);
m_ShadowSettings.maxShadowDistance = commonSettings.shadowMaxDistance;
return useForwardRenderingOnly || GL.wireframe;
}
}

public Vector4 screenSize;
public Matrix4x4 viewProjectionMatrix;
public Matrix4x4 invViewProjectionMatrix;
public Matrix4x4 invProjectionMatrix;
}
public class GBufferManager

// Various set of material use in render loop
readonly Material m_DebugViewMaterialGBuffer;
readonly Material m_CombineSubsurfaceScattering;
readonly Material m_FilterSubsurfaceScattering;
readonly Material m_FilterAndCombineSubsurfaceScattering;
readonly Material m_DebugDisplayShadowMap;
// Various buffer

readonly SkyManager m_SkyManager = new SkyManager();
private readonly BaseLightLoop m_LightLoop;
private DebugParameters debugParameters
{
get { return m_Owner.debugParameters; }
}
private GlobalDebugParameters globalDebugParameters
{
get { return m_Owner.globalDebugParameters; }

m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");
m_CombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_FilterSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_FilterSubsurfaceScattering.DisableKeyword("FILTER_HORIZONTAL");
m_FilterSubsurfaceScattering.SetFloat("_DstBlend", (float)BlendMode.Zero);
m_FilterAndCombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_FilterSubsurfaceScattering.EnableKeyword("FILTER_HORIZONTAL");
m_FilterAndCombineSubsurfaceScattering.SetFloat("_DstBlend", (float)BlendMode.One);
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap");
m_ShadowPass = new ShadowRenderPass(owner.shadowSettings);

if (m_LightLoop != null)
m_LightLoop.NewFrame();
m_Owner. ApplyDebugParameters();
m_Owner.ApplyDebugParameters();
m_Owner.UpdateCommonSettings();
// Set Frame constant buffer

cmd.Dispose();
}
if (debugParameters.debugViewMaterial != 0)
if (globalDebugParameters.materialDebugParameters.debugViewMaterial != 0)
{
RenderDebugViewMaterial(cullResults, hdCamera, renderContext);
}

void RenderOpaqueRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, string passName, RendererConfiguration rendererConfiguration = 0)
{
if (!debugParameters.displayOpaqueObjects)
if (!globalDebugParameters.renderingDebugParametrs.displayOpaqueObjects)
return;
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName(passName))

void RenderTransparentRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, string passName, RendererConfiguration rendererConfiguration = 0)
{
if (!debugParameters.displayTransparentObjects)
if (!globalDebugParameters.renderingDebugParametrs.displayTransparentObjects)
return;
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName(passName))

{
// If we are forward only we will do a depth prepass
// TODO: Depth prepass should be enabled based on light loop settings. LightLoop define if they need a depth prepass + forward only...
if (!debugParameters.useDepthPrepass)
if (!m_Owner.renderingParameters.useDepthPrepass)
return;
using (new Utilities.ProfilingSample("Depth Prepass", renderContext))

void RenderGBuffer(CullResults cull, Camera camera, ScriptableRenderContext renderContext)
{
if (debugParameters.ShouldUseForwardRenderingOnly())
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
{
return ;
}

bool debugLighting = globalDebugParameters.lightingDebugParameters.lightingDebugMode != LightingDebugMode.None;
RenderOpaqueRenderList(cull, camera, renderContext, "GBuffer", Utilities.kRendererConfigurationBakedLighting);
RenderOpaqueRenderList(cull, camera, renderContext, debugLighting ? "GBufferDebugLighting" : "GBuffer", Utilities.kRendererConfigurationBakedLighting);
}
}

// If we are forward only we don't need to render ForwardOnlyOpaqueDepthOnly object
// But in case we request a prepass we render it
if (debugParameters.ShouldUseForwardRenderingOnly() && !debugParameters.useDepthPrepass)
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly() && !m_Owner.renderingParameters.useDepthPrepass)
return;
using (new Utilities.ProfilingSample("Forward opaque depth", renderContext))

{
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, Utilities.kClearAll, Color.black);
Shader.SetGlobalInt("_DebugViewMaterial", (int)debugParameters.debugViewMaterial);
Shader.SetGlobalInt("_DebugViewMaterial", (int)globalDebugParameters.materialDebugParameters.debugViewMaterial);
if (!debugParameters.ShouldUseForwardRenderingOnly())
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
m_DebugViewMaterialGBuffer.SetFloat("_DebugViewMaterial", (float)debugParameters.debugViewMaterial);
m_DebugViewMaterialGBuffer.SetFloat("_DebugViewMaterial", (float)globalDebugParameters.materialDebugParameters.debugViewMaterial);
// m_gbufferManager.BindBuffers(m_DebugViewMaterialGBuffer);
// TODO: Bind depth textures

void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext)
{
if (debugParameters.ShouldUseForwardRenderingOnly() || m_LightLoop == null)
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly() || m_LightLoop == null)
{
return ;
}

// Output split lighting for materials tagged with the SSS stencil bit.
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, colorRTs, m_CameraStencilBufferRT, true);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, globalDebugParameters.lightingDebugParameters, colorRTs, m_CameraStencilBufferRT, true);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, colorRTs, m_CameraStencilBufferRT, false);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, globalDebugParameters.lightingDebugParameters, colorRTs, m_CameraStencilBufferRT, false);
}
// Combines specular lighting and diffuse lighting with subsurface scattering.

if (debugParameters.ShouldUseForwardRenderingOnly()) return;
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly()) return;
// Assume that the height of the projection window is 2 meters.
float distanceToProjectionWindow = 1.0f / Mathf.Tan(0.5f * Mathf.Deg2Rad * hdCamera.camera.fieldOfView);
m_CombineSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow);
m_CombineSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale);
// TODO: use user-defined values for '_ProfileID' and '_FilterRadius.'
m_CombineSubsurfaceScattering.SetVectorArray("_FilterKernel", sssParameters.profiles[0].filterKernel);
m_CombineSubsurfaceScattering.SetFloat("_FilterRadius", 3.0f);
MaterialPropertyBlock properties = new MaterialPropertyBlock();
// Load the kernel data.
Vector4[] kernelData = new Vector4[SubsurfaceScatteringParameters.maxNumProfiles * SubsurfaceScatteringProfile.numVectors];
for (int j = 0, m = sssParameters.profiles.Length; j < m; j++)
{
for (int i = 0, n = SubsurfaceScatteringProfile.numVectors; i < n; i++)
{
kernelData[n * j + i] = sssParameters.profiles[j].filterKernel[i];
}
}
var cmd = new CommandBuffer() { name = "Combine Subsurface Scattering" };
var cmd = new CommandBuffer() { name = "Subsurface Scattering Pass" };
properties.SetFloat("_DstBlend", (float)BlendMode.Zero); // TODO: this doesn't work for some reason...
properties.SetFloat("_FilterHorizontal", 0);
m_FilterSubsurfaceScattering.SetMatrix("_InvProjMatrix", hdCamera.invProjectionMatrix);
m_FilterSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData);
Utilities.DrawFullscreen(cmd, m_CombineSubsurfaceScattering, hdCamera,
m_CameraFilteringBufferRT, m_CameraStencilBufferRT, properties);
Utilities.DrawFullScreen(cmd, m_FilterSubsurfaceScattering, hdCamera,
m_CameraFilteringBufferRT, m_CameraStencilBufferRT);
properties.SetFloat("_DstBlend", (float)BlendMode.One); // TODO: this doesn't work for some reason...
properties.SetFloat("_FilterHorizontal", 1);
m_FilterAndCombineSubsurfaceScattering.SetMatrix("_InvProjMatrix", hdCamera.invProjectionMatrix);
m_FilterAndCombineSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData);
Utilities.DrawFullscreen(cmd, m_CombineSubsurfaceScattering, hdCamera,
m_CameraColorBufferRT, m_CameraStencilBufferRT, properties);
Utilities.DrawFullScreen(cmd, m_FilterAndCombineSubsurfaceScattering, hdCamera,
m_CameraColorBufferRT, m_CameraStencilBufferRT);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();

{
// TODO: Currently we can't render opaque object forward when deferred is enabled
// miss option
if (!debugParameters.ShouldUseForwardRenderingOnly() && renderOpaque)
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly() && renderOpaque)
return;
using (new Utilities.ProfilingSample("Forward Pass", renderContext))

if (m_LightLoop != null)
m_LightLoop.RenderForward(camera, renderContext, renderOpaque);
bool debugLighting = globalDebugParameters.lightingDebugParameters.lightingDebugMode != LightingDebugMode.None;
string forwardPassName = debugLighting ? "ForwardDebugLighting" : "Forward";
RenderOpaqueRenderList(cullResults, camera, renderContext, "Forward", Utilities.kRendererConfigurationBakedLighting);
RenderOpaqueRenderList(cullResults, camera, renderContext, forwardPassName, Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cullResults, camera, renderContext, "Forward", Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cullResults, camera, renderContext, forwardPassName, Utilities.kRendererConfigurationBakedLighting);
}
}
}

if (m_LightLoop != null)
m_LightLoop.RenderForward(camera, renderContext, true);
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardOnlyOpaque", Utilities.kRendererConfigurationBakedLighting);
bool debugLighting = globalDebugParameters.lightingDebugParameters.lightingDebugMode != LightingDebugMode.None;
RenderOpaqueRenderList(cullResults, camera, renderContext, debugLighting ? "ForwardOnlyOpaqueDebugLighting" : "ForwardOnlyOpaque", Utilities.kRendererConfigurationBakedLighting);
}
}

{
// If opaque velocity have been render during GBuffer no need to render it here
if ((ShaderConfig.s_VelocityInGbuffer == 1) || debugParameters.ShouldUseForwardRenderingOnly())
if ((ShaderConfig.s_VelocityInGbuffer == 1) || m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
return ;
int w = camera.pixelWidth;

void RenderDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
{
if (!debugParameters.useDistortion)
if (!globalDebugParameters.renderingDebugParametrs.enableDistortion)
return ;
using (new Utilities.ProfilingSample("Distortion Pass", renderContext))

MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
ShadowDebugParameters shadowDebug = globalDebugParameters.shadowDebugParameters;
LightingDebugParameters shadowDebug = globalDebugParameters.lightingDebugParameters;
if (shadowDebug.visualizationMode != ShadowDebugMode.None)
if (shadowDebug.shadowDebugMode != ShadowDebugMode.None)
if (shadowDebug.visualizationMode == ShadowDebugMode.VisualizeShadowMap)
if (shadowDebug.shadowDebugMode == ShadowDebugMode.VisualizeShadowMap)
uint visualizeShadowIndex = Math.Min(shadowDebug.visualizeShadowMapIndex, (uint)(GetCurrentShadowCount() - 1));
uint visualizeShadowIndex = Math.Min(shadowDebug.shadowMapIndex, (uint)(GetCurrentShadowCount() - 1));
ShadowLight shadowLight = m_ShadowsResult.shadowLights[visualizeShadowIndex];
for (int slice = 0; slice < shadowLight.shadowSliceCount; ++slice)
{

NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
}
else if (shadowDebug.visualizationMode == ShadowDebugMode.VisualizeAtlas)
else if (shadowDebug.shadowDebugMode == ShadowDebugMode.VisualizeAtlas)
{
propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));

cmd.GetTemporaryRT(m_CameraDepthStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(m_CameraStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
if (!m_Owner.debugParameters.ShouldUseForwardRenderingOnly())
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
{
m_gbufferManager.InitGBuffers(w, h, cmd);
}

}
// Clear GBuffers
if (!debugParameters.ShouldUseForwardRenderingOnly())
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
{
using (new Utilities.ProfilingSample("Clear GBuffer", renderContext))
{

1
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs


public virtual void PushGlobalParams(Camera camera, ScriptableRenderContext loop) {}
public virtual void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext,
LightingDebugParameters lightDebugParameters,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier stencilBuffer,
bool outputSplitLighting) {}

29
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader


ZWrite Off
ZTest Always
Blend [_SrcBlend][_DstBlend]
Blend [_SrcBlend] [_DstBlend], One Zero
Cull Off
HLSLPROGRAM

// Split lighting is utilized during the SSS pass.
#pragma multi_compile _ OUTPUT_SPLIT_LIGHTING
#pragma multi_compile _ LIGHTING_DEBUG
//-------------------------------------------------------------------------------------
// Include

#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),

DECLARE_GBUFFER_TEXTURE(_GBufferTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
struct Attributes
{

Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullscreenTriangleVertexPosition(input.vertexID);
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
return output;
}

PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
float3 diffuseLighting;
float3 specularLighting;
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
float3 diffuseLighting = float3(0, 0, 0);
float3 specularLighting = float3(0, 0, 0);
#if UNITY_REVERSED_Z
float clearDepth = 0;
#else
float clearDepth = 1;
#endif
// Do not shade the far plane - wastes cycles and produces wrong results.
if (depth != clearDepth)
{
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
}
Outputs outputs;
#ifdef OUTPUT_SPLIT_LIGHTING

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs


#endif
[Serializable]
public struct TileSettings
public class TileSettings
{
public bool enableDrawLightBoundsDebug;
public bool disableTileAndCluster; // For debug / test

8
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute


#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST=1
#pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST=1
#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST
#pragma kernel ShadeOpaque_Fptl_DebugLighting SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl_DebugLighting USE_FPTL_LIGHTLIST LIGHTING_DEBUG
#pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST
#pragma kernel ShadeOpaque_Clustered_DebugLighting SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered_DebugLighting USE_CLUSTERED_LIGHTLIST LIGHTING_DEBUG
// Split lighting is required for the SSS pass.
// Not currently possible since we need to access the stencil buffer from the compute shader.

//-------------------------------------------------------------------------------------
#include "Common.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),

62
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs


static int s_ClearVoxelAtomicKernel;
static int s_shadeOpaqueClusteredKernel;
static int s_shadeOpaqueFptlKernel;
static int s_shadeOpaqueClusteredDebugLightingKernel;
static int s_shadeOpaqueFptlDebugLightingKernel;
static ComputeBuffer s_LightVolumeDataBuffer = null;
static ComputeBuffer s_ConvexBoundsBuffer = null;

s_shadeOpaqueClusteredKernel = shadeOpaqueShader.FindKernel("ShadeOpaque_Clustered");
s_shadeOpaqueFptlKernel = shadeOpaqueShader.FindKernel("ShadeOpaque_Fptl");
s_shadeOpaqueClusteredDebugLightingKernel = shadeOpaqueShader.FindKernel("ShadeOpaque_Clustered_DebugLighting");
s_shadeOpaqueFptlDebugLightingKernel = shadeOpaqueShader.FindKernel("ShadeOpaque_Fptl_DebugLighting");
s_LightList = null;

m_DeferredIndirectMaterialSRT.DisableKeyword("OUTPUT_SPLIT_LIGHTING");
m_DeferredIndirectMaterialSRT.SetInt("_StencilRef", (int)StencilBits.None);
m_DeferredIndirectMaterialSRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredIndirectMaterialSRT.SetInt("_DstBlend", (int)BlendMode.One); // Additive
m_DeferredIndirectMaterialSRT.SetInt("_DstBlend", (int)BlendMode.One); // Additive color & alpha source
m_DeferredIndirectMaterialMRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredIndirectMaterialMRT, tileKeywords, 1);

m_DeferredIndirectMaterialMRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredIndirectMaterialMRT.SetInt("_DstBlend", (int)BlendMode.One); // Additive
m_DeferredIndirectMaterialMRT.SetInt("_DstBlend", (int)BlendMode.One); // Additive color & alpha source
m_DeferredAllMaterialSRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredAllMaterialSRT, tileKeywords, 2);

if (additionalData == null)
{
// PreRenderLight is used to display preview
if (light.light.name != "PreRenderLight")
// Don't display warning for the preview windows
if (camera.cameraType != CameraType.Preview)
Debug.LogWarningFormat("Light entity {0} has no additional data, will be rendered using default values.", light.light.name);
Debug.LogWarningFormat("Light entity {0} has no additional data, will be rendered using default values.", light.light.name);
}
additionalData = DefaultAdditionalLightData;
}

Shader.SetGlobalFloat(name, value);
}
private void SetGlobalVector(string name, Vector4 value)
{
if (activeComputeShader)
activeCommandBuffer.SetComputeVectorParam(activeComputeShader, name, value);
else
Shader.SetGlobalVector(name, value);
}
private void SetGlobalVectorArray(string name, Vector4[] values)
{
if (activeComputeShader)

}
#endif
private void SetupRenderingForDebug(LightingDebugParameters lightDebugParameters)
{
Utilities.SetKeyword(m_DeferredDirectMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredDirectMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredIndirectMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredIndirectMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredAllMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredAllMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_SingleDeferredMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_SingleDeferredMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
}
LightingDebugParameters lightDebugParameters,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier stencilBuffer,
bool outputSplitLighting)
{

mousePixelCoord.y = (hdCamera.screenSize.y - 1.0f) - mousePixelCoord.y;
}
#endif
using (new Utilities.ProfilingSample(m_PassSettings.disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderContext))
{
var cmd = new CommandBuffer();

SetGlobalPropertyRedirect(shadeOpaqueShader, usingFptl ? s_shadeOpaqueFptlKernel : s_shadeOpaqueClusteredKernel, cmd);
if (lightDebugParameters.lightingDebugMode == LightingDebugMode.None)
SetGlobalPropertyRedirect(shadeOpaqueShader, usingFptl ? s_shadeOpaqueFptlKernel : s_shadeOpaqueClusteredKernel, cmd);
else
SetGlobalPropertyRedirect(shadeOpaqueShader, usingFptl ? s_shadeOpaqueFptlDebugLightingKernel : s_shadeOpaqueClusteredDebugLightingKernel, cmd);
// In case of bUseClusteredForDeferred disable toggle option since we're using m_perVoxelLightLists as opposed to lightList
if (bUseClusteredForDeferred)

// Must be done after setting up the compute shader above.
SetupRenderingForDebug(lightDebugParameters);
Utilities.DrawFullscreen(cmd, m_SingleDeferredMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullScreen(cmd, m_SingleDeferredMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullscreen(cmd, m_SingleDeferredMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
Utilities.DrawFullScreen(cmd, m_SingleDeferredMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
}
}
else

if (outputSplitLighting)
{
Utilities.SelectKeyword(m_DeferredDirectMaterialMRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullscreen(cmd, m_DeferredDirectMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullScreen(cmd, m_DeferredDirectMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullscreen(cmd, m_DeferredIndirectMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullScreen(cmd, m_DeferredIndirectMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullscreen(cmd, m_DeferredDirectMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
Utilities.DrawFullScreen(cmd, m_DeferredDirectMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
Utilities.DrawFullscreen(cmd, m_DeferredIndirectMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
Utilities.DrawFullScreen(cmd, m_DeferredIndirectMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
}
}
else

Utilities.SelectKeyword(m_DeferredAllMaterialMRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullscreen(cmd, m_DeferredAllMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullScreen(cmd, m_DeferredAllMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.DrawFullscreen(cmd, m_DeferredAllMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
Utilities.DrawFullScreen(cmd, m_DeferredAllMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
}
}
}

11
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl


// Gets the cascade weights based on the world position of the fragment and the positions of the split spheres for each cascade.
// Returns an invalid split index if past shadowDistance (ie 4 is invalid for cascade)
uint GetSplitSphereIndexForDirshadows(float3 positionWS, float4 dirShadowSplitSpheres[4])
int GetSplitSphereIndexForDirshadows(float3 positionWS, float4 dirShadowSplitSpheres[4])
{
float3 fromCenter0 = positionWS.xyz - dirShadowSplitSpheres[0].xyz;
float3 fromCenter1 = positionWS.xyz - dirShadowSplitSpheres[1].xyz;

dirShadowSplitSphereSqRadii.z = dirShadowSplitSpheres[2].w;
dirShadowSplitSphereSqRadii.w = dirShadowSplitSpheres[3].w;
if (distances2.w > dirShadowSplitSphereSqRadii.w)
return -1;
return uint(4.0 - dot(weights, float4(4.0, 3.0, 2.0, 1.0)));
return int(4.0 - dot(weights, float4(4.0, 3.0, 2.0, 1.0)));
uint shadowSplitIndex = GetSplitSphereIndexForDirshadows(positionWS, _DirShadowSplitSpheres);
int shadowSplitIndex = GetSplitSphereIndexForDirshadows(positionWS, _DirShadowSplitSpheres);
if (shadowSplitIndex == -1)
return 1.0;
ShadowData shadowData = _ShadowDatas[shadowSplitIndex];

20
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl


// LightLoop
// ----------------------------------------------------------------------------
void ApplyDebug(inout float3 diffuseLighting, inout float3 specularLighting)
{
#ifdef LIGHTING_DEBUG
int lightDebugMode = (int)_DebugLightModeAndAlbedo.x;
if (lightDebugMode == LIGHTINGDEBUGMODE_DIFFUSE_LIGHTING)
{
specularLighting = float3(0.0, 0.0, 0.0);
}
else if (lightDebugMode == LIGHTINGDEBUGMODE_SPECULAR_LIGHTING)
{
diffuseLighting = float3(0.0, 0.0, 0.0);
}
#endif
}
#ifdef LIGHTLOOP_TILE_PASS
// Calculate the offset in global light index light for current light category

// Add indirect diffuse + emissive (if any)
diffuseLighting += bakeDiffuseLighting;
#endif
ApplyDebug(diffuseLighting, specularLighting);
}
#else // LIGHTLOOP_SINGLE_PASS

// Add indirect diffuse + emissive (if any)
diffuseLighting += bakeDiffuseLighting;
ApplyDebug(diffuseLighting, specularLighting);
}
#endif

31
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


MaterialProperty[] heightFactor = new MaterialProperty[kMaxLayerCount];
const string kHeightCenterOffset = "_HeightCenterOffset";
MaterialProperty[] heightCenterOffset = new MaterialProperty[kMaxLayerCount];
const string kLayerHeightAmplitude = "_LayerHeightAmplitude";
MaterialProperty[] layerHeightAmplitude = new MaterialProperty[kMaxLayerCount];
const string kLayerCenterOffset = "_LayerCenterOffset";
MaterialProperty[] layerCenterOffset = new MaterialProperty[kMaxLayerCount];
const string kBlendUsingHeight = "_BlendUsingHeight";
MaterialProperty[] blendUsingHeight = new MaterialProperty[kMaxLayerCount - 1];

opacityAsDensity[i] = FindProperty(string.Format("{0}{1}", kOpacityAsDensity, i), props);
heightFactor[i] = FindProperty(string.Format("{0}{1}", kHeightFactor, i), props);
heightCenterOffset[i] = FindProperty(string.Format("{0}{1}", kHeightCenterOffset, i), props);
layerHeightAmplitude[i] = FindProperty(string.Format("{0}{1}", kLayerHeightAmplitude, i), props);
layerCenterOffset[i] = FindProperty(string.Format("{0}{1}", kLayerCenterOffset, i), props);
if(i != 0)
if (i != 0)
{
blendUsingHeight[i - 1] = FindProperty(string.Format("{0}{1}", kBlendUsingHeight, i), props);
inheritBaseNormal[i - 1] = FindProperty(string.Format("{0}{1}", kInheritBaseNormal, i), props);

{
warningInputOptions += "Normal Map Space: " + optionValueNames + "\n";
}
if (!CheckInputFloatOptionConsistency(kEnablePerPixelDisplacement, ref optionValueNames))
{
warningInputOptions += "Per pixel displacement: " + optionValueNames + "\n";
}
if (!CheckInputOptionConsistency(kDetailMapMode, detailModeShortNames, ref optionValueNames))
{
warningInputOptions += "Detail Map Mode: " + optionValueNames + "\n";

if (!CheckInputMapConsistency(kSpecularOcclusionMap, ref optionValueNames))
{
warningInputMaps += "Specular Occlusion Map: " + optionValueNames + "\n";
}
if (!CheckInputMapConsistency(kHeightMap, ref optionValueNames))
{
warningInputMaps += "Height Map: " + optionValueNames + "\n";
}
if (warningInputMaps != string.Empty)

{
material.SetFloat(kSmoothnessTextureChannel, firstLayer.GetFloat(kSmoothnessTextureChannel));
material.SetFloat(kNormalMapSpace, firstLayer.GetFloat(kNormalMapSpace));
material.SetFloat(kEnablePerPixelDisplacement, firstLayer.GetFloat(kEnablePerPixelDisplacement));
// Force emissive to be emissive color
material.SetFloat(kEmissiveColorMode, (float)EmissiveColorMode.UseEmissiveColor);
}

EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightFactor[layerIndex], styles.heightFactorText);
layerHeightAmplitude[layerIndex].floatValue = material.GetFloat(kHeightAmplitude + layerIndex) * heightFactor[layerIndex].floatValue;
layerCenterOffset[layerIndex].floatValue = material.GetFloat(kHeightCenter + layerIndex) + heightCenterOffset[layerIndex].floatValue;
EditorGUI.indentLevel--;
// influence

SetKeyword(material, "_NORMALMAP", material.GetTexture(kNormalMap + i));
SetKeyword(material, "_MASKMAP", material.GetTexture(kMaskMap + i));
SetKeyword(material, "_SPECULAROCCLUSIONMAP", material.GetTexture(kSpecularOcclusionMap + i));
SetKeyword(material, "_HEIGHTMAP", material.GetTexture(kHeightMap + i));
bool perPixelDisplacement = material.GetFloat(kEnablePerPixelDisplacement) == 1.0;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT", perPixelDisplacement);
SetKeyword(material, "_HEIGHTMAP0", material.GetTexture(kHeightMap + 0));
SetKeyword(material, "_HEIGHTMAP1", material.GetTexture(kHeightMap + 1));
SetKeyword(material, "_HEIGHTMAP2", material.GetTexture(kHeightMap + 2));
SetKeyword(material, "_HEIGHTMAP3", material.GetTexture(kHeightMap + 3));
bool perPixelDisplacement = material.GetFloat(kEnablePerPixelDisplacement) == 1.0;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT", perPixelDisplacement);
SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap));

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


_HeightFactor2("_HeightFactor2", Float) = 1
_HeightFactor3("_HeightFactor3", Float) = 1
_LayerHeightAmplitude0("_LayerHeightAmplitude0", Float) = 1
_LayerHeightAmplitude1("_LayerHeightAmplitude1", Float) = 1
_LayerHeightAmplitude2("_LayerHeightAmplitude2", Float) = 1
_LayerHeightAmplitude3("_LayerHeightAmplitude3", Float) = 1
_LayerCenterOffset0("_LayerCenterOffset0", Float) = 0.0
_LayerCenterOffset1("_LayerCenterOffset1", Float) = 0.0
_LayerCenterOffset2("_LayerCenterOffset2", Float) = 0.0
_LayerCenterOffset3("_LayerCenterOffset3", Float) = 0.0
_BlendUsingHeight1("_BlendUsingHeight1", Float) = 0.0
_BlendUsingHeight2("_BlendUsingHeight2", Float) = 0.0
_BlendUsingHeight3("_BlendUsingHeight3", Float) = 0.0

[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1

_TexWorldScale2("Tiling", Float) = 1.0
_TexWorldScale3("Tiling", Float) = 1.0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0

#pragma shader_feature _MASKMAP
#pragma shader_feature _SPECULAROCCLUSIONMAP
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _HEIGHTMAP0
#pragma shader_feature _HEIGHTMAP1
#pragma shader_feature _HEIGHTMAP2
#pragma shader_feature _HEIGHTMAP3
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD
#pragma shader_feature _MAIN_LAYER_INFLUENCE_MODE

Pass
{
Name "GBufferDebugLighting" // Name is not used
Tags{ "LightMode" = "GBufferDebugLighting" } // This will be only for opaque object based on the RenderQueue index
Cull[_CullMode]
HLSLPROGRAM
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_GBUFFER
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "Debug"
Tags{ "LightMode" = "DebugViewMaterial" }

#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardDebugLighting" // Name is not used
Tags{ "LightMode" = "ForwardDebugLighting" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

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


_HeightFactor2("_HeightFactor2", Float) = 1
_HeightFactor3("_HeightFactor3", Float) = 1
_LayerHeightAmplitude0("_LayerHeightAmplitude0", Float) = 1
_LayerHeightAmplitude1("_LayerHeightAmplitude1", Float) = 1
_LayerHeightAmplitude2("_LayerHeightAmplitude2", Float) = 1
_LayerHeightAmplitude3("_LayerHeightAmplitude3", Float) = 1
_LayerCenterOffset0("_LayerCenterOffset0", Float) = 0.0
_LayerCenterOffset1("_LayerCenterOffset1", Float) = 0.0
_LayerCenterOffset2("_LayerCenterOffset2", Float) = 0.0
_LayerCenterOffset3("_LayerCenterOffset3", Float) = 0.0
_BlendUsingHeight1("_BlendUsingHeight1", Float) = 0.0
_BlendUsingHeight2("_BlendUsingHeight2", Float) = 0.0

[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1

_TexWorldScale2("Tiling", Float) = 1.0
_TexWorldScale3("Tiling", Float) = 1.0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0

#pragma shader_feature _MASKMAP
#pragma shader_feature _SPECULAROCCLUSIONMAP
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _HEIGHTMAP0
#pragma shader_feature _HEIGHTMAP1
#pragma shader_feature _HEIGHTMAP2
#pragma shader_feature _HEIGHTMAP3
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD
#pragma shader_feature _MAIN_LAYER_INFLUENCE_MODE

Pass
{
Name "GBufferDebugLighting" // Name is not used
Tags{ "LightMode" = "GBufferDebugLighting" } // This will be only for opaque object based on the RenderQueue index
Cull[_CullMode]
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_GBUFFER
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "Debug"
Tags{ "LightMode" = "DebugViewMaterial" }

#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardDebugLighting" // Name is not used
Tags{ "LightMode" = "ForwardDebugLighting" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

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


public static GUIContent enablePerPixelDisplacementText = new GUIContent("Enable Per Pixel Displacement", "");
public static GUIContent ppdMinSamplesText = new GUIContent("Minimum samples", "Minimun samples to use with per pixel displacement mapping");
public static GUIContent ppdMaxSamplesText = new GUIContent("Maximum samples", "Maximum samples to use with per pxiel displacement mapping");
public static GUIContent ppdLodThresholdText = new GUIContent("Fading LOD start", "Starting Lod where the parallax occlusion mapping effect start to disappear");
public static GUIContent detailMapModeText = new GUIContent("Detail Map with Normal", "Detail Map with AO / Height");
public static GUIContent UVDetailMappingText = new GUIContent("UV set for Detail", "");
public static GUIContent emissiveColorModeText = new GUIContent("Emissive Color Usage", "Use emissive color or emissive mask");

public static GUIContent tessellationBackFaceCullEpsilonText = new GUIContent("Triangle culling Epsilon", "If -1.0 back face culling is enabled for tessellation, higher number mean more aggressive culling and better performance");
public static GUIContent tessellationObjectScaleText = new GUIContent("Enable object scale", "Tesselation displacement will take into account the object scale - Only work with uniform positive scale");
public static GUIContent materialIDText = new GUIContent("Material Class", "Subsurface Scattering: enable for translucent materials such as skin, vegetation, fruit, marble, wax and milk.");
public static GUIContent subsurfaceProfileText = new GUIContent("Subsurface scattering profile", "A profile determines the shape of the blur filter.");
public static GUIContent subsurfaceRadiusText = new GUIContent("Subsurface scattering radius", "Determines the range of the blur.");
public static GUIContent subsurfaceRadiusMapText = new GUIContent("Subsurface scattering radius map", "Determines the range of the blur.");
public static GUIContent thicknessText = new GUIContent("Thickness", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
public static GUIContent thicknessMapText = new GUIContent("Thickness map", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
public static GUIContent perPixelDisplacementText = new GUIContent("Per pixel displacement", "Per pixel displacement options");
public static GUIContent materialIDText = new GUIContent("Material type", "Subsurface Scattering: enable for translucent materials such as skin, vegetation, fruit, marble, wax and milk.");
public static GUIContent subsurfaceProfileText = new GUIContent("Subsurface profile", "A profile determines the shape of the blur filter.");
public static GUIContent subsurfaceRadiusText = new GUIContent("Subsurface radius", "Determines the range of the blur.");
public static GUIContent subsurfaceRadiusMapText = new GUIContent("Subsurface radius map", "Determines the range of the blur.");
public static GUIContent thicknessText = new GUIContent("Thickness", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
public static GUIContent thicknessMapText = new GUIContent("Thickness map", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
}
public enum SurfaceType

m_MaterialEditor.ShaderProperty(tessellationObjectScale, Styles.tessellationObjectScaleText);
EditorGUI.indentLevel--;
}
GUILayout.Label(Styles.perPixelDisplacementText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, Styles.enablePerPixelDisplacementText);
if (enablePerPixelDisplacement.floatValue > 0.0)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(ppdMinSamples, Styles.ppdMinSamplesText);
m_MaterialEditor.ShaderProperty(ppdMaxSamples, Styles.ppdMaxSamplesText);
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
m_MaterialEditor.ShaderProperty(ppdLodThreshold, Styles.ppdLodThresholdText);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
protected void FindCommonOptionProperties(MaterialProperty[] props)

tessellationShapeFactor = FindProperty(kTessellationShapeFactor, props, false);
tessellationBackFaceCullEpsilon = FindProperty(kTessellationBackFaceCullEpsilon, props, false);
tessellationObjectScale = FindProperty(kTessellationObjectScale, props, false);
// Per pixel displacement
enablePerPixelDisplacement = FindProperty(kEnablePerPixelDisplacement, props);
ppdMinSamples = FindProperty(kPpdMinSamples, props);
ppdMaxSamples = FindProperty(kPpdMaxSamples, props);
ppdLodThreshold = FindProperty(kPpdLodThreshold, props);
}
protected void SetupCommonOptionsKeywords(Material material)

const string kTessellationBackFaceCullEpsilon = "_TessellationBackFaceCullEpsilon";
MaterialProperty tessellationObjectScale = null;
const string kTessellationObjectScale = "_TessellationObjectScale";
// Per pixel displacement params
protected MaterialProperty enablePerPixelDisplacement = null;
protected const string kEnablePerPixelDisplacement = "_EnablePerPixelDisplacement";
protected MaterialProperty ppdMinSamples = null;
protected const string kPpdMinSamples = "_PPDMinSamples";
protected MaterialProperty ppdMaxSamples = null;
protected const string kPpdMaxSamples = "_PPDMaxSamples";
protected MaterialProperty ppdLodThreshold = null;
protected const string kPpdLodThreshold = "_PPDLodThreshold";
protected static string[] reservedProperties = new string[] { kSurfaceType, kBlendMode, kAlphaCutoff, kAlphaCutoffEnabled, kDoubleSidedMode };

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


UseEmissiveMask,
}
public enum MaterialIDType
{
Standard = 0,
SubsurfaceScattering = 1,
ClearCoat = 2,
SpecularColor = 3
}
protected MaterialProperty smoothnessMapChannel = null;
protected const string kSmoothnessTextureChannel = "_SmoothnessTextureChannel";
protected MaterialProperty UVBase = null;

protected const string kUVMappingPlanar = "_UVMappingPlanar";
protected MaterialProperty normalMapSpace = null;
protected const string kNormalMapSpace = "_NormalMapSpace";
protected MaterialProperty enablePerPixelDisplacement = null;
protected const string kEnablePerPixelDisplacement = "_EnablePerPixelDisplacement";
protected MaterialProperty ppdMinSamples = null;
protected const string kPpdMinSamples = "_PPDMinSamples";
protected MaterialProperty ppdMaxSamples = null;
protected const string kPpdMaxSamples = "_PPDMaxSamples";
protected MaterialProperty detailMapMode = null;
protected const string kDetailMapMode = "_DetailMapMode";
protected MaterialProperty UVDetail = null;

protected void FindMaterialOptionProperties(MaterialProperty[] props)
{
smoothnessMapChannel = FindProperty(kSmoothnessTextureChannel, props);
normalMapSpace = FindProperty(kNormalMapSpace, props);
enablePerPixelDisplacement = FindProperty(kEnablePerPixelDisplacement, props);
ppdMinSamples = FindProperty(kPpdMinSamples, props);
ppdMaxSamples = FindProperty(kPpdMaxSamples, props);
normalMapSpace = FindProperty(kNormalMapSpace, props);
detailMapMode = FindProperty(kDetailMapMode, props);
emissiveColorMode = FindProperty(kEmissiveColorMode, props);
}

EditorGUI.indentLevel++;
GUILayout.Label(Styles.InputsOptionsText, EditorStyles.boldLabel);
m_MaterialEditor.ShaderProperty(materialID, Styles.materialIDText);
m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText);
m_MaterialEditor.ShaderProperty(UVBase, enableUVDetail ? Styles.UVBaseDetailMappingText : Styles.UVBaseMappingText);

//m_MaterialEditor.ShaderProperty(detailMapMode, Styles.detailMapModeText);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText);
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText);
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, Styles.enablePerPixelDisplacementText);
m_MaterialEditor.ShaderProperty(ppdMinSamples, Styles.ppdMinSamplesText);
m_MaterialEditor.ShaderProperty(ppdMaxSamples, Styles.ppdMaxSamplesText);
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText);
EditorGUI.indentLevel--;
}
m_MaterialEditor.ShaderProperty(materialID, Styles.materialIDText);
m_MaterialEditor.ShaderProperty(subsurfaceProfile, Styles.subsurfaceProfileText);
m_MaterialEditor.ShaderProperty(subsurfaceRadius, Styles.subsurfaceRadiusText);
m_MaterialEditor.ShaderProperty(subsurfaceRadiusMap, Styles.subsurfaceRadiusMapText);
m_MaterialEditor.ShaderProperty(thickness, Styles.thicknessText);
m_MaterialEditor.ShaderProperty(thicknessMap, Styles.thicknessMapText);
protected void ShaderSSSInputGUI()
{
m_MaterialEditor.ShaderProperty(subsurfaceProfile, Styles.subsurfaceProfileText);
m_MaterialEditor.ShaderProperty(subsurfaceRadius, Styles.subsurfaceRadiusText);
m_MaterialEditor.TexturePropertySingleLine(Styles.subsurfaceRadiusMapText, subsurfaceRadiusMap);
m_MaterialEditor.ShaderProperty(thickness, Styles.thicknessText);
m_MaterialEditor.TexturePropertySingleLine(Styles.thicknessMapText, thicknessMap);
}
EditorGUI.indentLevel--;
protected void ShaderStandardInputGUI()
{
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);
m_MaterialEditor.ShaderProperty(anisotropy, Styles.anisotropyText);
m_MaterialEditor.TexturePropertySingleLine(Styles.anisotropyMapText, anisotropyMap);
}
override protected void ShaderInputGUI()

EditorGUI.indentLevel--;
}
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);
m_MaterialEditor.ShaderProperty(anisotropy, Styles.anisotropyText);
m_MaterialEditor.TexturePropertySingleLine(Styles.anisotropyMapText, anisotropyMap);
if ((MaterialIDType)materialID.floatValue == MaterialIDType.Standard)
{
ShaderStandardInputGUI();
}
else if ((MaterialIDType)materialID.floatValue == MaterialIDType.SubsurfaceScattering)
{
ShaderSSSInputGUI();
}
EditorGUILayout.Space();
GUILayout.Label(Styles.textureControlText, EditorStyles.label);

8
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs.hlsl


#define DEBUGVIEW_LIT_SURFACEDATA_ANISOTROPY (1007)
#define DEBUGVIEW_LIT_SURFACEDATA_METALLIC (1008)
#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR (1009)
#define DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_RADIUS (1010)
#define DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_RADIUS (1010)
#define DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_PROFILE (1012)
#define DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_PROFILE (1012)
#define DEBUGVIEW_LIT_SURFACEDATA_COAT_NORMAL_WS (1013)
#define DEBUGVIEW_LIT_SURFACEDATA_COAT_PERCEPTUAL_SMOOTHNESS (1014)
#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_COLOR (1015)

#define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_T (1039)
#define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_B (1040)
#define DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY (1041)
#define DEBUGVIEW_LIT_BSDFDATA_SUB_SURFACE_RADIUS (1042)
#define DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_RADIUS (1042)
#define DEBUGVIEW_LIT_BSDFDATA_SUB_SURFACE_PROFILE (1044)
#define DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_PROFILE (1044)
#define DEBUGVIEW_LIT_BSDFDATA_COAT_NORMAL_WS (1045)
#define DEBUGVIEW_LIT_BSDFDATA_COAT_ROUGHNESS (1046)

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


#endif
}
void ApplyDebugToBSDFData(inout BSDFData bsdfData)
{
#ifdef LIGHTING_DEBUG
int lightDebugMode = (int)_DebugLightModeAndAlbedo.x;
float3 lightDebugAlbedo = _DebugLightModeAndAlbedo.yzw;
bool overrideSmoothness = _DebugLightingSmoothness.x != 0.0f;
float overrideSmoothnessValue = _DebugLightingSmoothness.y;
if (overrideSmoothness)
{
bsdfData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(overrideSmoothnessValue);
bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
}
if (lightDebugMode == LIGHTINGDEBUGMODE_DIFFUSE_LIGHTING)
{
bsdfData.diffuseColor = lightDebugAlbedo;
}
#endif
}
//-----------------------------------------------------------------------------
// conversion function for forward
//-----------------------------------------------------------------------------

bsdfData.fresnel0 = surfaceData.specularColor;
}
ApplyDebugToBSDFData(bsdfData);
return bsdfData;
}

}
bakeDiffuseLighting = inGBuffer3.rgb;
ApplyDebugToBSDFData(bsdfData);
}
//-----------------------------------------------------------------------------

case DEBUGVIEW_LIT_SURFACEDATA_SPECULAR:
result = surfaceData.specular.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_RADIUS:
case DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_RADIUS:
case DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_PROFILE:
case DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_PROFILE:
result = GetIndexColor(surfaceData.subsurfaceProfile);
break;
case DEBUGVIEW_LIT_SURFACEDATA_COAT_NORMAL_WS:

case DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY:
result = bsdfData.anisotropy.xxx;
break;
case DEBUGVIEW_LIT_BSDFDATA_SUB_SURFACE_RADIUS:
case DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_RADIUS:
case DEBUGVIEW_LIT_BSDFDATA_SUB_SURFACE_PROFILE:
case DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_PROFILE:
result = GetIndexColor(bsdfData.subsurfaceProfile);
break;
case DEBUGVIEW_LIT_BSDFDATA_COAT_NORMAL_WS:

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


_DetailHeightScale("_DetailHeightScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2)] _MaterialID("Material Class", Int) = 0
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2, Specular Color, 3)] _MaterialID("MaterialId", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.004, 1.0)) = 0.5
_Thickness("Thickness", Range(0.0, 1.0)) = 0
_Thickness("Thickness", Range(0.004, 1.0)) = 0.5
_ThicknessMap("Thickness Map", 2D) = "white" {}
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0

[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)

#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _MAPPING_TRIPLANAR
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3
#pragma shader_feature _EMISSIVE_COLOR

#pragma shader_feature _TANGENTMAP
#pragma shader_feature _ANISOTROPYMAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _THICKNESS_MAP
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON

//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define

//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "common.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"

Pass
{
Name "GBufferDebugLighting" // Name is not used
Tags{ "LightMode" = "GBufferDebugLighting" } // This will be only for opaque object based on the RenderQueue index
Cull[_CullMode]
Stencil
{
Ref[_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_GBUFFER
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "Debug"
Tags { "LightMode" = "DebugViewMaterial" }

// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitMetaPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"

Cull[_CullMode]
ZWrite On
ZWrite On
ZTest LEqual
HLSLPROGRAM

Cull[_CullMode]
ZWrite On
ZWrite On
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitVelocityPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"

ENDHLSL
}
Pass
{
Name "ForwardDebugLighting" // Name is not used
Tags{ "LightMode" = "ForwardDebugLighting" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.LitGUI"

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


#endif
// triplanar weight
float3 weights;
float3 triplanarWeights;
};
#ifndef LAYERED_LIT_SHADER

{
ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
bool isTriplanar = false;
layerTexCoord.weights = ComputeTriplanarWeights(normalWS);
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(normalWS);
isTriplanar = true;
// Be sure that the compiler is aware that we don't touch UV1 to UV3 for base layer in case of non layer shader
// so it can remove code
// Be sure that the compiler is aware that we don't touch UV1 to UV3 for main layer so it can optimize code
bool isTriplanar = false;
#ifdef _MAPPING_TRIPLANAR
isTriplanar = true;
#endif
void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord layerTexCoord)
float GetMaxDisplacement()
#if defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)
float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP)
maxDisplacement = _HeightAmplitude;
#endif
return maxDisplacement;
}
// ref: https://www.gamedev.net/resources/_/technical/graphics-programming-and-theory/a-closer-look-at-parallax-occlusion-mapping-r3262
float3 viewDirTS = TransformWorldToTangent(V, input.tangentToWorld);
// Change the number of samples per ray depending on the viewing angle for the surface.
// Oblique angles require smaller step sizes to achieve more accurate precision for computing displacement.
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
// Return the minimun uv size for all layers including triplanar
float2 GetMinUvSize(LayerTexCoord layerTexCoord)
{
float2 minUvSize = float2(FLT_MAX, FLT_MAX);
ParallaxOcclusionMappingLayer(layerTexCoord, numSteps, viewDirTS);
#if defined(_HEIGHTMAP)
if (layerTexCoord.base.isTriplanar)
{
minUvSize = min(layerTexCoord.base.uvYZ * _HeightMap_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base.uvZX * _HeightMap_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base.uvXY * _HeightMap_TexelSize.zw, minUvSize);
}
else
{
minUvSize = min(layerTexCoord.base.uv * _HeightMap_TexelSize.zw, minUvSize);
}
#endif
// TODO: We are supposed to modify lightmaps coordinate (fetch in GetBuiltin), but this isn't the same uv mapping, so can't apply the offset here...
// Let's assume it will be "fine" as indirect diffuse is often low frequency
return minUvSize;
}
struct PerPixelHeightDisplacementParam
{
float2 uv;
};
// Calculate displacement for per vertex displacement mapping
float ComputePerPixelHeightDisplacement(float2 texOffsetCurrent, float lod, PerPixelHeightDisplacementParam param)
{
// Note: No multiply by amplitude here. This is include in the maxHeight provide to POM
// Tiling is automatically handled correctly here.
return SAMPLE_TEXTURE2D_LOD(_HeightMap, sampler_HeightMap, param.uv + texOffsetCurrent, lod).r;
}
#include "PerPixelDisplacement.hlsl"
void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord layerTexCoord)
{
bool ppdEnable = false;
bool isPlanar = false;
bool isTriplanar = false;
#if defined(_PER_PIXEL_DISPLACEMENT) && defined(_HEIGHTMAP)
ppdEnable = true;
isPlanar = layerTexCoord.base.isPlanar;
isTriplanar = layerTexCoord.base.isTriplanar;
if (ppdEnable)
{
// See comment in layered version for details
float maxHeight = GetMaxDisplacement();
float2 minUvSize = GetMinUvSize(layerTexCoord);
float lod = ComputeTextureLOD(minUvSize);
PerPixelHeightDisplacementParam ppdParam;
// We need to calculate the texture space direction. It depends on the mapping.
if (isTriplanar)
{
// TODO: implement. Require 3 call to POM + dedicated viewDirTS based on triplanar convention
// apply the 3 offset on all layers
/*
ppdParam.uv = layerTexCoord.base0.uvYZ;
float3 viewDirTS = ;
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, abs(viewDirTS.z));
ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam);
(...)
*/
}
else
{
ppdParam.uv = layerTexCoord.base.uv;
// For planar the view vector is the world view vector (unless we want to support object triplanar ? and in this case used TransformWorldToObject)
// TODO: do we support object triplanar ? See ComputeLayerTexCoord
float3 viewDirTS = isPlanar ? float3(-V.xz, V.y) : TransformWorldToTangent(V, input.tangentToWorld);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam);
// Apply offset to all UVSet
layerTexCoord.base.uv += offset;
layerTexCoord.details.uv += offset;
}
}
return SampleHeightmapLod(layerTexCoord, lod);
return (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap, sampler_HeightMap, layerTexCoord.base, lod).r - _HeightCenter) * _HeightAmplitude;
}
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)

#undef LAYER_INDEX
#undef ADD_IDX
void ComputeMaskWeights(float4 inputMasks, out float outWeights[_MAX_LAYER])
{
float masks[_MAX_LAYER];
#if defined(_DENSITY_MODE)
masks[0] = inputMasks.a;
#else
masks[0] = 1.0;
#endif
masks[1] = inputMasks.r;
masks[2] = inputMasks.g;
masks[3] = inputMasks.b;
// calculate weight of each layers
// Algorithm is like this:
// Top layer have priority on others layers
// If a top layer doesn't use the full weight, the remaining can be use by the following layer.
float weightsSum = 0.0;
[unroll]
for (int i = _LAYER_COUNT - 1; i >= 0; --i)
{
outWeights[i] = min(masks[i], (1.0 - weightsSum));
weightsSum = saturate(weightsSum + masks[i]);
}
}
float3 BlendLayeredVector3(float3 x0, float3 x1, float3 x2, float3 x3, float weight[4])
{
float3 result = float3(0.0, 0.0, 0.0);

#if defined(_LAYER_MAPPING_TRIPLANAR_0) || defined(_LAYER_MAPPING_TRIPLANAR_1) || defined(_LAYER_MAPPING_TRIPLANAR_2) || defined(_LAYER_MAPPING_TRIPLANAR_3)
// one weight for each direction XYZ - Use vertex normal for triplanar
layerTexCoord.weights = ComputeTriplanarWeights(normalWS);
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(normalWS);
#endif
bool isTriplanar = false;

// Be sure that the compiler is aware that we don't touch UV1 to UV3 for main layer so it can optimize code
_UVMappingMask0.yzw = float3(0.0, 0.0, 0.0);
ComputeLayerTexCoord0( texCoord0, texCoord1, texCoord2, texCoord3,
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling0);

positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling3);
}
void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord layerTexCoord)
{
#if defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)
float3 viewDirTS = TransformWorldToTangent(V, input.tangentToWorld);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
ParallaxOcclusionMappingLayer0(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer1(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer2(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer3(layerTexCoord, numSteps, viewDirTS);
#if defined(_HEIGHTMAP0)
#define sampler_ShareHeightMap sampler_HeightMap0
#elif defined(_HEIGHTMAP1)
#define sampler_ShareHeightMap sampler_HeightMap1
#elif defined(_HEIGHTMAP2)
#define sampler_ShareHeightMap sampler_HeightMap2
#elif defined(_HEIGHTMAP3)
#define sampler_ShareHeightMap sampler_HeightMap3
}
float3 ComputeMainNormalInfluence(FragInputs input, float3 normalTS0, float3 normalTS1, float3 normalTS2, float3 normalTS3, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])
// This function is just syntaxic sugar to nullify height not used based on heightmap avaibility and layer
void SetEnabledHeightByLayer(inout float height0, inout float height1, inout float height2, inout float height3)
// Get our regular normal from regular layering
float3 normalTS = BlendLayeredVector3(normalTS0, normalTS1, normalTS2, normalTS3, weights);
#ifndef _HEIGHTMAP0
height0 = 0.0;
#endif
#ifndef _HEIGHTMAP1
height1 = 0.0;
#endif
#ifndef _HEIGHTMAP2
height2 = 0.0;
#endif
#ifndef _HEIGHTMAP3
height3 = 0.0;
#endif
// THen get Main Layer Normal influence factor. Main layer is 0 because it can't be influence. In this case the final lerp return normalTS.
float influenceFactor = BlendLayeredScalar(0.0, _InheritBaseNormal1, _InheritBaseNormal2, _InheritBaseNormal3, weights);
// We will add smoothly the contribution of the normal map by using lower mips with help of bias sampling. InfluenceFactor must be [0..numMips] // Caution it cause banding...
// Note: that we don't take details map into account here.
float maxMipBias = log2(max(_NormalMap0_TexelSize.z, _NormalMap0_TexelSize.w)); // don't do + 1 as it is for bias, not lod
float3 mainNormalTS = GetNormalTS0(input, layerTexCoord, float3(0.0, 0.0, 1.0), 0.0, true, maxMipBias * (1.0 - influenceFactor));
// Add on our regular normal a bit of Main Layer normal base on influence factor. Note that this affect only the "visible" normal.
return lerp(normalTS, BlendNormalRNM(normalTS, mainNormalTS), influenceFactor);
#if _LAYER_COUNT < 4
height3 = 0.0;
#endif
#if _LAYER_COUNT < 3
height2 = 0.0;
#endif
float3 ComputeMainBaseColorInfluence(float3 baseColor0, float3 baseColor1, float3 baseColor2, float3 baseColor3, float compoMask, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])
void ComputeMaskWeights(float4 inputMasks, out float outWeights[_MAX_LAYER])
float3 baseColor = BlendLayeredVector3(baseColor0, baseColor1, baseColor2, baseColor3, weights);
float influenceFactor = BlendLayeredScalar(0.0, _InheritBaseColor1, _InheritBaseColor2, _InheritBaseColor3, weights);
float influenceThreshold = BlendLayeredScalar(1.0, _InheritBaseColorThreshold1, _InheritBaseColorThreshold2, _InheritBaseColorThreshold3, weights);
float masks[_MAX_LAYER];
#if defined(_DENSITY_MODE)
masks[0] = inputMasks.a;
#else
masks[0] = 1.0;
#endif
masks[1] = inputMasks.r;
#if _LAYER_COUNT > 2
masks[2] = inputMasks.g;
#else
masks[2] = 0.0;
#endif
#if _LAYER_COUNT > 3
masks[3] = inputMasks.b;
#else
masks[3] = 0.0;
#endif
influenceFactor = influenceFactor * (1.0 - saturate(compoMask / influenceThreshold));
// We want to calculate the mean color of the texture. For this we will sample a low mipmap
float textureBias = 15.0; // Use maximum bias
float3 baseMeanColor0 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap0, sampler_BaseColorMap0, layerTexCoord.base0, textureBias).rgb *_BaseColor0.rgb;
float3 baseMeanColor1 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap1, sampler_BaseColorMap0, layerTexCoord.base1, textureBias).rgb *_BaseColor1.rgb;
float3 baseMeanColor2 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap2, sampler_BaseColorMap0, layerTexCoord.base2, textureBias).rgb *_BaseColor2.rgb;
float3 baseMeanColor3 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap3, sampler_BaseColorMap0, layerTexCoord.base3, textureBias).rgb *_BaseColor3.rgb;
float3 meanColor = BlendLayeredVector3(baseMeanColor0, baseMeanColor1, baseMeanColor2, baseMeanColor3, weights);
// calculate weight of each layers
// Algorithm is like this:
// Top layer have priority on others layers
// If a top layer doesn't use the full weight, the remaining can be use by the following layer.
float weightsSum = 0.0;
// If we inherit from base layer, we will add a bit of it
// We add variance of current visible level and the base color 0 or mean (to retrieve initial color) depends on influence
// (baseColor - meanColor) + lerp(meanColor, baseColor0, inheritBaseColor) simplify to
return saturate(influenceFactor * (baseColor0 - meanColor) + baseColor);
[unroll]
for (int i = _LAYER_COUNT - 1; i >= 0; --i)
{
outWeights[i] = min(masks[i], (1.0 - weightsSum));
weightsSum = saturate(weightsSum + masks[i]);
}
}
// Caution: Blend mask are Layer 1 R - Layer 2 G - Layer 3 B - Main Layer A

// Blend mask are Main Layer A - Layer 1 R - Layer 2 G - Layer 3 B
// Value for Mani layer is not use for blending itself but for alternate weighting like density.
// Value for main layer is not use for blending itself but for alternate weighting like density.
// Settings this specific Main layer blend mask in alpha allow to be transparent in case we don't use it and 1 is provide by default.
float4 blendMasks = useLodSampling ? SAMPLE_LAYER_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.base0, lod) : SAMPLE_LAYER_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.base0);

return blendMasks;
}
// Return the maximun amplitude use by all enabled heightmap
// use for tessellation culling and per pixel displacement
float GetMaxDisplacement()
{
float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP0)
maxDisplacement = max( _LayerHeightAmplitude0, maxDisplacement);
#endif
#if defined(_HEIGHTMAP1)
maxDisplacement = max( _LayerHeightAmplitude1
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
+_LayerHeightAmplitude0 * _InheritBaseHeight1
#endif
, maxDisplacement);
#endif
#if _LAYER_COUNT >= 3
#if defined(_HEIGHTMAP2)
maxDisplacement = max( _LayerHeightAmplitude2
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
+_LayerHeightAmplitude0 * _InheritBaseHeight2
#endif
, maxDisplacement);
#endif
#endif
#if _LAYER_COUNT >= 4
#if defined(_HEIGHTMAP3)
maxDisplacement = max( _LayerHeightAmplitude3
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
+_LayerHeightAmplitude0 * _InheritBaseHeight3
#endif
, maxDisplacement);
#endif
#endif
return maxDisplacement;
}
// Return the minimun uv size for all layers including triplanar
float2 GetMinUvSize(LayerTexCoord layerTexCoord)
{
float2 minUvSize = float2(FLT_MAX, FLT_MAX);
#if defined(_HEIGHTMAP0)
if (layerTexCoord.base0.isTriplanar)
{
minUvSize = min(layerTexCoord.base0.uvYZ * _HeightMap0_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base0.uvZX * _HeightMap0_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base0.uvXY * _HeightMap0_TexelSize.zw, minUvSize);
}
else
{
minUvSize = min(layerTexCoord.base0.uv * _HeightMap0_TexelSize.zw, minUvSize);
}
#endif
#if defined(_HEIGHTMAP1)
if (layerTexCoord.base1.isTriplanar)
{
minUvSize = min(layerTexCoord.base1.uvYZ * _HeightMap1_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base1.uvZX * _HeightMap1_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base1.uvXY * _HeightMap1_TexelSize.zw, minUvSize);
}
else
{
minUvSize = min(layerTexCoord.base1.uv * _HeightMap1_TexelSize.zw, minUvSize);
}
#endif
#if _LAYER_COUNT >= 3
#if defined(_HEIGHTMAP2)
if (layerTexCoord.base2.isTriplanar)
{
minUvSize = min(layerTexCoord.base2.uvYZ * _HeightMap2_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base2.uvZX * _HeightMap2_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base2.uvXY * _HeightMap2_TexelSize.zw, minUvSize);
}
else
{
minUvSize = min(layerTexCoord.base2.uv * _HeightMap2_TexelSize.zw, minUvSize);
}
#endif
#endif
#if _LAYER_COUNT >= 4
#if defined(_HEIGHTMAP3)
if (layerTexCoord.base3.isTriplanar)
{
minUvSize = min(layerTexCoord.base3.uvYZ * _HeightMap3_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base3.uvZX * _HeightMap3_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base3.uvXY * _HeightMap3_TexelSize.zw, minUvSize);
}
else
{
minUvSize = min(layerTexCoord.base3.uv * _HeightMap3_TexelSize.zw, minUvSize);
}
#endif
#endif
return minUvSize;
}
struct PerPixelHeightDisplacementParam
{
float weights[_MAX_LAYER];
float2 uv[_MAX_LAYER];
float mainHeightInfluence;
};
// Calculate displacement for per vertex displacement mapping
float ComputePerPixelHeightDisplacement(float2 texOffsetCurrent, float lod, PerPixelHeightDisplacementParam param)
{
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
// Note: No multiply by amplitude here, this is bake into the weights and apply in BlendLayeredScalar
// The amplitude is normalize to be able to work with POM algorithm
// Tiling is automatically handled correctly here as we use 4 differents uv even if they come from the same UVSet (they include the tiling)
float height0 = SAMPLE_TEXTURE2D_LOD(_HeightMap0, sampler_ShareHeightMap, param.uv[0] + texOffsetCurrent, lod).r;
float height1 = SAMPLE_TEXTURE2D_LOD(_HeightMap1, sampler_ShareHeightMap, param.uv[1] + texOffsetCurrent, lod).r;
float height2 = SAMPLE_TEXTURE2D_LOD(_HeightMap2, sampler_ShareHeightMap, param.uv[2] + texOffsetCurrent, lod).r;
float height3 = SAMPLE_TEXTURE2D_LOD(_HeightMap3, sampler_ShareHeightMap, param.uv[3] + texOffsetCurrent, lod).r;
SetEnabledHeightByLayer(height0, height1, height2, height3); // Not needed as already put in weights but paranoid mode
return BlendLayeredScalar(height0, height1, height2, height3, param.weights) + height0 * param.mainHeightInfluence;
#else
return 0.0;
#endif
}
#include "PerPixelDisplacement.hlsl"
// PPD is affecting only one mapping at the same time, mean we need to execute it for each mapping (UV0, UV1, 3 times for triplanar etc..)
// We chose to not support all this case that are extremely hard to manage (for example mixing different mapping, mean it also require different tangent space that is not supported in Unity)
// For these reasons we put the following rules
// Rules:
// - Mapping is the same for all layers that use an Heightmap (i.e all are UV, planar or triplanar)
// - Mapping UV is UV0 only because we need to convert view vector in texture space and this is only available for UV0
// - Heightmap can be enabled per layer
// - Blend Mask use same mapping as main layer (UVO, Planar, Triplanar)
// From these rules it mean that PPD is enable only if the user 1) ask for it, 2) if there is one heightmap enabled on active layer, 3) if mapping is the same for all layer respecting 2), 4) if mapping is UV0, planar or triplanar mapping
// Most contraint are handled by the inspector (i.e the UI) like the mapping constraint and is assumed in the shader.
void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord layerTexCoord)
{
bool ppdEnable = false;
bool isPlanar = false;
bool isTriplanar = false;
#ifdef _PER_PIXEL_DISPLACEMENT
// To know if we are planar or triplanar just need to check if any of the active heightmap layer is true as they are enforce to be the same mapping
#if defined(_HEIGHTMAP0)
ppdEnable = true;
isPlanar = layerTexCoord.base0.isPlanar;
isTriplanar = layerTexCoord.base0.isTriplanar;
#endif
#if defined(_HEIGHTMAP1)
ppdEnable = true;
isPlanar = layerTexCoord.base1.isPlanar;
isTriplanar = layerTexCoord.base1.isTriplanar;
#endif
#if _LAYER_COUNT >= 3
#if defined(_HEIGHTMAP2)
ppdEnable = true;
isPlanar = layerTexCoord.base2.isPlanar;
isTriplanar = layerTexCoord.base2.isTriplanar;
#endif
#endif
#if _LAYER_COUNT >= 4
#if defined(_HEIGHTMAP3)
ppdEnable = true;
isPlanar = layerTexCoord.base3.isPlanar;
isTriplanar = layerTexCoord.base3.isTriplanar;
#endif
#endif
#endif // _PER_PIXEL_DISPLACEMENT
if (ppdEnable)
{
// Even if we use same mapping we can have different tiling. For per pixel displacement we will perform the ray marching with already tiled uv
float maxHeight = GetMaxDisplacement();
// Compute lod as we will sample inside a loop(so can't use regular sampling)
// Note: It appear that CALCULATE_TEXTURE2D_LOD only return interger lod. We want to use float lod to have smoother transition and fading, so do our own calculation.
// Approximation of lod to used. Be conservative here, we will take the highest mip of all layers.
// Remember, we assume that we used the same mapping for all layer, so only size matter.
float2 minUvSize = GetMinUvSize(layerTexCoord);
float lod = ComputeTextureLOD(minUvSize);
// Calculate blend weights
float4 blendMasks = GetBlendMask(layerTexCoord, input.color);
float weights[_MAX_LAYER];
ComputeMaskWeights(blendMasks, weights);
// Be sure we are not considering weight here were there is no heightmap
SetEnabledHeightByLayer(weights[0], weights[1], weights[2], weights[3]);
PerPixelHeightDisplacementParam ppdParam;
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
// For per pixel displacement we need to have normalized height scale to calculate the interesection (required by the algorithm we use)
// mean that we will normalize by the highest amplitude.
// We store this normalization factor with the weights as it will be multiply by the readed height.
ppdParam.weights[0] = weights[0] * (_LayerHeightAmplitude0) / maxHeight;
ppdParam.weights[1] = weights[1] * (_LayerHeightAmplitude1 + _LayerHeightAmplitude0 * _InheritBaseHeight1) / maxHeight;
ppdParam.weights[2] = weights[2] * (_LayerHeightAmplitude2 + _LayerHeightAmplitude0 * _InheritBaseHeight2) / maxHeight;
ppdParam.weights[3] = weights[3] * (_LayerHeightAmplitude3 + _LayerHeightAmplitude0 * _InheritBaseHeight3) / maxHeight;
// Think that inheritbasedheight will be 0 if height0 is fully visible in weights. So there is no double contribution of height0
float mainHeightInfluence = BlendLayeredScalar(0.0, _InheritBaseHeight1, _InheritBaseHeight2, _InheritBaseHeight3, weights);
ppdParam.mainHeightInfluence = mainHeightInfluence;
#else
[unroll]
for (int i = 0; i < _MAX_LAYER; ++i)
{
ppdParam.weights[i] = weights[i];
}
ppdParam.mainHeightInfluence = 0.0;
#endif
// We need to calculate the texture space direction. It depends on the mapping.
if (isTriplanar)
{
// TODO: implement. Require 3 call to POM + dedicated viewDirTS based on triplanar convention
// apply the 3 offset on all layers
/*
ppdParam.uv[0] = layerTexCoord.base0.uvYZ;
ppdParam.uv[1] = layerTexCoord.base1.uvYZ;
ppdParam.uv[2] = layerTexCoord.base2.uvYZ;
ppdParam.uv[3] = layerTexCoord.base3.uvYZ;
float3 viewDirTS = ;
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, abs(viewDirTS.z));
ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam);
// Apply to all uvYZ
// Repeat for uvZX
// Repeat for uvXY
// Apply to all layer that used triplanar
*/
}
else
{
ppdParam.uv[0] = layerTexCoord.base0.uv;
ppdParam.uv[1] = layerTexCoord.base1.uv;
ppdParam.uv[2] = layerTexCoord.base2.uv;
ppdParam.uv[3] = layerTexCoord.base3.uv;
// For planar the view vector is the world view vector (unless we want to support object triplanar ? and in this case used TransformWorldToObject)
// TODO: do we support object triplanar ? See ComputeLayerTexCoord
float3 viewDirTS = isPlanar ? float3(-V.xz, V.y) : TransformWorldToTangent(V, input.tangentToWorld);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam);
// Apply offset to all planar uvset
// _UVMappingPlanar0 will be 1.0 is planar is used - _UVMappingMask0.x will be 1.0 is UVSet0 is used;
float4 offsetWeights = isPlanar ? float4(_UVMappingPlanar0, _UVMappingPlanar1, _UVMappingPlanar2, _UVMappingPlanar3) : float4(_UVMappingMask0.x, _UVMappingMask1.x, _UVMappingMask2.x, _UVMappingMask3.x);
layerTexCoord.base0.uv += offsetWeights.x * offset;
layerTexCoord.base1.uv += offsetWeights.y * offset;
layerTexCoord.base2.uv += offsetWeights.z * offset;
layerTexCoord.base3.uv += offsetWeights.w * offset;
offsetWeights = isPlanar ? float4(_UVMappingPlanar0, _UVMappingPlanar1, _UVMappingPlanar2, _UVMappingPlanar3) : float4(_UVDetailsMappingMask0.x, _UVDetailsMappingMask1.x, _UVDetailsMappingMask2.x, _UVDetailsMappingMask3.x);
layerTexCoord.details0.uv += offsetWeights.x * offset;
layerTexCoord.details1.uv += offsetWeights.y * offset;
layerTexCoord.details2.uv += offsetWeights.z * offset;
layerTexCoord.details3.uv += offsetWeights.w * offset;
}
}
}
// Calculate displacement for per vertex displacement mapping
float ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod)
{

ComputeMaskWeights(blendMasks, weights);
float height0 = SampleHeightmapLod0(layerTexCoord, lod, _HeightCenterOffset0, _HeightFactor0);
float height1 = SampleHeightmapLod1(layerTexCoord, lod, _HeightCenterOffset1, _HeightFactor1);
float height2 = SampleHeightmapLod2(layerTexCoord, lod, _HeightCenterOffset2, _HeightFactor2);
float height3 = SampleHeightmapLod3(layerTexCoord, lod, _HeightCenterOffset3, _HeightFactor3);
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
float height0 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap0, sampler_ShareHeightMap, layerTexCoord.base0, lod).r - _LayerCenterOffset0) * _LayerHeightAmplitude0;
float height1 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap1, sampler_ShareHeightMap, layerTexCoord.base1, lod).r - _LayerCenterOffset1) * _LayerHeightAmplitude1;
float height2 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap2, sampler_ShareHeightMap, layerTexCoord.base2, lod).r - _LayerCenterOffset2) * _LayerHeightAmplitude2;
float height3 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap3, sampler_ShareHeightMap, layerTexCoord.base3, lod).r - _LayerCenterOffset3) * _LayerHeightAmplitude3;
SetEnabledHeightByLayer(height0, height1, height2, height3);
float heightResult = BlendLayeredScalar(height0, height1, height2, height3, weights);
#if defined(_MAIN_LAYER_INFLUENCE_MODE)

#endif
#else
float heightResult = 0.0;
#endif
return heightResult;
}

}
// Calculate weights to apply to each layer
// Caution: This function must not be use for per vertex of per pixel displacement, there is a dedicated function for them.
// this function handle triplanar
// Caution: This function must not be use for per vertex/pixel displacement, there is a dedicated function for them.
// This function handle triplanar
void ComputeLayerWeights(FragInputs input, LayerTexCoord layerTexCoord, float4 inputAlphaMask, out float outWeights[_MAX_LAYER])
{
float4 blendMasks = GetBlendMask(layerTexCoord, input.color);

#endif
#if defined(_HEIGHT_BASED_BLEND)
float height0 = SampleHeightmap0(layerTexCoord, _HeightCenterOffset0, _HeightFactor0);
float height1 = SampleHeightmap1(layerTexCoord, _HeightCenterOffset1, _HeightFactor1);
float height2 = SampleHeightmap2(layerTexCoord, _HeightCenterOffset2, _HeightFactor2);
float height3 = SampleHeightmap3(layerTexCoord, _HeightCenterOffset3, _HeightFactor3);
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
float height0 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap0, sampler_ShareHeightMap, layerTexCoord.base0).r - _LayerCenterOffset0) * _LayerHeightAmplitude0;
float height1 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap1, sampler_ShareHeightMap, layerTexCoord.base1).r - _LayerCenterOffset1) * _LayerHeightAmplitude1;
float height2 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap2, sampler_ShareHeightMap, layerTexCoord.base2).r - _LayerCenterOffset2) * _LayerHeightAmplitude2;
float height3 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap3, sampler_ShareHeightMap, layerTexCoord.base3).r - _LayerCenterOffset3) * _LayerHeightAmplitude3;
SetEnabledHeightByLayer(height0, height1, height2, height3);
// HACK, use height0 to avoid compiler error for unused sampler
// To remove once we have POM
// HACK: use height0 to avoid compiler error for unused sampler - To remove when we can have a sampler without a textures
#if !defined(_PER_PIXEL_DISPLACEMENT)
// We don't use height 0 for the height blend based mode
#endif
#else
float4 heights = float4(0.0, 0.0, 0.0, 0.0);
#endif
// don't apply on main layer
blendMasks.rgb = ApplyHeightBasedBlend(blendMasks.rgb, heights.yzw, float3(_BlendUsingHeight1, _BlendUsingHeight2, _BlendUsingHeight3));

}
float3 ComputeMainNormalInfluence(FragInputs input, float3 normalTS0, float3 normalTS1, float3 normalTS2, float3 normalTS3, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])
{
// Get our regular normal from regular layering
float3 normalTS = BlendLayeredVector3(normalTS0, normalTS1, normalTS2, normalTS3, weights);
// THen get Main Layer Normal influence factor. Main layer is 0 because it can't be influence. In this case the final lerp return normalTS.
float influenceFactor = BlendLayeredScalar(0.0, _InheritBaseNormal1, _InheritBaseNormal2, _InheritBaseNormal3, weights);
// We will add smoothly the contribution of the normal map by using lower mips with help of bias sampling. InfluenceFactor must be [0..numMips] // Caution it cause banding...
// Note: that we don't take details map into account here.
float maxMipBias = log2(max(_NormalMap0_TexelSize.z, _NormalMap0_TexelSize.w)); // don't do + 1 as it is for bias, not lod
float3 mainNormalTS = GetNormalTS0(input, layerTexCoord, float3(0.0, 0.0, 1.0), 0.0, true, maxMipBias * (1.0 - influenceFactor));
// Add on our regular normal a bit of Main Layer normal base on influence factor. Note that this affect only the "visible" normal.
return lerp(normalTS, BlendNormalRNM(normalTS, mainNormalTS), influenceFactor);
}
float3 ComputeMainBaseColorInfluence(float3 baseColor0, float3 baseColor1, float3 baseColor2, float3 baseColor3, float compoMask, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])
{
float3 baseColor = BlendLayeredVector3(baseColor0, baseColor1, baseColor2, baseColor3, weights);
float influenceFactor = BlendLayeredScalar(0.0, _InheritBaseColor1, _InheritBaseColor2, _InheritBaseColor3, weights);
float influenceThreshold = BlendLayeredScalar(1.0, _InheritBaseColorThreshold1, _InheritBaseColorThreshold2, _InheritBaseColorThreshold3, weights);
influenceFactor = influenceFactor * (1.0 - saturate(compoMask / influenceThreshold));
// We want to calculate the mean color of the texture. For this we will sample a low mipmap
float textureBias = 15.0; // Use maximum bias
float3 baseMeanColor0 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap0, sampler_BaseColorMap0, layerTexCoord.base0, textureBias).rgb *_BaseColor0.rgb;
float3 baseMeanColor1 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap1, sampler_BaseColorMap0, layerTexCoord.base1, textureBias).rgb *_BaseColor1.rgb;
float3 baseMeanColor2 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap2, sampler_BaseColorMap0, layerTexCoord.base2, textureBias).rgb *_BaseColor2.rgb;
float3 baseMeanColor3 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap3, sampler_BaseColorMap0, layerTexCoord.base3, textureBias).rgb *_BaseColor3.rgb;
float3 meanColor = BlendLayeredVector3(baseMeanColor0, baseMeanColor1, baseMeanColor2, baseMeanColor3, weights);
// If we inherit from base layer, we will add a bit of it
// We add variance of current visible level and the base color 0 or mean (to retrieve initial color) depends on influence
// (baseColor - meanColor) + lerp(meanColor, baseColor0, inheritBaseColor) simplify to
return saturate(influenceFactor * (baseColor0 - meanColor) + baseColor);
}
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
LayerTexCoord layerTexCoord;

float alpha2 = GetSurfaceData2(input, layerTexCoord, surfaceData2, normalTS2);
float alpha3 = GetSurfaceData3(input, layerTexCoord, surfaceData3, normalTS3);
// For layering we kill pixel based on maximun alpha
#ifdef _ALPHATEST_ON
#if _LAYER_COUNT == 2
clip(max(alpha0, alpha1) - _AlphaCutoff);
#endif
#if _LAYER_COUNT == 3
clip(max3(alpha0, alpha1, alpha2) - _AlphaCutoff);
#endif
#if _LAYER_COUNT == 4
clip(max(alpha3, max3(alpha0, alpha1, alpha2)) - _AlphaCutoff);
#endif
#endif
// Note: If per pixel displacement is enabled it mean we will fetch again the various heightmaps at the intersection location. Not sure the compiler can optimize.
#ifdef _ALPHATEST_ON
clip(alpha - _AlphaCutoff);
#endif
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
surfaceData.baseColor = ComputeMainBaseColorInfluence(surfaceData0.baseColor, surfaceData1.baseColor, surfaceData2.baseColor, surfaceData3.baseColor, alpha, layerTexCoord, weights);

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


void ADD_IDX(ComputeLayerTexCoord)( float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3,
float3 positionWS, float3 normalWS, bool isTriplanar, inout LayerTexCoord layerTexCoord, float additionalTiling = 1.0)
float3 positionWS, float3 vertexNormalWS, bool isTriplanar, inout LayerTexCoord layerTexCoord, float additionalTiling = 1.0)
{
// Handle uv0, uv1, uv2, uv3 based on _UVMappingMask weight (exclusif 0..1)
float2 uvBase = ADD_IDX(_UVMappingMask).x * texCoord0 +

// Note that if base is planar/triplanar, detail map is too
// planar
// TODO: Do we want to manage local or world triplanar/planar
// TODO: Do we want to manage local or world triplanar/planar ? In this case update ApplyPerPixelDisplacement() too
//float3 position = localTriplanar ? TransformWorldToObject(positionWS) : positionWS;
float3 position = positionWS;
position *= ADD_IDX(_TexWorldScale);

uvBase = -position.xz;
uvDetails = -position.xz;
ADD_IDX(layerTexCoord.base).isPlanar = true;
ADD_IDX(layerTexCoord.details).isPlanar = true;
}
else
{
ADD_IDX(layerTexCoord.base).isPlanar = false;
ADD_IDX(layerTexCoord.details).isPlanar = false;
}
ADD_IDX(layerTexCoord.base).uv = TRANSFORM_TEX(uvBase, ADD_IDX(_BaseColorMap));

ADD_IDX(layerTexCoord.base).isTriplanar = isTriplanar;
float3 direction = sign(normalWS);
float3 direction = sign(vertexNormalWS);
// In triplanar, if we are facing away from the world axis, a different axis will be flipped for each direction.
// This is particularly problematic for tangent space normal maps which need to be in the right direction.

ADD_IDX(layerTexCoord.details).uvYZ = TRANSFORM_TEX(uvYZ, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZX = TRANSFORM_TEX(uvZX, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(uvXY, ADD_IDX(_DetailMap));
}
float ADD_IDX(SampleHeightmap)(LayerTexCoord layerTexCoord, float centerOffset = 0.0, float multiplier = 1.0)
{
#ifdef _HEIGHTMAP
return (SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r - ADD_IDX(_HeightCenter) - centerOffset) * ADD_IDX(_HeightAmplitude) * multiplier;
#else
return 0.0;
#endif
}
float ADD_IDX(SampleHeightmapLod)(LayerTexCoord layerTexCoord, float lod, float centerOffset = 0.0, float multiplier = 1.0)
{
#ifdef _HEIGHTMAP
return (SAMPLE_LAYER_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base), lod).r - ADD_IDX(_HeightCenter) - centerOffset) * ADD_IDX(_HeightAmplitude) * multiplier;
#else
return 0.0;
#endif
}
// Note: The sampling of heightmap inside POM don't use sampling abstraction (with triplanar) as
// POM must be apply separately for each uv set (so 3 time for triplanar)
void ADD_IDX(ParallaxOcclusionMappingLayer)(inout LayerTexCoord layerTexCoord, int numSteps, float3 viewDirTS)
{
// Convention: 1.0 is top, 0.0 is bottom - POM is always inward, no extrusion
float stepSize = 1.0 / (float)numSteps;
// View vector is from the point to the camera, but we want to raymarch from camera to point, so reverse the sign
// The length of viewDirTS vector determines the furthest amount of displacement:
// float parallaxLimit = -length(viewDirTS.xy) / viewDirTS.z;
// float2 parallaxDir = normalize(Out.viewDirTS.xy);
// float2 parallaxMaxOffsetTS = parallaxDir * parallaxLimit;
// Above code simplify to
float2 parallaxMaxOffsetTS = (viewDirTS.xy / -viewDirTS.z) * ADD_IDX(_HeightAmplitude);
float2 texOffsetPerStep = stepSize * parallaxMaxOffsetTS;
float2 uv = ADD_IDX(layerTexCoord.base).uv;
// Compute lod as we will sample inside a loop (so can't use regular sampling)
// It appear that CALCULATE_TEXTURE2D_LOD only return interger lod. We want to use float lod to have smoother transition and fading
// float lod = CALCULATE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv);
float lod = ComputeTextureLOD(uv, GET_TEXELSIZE_NAME(ADD_IDX(_HeightMap)));
// Do a first step before the loop to init all value correctly
float2 texOffsetCurrent = 0;
float prevHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + texOffsetCurrent, lod).r;
texOffsetCurrent += texOffsetPerStep;
float currHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + texOffsetCurrent, lod).r;
float rayHeight = 1.0 - stepSize; // Start at top less one sample
// Linear search
for (int stepIndex = 0; stepIndex < numSteps; ++stepIndex)
{
// Have we found a height below our ray height ? then we have an intersection
if (currHeight > rayHeight)
break; // end the loop
prevHeight = currHeight;
rayHeight -= stepSize;
texOffsetCurrent += texOffsetPerStep;
// Sample height map which in this case is stored in the alpha channel of the normal map:
currHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + texOffsetCurrent, lod).r;
}
// Found below and above points, now perform line interesection (ray) with piecewise linear heightfield approximation
// Refine the search by adding few extra intersection
#define POM_REFINE 1
#if POM_REFINE
float pt0 = rayHeight + stepSize;
float pt1 = rayHeight;
float delta0 = pt0 - prevHeight;
float delta1 = pt1 - currHeight;
float2 offset = float2(0.0, 0.0);
float threshold = 1.0;
for (int i = 0; i < 5; ++i)
{
float t = (pt0 * delta1 - pt1 * delta0) / (delta1 - delta0);
offset = (1 - t) * texOffsetPerStep * numSteps;
currHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + offset, lod).r;
threshold = t - currHeight;
if (abs(threshold) <= 0.01)
break;
if (threshold < 0.0)
{
delta1 = threshold;
pt1 = t;
}
else
{
delta0 = threshold;
pt0 = t;
}
}
#else
//float pt0 = rayHeight + stepSize;
//float pt1 = rayHeight;
//float delta0 = pt0 - prevHeight;
//float delta1 = pt1 - currHeight;
//float t = (pt0 * delta1 - pt1 * delta0) / (delta1 - delta0);
//float2 offset = (1 - t) * texOffsetPerStep * numSteps;
// A bit more optimize
float delta0 = currHeight - rayHeight;
float delta1 = (rayHeight + stepSize) - prevHeight;
float ratio = delta0 / (delta0 + delta1);
float2 offset = texOffsetCurrent - ratio * texOffsetPerStep;
#endif
// TODO: expose LOD fading
//float lodThreshold = 0.0;
//offset *= (1.0 - saturate(lod - lodThreshold));
// Apply offset only on base. Details could use another mapping and will not be consistant...
// Don't know if this will still ok.
// TODO: check with artists
ADD_IDX(layerTexCoord.base).uv += offset;
}
float3 ADD_IDX(GetNormalTS)(FragInputs input, LayerTexCoord layerTexCoord, float3 detailNormalTS, float detailMask, bool useBias, float bias)

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


float _PPDMaxSamples;
float _PPDMinSamples;
float _PPDLodThreshold;
#else // LAYERED_LIT_SHADER

float _BlendUsingHeight1;
float _BlendUsingHeight2;
float _BlendUsingHeight3;
PROP_DECL(float, _HeightFactor);
PROP_DECL(float, _HeightCenterOffset);
PROP_DECL(float, _LayerHeightAmplitude);
PROP_DECL(float, _LayerCenterOffset);
PROP_DECL(float, _MinimumOpacity);
PROP_DECL(float, _OpacityAsDensity);
float _InheritBaseNormal1;

float _PPDMaxSamples;
float _PPDMinSamples;
float _PPDLodThreshold;
#endif // LAYERED_LIT_SHADER

20
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl


float4 GetTessellationFactors(float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2)
{
float maxDisplacement = ADD_ZERO_IDX(_HeightAmplitude);
#ifdef _LAYER_COUNT
maxDisplacement = max(maxDisplacement, _HeightAmplitude1);
#if _LAYER_COUNT >= 3
maxDisplacement = max(maxDisplacement, _HeightAmplitude2);
#endif
#if _LAYER_COUNT >= 4
maxDisplacement = max(maxDisplacement, _HeightAmplitude3);
#endif
#endif
float maxDisplacement = GetMaxDisplacement();
bool frustumCulled = WorldViewFrustumCull(p0, p1, p2, maxDisplacement, (float4[4])unity_CameraWorldClipPlanes);

return CalcTriEdgeTessFactors(tessFactor);
}
float3 GetDisplacement(VaryingsMeshToDS input)
// tessellationFactors
// x - 1->2 edge
// y - 2->0 edge
// z - 0->1 edge
// w - inside tessellation factor
float3 GetTessellationDisplacement(VaryingsMeshToDS input)
{
// This call will work for both LayeredLit and Lit shader
LayerTexCoord layerTexCoord;

input.normalWS,
layerTexCoord);
// TODO: Move to camera relative and change distance to length
// http://www.sebastiansylvan.com/post/the-problem-with-tessellation-in-directx-11/
float lod = 0.0;
float4 vertexColor = float4(0.0, 0.0, 0.0, 0.0);
#ifdef VARYINGS_DS_NEED_COLOR

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


_DetailHeightScale("_DetailHeightScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2)] _MaterialID("Material Class", Int) = 0
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2, Specular Color, 3)] _MaterialID("MaterialId", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.004, 1.0)) = 0.5
_Thickness("Thickness", Range(0.0, 1.0)) = 0
_Thickness("Thickness", Range(0.004, 1.0)) = 0.5
_ThicknessMap("Thickness Map", 2D) = "white" {}
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0

[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)

Pass
{
Name "GBufferDebugLighting" // Name is not used
Tags{ "LightMode" = "GBufferDebugLighting" } // This will be only for opaque object based on the RenderQueue index
Cull[_CullMode]
Stencil
{
Ref[_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_GBUFFER
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "Debug"
Tags { "LightMode" = "DebugViewMaterial" }

ENDHLSL
}
Pass
{
Name "ForwardDebugLighting" // Name is not used
Tags{ "LightMode" = "ForwardDebugLighting" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define LIGHTING_DEBUG
#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.LitGUI"

96
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader


{
Properties
{
_FilterRadius("", Float) = 20
_BilateralScale("", Float) = 0.1
[HideInInspector] _DstBlend("", Float) = 1 // Can be set to 1 for blending with specular
}

Pass Keep
}
Cull Off
Blend One [_DstBlend], Zero [_DstBlend]
Blend One [_DstBlend]
HLSLPROGRAM
#pragma target 4.5

#pragma fragment Frag
#pragma multi_compile _ FILTER_HORIZONTAL
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------

// Inputs & outputs
//-------------------------------------------------------------------------------------
#define N_SAMPLES 7
#define N_PROFILES 8
#define N_SAMPLES 7
float _BilateralScale; // Uses world-space units
float _DistToProjWindow; // The height of the projection window is 2 meters
float _FilterHorizontal; // Vertical = 0, horizontal = 1
float4 _FilterKernel[7]; // RGB = weights, A = radial distance
float _FilterRadius; // Uses world-space units
float4 _FilterKernels[N_PROFILES][N_SAMPLES + 1]; // RGB = weights, A = radial distance
float4x4 _InvProjMatrix;
TEXTURE2D(_GBufferTexture2);
SAMPLER2D(sampler_IrradianceSource);
#define bilinearSampler sampler_IrradianceSource
//-------------------------------------------------------------------------------------
// Implementation

Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullscreenTriangleVertexPosition(input.vertexID);
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
float4 Frag(Varyings input) : SV_Target
float3 Frag(Varyings input) : SV_Target
float rawDepth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).r;
float centerDepth = LinearEyeDepth(rawDepth, _ZBufferParams);
float radiusScale = _FilterRadius * _DistToProjWindow / centerDepth;
float2 gBufferData = LOAD_TEXTURE2D(_GBufferTexture2, posInput.unPositionSS).ra;
int profileID = int(gBufferData.y * N_PROFILES);
float distScale = gBufferData.x * 0.01;
float invDistScale = rcp(distScale);
// Compute the filtering direction.
float2 unitDirection = _FilterHorizontal ? float2(1, 0) : float2(0, 1);
float2 scaledDirection = radiusScale * unitDirection;
// Reconstruct the view-space position.
float rawDepth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).r;
float3 centerPosVS = ComputeViewSpacePosition(posInput.positionSS, rawDepth, _InvProjMatrix);
// Premultiply with the inverse of the screen size.
scaledDirection *= _ScreenSize.zw;
// Compute the dimensions of the surface fragment viewed as a quad facing the camera.
float fragWidth = ddx(centerPosVS.x);
float fragheight = ddy(centerPosVS.y);
float stepSizeX = rcp(fragWidth);
float stepSizeY = rcp(fragheight);
// Take the first (central) sample.
float3 sampleWeight = _FilterKernel[0].rgb;
float2 samplePosition = posInput.unPositionSS;
// Compute the filtering direction.
#ifdef FILTER_HORIZONTAL
float stepSize = stepSizeX;
float2 unitDirection = float2(1, 0);
#else
float stepSize = stepSizeY;
float2 unitDirection = float2(0, 1);
#endif
float2 scaledDirection = distScale * stepSize * unitDirection;
// Load (1 / (2 * Variance)) for bilateral weighting.
#ifdef RBG_BILATERAL_WEIGHTS
float3 halfRcpVariance = _FilterKernels[profileID][N_SAMPLES].rgb;
#else
float halfRcpVariance = _FilterKernels[profileID][N_SAMPLES].a;
#endif
// Take the first (central) sample.
float2 samplePosition = posInput.unPositionSS;
float3 sampleWeight = _FilterKernels[profileID][0].rgb;
float3 centerIrradiance = sampleIrradiance;
float3 filteredIrradiance = sampleIrradiance * sampleWeight;
float3 totalIrradiance = sampleIrradiance * sampleWeight;
// Make sure bilateral filtering does not cause energy loss.
// TODO: ask Morten if there is a better way to do this.
float3 totalWeight = sampleWeight;
sampleWeight = _FilterKernel[i].rgb;
samplePosition = posInput.positionSS + scaledDirection * _FilterKernel[i].a;
samplePosition = posInput.unPositionSS + scaledDirection * _FilterKernels[profileID][i].a;
sampleWeight = _FilterKernels[profileID][i].rgb;
sampleIrradiance = SAMPLE_TEXTURE2D_LOD(_IrradianceSource, bilinearSampler, samplePosition, 0).rgb;
rawDepth = SAMPLE_TEXTURE2D_LOD(_CameraDepthTexture, bilinearSampler, samplePosition, 0).r;
rawDepth = LOAD_TEXTURE2D(_CameraDepthTexture, samplePosition).r;
sampleIrradiance = LOAD_TEXTURE2D(_IrradianceSource, samplePosition).rgb;
// Apply bilateral filtering.
// Apply bilateral weighting.
// Ref #1: Skin Rendering by Pseudo–Separable Cross Bilateral Filtering.
// Ref #2: Separable SSS, Supplementary Materials, Section E.
float depthDiff = abs(sampleDepth - centerDepth);
float scaleDiff = _BilateralScale * _FilterRadius * _DistToProjWindow;
float t = saturate(depthDiff / scaleDiff);
float zDistance = invDistScale * sampleDepth - (invDistScale * centerPosVS.z);
sampleWeight *= exp(-zDistance * zDistance * halfRcpVariance);
// TODO: use real-world distances for weighting.
filteredIrradiance += lerp(sampleIrradiance, centerIrradiance, t) * sampleWeight;
totalIrradiance += sampleIrradiance * sampleWeight;
totalWeight += sampleWeight;
return float4(filteredIrradiance, 1.0);
return totalIrradiance / totalWeight;
}
ENDHLSL
}

25
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/SampleLayer.hlsl


struct LayerUV
{
float2 uv;
bool isPlanar; // mutually exclusive with isTriplanar
// triplanar
bool isTriplanar;
float2 uvYZ;

#undef SAMPLE_TEXTURE_FUNC
// Macro to improve readibility of surface data
#define SAMPLE_LAYER_TEXTURE2D(textureName, samplerName, coord) SampleLayer(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, 0.0) // Last 0.0 is unused
#define SAMPLE_LAYER_TEXTURE2D_LOD(textureName, samplerName, coord, lod) SampleLayerLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, lod)
#define SAMPLE_LAYER_TEXTURE2D_BIAS(textureName, samplerName, coord, bias) SampleLayerBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, bias)
#define SAMPLE_LAYER_TEXTURE2D(textureName, samplerName, coord) SampleLayer(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, 0.0) // Last 0.0 is unused
#define SAMPLE_LAYER_TEXTURE2D_LOD(textureName, samplerName, coord, lod) SampleLayerLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, lod)
#define SAMPLE_LAYER_TEXTURE2D_BIAS(textureName, samplerName, coord, bias) SampleLayerBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, bias)
#define SAMPLE_LAYER_NORMALMAP(textureName, samplerName, coord, scale) SampleLayerNormal(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, bias)
#define SAMPLE_LAYER_NORMALMAP(textureName, samplerName, coord, scale) SampleLayerNormal(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, bias)
#define SAMPLE_LAYER_NORMALMAP_AG(textureName, samplerName, coord, scale) SampleLayerNormalAG(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_AG_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalAGLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_AG_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalAGBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, bias)
#define SAMPLE_LAYER_NORMALMAP_AG(textureName, samplerName, coord, scale) SampleLayerNormalAG(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_AG_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalAGLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_AG_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalAGBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, bias)
#define SAMPLE_LAYER_NORMALMAP_RGB(textureName, samplerName, coord, scale) SampleLayerNormalRGB(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_RGB_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalRGBLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_RGB_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalRGBBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.weights, scale, bias)
#define SAMPLE_LAYER_NORMALMAP_RGB(textureName, samplerName, coord, scale) SampleLayerNormalRGB(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_RGB_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalRGBLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_RGB_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalRGBBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.triplanarWeights, scale, bias)

60
Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/SubsurfaceScatteringParameters.cs


using System;
using UnityEditor;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

public const int numSamples = 7; // Must be an odd number
public const int numVectors = 8; // numSamples + 1 for (1 / (2 * WeightedVariance))
[SerializeField, ColorUsage(false, true, 0.05f, 2.0f, 1.0f, 1.0f)]
Color m_StdDev1;

void ComputeKernel()
{
if (m_FilterKernel == null || m_FilterKernel.Length != numSamples)
if (m_FilterKernel == null || m_FilterKernel.Length != numVectors)
m_FilterKernel = new Vector4[numSamples];
m_FilterKernel = new Vector4[numVectors];
}
// Our goal is to blur the image using a filter which is represented

val.y = GaussianCombination(pos, m_StdDev1.g, m_StdDev2.g, m_LerpWeight);
val.z = GaussianCombination(pos, m_StdDev1.b, m_StdDev2.b, m_LerpWeight);
m_FilterKernel[i].x = val.x / (pdf * numSamples);
m_FilterKernel[i].y = val.y / (pdf * numSamples);
m_FilterKernel[i].z = val.z / (pdf * numSamples);
// We do not divide by 'numSamples' since we will renormalize, anyway.
m_FilterKernel[i].x = val.x * (1 / pdf);
m_FilterKernel[i].y = val.y * (1 / pdf);
m_FilterKernel[i].z = val.z * (1 / pdf);
m_FilterKernel[i].w = pos;
weightSum.x += m_FilterKernel[i].x;

// Renormalize the weights to conserve energy.
for (uint i = 0; i < numSamples; i++)
{
m_FilterKernel[i].x *= 1.0f / weightSum.x;
m_FilterKernel[i].y *= 1.0f / weightSum.y;
m_FilterKernel[i].z *= 1.0f / weightSum.z;
m_FilterKernel[i].x *= 1 / weightSum.x;
m_FilterKernel[i].y *= 1 / weightSum.y;
m_FilterKernel[i].z *= 1 / weightSum.z;
m_KernelNeedsUpdate = false;
Vector4 weightedStdDev;
weightedStdDev.x = Mathf.Lerp(m_StdDev1.r, m_StdDev2.r, m_LerpWeight);
weightedStdDev.y = Mathf.Lerp(m_StdDev1.g, m_StdDev2.g, m_LerpWeight);
weightedStdDev.z = Mathf.Lerp(m_StdDev1.b, m_StdDev2.b, m_LerpWeight);
weightedStdDev.w = Mathf.Lerp(maxStdDev1, maxStdDev2, m_LerpWeight);
// Store (1 / (2 * Variance)) per color channel.
m_FilterKernel[numSamples].x = 0.5f / (weightedStdDev.x * weightedStdDev.x);
m_FilterKernel[numSamples].y = 0.5f / (weightedStdDev.y * weightedStdDev.y);
m_FilterKernel[numSamples].z = 0.5f / (weightedStdDev.z * weightedStdDev.z);
m_FilterKernel[numSamples].w = 0.5f / (weightedStdDev.w * weightedStdDev.w);
const int m_maxNumProfiles = 8;
public const int maxNumProfiles = 8;
[SerializeField]
float m_BilateralScale;
m_NumProfiles = 1;
m_Profiles = new SubsurfaceScatteringProfile[m_NumProfiles];
m_BilateralScale = 0.1f;
m_NumProfiles = 1;
m_Profiles = new SubsurfaceScatteringProfile[m_NumProfiles];
for (int i = 0; i < m_NumProfiles; i++)
{

public SubsurfaceScatteringProfile[] profiles { set { m_Profiles = value; OnValidate(); } get { return m_Profiles; } }
public float bilateralScale { set { m_BilateralScale = value; OnValidate(); } get { return m_BilateralScale; } }
public SubsurfaceScatteringProfile[] profiles { set { m_Profiles = value; OnValidate(); } get { return m_Profiles; } }
public void SetDirtyFlag()
{

void OnValidate()
{
if (m_Profiles.Length > m_maxNumProfiles)
if (m_Profiles.Length > maxNumProfiles)
Array.Resize(ref m_Profiles, m_maxNumProfiles);
Array.Resize(ref m_Profiles, maxNumProfiles);
}
m_NumProfiles = m_Profiles.Length;

m_Profiles[i].lerpWeight = Mathf.Clamp01(m_Profiles[i].lerpWeight);
}
m_BilateralScale = Mathf.Clamp01(m_BilateralScale);
}
}

}
}
#if UNITY_EDITOR
[CustomEditor(typeof(SubsurfaceScatteringParameters))]
public class SubsurfaceScatteringParametersEditor : Editor
{

public readonly GUIContent sssProfileStdDev1 = new GUIContent("SSS profile standard deviation #1", "Determines the shape of the 1st Gaussian filter. Increases the strength and the radius of the blur of the corresponding color channel.");
public readonly GUIContent sssProfileStdDev2 = new GUIContent("SSS profile standard deviation #2", "Determines the shape of the 2nd Gaussian filter. Increases the strength and the radius of the blur of the corresponding color channel.");
public readonly GUIContent sssProfileLerpWeight = new GUIContent("SSS profile filter interpolation", "Controls linear interpolation between the two Gaussian filters.");
public readonly GUIContent sssBilateralScale = new GUIContent("SSS bilateral filtering scale", "Larger values make the filter more tolerant to depth differences.");
private SerializedProperty m_BilateralScale;
// --- Public Methods ---

EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_Profiles, true);
EditorGUILayout.PropertyField(m_BilateralScale, styles.sssBilateralScale);
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();

void OnEnable()
{
m_Profiles = serializedObject.FindProperty("m_Profiles");
m_BilateralScale = serializedObject.FindProperty("m_BilateralScale");
m_Profiles = serializedObject.FindProperty("m_Profiles");
#endif
}

20
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/TessellationShare.hlsl


// AMD recommand this value for GCN http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/05/GCNPerformanceTweets.pdf
#define MAX_TESSELLATION_FACTORS 15.0
struct TessellationFactors
{
float edge[3] : SV_TessFactor;

float3 n1 = varying1.vmesh.normalWS;
float3 n2 = varying2.vmesh.normalWS;
// ref: http://reedbeta.com/blog/tess-quick-ref/
// x - 1->2 edge
// y - 2->0 edge
// z - 0->1 edge
// w - inside tessellation factor
output.edge[0] = tf.x;
output.edge[1] = tf.y;
output.edge[2] = tf.z;
output.inside = tf.w;
output.edge[0] = min(tf.x, MAX_TESSELLATION_FACTORS);
output.edge[1] = min(tf.y, MAX_TESSELLATION_FACTORS);
output.edge[2] = min(tf.z, MAX_TESSELLATION_FACTORS);
output.inside = min(tf.w, MAX_TESSELLATION_FACTORS);
[maxtessfactor(15.0)] // AMD recommand this value for GCN http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/05/GCNPerformanceTweets.pdf
[maxtessfactor(MAX_TESSELLATION_FACTORS)]
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]

#endif
#if defined(_TESSELLATION_DISPLACEMENT) || defined(_TESSELLATION_DISPLACEMENT_PHONG)
varying.vmesh.positionWS += GetDisplacement(varying.vmesh);
varying.vmesh.positionWS += GetTessellationDisplacement(varying.vmesh);
#endif
return VertTesselation(varying);

7
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl


// As I haven't change the variables name yet, I simply don't define anything, and I put the transform function at the end of the file outside the guard header.
// This need to be fixed.
float4x4 glstate_matrix_inv_projection;
#define UNITY_MATRIX_M unity_ObjectToWorld
// These are updated per eye in VR

float4x4 GetWorldToHClipMatrix()
{
return UNITY_MATRIX_VP;
}
// Transform from clip space to homogenous world space
float4x4 GetClipToHWorldMatrix()
{
return glstate_matrix_inv_projection;
}
float GetOddNegativeScale()

46
Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs


var gpuProj = GL.GetGPUProjectionMatrix(camera.projectionMatrix, false);
var gpuVP = gpuProj * camera.worldToCameraMatrix;
hdCamera.viewProjectionMatrix = gpuVP;
hdCamera.viewProjectionMatrix = gpuVP;
hdCamera.invProjectionMatrix = gpuProj.inverse;
return hdCamera;
}

return renderContext;
}
static Mesh m_ScreenSpaceTriangle = null;
static Mesh GetScreenSpaceTriangle()
{
// If the assembly has been reloaded, the pointer will become NULL.
if (!m_ScreenSpaceTriangle)
{
m_ScreenSpaceTriangle = new Mesh
{
// Note: neither the vertex nor the index data is actually used if the vertex shader computes vertices
// using 'SV_VertexID'. However, there is currently no way to bind NULL vertex or index buffers.
vertices = new[] { new Vector3(-1, -1, 1), new Vector3(3, -1, 1), new Vector3(-1, 3, 1) },
triangles = new[] { 0, 1, 2 }
};
}
return m_ScreenSpaceTriangle;
}
// Draws a full screen triangle as a faster alternative to drawing a full-screen quad.
public static void DrawFullscreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
// Draws a full screen triangle as a faster alternative to drawing a full screen quad.
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
commandBuffer.DrawMesh(GetScreenSpaceTriangle(), Matrix4x4.identity, material, 0, shaderPassID, properties);
commandBuffer.DrawProcedural(Matrix4x4.identity, material, shaderPassID, MeshTopology.Triangles, 3, 1, properties);
// Draws a full screen triangle as a faster alternative to drawing a full-screen quad.
public static void DrawFullscreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
// Draws a full screen triangle as a faster alternative to drawing a full screen quad.
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
commandBuffer.DrawMesh(GetScreenSpaceTriangle(), Matrix4x4.identity, material, 0, shaderPassID, properties);
commandBuffer.DrawProcedural(Matrix4x4.identity, material, shaderPassID, MeshTopology.Triangles, 3, 1, properties);
// Draws a full screen triangle as a faster alternative to drawing a full-screen quad.
public static void DrawFullscreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
// Draws a full screen triangle as a faster alternative to drawing a full screen quad.
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
commandBuffer.DrawMesh(GetScreenSpaceTriangle(), Matrix4x4.identity, material, 0, shaderPassID, properties);
commandBuffer.DrawProcedural(Matrix4x4.identity, material, shaderPassID, MeshTopology.Triangles, 3, 1, properties);
// Draws a full screen triangle as a faster alternative to drawing a full-screen quad.
// Draws a full screen triangle as a faster alternative to drawing a full screen quad.
public static void DrawFullscreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
RenderTargetIdentifier[] colorBuffers,
MaterialPropertyBlock properties = null, int shaderPassID = 0)
{

// no depth target ends up being bound.
DrawFullscreen(commandBuffer, material, camera, colorBuffers, colorBuffers[0], properties, shaderPassID);
DrawFullScreen(commandBuffer, material, camera, colorBuffers, colorBuffers[0], properties, shaderPassID);
}
}
}

29
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// Texture utilities
// ----------------------------------------------------------------------------
float ComputeTextureLOD(float2 uv)
{
float2 ddx_ = ddx(uv);
float2 ddy_ = ddy(uv);
float d = max(dot(ddx_, ddx_), dot(ddy_, ddy_));
return max(0.5 * log2(d), 0.0);
}
// texelSize is Unity XXX_TexelSize feature parameters
// x contains 1.0/width, y contains 1.0 / height, z contains width, w contains height
float ComputeTextureLOD(float2 uv, float4 texelSize)

float2 ddx_ = ddx(uv);
float2 ddy_ = ddy(uv);
float d = max(dot(ddx_, ddx_), dot(ddy_, ddy_));
return max(0.5 * log2(d), 0.0);
return ComputeTextureLOD(uv);
}
// ----------------------------------------------------------------------------

posInput.positionCS *= posInput.depthVS;
}
float3 ComputeViewSpacePosition(float2 positionSS, float rawDepth, float4x4 invProjMatrix)
{
float4 positionCS = float4(positionSS * 2.0 - 1.0, rawDepth, 1.0);
float4 positionVS = mul(invProjMatrix, positionCS);
// The view space uses a right-handed coordinate system.
positionVS.z = -positionVS.z;
return positionVS.xyz / positionVS.w;
}
// depthOffsetVS is always in the direction of the view vector (V)
void ApplyDepthOffsetPositionInput(float3 V, float depthOffsetVS, inout PositionInputs posInput)
{

posInput.positionWS += V * depthOffsetVS;
}
float2 GetFullscreenTriangleTexcoord(uint vertexID)
float2 GetFullScreenTriangleTexcoord(uint vertexID)
{
#if UNITY_UV_STARTS_AT_TOP
return float2((vertexID << 1) & 2, 1.0 - (vertexID & 2));

}
float4 GetFullscreenTriangleVertexPosition(uint vertexID)
float4 GetFullScreenTriangleVertexPosition(uint vertexID)
{
float2 uv = float2((vertexID << 1) & 2, vertexID & 2);
return float4(uv * 2.0 - 1.0, 1.0, 1.0);

17
Assets/TestScenes/HDTest/GraphicTest/LayeredTessellation/Layer-2-woord-rock.mat


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Layer-2-woord-rock
m_Shader: {fileID: 4800000, guid: eab0538d9d5746246806a9611c04ac4d, type: 3}
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
_TESSELLATION_DISPLACEMENT _USEHEIGHTBASEDBLENDV2_OFF _USEHEIGHTBASEDBLEND_OFF
_TESSELLATION_DISPLACEMENT _USEDENSITYMODE_OFF _USEHEIGHTBASEDBLENDV2_OFF _USEHEIGHTBASEDBLEND_OFF
_USEMAINLAYERINFLUENCE_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0

- _InheritBaseNormal3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 0
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1

- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

920
Assets/TestScenes/HDTest/LayeredLitTest.unity
文件差异内容过多而无法显示
查看文件

64
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat


_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYER _LAYEREDLIT_4_LAYERS
_LAYERMASKMAP _LAYERMASKVERTEXCOLOR_OFF _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_PLANAR_0
_LAYER_MAPPING_PLANAR_1 _LAYER_MAPPING_PLANAR_2 _LAYER_MAPPING_PLANAR_3 _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV3
m_EnableInstancingVariants: 0
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _EmissiveIntensity1: 0
- _EmissiveIntensity2: 0
- _EmissiveIntensity3: 0
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude0: 1
- _HeightAmplitude1: 1
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0
- _HeightCenter1: 0
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0
- _LayerCenterOffset1: 0
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 1
- _LayerHeightAmplitude1: 1
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerMapping0: 2
- _LayerMapping1: 2
- _LayerMapping2: 2

- _LayerSize1: 4
- _LayerSize2: 2
- _LayerSize3: 2
- _LayerTiling0: 10
- _LayerTiling0: 2
- _LayerTiling1: 10
- _LayerTiling2: 1
- _LayerTiling3: 1

- _Metallic1: 0
- _Metallic2: 0
- _Metallic3: 0
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness: 0.5
- _Smoothness0: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseHeightBasedBlend: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat.meta


timeCreated: 1480682670
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["fbea672215bd9944f8d9f98d5437e3cb","b91619c97bb14b64b82c0cdeaac0cc68","be6f395f0458348419faf76aca4cf856","000d0f1d5b188ed43a674de93e854997"]}'
assetBundleName:
assetBundleVariant:

53
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _HEIGHTMAP
_HEIGHT_BASED_BLEND _LAYEREDLIT_4_LAYERS _LAYERMASKVERTEXCOLOR_OFF _MASKMAP _NORMALMAP
_NORMALMAP_TANGENT_SPACE
_HEIGHTMAP0 _HEIGHTMAP1 _HEIGHTMAP2 _HEIGHTMAP3 _HEIGHT_BASED_BLEND _LAYEREDLIT_4_LAYERS
_LAYERMASKVERTEXCOLOR_OFF _LAYER_MASK_VERTEX_COLOR_ADD _MASKMAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0.023
- _BlendSize2: 0.011
- _BlendSize3: 0.008
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0.5
- _HeightCenter3: 0.5
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 0.1
- _HeightScale2: 0.05
- _HeightScale3: 0.06
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0.5
- _LayerCenterOffset3: 0.5
- _LayerHeightAmplitude0: 0.25
- _LayerHeightAmplitude1: 0.15
- _LayerHeightAmplitude2: 0.1
- _LayerHeightAmplitude3: 0.15
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 1

- _UVMappingPlanar2: 1
- _UVMappingPlanar3: 1
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 2
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat.meta


timeCreated: 1482421811
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["7adfbb6db534e344c85f8eb7ab642b97","800aedd86ec775045b0b4974eda75658","8bba27ebea7237741bac166a2cb5165e","1534f8b1e5a4e0341b37dc1ec2592b29"]}'
assetBundleName:
assetBundleVariant:

49
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat


_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat.meta


timeCreated: 1481879942
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'
assetBundleName:
assetBundleVariant:

53
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat


m_Name: Layered_Layer0_Triplanar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_0 _LAYER_MASK_VERTEX_COLOR
_LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE
_DISTORTIONONLY_OFF _DOUBLESIDED _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_0
_LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 0
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat.meta


timeCreated: 1481881655
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'
assetBundleName:
assetBundleVariant:

49
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat


_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat.meta


timeCreated: 1481819419
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'
assetBundleName:
assetBundleVariant:

53
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat


_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _TexWorldScale2: 1
- _TexWorldScale3: 1
- _UVBase: 0
- _UVBase0: 1
- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 0
- _UVBase3: 0

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

- _UVDetailsMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask3: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask0: {r: 0, g: 1, b: 0, a: 0}
- _UVMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat.meta


timeCreated: 1481819429
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'
assetBundleName:
assetBundleVariant:

51
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2 _REQUIRE_UV2_OR_UV3
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat.meta


timeCreated: 1481881733
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'
assetBundleName:
assetBundleVariant:

55
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat


_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1

- _OcclusionStrength: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _TexWorldScale2: 1
- _TexWorldScale3: 1
- _UVBase: 0
- _UVBase0: 3
- _UVBase0: 4
- _UVBase1: 3
- _UVBase2: 0
- _UVBase3: 0

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar0: 1
- _UseDensityMode: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

- _UVDetailsMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask3: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask0: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask0: {r: 0, g: 0, b: 0, a: 0}
- _UVMappingMask1: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat.meta


timeCreated: 1481881392
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'
assetBundleName:
assetBundleVariant:

63
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV3
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _BlendUsingHeight1: 0
- _BlendUsingHeight2: 0
- _BlendUsingHeight3: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _DstBlend: 0
- _EmissiveColorMode: 0
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightCenterOffset0: 0
- _HeightCenterOffset1: 0
- _HeightCenterOffset2: 0
- _HeightCenterOffset3: 0
- _HeightFactor0: 1
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _HorizonFade: 1
- _InheritBaseColor1: 0
- _InheritBaseColor2: 0
- _InheritBaseColor3: 0
- _InheritBaseColorThreshold1: 1
- _InheritBaseColorThreshold2: 1
- _InheritBaseColorThreshold3: 1
- _InheritBaseHeight1: 0
- _InheritBaseHeight2: 0
- _InheritBaseHeight3: 0
- _InheritBaseNormal1: 0
- _InheritBaseNormal2: 0
- _InheritBaseNormal3: 0
- _LayerCenterOffset0: 0.5
- _LayerCenterOffset1: 0.5
- _LayerCenterOffset2: 0
- _LayerCenterOffset3: 0
- _LayerHeightAmplitude0: 0.01
- _LayerHeightAmplitude1: 0.01
- _LayerHeightAmplitude2: 1
- _LayerHeightAmplitude3: 1
- _LayerTiling0: 1
- _LayerTiling1: 1
- _LayerTiling2: 1
- _LayerTiling3: 1
- _MinimumOpacity0: 1
- _MinimumOpacity1: 1
- _MinimumOpacity2: 1
- _MinimumOpacity3: 1
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OpacityAsDensity0: 0
- _OpacityAsDensity1: 0
- _OpacityAsDensity2: 0
- _OpacityAsDensity3: 0
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness0: 0.5
- _Smoothness1: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseDensityMode: 0
- _UseHeightBasedBlend: 0
- _UseMainLayerInfluence: 0
- _VertexColorMode: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

1
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat.meta


timeCreated: 1480680724
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: -1
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}'
assetBundleName:
assetBundleVariant:

2
ProjectSettings/QualitySettings.asset


shadowProjection: 1
shadowCascades: 2
shadowDistance: 200
shadowNearPlaneOffset: 2
shadowNearPlaneOffset: 5
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.021409363, y: 0.051549375, z: 0.07213539}
blendWeights: 4

7
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl


#ifndef UNITY_DEBUG_LIGHTING_INCLUDED
#define UNITY_DEBUG_LIGHTING_INCLUDED
float4 _DebugLightModeAndAlbedo; // x == debug mode, yzw = albedo for diffuse.
float4 _DebugLightingSmoothness; // x == bool override, y == override value
#endif

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl.meta


fileFormatVersion: 2
guid: 1af9f7b2ee767504fb89dc98550d62f6
timeCreated: 1486032323
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

15
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs. Please don't edit by hand.
//
#ifndef HDRENDERPIPELINEDEBUG_CS_HLSL
#define HDRENDERPIPELINEDEBUG_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.LightingDebugMode: static fields
//
#define LIGHTINGDEBUGMODE_NONE (0)
#define LIGHTINGDEBUGMODE_DIFFUSE_LIGHTING (1)
#define LIGHTINGDEBUGMODE_SPECULAR_LIGHTING (2)
#endif

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl.meta


fileFormatVersion: 2
guid: 04e346a720261d94b85f6d20b0cd8064
timeCreated: 1486041561
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

105
Assets/ScriptableRenderLoop/ShaderLibrary/PerPixelDisplacement.hlsl


// This is implementation of parallax occlusion mapping (POM)
// This function require that the caller define a callback for the height sampling name ComputePerPixelHeightDisplacement
// A PerPixelHeightDisplacementParam is used to provide all data necessary to calculate the heights to ComputePerPixelHeightDisplacement it doesn't need to be
// visible by the POM algorithm.
// This function is compatible with tiled uv.
// it return the offset to apply to the UVSet provide in PerPixelHeightDisplacementParam
// viewDirTS is view vector in texture space matching the UVSet
// ref: https://www.gamedev.net/resources/_/technical/graphics-programming-and-theory/a-closer-look-at-parallax-occlusion-mapping-r3262
float2 ParallaxOcclusionMapping(float lod, float lodThreshold, int numSteps, float3 viewDirTS, float maxHeight, PerPixelHeightDisplacementParam ppdParam)
{
// Convention: 1.0 is top, 0.0 is bottom - POM is always inward, no extrusion
float stepSize = 1.0 / (float)numSteps;
// View vector is from the point to the camera, but we want to raymarch from camera to point, so reverse the sign
// The length of viewDirTS vector determines the furthest amount of displacement:
// float parallaxLimit = -length(viewDirTS.xy) / viewDirTS.z;
// float2 parallaxDir = normalize(Out.viewDirTS.xy);
// float2 parallaxMaxOffsetTS = parallaxDir * parallaxLimit;
// Above code simplify to
float2 parallaxMaxOffsetTS = (viewDirTS.xy / -viewDirTS.z) * maxHeight;
float2 texOffsetPerStep = stepSize * parallaxMaxOffsetTS;
// Do a first step before the loop to init all value correctly
float2 texOffsetCurrent = float2(0.0, 0.0);
float prevHeight = ComputePerPixelHeightDisplacement(texOffsetCurrent, lod, ppdParam);
texOffsetCurrent += texOffsetPerStep;
float currHeight = ComputePerPixelHeightDisplacement(texOffsetCurrent, lod, ppdParam);
float rayHeight = 1.0 - stepSize; // Start at top less one sample
// Linear search
for (int stepIndex = 0; stepIndex < numSteps; ++stepIndex)
{
// Have we found a height below our ray height ? then we have an intersection
if (currHeight > rayHeight)
break; // end the loop
prevHeight = currHeight;
rayHeight -= stepSize;
texOffsetCurrent += texOffsetPerStep;
// Sample height map which in this case is stored in the alpha channel of the normal map:
currHeight = ComputePerPixelHeightDisplacement(texOffsetCurrent, lod, ppdParam);
}
// Found below and above points, now perform line interesection (ray) with piecewise linear heightfield approximation
// Refine the search by adding few extra intersection
#define POM_REFINE 1
#if POM_REFINE
float pt0 = rayHeight + stepSize;
float pt1 = rayHeight;
float delta0 = pt0 - prevHeight;
float delta1 = pt1 - currHeight;
float2 offset = float2(0.0, 0.0);
float threshold = 1.0;
for (int i = 0; i < 5; ++i)
{
float t = (pt0 * delta1 - pt1 * delta0) / (delta1 - delta0);
offset = (1 - t) * texOffsetPerStep * numSteps;
currHeight = ComputePerPixelHeightDisplacement(offset, lod, ppdParam);
threshold = t - currHeight;
if (abs(threshold) <= 0.01)
break;
if (threshold < 0.0)
{
delta1 = threshold;
pt1 = t;
}
else
{
delta0 = threshold;
pt0 = t;
}
}
#else
//float pt0 = rayHeight + stepSize;
//float pt1 = rayHeight;
//float delta0 = pt0 - prevHeight;
//float delta1 = pt1 - currHeight;
//float t = (pt0 * delta1 - pt1 * delta0) / (delta1 - delta0);
//float2 offset = (1 - t) * texOffsetPerStep * numSteps;
// A bit more optimize
float delta0 = currHeight - rayHeight;
float delta1 = (rayHeight + stepSize) - prevHeight;
float ratio = delta0 / (delta0 + delta1);
float2 offset = texOffsetCurrent - ratio * texOffsetPerStep;
#endif
// Fade the effect with lod (allow to avoid pop when switching to a discrete LOD mesh)
offset *= (1.0 - saturate(lod - lodThreshold));
return offset;
}

9
Assets/ScriptableRenderLoop/ShaderLibrary/PerPixelDisplacement.hlsl.meta


fileFormatVersion: 2
guid: 0a40799d368cbbd4982d2f423cdd8595
timeCreated: 1486045136
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

19
Assets/TestScenes/HDTest/CascadedShadowsTest/CommonSettings_Cascaded.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc357c46587fc9d4cb8f311794d7d2f3, type: 3}
m_Name: CommonSettings_Cascaded
m_EditorClassIdentifier:
m_Settings:
m_ShadowMaxDistance: 450
m_ShadowCascadeCount: 4
m_ShadowCascadeSplit0: 0.015
m_ShadowCascadeSplit1: 0.05
m_ShadowCascadeSplit2: 0.2

9
Assets/TestScenes/HDTest/CascadedShadowsTest/CommonSettings_Cascaded.asset.meta


fileFormatVersion: 2
guid: 075f395cb6ba2534196f2ce83c32e633
timeCreated: 1485858348
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

20
Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59b6606ef2548734bb6d11b9d160bc7e, type: 3}
m_Name: HDRISkyParameters_Cascaded
m_EditorClassIdentifier:
rotation: 0
exposure: 0
multiplier: 1
resolution: 256
updateMode: 0
updatePeriod: 0
skyHDRI: {fileID: 8900000, guid: 9b513842339ef704ca63ef696691bc34, type: 3}

9
Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset.meta


fileFormatVersion: 2
guid: e87251404948e274ab006302af9b80f8
timeCreated: 1486126252
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存