浏览代码

Merge branch 'master' into batch_rendering

# Conflicts:
#	Assets/BasicRenderBatching.meta
#	Assets/BasicRenderBatching/LightingBatching.meta
#	Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
#	Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/Textures.meta
#	Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
#	Assets/TestScenes/HDTest/CascadedShadowsTest.meta
#	Assets/TestScenes/HDTest/GlobalIlluminationTest/LightingData.asset
#	Assets/TestScenes/HDTest/GraphicTest/Two Sided/Prefabs/Materials.meta
#	Assets/TestScenes/HDTest/Leaf.meta
#	Assets/TestScenes/HDTest/Leaf/GroundLeaf.meta
/batch_rendering
Arnaud Carré arnaud@unity3d.com 8 年前
当前提交
ca6b7f62
共有 364 个文件被更改,包括 5850 次插入3376 次删除
  1. 4
      Assets/BasicRenderBatching/BasicRenderBatching.cs
  2. 8
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  3. 2
      Assets/ScriptableRenderLoop/AdditionalLightData.cs
  4. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
  5. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
  6. 316
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  7. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
  8. 33
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  9. 3
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta
  10. 886
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  11. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs
  12. 80
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
  13. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/ClusteredUtils.hlsl
  14. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl
  15. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
  16. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-clustered.compute
  17. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute
  18. 28
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute
  19. 310
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  20. 17
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  21. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  22. 199
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  23. 103
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  24. 110
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  25. 73
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  26. 103
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  27. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs
  28. 16
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  29. 55
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  30. 109
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  31. 708
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  32. 177
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  33. 61
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  34. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
  35. 124
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
  36. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
  37. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl
  38. 25
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/SampleLayer.hlsl
  39. 56
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/SampleLayerInternal.hlsl
  40. 286
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  41. 89
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
  42. 202
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Editor/PostProcessingEditor.cs
  43. 446
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.cs
  44. 114
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
  45. 134
      Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/CommonSettings.cs
  46. 5
      Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/Editor/CommonSettingsEditor.cs
  47. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  48. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  49. 20
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/TessellationShare.hlsl
  50. 67
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
  51. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs
  52. 37
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
  53. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
  54. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyParameters.cs
  55. 35
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  56. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
  57. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
  58. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
  59. 162
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs
  60. 35
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyParameters.cs
  61. 35
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyRenderer.cs
  62. 129
      Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
  63. 30
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
  64. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/API/D3D11.hlsl
  65. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/API/Metal.hlsl
  66. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl
  67. 41
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  68. 13
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  69. 6
      Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl
  70. 72
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
  71. 83
      Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl
  72. 4
      Assets/ScriptableRenderLoop/core/RenderPipeline.cs
  73. 7
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  74. 2
      Assets/ScriptableRenderLoop/fptl/LightingConvexHullUtils.hlsl
  75. 6
      Assets/ScriptableRenderLoop/fptl/TiledLightingUtils.hlsl
  76. 2
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute
  77. 10
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-clustered.compute
  78. 4
      Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute
  79. 596
      Assets/TestScenes/HDTest/GlobalIlluminationTest.unity
  80. 998
      Assets/TestScenes/HDTest/GlobalIlluminationTest/LightingData.asset
  81. 3
      Assets/TestScenes/HDTest/GlobalIlluminationTest/LightingData.asset.meta
  82. 17
      Assets/TestScenes/HDTest/GraphicTest/LayeredTessellation/Layer-2-woord-rock.mat
  83. 4
      Assets/TestScenes/HDTest/GraphicTest/Two Sided/Prefabs/Materials.meta
  84. 453
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity
  85. 920
      Assets/TestScenes/HDTest/LayeredLitTest.unity
  86. 64
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat
  87. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat.meta
  88. 53
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat
  89. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat.meta
  90. 49
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
  91. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat.meta
  92. 53
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
  93. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat.meta
  94. 49
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
  95. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat.meta
  96. 53
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat
  97. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat.meta
  98. 51
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat
  99. 1
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat.meta

4
Assets/BasicRenderBatching/BasicRenderBatching.cs


var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("BasicPass"));
settings.sorting.flags = SortFlags.CommonOpaque;
settings.inputFilter.SetQueuesOpaque();
context.DrawRenderers(settings);
context.DrawRenderers(ref settings);
// Draw skybox
context.DrawSkybox(camera);

settings.inputFilter.SetQueuesTransparent();
context.DrawRenderers(settings);
context.DrawRenderers(ref settings);
context.Submit();
}

8
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


var instance = ScriptableObject.CreateInstance<BasicRenderLoop>();
UnityEditor.AssetDatabase.CreateAsset(instance, "Assets/BasicRenderLoopTutorial/BasicRenderLoop.asset");
}
#endif
protected override IRenderPipeline InternalCreatePipeline()

public class BasicRenderLoopInstance : RenderPipeline
{
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{
base.Render(renderContext, cameras);

var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("BasicPass"));
settings.sorting.flags = SortFlags.CommonOpaque;
settings.inputFilter.SetQueuesOpaque();
context.DrawRenderers(settings);
context.DrawRenderers(ref settings);
// Draw skybox
context.DrawSkybox(camera);

settings.inputFilter.SetQueuesTransparent();
context.DrawRenderers(settings);
context.DrawRenderers(ref settings);
// Setup lighting variables for shader to use

context.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
// Prepare L2 spherical harmonics values for efficient evaluation in a shader

2
Assets/ScriptableRenderLoop/AdditionalLightData.cs


}
[Range(0.0F, 100.0F)]
private float m_innerSpotPercent = 0.0F;
public float m_innerSpotPercent = 0.0f; // To display this field in the UI this need to be public
public float GetInnerSpotPercent01()
{

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader


HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma vertex Vert
#pragma fragment Frag

DECLARE_GBUFFER_TEXTURE(_GBufferTexture);
TEXTURE2D(_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
int _DebugViewMaterial;

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader


HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma vertex Vert
#pragma fragment Frag

// variable declaration
//-------------------------------------------------------------------------------------
TEXTURE2D(_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
uint _ViewTilesFlags;

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


using System;
using System.Reflection;
using System.Linq.Expressions;
using UnityEditor;
//using EditorGUIUtility=UnityEditor.EditorGUIUtility;

{
private class Styles
{
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.");
public readonly GUIContent settingsLabel = new GUIContent("Settings");
// 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 shadowSettings = new GUIContent("Shadow Settings");
public readonly GUIContent sssSettings = new GUIContent("Subsurface Scattering Settings");
public readonly GUIContent shadowsEnabled = new GUIContent("Enabled");
// Shadow Settings
public readonly GUIContent shadowSettings = new GUIContent("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");
// 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 textureSettings = new GUIContent("Texture Settings");
// 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");
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");
// 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;

}
}
const float k_MaxExposure = 32.0f;
// Global debug
SerializedProperty m_ShowMaterialDebug = null;
SerializedProperty m_ShowLightingDebug = null;
SerializedProperty m_ShowRenderingDebug = null;
SerializedProperty m_DebugOverlayRatio = 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_DebugShadowEnabled = 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;
private void InitializeProperties()
{
// Global debug
m_DebugOverlayRatio = FindProperty(x => x.globalDebugParameters.debugOverlayRatio);
m_ShowLightingDebug = FindProperty(x => x.globalDebugParameters.displayLightingDebug);
m_ShowRenderingDebug = FindProperty(x => x.globalDebugParameters.displayRenderingDebug);
m_ShowMaterialDebug = FindProperty(x => x.globalDebugParameters.displayMaterialDebug);
// 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)
{
var path = Utilities.GetFieldPath(expr);
return serializedObject.FindProperty(path);
}
string GetSubNameSpaceName(Type type)
{

}
}
private void DebugParametersUI(HDRenderPipeline renderContext)
static void HackSetDirty(RenderPipelineAsset asset)
{
EditorUtility.SetDirty(asset);
var method = typeof(RenderPipelineAsset).GetMethod("OnValidate", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Instance);
if (method != null)
method.Invoke(asset, new object[0]);
}
private void DebuggingUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
var debugParameters = renderContext.debugParameters;
EditorGUILayout.LabelField(styles.debugging);
EditorGUILayout.LabelField(styles.debugParameters);
// Global debug parameters
EditorGUI.indentLevel++;
m_DebugOverlayRatio.floatValue = EditorGUILayout.Slider(styles.debugOverlayRatio, m_DebugOverlayRatio.floatValue, 0.1f, 1.0f);
EditorGUILayout.Space();
MaterialDebugParametersUI(renderContext);
RenderingDebugParametersUI(renderContext);
LightingDebugParametersUI(renderContext, renderpipelineInstance);
EditorGUILayout.Space();
EditorGUI.indentLevel--;
}
private void MaterialDebugParametersUI(HDRenderPipeline renderContext)
{
m_ShowMaterialDebug.boolValue = EditorGUILayout.Foldout(m_ShowMaterialDebug.boolValue, styles.materialDebugLabel);
if (!m_ShowMaterialDebug.boolValue)
return;
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();

styles.isDebugViewMaterialInit = true;
}
debugParameters.debugViewMaterial = EditorGUILayout.IntPopup(styles.debugViewMaterial, (int)debugParameters.debugViewMaterial, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
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())
{
HackSetDirty(renderContext); // Repaint
}
EditorGUI.indentLevel--;
}
private void RenderingDebugParametersUI(HDRenderPipeline renderContext)
{
m_ShowRenderingDebug.boolValue = EditorGUILayout.Foldout(m_ShowRenderingDebug.boolValue, styles.renderingDebugParameters);
if (!m_ShowRenderingDebug.boolValue)
return;
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_DisplayOpaqueObjects, styles.displayOpaqueObjects);
EditorGUILayout.PropertyField(m_DisplayTransparentObjects, styles.displayTransparentObjects);
EditorGUILayout.PropertyField(m_EnableDistortion, styles.enableDistortion);
EditorGUI.indentLevel--;
}
private void SssSettingsUI(HDRenderPipeline pipe)
{
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);
EditorGUILayout.LabelField(styles.sssSettings);
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel++;
pipe.localSssParameters = (SubsurfaceScatteringParameters) EditorGUILayout.ObjectField(new GUIContent("Subsurface Scattering Parameters"), pipe.localSssParameters, typeof(SubsurfaceScatteringParameters), false);
EditorGUI.indentLevel--;
EditorUtility.SetDirty(renderContext); // Repaint
HackSetDirty(pipe); // Repaint
}
}
private void LightingDebugParametersUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
{
m_ShowLightingDebug.boolValue = EditorGUILayout.Foldout(m_ShowLightingDebug.boolValue, styles.lightingDebugParameters);
if (!m_ShowLightingDebug.boolValue)
return;
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_DebugShadowEnabled, styles.shadowDebugEnable);
EditorGUILayout.PropertyField(m_ShadowDebugMode, styles.shadowDebugVisualizationMode);
if (!m_ShadowDebugMode.hasMultipleDifferentValues)
{
if ((ShadowDebugMode)m_ShadowDebugMode.intValue == ShadowDebugMode.VisualizeShadowMap)
{
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)

EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
shadowParameters.enabled = EditorGUILayout.Toggle(styles.shadowsEnabled, shadowParameters.enabled);
EditorUtility.SetDirty(renderContext); // Repaint
HackSetDirty(renderContext); // Repaint
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--;
}
private void TextureParametersUI(HDRenderPipeline renderContext)
{
EditorGUILayout.Space();

if (EditorGUI.EndChangeCheck())
{
renderContext.textureSettings = textureParameters;
EditorUtility.SetDirty(renderContext); // Repaint
HackSetDirty(renderContext); // Repaint
private void TilePassUI(HDRenderPipeline renderContext)
/* private void TilePassUI(HDRenderPipeline renderContext)
TilePass.LightLoop tilePass = renderContext.lightLoop as TilePass.LightLoop;
var tilePass = renderContext.tileSettings;
if (tilePass != null)
{
EditorGUILayout.LabelField(styles.tileLightLoopSettings);

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderContext); // Repaint
HackSetDirty(renderContext); // Repaint
// SetAssetDirty will tell renderloop to rebuild
renderContext.DestroyCreatedInstances();

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderContext); // Repaint
HackSetDirty(renderContext); // Repaint
}*/
public void OnEnable()
{
InitializeProperties();
HDRenderPipelineInstance renderpipelineInstance = UnityEngine.Experimental.Rendering.RenderPipelineManager.currentPipeline as HDRenderPipelineInstance;
if (!renderContext)
if (!renderContext || renderpipelineInstance == null)
DebugParametersUI(renderContext);
ShadowParametersUI(renderContext);
TextureParametersUI(renderContext);
TilePassUI(renderContext);
serializedObject.Update();
DebuggingUI(renderContext, renderpipelineInstance);
SettingsUI(renderContext);
serializedObject.ApplyModifiedProperties();
}
}
}

20
Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
[MenuItem("HDRenderPipeline/Create Scene Settings")]
static void CreateSceneSettings()
{
CommonSettings[] settings = Object.FindObjectsOfType<CommonSettings>();
if (settings.Length == 0)
{
GameObject go = new GameObject { name = "SceneSettings" };
go.AddComponent<CommonSettings>();
go.AddComponent<PostProcessing>();
}
else
{
Debug.LogWarning("SceneSettings has already been created.");
}
}
[MenuItem("HDRenderPipeline/Synchronize all Layered materials")]
static void SynchronizeAllLayeredMaterial()
{

Material mat = obj as Material;
if(mat.shader.name == "HDRenderLoop/LayeredLit")
if (mat.shader.name == "HDRenderLoop/LayeredLit")
{
LayeredLitGUI.SynchronizeAllLayers(mat);
}

33
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


m_Script: {fileID: 11500000, guid: d440c0deec24a2f478b3e9021cb66c29, type: 3}
m_Name: HDRenderPipeline
m_EditorClassIdentifier:
m_setup: {fileID: 11400000, guid: c90ada6c2ed7b4e4b85a303678826111, type: 2}
m_LightLoopProducer: {fileID: 11400000, guid: bf8cd9ae03ff7d54c89603e67be0bfc5,
type: 2}
globalDebugParameters:
debugOverlayRatio: 0.33
displayMaterialDebug: 1
displayRenderingDebug: 1
displayLightingDebug: 1
materialDebugParameters:
debugViewMaterial: 0
lightingDebugParameters:
enableShadows: 1
shadowDebugMode: 0
shadowMapIndex: 0
lightingDebugMode: 0
overrideSmoothness: 0
overrideSmoothnessValue: 0.78
debugLightingAlbedo: {r: 0.53676474, g: 0.53676474, b: 0.53676474, a: 1}
renderingDebugParametrs:
displayOpaqueObjects: 1
displayTransparentObjects: 1
enableDistortion: 0
renderingParameters:
useForwardRenderingOnly: 0
useDepthPrepass: 0
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096

directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
localSssParameters: {fileID: 0}
m_CommonSettings:
m_ShadowMaxDistance: 1000
m_ShadowCascadeCount: 4
m_ShadowCascadeSplit0: 0.05
m_ShadowCascadeSplit1: 0.2
m_ShadowCascadeSplit2: 0.3
m_SkyParameters: {fileID: 0}

3
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta


fileFormatVersion: 2
guid: e185fecca3c73cd47a09f1092663ef32
timeCreated: 1484329328
timeCreated: 1485874614
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

886
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
文件差异内容过多而无法显示
查看文件

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


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

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

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


// We need to be able to control the blend mode for deferred shader in case we do multiple pass
_SrcBlend("", Float) = 1
_DstBlend("", Float) = 1
_StencilRef("_StencilRef", Int) = 0
Stencil
{
Ref [_StencilRef]
Comp Equal
Pass Keep
}
Blend Off
Blend[_SrcBlend][_DstBlend]
ZTest Always
Blend [_SrcBlend] [_DstBlend], One Zero
Cull Off
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma vertex Vert
#pragma fragment Frag

#pragma multi_compile LIGHTLOOP_TILE_DIRECT LIGHTLOOP_TILE_INDIRECT LIGHTLOOP_TILE_ALL
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
// Split lighting is utilized during the SSS pass.
#pragma multi_compile _ OUTPUT_SPLIT_LIGHTING
#pragma multi_compile _ LIGHTING_DEBUG
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugLighting.hlsl"
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
TEXTURE2D(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
float3 positionOS : POSITION;
uint vertexID : SV_VertexID;
};
struct Varyings

struct Outputs
{
#ifdef OUTPUT_SPLIT_LIGHTING
float4 specularLighting : SV_Target0;
float3 diffuseLighting : SV_Target1;
#else
float4 combinedLighting : SV_Target0;
#endif
};
// TODO: implement SV_vertexID full screen quad
// Lights are draw as one fullscreen quad
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionCS = TransformWorldToHClip(positionWS);
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
float4 Frag(Varyings input) : SV_Target
Outputs Frag(Varyings input)
{
// input.positionCS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);

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);
return float4(diffuseLighting + specularLighting, 1.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
outputs.specularLighting = float4(specularLighting, 1.0);
outputs.diffuseLighting = diffuseLighting;
#else
outputs.combinedLighting = float4(diffuseLighting + specularLighting, 1.0);
#endif
return outputs;
}
ENDHLSL

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/ClusteredUtils.hlsl


float GetScaleFromBase(float base)
{
const float C = (float)(1 << g_iLog2NumClusters);
const float geomSeries = (1.0 - pow(abs(base), C)) / (1 - base); // geometric series: sum_k=0^{C-1} base^k
const float geomSeries = (1.0 - PositivePow(base, C)) / (1 - base); // geometric series: sum_k=0^{C-1} base^k
return geomSeries / (g_fFarPlane - g_fNearPlane);
}

if (logBasePerTile)
userscale = GetScaleFromBase(suggestedBase);
float dist = (pow(suggestedBase, (float)k) - 1.0) / (userscale * (suggestedBase - 1.0f));
float dist = (PositivePow(suggestedBase, (float)k) - 1.0) / (userscale * (suggestedBase - 1.0f));
res = dist + g_fNearPlane;
#if USE_LEFTHAND_CAMERASPACE

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl


#if 1
float3 maxZdir = float3(-sphCen.z*sphCen.x, -sphCen.z*sphCen.y, sphCen.x*sphCen.x + sphCen.y*sphCen.y); // cross(sphCen,cross(Zaxis,sphCen))
float len = length(maxZdir);
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // since len>=(maxZdir.z/len) we can use len as an approximate value when len<=epsilon
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // if len<=0.0001 then either |sphCen|<sphRadius or sphCen is very closely aligned with Z axis in which case little to no additional offs needed.
float offs = scalarProj*sphRadiusIn;
#else
float offs = sphRadiusIn; // more false positives due to larger radius but works too

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute


#define NR_THREADS 64
// output buffer
RWBuffer<uint> g_vLightList : register( u0 );
RWStructuredBuffer<uint> g_vLightList : register( u0 ); // don't support RWBuffer yet in unity
// 2kB (room for roughly 30 wavefronts)

lightOffs = 0;
GroupMemoryBarrierWithGroupSync();
int i;
for(i=t; i<iNrCoarseLights; i+=NR_THREADS) if(lightsListLDS[i]<g_iNrVisibLights) InterlockedAdd(lightOffs, 1);
for(i=t; i<iNrCoarseLights; i+=NR_THREADS) if((int)lightsListLDS[i]<g_iNrVisibLights) InterlockedAdd(lightOffs, 1);
GroupMemoryBarrierWithGroupSync();
iNrCoarseLights = lightOffs;

int i=iSwizzle + (2*(iSection&0x2)); // offset by 4 at section 2
vP0 = GetTileVertex(uint2(viTilLL.x, viTilUR.y), uint2(viTilUR.x, viTilLL.y), i, fTileFarPlane);
vE0 = iSection==0 ? vP0 : (((iSwizzle&0x2)==0 ? 1.0f : (-1.0f))*((iSwizzle&0x1)==(iSwizzle>>1) ? float3(1,0,0) : float3(0,1,0)));
vE0 = iSection == 0 ? vP0 : (((iSwizzle & 0x2) == 0 ? 1.0f : (-1.0f)) * ((int)(iSwizzle & 0x1) == (iSwizzle >> 1) ? float3(1, 0, 0) : float3(0, 1, 0)));
}
void CullByExactEdgeTests(uint threadID, int iNrCoarseLights, uint2 viTilLL, uint2 viTilUR)

12
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-clustered.compute


StructuredBuffer<SFiniteLightBound> g_data : register( t3 );
#ifdef USE_TWO_PASS_TILED_LIGHTING
Buffer<uint> g_vBigTileLightList : register( t4 );
StructuredBuffer<uint> g_vBigTileLightList : register( t4 ); // don't support Buffer yet in unity
#endif

RWBuffer<uint> g_vLayeredLightList : register( u0 );
RWBuffer<uint> g_LayeredOffset : register( u1 );
RWBuffer<uint> g_LayeredSingleIdxBuffer : register( u2 );
RWStructuredBuffer<uint> g_vLayeredLightList : register( u0 ); // don't support RWBuffer yet in unity
RWStructuredBuffer<uint> g_LayeredOffset : register( u1 ); // don't support RWBuffer yet in unity
RWStructuredBuffer<uint> g_LayeredSingleIdxBuffer : register( u2 ); // don't support RWBuffer yet in unity
RWBuffer<float> g_logBaseBuffer : register( u3 );
RWStructuredBuffer<float> g_logBaseBuffer : register( u3 ); // don't support RWBuffer yet in unity
#endif

groupshared uint lightOffs;
#ifdef ENABLE_DEPTH_TEXTURE_BACKPLANE
groupshared int ldsZMax;
groupshared uint ldsZMax;
#endif
#ifdef EXACT_EDGE_TESTS

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute


StructuredBuffer<SFiniteLightBound> g_data : register( t3 );
#ifdef USE_TWO_PASS_TILED_LIGHTING
Buffer<uint> g_vBigTileLightList : register( t4 );
StructuredBuffer<uint> g_vBigTileLightList : register( t4 ); // don't support Buffer yet in unity
RWBuffer<uint> g_vLightList : register( u0 );
RWStructuredBuffer<uint> g_vLightList : register( u0 ); // don't support RWBuffer yet in unity
#define MAX_NR_COARSE_ENTRIES 64

28
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.
// #pragma multi_compile _ OUTPUT_SPLIT_LIGHTING
#define LIGHTLOOP_TILE_PASS 1
#define LIGHTLOOP_TILE_DIRECT 1

#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(_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
RWTexture2D<float4> uavOutput;
#ifdef OUTPUT_SPLIT_LIGHTING
RWTexture2D<float4> specularLightingUAV;
RWTexture2D<float3> diffuseLightingUAV;
#else
RWTexture2D<float4> combinedLightingUAV;
#endif
[numthreads(TILE_SIZE, TILE_SIZE, 1)]
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID)

float3 specularLighting;
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
uavOutput[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0);
#ifdef OUTPUT_SPLIT_LIGHTING
specularLightingUAV[pixelCoord] = float4(specularLighting, 1.0);
diffuseLightingUAV[pixelCoord] = diffuseLighting;
#else
combinedLightingUAV[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0);
#endif
}

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


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

int m_areaLightCount = 0;
int m_lightCount = 0;
private ComputeShader buildScreenAABBShader { get { return m_Parent.renderPipelineSetup.buildScreenAABBShader; } }
private ComputeShader buildPerTileLightListShader { get { return m_Parent.renderPipelineSetup.buildPerTileLightListShader; } }
private ComputeShader buildPerBigTileLightListShader { get { return m_Parent.renderPipelineSetup.buildPerBigTileLightListShader; } }
private ComputeShader buildPerVoxelLightListShader { get { return m_Parent.renderPipelineSetup.buildPerVoxelLightListShader; } }
private ComputeShader shadeOpaqueShader { get { return m_Parent.renderPipelineSetup.shadeOpaqueShader; } }
private ComputeShader buildScreenAABBShader { get { return m_PassResources.buildScreenAABBShader; } }
private ComputeShader buildPerTileLightListShader { get { return m_PassResources.buildPerTileLightListShader; } }
private ComputeShader buildPerBigTileLightListShader { get { return m_PassResources.buildPerBigTileLightListShader; } }
private ComputeShader buildPerVoxelLightListShader { get { return m_PassResources.buildPerVoxelLightListShader; } }
private ComputeShader shadeOpaqueShader { get { return m_PassResources.shadeOpaqueShader; } }
static int s_GenAABBKernel;
static int s_GenListPerTileKernel;

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

static ComputeBuffer s_BigTileLightList = null; // used for pre-pass coarse culling on 64x64 tiles
static int s_GenListPerBigTileKernel;
public bool enableDrawLightBoundsDebug = false;
public bool disableTileAndCluster = false; // For debug / test
public bool disableDeferredShadingInCompute = true;
public bool enableSplitLightEvaluation = true;
public bool enableComputeLightEvaluation = false;
// clustered light list specific buffers and data begin
public int debugViewTilesFlags = 0;
public bool enableClustered = true;
public bool disableFptlWhenClustered = false; // still useful on opaques. Should be false by default to force tile on opaque.
public bool enableBigTilePrepass = true;
const bool k_UseDepthBuffer = true; // only has an impact when EnableClustered is true (requires a depth-prepass)
const bool k_UseAsyncCompute = true; // should not use on mobile

get
{
bool isEnabledMSAA = false;
Debug.Assert(!isEnabledMSAA || enableClustered);
bool disableFptl = (disableFptlWhenClustered && enableClustered) || isEnabledMSAA;
Debug.Assert(!isEnabledMSAA || m_PassSettings.enableClustered);
bool disableFptl = (m_PassSettings.disableFptlWhenClustered && m_PassSettings.enableClustered) || isEnabledMSAA;
return !disableFptl;
}
}

s_DefaultAdditionalLightDataGameObject = new GameObject("Default Light Data");
s_DefaultAdditionalLightDataGameObject.hideFlags = HideFlags.HideAndDontSave;
s_DefaultAdditionalLightData = s_DefaultAdditionalLightDataGameObject.AddComponent<AdditionalLightData>();
s_DefaultAdditionalLightDataGameObject.SetActive(false);
Material m_DeferredDirectMaterial = null;
Material m_DeferredIndirectMaterial = null;
Material m_DeferredAllMaterial = null;
Material m_DebugViewTilesMaterial = null;
Material m_DeferredDirectMaterialSRT = null;
Material m_DeferredDirectMaterialMRT = null;
Material m_DeferredIndirectMaterialSRT = null;
Material m_DeferredIndirectMaterialMRT = null;
Material m_DeferredAllMaterialSRT = null;
Material m_DeferredAllMaterialMRT = null;
Material m_SingleDeferredMaterial = null;
Material m_DebugViewTilesMaterial = null;
const int k_TileSize = 16;
private readonly HDRenderPipeline m_Parent;
Material m_SingleDeferredMaterialSRT = null;
Material m_SingleDeferredMaterialMRT = null;
const int k_TileSize = 16;
int GetNumTileX(Camera camera)
{

return (camera.pixelHeight + (k_TileSize - 1)) / k_TileSize;
}
public LightLoop(HDRenderPipeline hdRenderPipeline)
TileLightLoopProducer.TileSettings m_PassSettings;
private TilePassResources m_PassResources;
public LightLoop(TileLightLoopProducer producer)
m_Parent = hdRenderPipeline;
m_PassSettings = producer.tileSettings;
m_PassResources = producer.passResources;
}
public override void Build(TextureSettings textureSettings)

m_CubeReflTexArray.AllocTextureArray(32, textureSettings.reflectionCubemapSize, TextureFormat.BC6H, true);
s_GenAABBKernel = buildScreenAABBShader.FindKernel("ScreenBoundsAABB");
s_GenListPerTileKernel = buildPerTileLightListShader.FindKernel(enableBigTilePrepass ? "TileLightListGen_SrcBigTile" : "TileLightListGen");
s_GenListPerTileKernel = buildPerTileLightListShader.FindKernel(m_PassSettings.enableBigTilePrepass ? "TileLightListGen_SrcBigTile" : "TileLightListGen");
s_AABBBoundsBuffer = new ComputeBuffer(2 * k_MaxLightsOnScreen, 3 * sizeof(float));
s_ConvexBoundsBuffer = new ComputeBuffer(k_MaxLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(SFiniteLightBound)));
s_LightVolumeDataBuffer = new ComputeBuffer(k_MaxLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightVolumeData)));

buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "_LightVolumeData", s_LightVolumeDataBuffer);
buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "g_data", s_ConvexBoundsBuffer);
if (enableClustered)
if (m_PassSettings.enableClustered)
var kernelName = enableBigTilePrepass ? (k_UseDepthBuffer ? "TileLightListGen_DepthRT_SrcBigTile" : "TileLightListGen_NoDepthRT_SrcBigTile") : (k_UseDepthBuffer ? "TileLightListGen_DepthRT" : "TileLightListGen_NoDepthRT");
var kernelName = m_PassSettings.enableBigTilePrepass ? (k_UseDepthBuffer ? "TileLightListGen_DepthRT_SrcBigTile" : "TileLightListGen_NoDepthRT_SrcBigTile") : (k_UseDepthBuffer ? "TileLightListGen_DepthRT" : "TileLightListGen_NoDepthRT");
s_GenListPerVoxelKernel = buildPerVoxelLightListShader.FindKernel(kernelName);
s_ClearVoxelAtomicKernel = buildPerVoxelLightListShader.FindKernel("ClearAtomic");
buildPerVoxelLightListShader.SetBuffer(s_GenListPerVoxelKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);

s_GlobalLightListAtomic = new ComputeBuffer(1, sizeof(uint));
}
if (enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
{
s_GenListPerBigTileKernel = buildPerBigTileLightListShader.FindKernel("BigTileLightListGen");
buildPerBigTileLightListShader.SetBuffer(s_GenListPerBigTileKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);

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");
m_DeferredDirectMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_DeferredDirectMaterial.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredDirectMaterial.EnableKeyword("LIGHTLOOP_TILE_DIRECT");
m_DeferredDirectMaterial.DisableKeyword("LIGHTLOOP_TILE_INDIRECT");
m_DeferredDirectMaterial.DisableKeyword("LIGHTLOOP_TILE_ALL");
string[] tileKeywords = {"LIGHTLOOP_TILE_DIRECT", "LIGHTLOOP_TILE_INDIRECT", "LIGHTLOOP_TILE_ALL"};
m_DeferredDirectMaterialSRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredDirectMaterialSRT, tileKeywords, 0);
m_DeferredDirectMaterialSRT.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredDirectMaterialSRT.DisableKeyword("OUTPUT_SPLIT_LIGHTING");
m_DeferredDirectMaterialSRT.SetInt("_StencilRef", (int)StencilBits.None);
m_DeferredDirectMaterialSRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredDirectMaterialSRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_DeferredDirectMaterialMRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredDirectMaterialMRT, tileKeywords, 0);
m_DeferredDirectMaterialMRT.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredDirectMaterialMRT.EnableKeyword("OUTPUT_SPLIT_LIGHTING");
m_DeferredDirectMaterialMRT.SetInt("_StencilRef", (int)StencilBits.SSS);
m_DeferredDirectMaterialMRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredDirectMaterialMRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_DeferredIndirectMaterialSRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredIndirectMaterialSRT, tileKeywords, 1);
m_DeferredIndirectMaterialSRT.EnableKeyword("LIGHTLOOP_TILE_PASS");
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 color & alpha source
m_DeferredIndirectMaterialMRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredIndirectMaterialMRT, tileKeywords, 1);
m_DeferredIndirectMaterialMRT.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredIndirectMaterialMRT.EnableKeyword("OUTPUT_SPLIT_LIGHTING");
m_DeferredIndirectMaterialMRT.SetInt("_StencilRef", (int)StencilBits.SSS);
m_DeferredIndirectMaterialMRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredIndirectMaterialMRT.SetInt("_DstBlend", (int)BlendMode.One); // Additive color & alpha source
m_DeferredIndirectMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_DeferredIndirectMaterial.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredIndirectMaterial.DisableKeyword("LIGHTLOOP_TILE_DIRECT");
m_DeferredIndirectMaterial.EnableKeyword("LIGHTLOOP_TILE_INDIRECT");
m_DeferredIndirectMaterial.DisableKeyword("LIGHTLOOP_TILE_ALL");
m_DeferredAllMaterialSRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredAllMaterialSRT, tileKeywords, 2);
m_DeferredAllMaterialSRT.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredAllMaterialSRT.DisableKeyword("OUTPUT_SPLIT_LIGHTING");
m_DeferredAllMaterialSRT.SetInt("_StencilRef", (int)StencilBits.None);
m_DeferredAllMaterialSRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredAllMaterialSRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_DeferredAllMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_DeferredAllMaterial.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredAllMaterial.DisableKeyword("LIGHTLOOP_TILE_DIRECT");
m_DeferredAllMaterial.DisableKeyword("LIGHTLOOP_TILE_INDIRECT");
m_DeferredAllMaterial.EnableKeyword("LIGHTLOOP_TILE_ALL");
m_DeferredAllMaterialMRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
Utilities.SelectKeyword(m_DeferredAllMaterialMRT, tileKeywords, 2);
m_DeferredAllMaterialMRT.EnableKeyword("LIGHTLOOP_TILE_PASS");
m_DeferredAllMaterialMRT.EnableKeyword("OUTPUT_SPLIT_LIGHTING");
m_DeferredAllMaterialMRT.SetInt("_StencilRef", (int)StencilBits.SSS);
m_DeferredAllMaterialMRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_DeferredAllMaterialMRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_SingleDeferredMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_SingleDeferredMaterial.EnableKeyword("LIGHTLOOP_SINGLE_PASS");
m_SingleDeferredMaterialSRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_SingleDeferredMaterialSRT.EnableKeyword("LIGHTLOOP_SINGLE_PASS");
m_SingleDeferredMaterialSRT.DisableKeyword("OUTPUT_SPLIT_LIGHTING");
m_SingleDeferredMaterialSRT.SetInt("_StencilRef", (int)StencilBits.None);
m_SingleDeferredMaterialSRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_SingleDeferredMaterialSRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_SingleDeferredMaterialMRT = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_SingleDeferredMaterialMRT.EnableKeyword("LIGHTLOOP_SINGLE_PASS");
m_SingleDeferredMaterialMRT.EnableKeyword("OUTPUT_SPLIT_LIGHTING");
m_SingleDeferredMaterialMRT.SetInt("_StencilRef", (int)StencilBits.SSS);
m_SingleDeferredMaterialMRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_SingleDeferredMaterialMRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_DefaultTexture2DArray = new Texture2DArray(1, 1, 1, TextureFormat.ARGB32, false);
m_DefaultTexture2DArray.SetPixels32(new Color32[1] { new Color32(128, 128, 128, 128) }, 0);

// enableClustered
Utilities.SafeRelease(s_GlobalLightListAtomic);
Utilities.Destroy(m_DeferredDirectMaterial);
Utilities.Destroy(m_DeferredIndirectMaterial);
Utilities.Destroy(m_DeferredAllMaterial);
Utilities.Destroy(m_DeferredDirectMaterialSRT);
Utilities.Destroy(m_DeferredDirectMaterialMRT);
Utilities.Destroy(m_DeferredIndirectMaterialSRT);
Utilities.Destroy(m_DeferredIndirectMaterialMRT);
Utilities.Destroy(m_DeferredAllMaterialSRT);
Utilities.Destroy(m_DeferredAllMaterialMRT);
Utilities.Destroy(m_SingleDeferredMaterial);
Utilities.Destroy(m_SingleDeferredMaterialSRT);
Utilities.Destroy(m_SingleDeferredMaterialMRT);
GameObject.DestroyImmediate(s_DefaultAdditionalLightDataGameObject);
Utilities.Destroy(s_DefaultAdditionalLightDataGameObject);
s_DefaultAdditionalLightDataGameObject = null;
s_DefaultAdditionalLightData = null;
}

public override bool NeedResize()
{
return s_LightList == null ||
(s_BigTileLightList == null && enableBigTilePrepass) ||
(s_PerVoxelLightLists == null && enableClustered);
(s_BigTileLightList == null && m_PassSettings.enableBigTilePrepass) ||
(s_PerVoxelLightLists == null && m_PassSettings.enableClustered);
}
public override void ReleaseResolutionDependentBuffers()

s_LightList = new ComputeBuffer((int)LightCategory.Count * dwordsPerTile * nrTiles, sizeof(uint)); // enough list memory for a 4k x 4k display
if (enableClustered)
if (m_PassSettings.enableClustered)
{
s_PerVoxelOffset = new ComputeBuffer((int)LightCategory.Count * (1 << k_Log2NumClusters) * nrTiles, sizeof(uint));
s_PerVoxelLightLists = new ComputeBuffer(NumLightIndicesPerClusteredTile() * nrTiles, sizeof(uint));

}
}
if (enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
{
var nrBigTilesX = (width + 63) / 64;
var nrBigTilesY = (height + 63) / 64;

int punctualLightcount = 0;
int areaLightCount = 0;
var sortKeys = new uint[Math.Min(cullResults.visibleLights.Length, k_MaxLightsOnScreen)];
int lightCount = Math.Min(cullResults.visibleLights.Length, k_MaxLightsOnScreen);
var sortKeys = new uint[lightCount];
for (int lightIndex = 0, numLights = cullResults.visibleLights.Length; lightIndex < numLights; ++lightIndex)
for (int lightIndex = 0, numLights = cullResults.visibleLights.Length; (lightIndex < numLights) && (sortCount < lightCount); ++lightIndex)
{
var light = cullResults.visibleLights[lightIndex];

if (additionalData == null)
{
Debug.LogWarningFormat("Light entity {0} has no additional data, will be rendered using default values.", light.light.name);
// 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);
}
additionalData = DefaultAdditionalLightData;
}

// Redo everything but this time with envLights
int envLightCount = 0;
sortKeys = new uint[Math.Min(cullResults.visibleReflectionProbes.Length, k_MaxEnvLightsOnScreen)];
int probeCount = Math.Min(cullResults.visibleReflectionProbes.Length, k_MaxEnvLightsOnScreen);
sortKeys = new uint[probeCount];
for (int probeIndex = 0, numProbes = cullResults.visibleReflectionProbes.Length; probeIndex < numProbes; probeIndex++)
for (int probeIndex = 0, numProbes = cullResults.visibleReflectionProbes.Length; (probeIndex < numProbes) && (sortCount < probeCount); probeIndex++)
if (envLightCount >= k_MaxEnvLightsOnScreen)
// probe.texture can be null when we are adding a reflection probe in the editor
if (probe.texture == null || envLightCount >= k_MaxEnvLightsOnScreen)
continue;
// TODO: Support LightVolumeType.Sphere, currently in UI there is no way to specify a sphere influence volume

cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_vLayeredLightList", s_PerVoxelLightLists);
cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_LayeredOffset", s_PerVoxelOffset);
cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_LayeredSingleIdxBuffer", s_GlobalLightListAtomic);
if (enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_vBigTileLightList", s_BigTileLightList);
if (k_UseDepthBuffer)

var cmd = new CommandBuffer() { name = "" };
// generate screen-space AABBs (used for both fptl and clustered).
if (m_lightCount != 0)
{
temp.SetRow(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
temp.SetRow(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));

}
// enable coarse 2D pass on 64x64 tiles (used for both fptl and clustered).
if (enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
{
cmd.SetComputeIntParams(buildPerBigTileLightListShader, "g_viDimensions", new int[2] { w, h });
cmd.SetComputeIntParam(buildPerBigTileLightListShader, "_EnvLightIndexShift", m_lightList.lights.Count);

Utilities.SetMatrixCS(cmd, buildPerTileLightListShader, "g_mInvScrProjection", invProjscr);
cmd.SetComputeTextureParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_depth_tex", cameraDepthBufferRT);
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_vLightList", s_LightList);
if (enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
if (enableClustered) // works for transparencies too.
if (m_PassSettings.enableClustered) // works for transparencies too.
{
VoxelLightListGeneration(cmd, camera, projscr, invProjscr, cameraDepthBufferRT);
}

activeCommandBuffer.SetComputeFloatParam(activeComputeShader, name, value);
else
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)

SetGlobalInt("_NumTileX", GetNumTileX(camera));
SetGlobalInt("_NumTileY", GetNumTileY(camera));
if (enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
if (enableClustered)
if (m_PassSettings.enableClustered)
{
SetGlobalFloat("g_fClustScale", m_ClustScale);
SetGlobalFloat("g_fClustBase", k_ClustLogBase);

}
#endif
public override void RenderDeferredLighting(HDRenderPipeline.HDCamera hdCamera, ScriptableRenderContext renderContext, RenderTargetIdentifier cameraColorBufferRT)
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);
}
public override void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext,
LightingDebugParameters lightDebugParameters,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier stencilBuffer,
bool outputSplitLighting)
{
var bUseClusteredForDeferred = !usingFptl;

}
#endif
using (new Utilities.ProfilingSample(disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderContext))
using (new Utilities.ProfilingSample(m_PassSettings.disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderContext))
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)

if (disableTileAndCluster)
// Must be done after setting up the compute shader above.
SetupRenderingForDebug(lightDebugParameters);
if (m_PassSettings.disableTileAndCluster)
Utilities.SetupMaterialHDCamera(hdCamera, m_SingleDeferredMaterial);
m_SingleDeferredMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
m_SingleDeferredMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
cmd.Blit(null, cameraColorBufferRT, m_SingleDeferredMaterial, 0);
if (outputSplitLighting)
{
Utilities.DrawFullScreen(cmd, m_SingleDeferredMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
}
else
{
Utilities.DrawFullScreen(cmd, m_SingleDeferredMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
}
if (!disableDeferredShadingInCompute)
if (!m_PassSettings.disableDeferredShadingInCompute)
{
// Compute shader evaluation
int kernel = bUseClusteredForDeferred ? s_shadeOpaqueClusteredKernel : s_shadeOpaqueFptlKernel;

cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_IESArray", IESArrayTexture ? IESArrayTexture : m_DefaultTexture2DArray);
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_SkyTexture", skyTexture ? skyTexture : m_DefaultTexture2DArray);
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "uavOutput", cameraColorBufferRT);
// Since we need the stencil test, the compute path does not currently support SSS.
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "combinedLightingUAV", colorBuffers[0]);
if (enableSplitLightEvaluation)
if (m_PassSettings.enableSplitLightEvaluation)
Utilities.SetupMaterialHDCamera(hdCamera, m_DeferredDirectMaterial);
m_DeferredDirectMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
m_DeferredDirectMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
m_DeferredDirectMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DeferredDirectMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
if (outputSplitLighting)
{
Utilities.SelectKeyword(m_DeferredDirectMaterialMRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullScreen(cmd, m_DeferredDirectMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
Utilities.SetupMaterialHDCamera(hdCamera, m_DeferredIndirectMaterial);
m_DeferredIndirectMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
m_DeferredIndirectMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One); // Additive
m_DeferredIndirectMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DeferredIndirectMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
Utilities.SelectKeyword(m_DeferredIndirectMaterialMRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullScreen(cmd, m_DeferredIndirectMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
}
else
{
Utilities.SelectKeyword(m_DeferredDirectMaterialSRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullScreen(cmd, m_DeferredDirectMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
cmd.Blit(null, cameraColorBufferRT, m_DeferredDirectMaterial, 0);
cmd.Blit(null, cameraColorBufferRT, m_DeferredIndirectMaterial, 0);
Utilities.SelectKeyword(m_DeferredIndirectMaterialSRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullScreen(cmd, m_DeferredIndirectMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
}
Utilities.SetupMaterialHDCamera(hdCamera, m_DeferredAllMaterial);
m_DeferredAllMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
m_DeferredAllMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
m_DeferredAllMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DeferredAllMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
cmd.Blit(null, cameraColorBufferRT, m_DeferredAllMaterial, 0);
if (outputSplitLighting)
{
Utilities.SelectKeyword(m_DeferredAllMaterialMRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullScreen(cmd, m_DeferredAllMaterialMRT, hdCamera, colorBuffers, stencilBuffer);
}
else
{
Utilities.SelectKeyword(m_DeferredAllMaterialSRT, "USE_CLUSTERED_LIGHTLIST", "USE_FPTL_LIGHTLIST", bUseClusteredForDeferred);
Utilities.DrawFullScreen(cmd, m_DeferredAllMaterialSRT, hdCamera, colorBuffers[0], stencilBuffer);
}
if (debugViewTilesFlags != 0)
if (m_PassSettings.debugViewTilesFlags != 0)
m_DebugViewTilesMaterial.SetInt("_ViewTilesFlags", debugViewTilesFlags);
m_DebugViewTilesMaterial.SetInt("_ViewTilesFlags", m_PassSettings.debugViewTilesFlags);
cmd.Blit(null, cameraColorBufferRT, m_DebugViewTilesMaterial, 0);
cmd.Blit(null, colorBuffers[0], m_DebugViewTilesMaterial, 0);
}
}

var cmd = new CommandBuffer();
if (disableTileAndCluster)
if (m_PassSettings.disableTileAndCluster)
{
cmd.name = "Forward pass";
cmd.EnableShaderKeyword("LIGHTLOOP_SINGLE_PASS");

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


uint _NumTileX;
uint _NumTileY;
Buffer<uint> g_vLightListGlobal;
StructuredBuffer<uint> g_vLightListGlobal; // don't support Buffer yet in unity
#define TILE_SIZE 16 // This is fixed
#define DWORD_PER_TILE 16 // See dwordsPerTile in TilePass.cs, we have roomm for 31 lights and a number of light value all store on 16 bit (ushort)

//#endif
//#ifdef USE_CLUSTERED_LIGHTLIST
Buffer<uint> g_vLayeredOffsetsBuffer;
Buffer<float> g_logBaseBuffer;
StructuredBuffer<uint> g_vLayeredOffsetsBuffer; // don't support Buffer yet in unity
StructuredBuffer<float> g_logBaseBuffer; // don't support Buffer yet in unity
//#endif
StructuredBuffer<DirectionalLightData> _DirectionalLightDatas;

// 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

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


public readonly GUIContent emissiveText = new GUIContent("Emissive");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask");
public readonly GUIContent vertexColorModeText = new GUIContent("Vertex Color Mode", "Mode multiply: vertex color is multiply with the mask. Mode additive: vertex color values are remapped between -1 and 1 and added to the mask (neutral at 0.5 vertex color).");
public readonly GUIContent vertexColorHeightMultiplierText = new GUIContent("Vertex Height Scale", "Scale applied to the vertex color height.");
public readonly GUIContent layerTilingBlendMaskText = new GUIContent("Tiling", "Tiling for the blend mask.");
public readonly GUIContent MainLayerInfluenceText = new GUIContent("Main layer influence", "Main layer influence.");
public readonly GUIContent DensityOpacityInfluenceText = new GUIContent("Density / Opacity", "Density / Opacity");
public readonly GUIContent mainLayerInfluenceText = new GUIContent("Main layer influence", "Main layer influence.");
public readonly GUIContent densityOpacityInfluenceText = new GUIContent("Density / Opacity", "Density / Opacity");
public readonly GUIContent useDensityModeModeText = new GUIContent("Use Density Mode", "Enable density mode");
public readonly GUIContent heightOffsetText = new GUIContent("Height Offset", "Height offset from the previous layer.");
public readonly GUIContent blendSizeText = new GUIContent("Blend Size", "Thickness over which the layer will be blended with the previous one.");
public readonly GUIContent useHeightBasedBlendV2Text = new GUIContent("Use V2", "Layer will be blended with the underlying layer based on the height.");
public readonly GUIContent blendUsingHeight = new GUIContent("Blend Using Height", "Blend Layers using height.");
public readonly GUIContent inheritBaseColorThresholdText = new GUIContent("Threshold", "Inherit the base color from the base layer.");
public readonly GUIContent minimumOpacityText = new GUIContent("Minimum Opacity", "Minimum Opacity.");

MaterialProperty[] layerUVDetail = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVDetailsMappingMask = new MaterialProperty[kMaxLayerCount];
const string kLayerTilingBlendMask = "_LayerTilingBlendMask";
MaterialProperty layerTilingBlendMask = null;
const string kLayerTiling = "_LayerTiling";
MaterialProperty[] layerTiling = new MaterialProperty[kMaxLayerCount];
const string kkUseMainLayerInfluence = "_UseMainLayerInfluence";

const string kUseHeightBasedBlendV2 = "_UseHeightBasedBlendV2";
MaterialProperty useHeightBasedBlendV2 = null;
const string kBlendUsingHeight = "_BlendUsingHeight";
MaterialProperty[] blendUsingHeight = new MaterialProperty[kMaxLayerCount - 1];
const string kHeightOffset = "_HeightOffset";
MaterialProperty[] heightOffset = new MaterialProperty[kMaxLayerCount-1];
const string kUseDensityMode = "_UseDensityMode";
MaterialProperty useDensityMode = null;
const string kOpacityAsDensity = "_OpacityAsDensity";
MaterialProperty[] opacityAsDensity = new MaterialProperty[kMaxLayerCount];
const string kMinimumOpacity = "_MinimumOpacity";
MaterialProperty[] minimumOpacity = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] heightFactor = new MaterialProperty[kMaxLayerCount-1];
MaterialProperty[] heightFactor = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] heightCenterOffset = new MaterialProperty[kMaxLayerCount - 1];
const string kBlendSize = "_BlendSize";
MaterialProperty[] blendSize = new MaterialProperty[kMaxLayerCount-1];
const string kVertexColorHeightFactor = "_VertexColorHeightFactor";
MaterialProperty vertexColorHeightFactor = null;
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];
// Height blend V2
// influence
const string kInheritBaseNormal = "_InheritBaseNormal";
MaterialProperty[] inheritBaseNormal = new MaterialProperty[kMaxLayerCount - 1];
const string kInheritBaseHeight = "_InheritBaseHeight";

const string kInheritBaseColorThreshold = "_InheritBaseColorThreshold";
MaterialProperty[] inheritBaseColorThreshold = new MaterialProperty[kMaxLayerCount - 1];
const string kOpacityAsDensity = "_OpacityAsDensity";
MaterialProperty[] opacityAsDensity = new MaterialProperty[kMaxLayerCount - 1];
const string kMinimumOpacity = "_MinimumOpacity";
MaterialProperty[] minimumOpacity = new MaterialProperty[kMaxLayerCount - 1];
MaterialProperty layerEmissiveColor = null;
MaterialProperty layerEmissiveColorMap = null;

FindMaterialOptionProperties(props);
layerMaskMap = FindProperty(kLayerMaskMap, props);
vertexColorHeightFactor = FindProperty(kVertexColorHeightFactor, props);
useHeightBasedBlendV2 = FindProperty(kUseHeightBasedBlendV2, props);
useDensityMode = FindProperty(kUseDensityMode, props);
layerTilingBlendMask = FindProperty(kLayerTilingBlendMask, props);
for (int i = 0; i < kMaxLayerCount; ++i)
{
layerTexWorldScale[i] = FindProperty(string.Format("{0}{1}", kTexWorldScale, i), props);

layerUVDetailsMappingMask[i] = FindProperty(string.Format("{0}{1}", kUVDetailsMappingMask, i), props);
layerTiling[i] = FindProperty(string.Format("{0}{1}", kLayerTiling, i), props);
if(i != 0)
{
heightOffset[i-1] = FindProperty(string.Format("{0}{1}", kHeightOffset, i), props);
heightFactor[i-1] = FindProperty(string.Format("{0}{1}", kHeightFactor, i), props);
blendSize[i-1] = FindProperty(string.Format("{0}{1}", kBlendSize, i), props);
minimumOpacity[i] = FindProperty(string.Format("{0}{1}", kMinimumOpacity, i), props);
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);
heightCenterOffset[i - 1] = FindProperty(string.Format("{0}{1}", kHeightCenterOffset, i), props);
if (i != 0)
{
minimumOpacity[i - 1] = FindProperty(string.Format("{0}{1}", kMinimumOpacity, i), props);
opacityAsDensity[i - 1] = FindProperty(string.Format("{0}{1}", kOpacityAsDensity, 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";

{
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);
}

Material material = m_MaterialEditor.target as Material;
bool baseLayerModeEnable = useMainLayerInfluence.floatValue > 0.0f;
bool mainLayerInfluenceEnable = useMainLayerInfluence.floatValue > 0.0f;
EditorGUILayout.LabelField(styles.layerLabels[layerIndex], styles.layerLabelColors[layerIndex]);

}
}
if(layerIndex > 0)
bool useDensityModeEnable = useDensityMode.floatValue != 0.0f;
if (useDensityModeEnable)
bool heightBasedBlendEnable = useHeightBasedBlend.floatValue != 0.0f;
bool heightBasedBlendV2Enable = useHeightBasedBlendV2.floatValue != 0.0f;
int paramIndex = layerIndex - 1;
EditorGUILayout.LabelField(styles.densityOpacityInfluenceText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(styles.DensityOpacityInfluenceText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(opacityAsDensity[layerIndex], styles.opacityAsDensityText);
m_MaterialEditor.ShaderProperty(minimumOpacity[layerIndex], styles.minimumOpacityText);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel++;
EditorGUILayout.LabelField(styles.heightControlText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightFactor[layerIndex], styles.heightFactorText);
layerHeightAmplitude[layerIndex].floatValue = material.GetFloat(kHeightAmplitude + layerIndex) * heightFactor[layerIndex].floatValue;
m_MaterialEditor.ShaderProperty(heightCenterOffset[layerIndex], styles.heightCenterOffsetText);
layerCenterOffset[layerIndex].floatValue = material.GetFloat(kHeightCenter + layerIndex) + heightCenterOffset[layerIndex].floatValue;
EditorGUI.indentLevel--;
m_MaterialEditor.ShaderProperty(opacityAsDensity[paramIndex], styles.opacityAsDensityText);
m_MaterialEditor.ShaderProperty(minimumOpacity[paramIndex], styles.minimumOpacityText);
// influence
if (layerIndex > 0)
{
int paramIndex = layerIndex - 1;
EditorGUI.indentLevel--;
bool heightBasedBlendEnable = useHeightBasedBlend.floatValue != 0.0f;
if (heightBasedBlendEnable)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(blendUsingHeight[paramIndex], styles.blendUsingHeight);
EditorGUI.indentLevel--;
}
if (baseLayerModeEnable)
if (mainLayerInfluenceEnable)
EditorGUILayout.LabelField(styles.MainLayerInfluenceText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(styles.mainLayerInfluenceText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;

EditorGUI.indentLevel--;
}
if (!useHeightBasedBlend.hasMixedValue && heightBasedBlendEnable)
{
EditorGUILayout.LabelField(styles.heightControlText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightFactor[paramIndex], styles.heightFactorText);
if (!heightBasedBlendV2Enable)
{
m_MaterialEditor.ShaderProperty(heightOffset[paramIndex], styles.heightOffsetText);
m_MaterialEditor.ShaderProperty(blendSize[paramIndex], styles.blendSizeText);
}
else
{
m_MaterialEditor.ShaderProperty(heightCenterOffset[paramIndex], styles.heightCenterOffsetText);
m_MaterialEditor.ShaderProperty(blendUsingHeight[paramIndex], styles.blendUsingHeight);
}
EditorGUI.indentLevel--;
}
}
EditorGUI.indentLevel--;

layerChanged = true;
}
if (((LayerUVBaseMapping)layerUVBase[0].floatValue == LayerUVBaseMapping.Planar) ||
((LayerUVBaseMapping)layerUVBase[0].floatValue == LayerUVBaseMapping.Triplanar))
{
// for now reuse settings from main layer
}
else
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(layerTilingBlendMask, styles.layerTilingBlendMaskText);
EditorGUI.indentLevel--;
}
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = useMainLayerInfluence.hasMixedValue;
bool mainLayerModeInfluenceEnable = EditorGUILayout.Toggle(styles.useMainLayerInfluenceModeText, useMainLayerInfluence.floatValue > 0.0f);

m_MaterialEditor.ShaderProperty(vertexColorMode, styles.vertexColorModeText);
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = useDensityMode.hasMixedValue;
bool useDensityModeEnable = EditorGUILayout.Toggle(styles.useDensityModeModeText, useDensityMode.floatValue > 0.0f);
if (EditorGUI.EndChangeCheck())
{
useDensityMode.floatValue = useDensityModeEnable ? 1.0f : 0.0f;
}
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = useHeightBasedBlend.hasMixedValue;
bool enabled = EditorGUILayout.Toggle(styles.useHeightBasedBlendText, useHeightBasedBlend.floatValue > 0.0f);
if (EditorGUI.EndChangeCheck())

if (enabled)
{
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel++;
bool enabledV2 = EditorGUILayout.Toggle(styles.useHeightBasedBlendV2Text, useHeightBasedBlendV2.floatValue > 0.0f);
if (EditorGUI.EndChangeCheck())
{
useHeightBasedBlendV2.floatValue = enabledV2 ? 1.0f : 0.0f;
}
if(!enabledV2)
m_MaterialEditor.ShaderProperty(vertexColorHeightFactor, styles.vertexColorHeightMultiplierText);
EditorGUI.indentLevel--;
}
EditorGUILayout.Space();

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));

}
bool useHeightBasedBlend = material.GetFloat(kUseHeightBasedBlend) != 0.0f;
bool useHeightBasedBlendV2 = material.GetFloat(kUseHeightBasedBlendV2) != 0.0f;
SetKeyword(material, "_HEIGHT_BASED_BLEND_V2", useHeightBasedBlend && useHeightBasedBlendV2);
bool useDensityModeEnable = material.GetFloat(kUseDensityMode) != 0.0f;
SetKeyword(material, "_DENSITY_MODE", useDensityModeEnable);
// We have to check for each layer if the UV2 or UV3 is needed.
bool needUV3 = false;

bool layerChanged = DoLayersGUI(materialImporter);
EditorGUILayout.Space();
GUILayout.Label(Styles.emissiveText, EditorStyles.boldLabel);
GUILayout.Label(Styles.lightingText, EditorStyles.boldLabel);
m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
EditorGUI.indentLevel--;
CheckLayerConsistency();

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


_Metallic2("Metallic2", Range(0.0, 1.0)) = 0
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 0.5
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 0.5
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 0.5
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 0.5
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 1.0
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 1.0
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 1.0
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 1.0
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}

_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0
// Layer blending options V2
[ToggleOff] _UseHeightBasedBlendV2("Use Height Blend V2", Float) = 0.0
[ToggleOff] _UseDensityMode("Use Density mode", Float) = 0.0
_HeightOffset1("_HeightOffset1", Range(-0.3, 0.3)) = 0.0
_HeightOffset2("_HeightOffset2", Range(-0.3, 0.3)) = 0.0
_HeightOffset3("_HeightOffset3", Range(-0.3, 0.3)) = 0.0
_HeightFactor0("_HeightFactor0", Float) = 1
_BlendSize1("_BlendSize1", Range(0, 0.30)) = 0.0
_BlendSize2("_BlendSize2", Range(0, 0.30)) = 0.0
_BlendSize3("_BlendSize3", Range(0, 0.30)) = 0.0
_LayerHeightAmplitude0("_LayerHeightAmplitude0", Float) = 1
_LayerHeightAmplitude1("_LayerHeightAmplitude1", Float) = 1
_LayerHeightAmplitude2("_LayerHeightAmplitude2", Float) = 1
_LayerHeightAmplitude3("_LayerHeightAmplitude3", Float) = 1
_VertexColorHeightFactor("_VertexColorHeightFactor", Float) = 0.3
_HeightCenterOffset0("_HeightCenterOffset0", Float) = 0.0
_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

_InheritBaseColorThreshold2("_InheritBaseColorThreshold2", Range(0, 1.0)) = 1.0
_InheritBaseColorThreshold3("_InheritBaseColorThreshold3", Range(0, 1.0)) = 1.0
_MinimumOpacity0("_MinimumOpacity0", Range(0, 1.0)) = 1.0
_OpacityAsDensity0("_OpacityAsDensity0", Range(0, 1.0)) = 0.0
_LayerTiling0("LayerTiling0", Float) = 1
_LayerTiling1("LayerTiling1", Float) = 1
_LayerTiling2("LayerTiling2", Float) = 1
_LayerTiling3("LayerTiling3", Float) = 1
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
_LayerTiling0("_LayerTiling0", Float) = 1
_LayerTiling1("_LayerTiling1", Float) = 1
_LayerTiling2("_LayerTiling2", Float) = 1
_LayerTiling3("_LayerTiling3", Float) = 1
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", 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

HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON

#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 _DENSITY_MODE
#pragma shader_feature _HEIGHT_BASED_BLEND_V2
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON

#define SHADERPASS SHADERPASS_GBUFFER
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
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"

#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

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


_Metallic2("Metallic2", Range(0.0, 1.0)) = 0
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 0.5
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 0.5
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 0.5
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 0.5
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 1.0
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 1.0
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 1.0
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 1.0
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}

_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0
// Layer blending options V2
[ToggleOff] _UseHeightBasedBlendV2("Use Height Blend V2", Float) = 0.0
[ToggleOff] _UseDensityMode("Use Density mode", Float) = 0.0
_HeightOffset1("_HeightOffset1", Range(-0.3, 0.3)) = 0.0
_HeightOffset2("_HeightOffset2", Range(-0.3, 0.3)) = 0.0
_HeightOffset3("_HeightOffset3", Range(-0.3, 0.3)) = 0.0
_HeightFactor0("_HeightFactor0", Float) = 1
_BlendSize1("_BlendSize1", Range(0, 0.30)) = 0.0
_BlendSize2("_BlendSize2", Range(0, 0.30)) = 0.0
_BlendSize3("_BlendSize3", Range(0, 0.30)) = 0.0
_VertexColorHeightFactor("_VertexColorHeightFactor", Float) = 0.3
_LayerHeightAmplitude0("_LayerHeightAmplitude0", Float) = 1
_LayerHeightAmplitude1("_LayerHeightAmplitude1", Float) = 1
_LayerHeightAmplitude2("_LayerHeightAmplitude2", Float) = 1
_LayerHeightAmplitude3("_LayerHeightAmplitude3", Float) = 1
_HeightCenterOffset0("_HeightCenterOffset0", Float) = 0.0
_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

_InheritBaseColorThreshold2("_InheritBaseColorThreshold2", Range(0, 1.0)) = 1.0
_InheritBaseColorThreshold3("_InheritBaseColorThreshold3", Range(0, 1.0)) = 1.0
_MinimumOpacity0("_MinimumOpacity0", Range(0, 1.0)) = 1.0
_OpacityAsDensity0("_OpacityAsDensity0", Range(0, 1.0)) = 0.0
_LayerTiling0("LayerTiling0", Float) = 1
_LayerTiling1("LayerTiling1", Float) = 1
_LayerTiling2("LayerTiling2", Float) = 1
_LayerTiling3("LayerTiling3", Float) = 1
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
_LayerTiling0("_LayerTiling0", Float) = 1
_LayerTiling1("_LayerTiling1", Float) = 1
_LayerTiling2("_LayerTiling2", Float) = 1
_LayerTiling3("_LayerTiling3", Float) = 1
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode ("__blendmode", 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

HLSLINCLUDE
#pragma target 5.0
#pragma only_renderers d3d11 ps4 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 // TEMP: until we go further in dev
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON

#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 _DENSITY_MODE
#pragma shader_feature _HEIGHT_BASED_BLEND_V2
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON

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

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


public static GUIContent distortionOnlyText = new GUIContent("Distortion Only", "This shader will only be use to render distortion");
public static GUIContent distortionDepthTestText = new GUIContent("Distortion Depth Test", "Enable the depth test for distortion");
public static GUIContent depthOffsetEnableText = new GUIContent("DepthOffset", "EnableDepthOffset on this shader (Use with heightmap)");
public static GUIContent horizonFadeText = new GUIContent("HorizonFade", "horizon fade is use to control specular occlusion");
public static readonly string[] surfaceTypeNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendModeNames = Enum.GetNames(typeof(BlendMode));

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 tessellationShapeFactorText = new GUIContent("Shape factor", "Strength of Phong tessellation shape (lerp factor)");
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 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

EditorGUI.showMixedValue = false;
}
private void BlendModePopup()
{
EditorGUI.showMixedValue = blendMode.hasMixedValue;
var mode = (BlendMode)blendMode.floatValue;
EditorGUI.BeginChangeCheck();
mode = (BlendMode)EditorGUILayout.Popup(Styles.blendModeText, (int)mode, Styles.blendModeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Blend Mode");
blendMode.floatValue = (float)mode;
}
EditorGUI.showMixedValue = false;
}
void TessellationModePopup()
{
EditorGUI.showMixedValue = tessellationMode.hasMixedValue;

m_MaterialEditor.ShaderProperty(tessellationObjectScale, Styles.tessellationObjectScaleText);
EditorGUI.indentLevel--;
}
}
private void BlendModePopup()
{
EditorGUI.showMixedValue = blendMode.hasMixedValue;
var mode = (BlendMode)blendMode.floatValue;
EditorGUI.BeginChangeCheck();
mode = (BlendMode)EditorGUILayout.Popup(Styles.blendModeText, (int)mode, Styles.blendModeNames);
if (EditorGUI.EndChangeCheck())
GUILayout.Label(Styles.perPixelDisplacementText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, Styles.enablePerPixelDisplacementText);
if (enablePerPixelDisplacement.floatValue > 0.0)
m_MaterialEditor.RegisterPropertyChangeUndo("Blend Mode");
blendMode.floatValue = (float)mode;
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.showMixedValue = false;
EditorGUI.indentLevel--;
}
protected void FindCommonOptionProperties(MaterialProperty[] props)

distortionOnly = FindProperty(kDistortionOnly, props);
distortionDepthTest = FindProperty(kDistortionDepthTest, props);
depthOffsetEnable = FindProperty(kDepthOffsetEnable, props);
horizonFade = FindProperty(kHorizonFade, props);
// tessellation specific, silent if not found
tessellationMode = FindProperty(kTessellationMode, props, false);

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 kDistortionDepthTest = "_DistortionDepthTest";
MaterialProperty depthOffsetEnable = null;
const string kDepthOffsetEnable = "_DepthOffsetEnable";
protected MaterialProperty horizonFade = null;
const string kHorizonFade = "_HorizonFade";
// tessellation params
protected MaterialProperty tessellationMode = null;

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 };

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


using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

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 MaterialProperty detailAOScale = null;
protected const string kDetailAOScale = "_DetailAOScale";
// MaterialProperty subSurfaceRadius = null;
// MaterialProperty subSurfaceRadiusMap = null;
protected MaterialProperty emissiveColor = null;
protected const string kEmissiveColor = "_EmissiveColor";
protected MaterialProperty emissiveColorMap = null;

protected MaterialProperty materialID = null;
protected const string kMaterialID = "_MaterialID";
protected MaterialProperty subsurfaceProfile = null;
protected const string kSubsurfaceProfile = "_SubsurfaceProfile";
protected MaterialProperty subsurfaceRadius = null;
protected const string kSubsurfaceRadius = "_SubsurfaceRadius";
protected MaterialProperty subsurfaceRadiusMap = null;
protected const string kSubsurfaceRadiusMap = "_SubsurfaceRadiusMap";
protected MaterialProperty thickness = null;
protected const string kThickness = "_Thickness";
protected MaterialProperty thicknessMap = null;
protected const string kThicknessMap = "_ThicknessMap";
{
{
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);
}

emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
materialID = FindProperty(kMaterialID, props);
subsurfaceProfile = FindProperty(kSubsurfaceProfile, props);
subsurfaceRadius = FindProperty(kSubsurfaceRadius, props);
subsurfaceRadiusMap = FindProperty(kSubsurfaceRadiusMap, props);
thickness = FindProperty(kThickness, props);
thicknessMap = FindProperty(kThicknessMap, props);
}
override protected void ShaderInputOptionsGUI()

EditorGUI.indentLevel++;
GUILayout.Label(Styles.InputsOptionsText, EditorStyles.boldLabel);
m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText.text);
m_MaterialEditor.ShaderProperty(UVBase, enableUVDetail ? Styles.UVBaseDetailMappingText.text : Styles.UVBaseMappingText.text);
m_MaterialEditor.ShaderProperty(materialID, Styles.materialIDText);
m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText);
m_MaterialEditor.ShaderProperty(UVBase, enableUVDetail ? Styles.UVBaseDetailMappingText : Styles.UVBaseMappingText);
float X, Y, Z, W;
X = ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.UV0) ? 1.0f : 0.0f;

{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(TexWorldScale, Styles.texWorldScaleText.text);
m_MaterialEditor.ShaderProperty(TexWorldScale, Styles.texWorldScaleText);
m_MaterialEditor.ShaderProperty(UVDetail, Styles.UVDetailMappingText.text);
m_MaterialEditor.ShaderProperty(UVDetail, Styles.UVDetailMappingText);
}
X = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV0) ? 1.0f : 0.0f;

UVDetailsMappingMask.colorValue = new Color(X, Y, Z, W);
//m_MaterialEditor.ShaderProperty(detailMapMode, Styles.detailMapModeText.text);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText.text);
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText.text);
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, Styles.enablePerPixelDisplacementText.text);
m_MaterialEditor.ShaderProperty(ppdMinSamples, Styles.ppdMinSamplesText.text);
m_MaterialEditor.ShaderProperty(ppdMaxSamples, Styles.ppdMaxSamplesText.text);
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
//m_MaterialEditor.ShaderProperty(detailMapMode, Styles.detailMapModeText);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText);
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText);
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);
}
protected void ShaderStandardInputGUI()
{
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);
m_MaterialEditor.ShaderProperty(anisotropy, Styles.anisotropyText);
m_MaterialEditor.TexturePropertySingleLine(Styles.anisotropyMapText, anisotropyMap);
}
bool smoothnessInAlbedoAlpha = (SmoothnessMapChannel)smoothnessMapChannel.floatValue == SmoothnessMapChannel.AlbedoAlpha;
bool smoothnessInAlbedoAlpha = (SmoothnessMapChannel)smoothnessMapChannel.floatValue == SmoothnessMapChannel.AlbedoAlpha;
bool useDetailMapWithNormal = (DetailMapMode)detailMapMode.floatValue == DetailMapMode.DetailWithNormal;
bool useEmissiveMask = (EmissiveColorMode)emissiveColorMode.floatValue == EmissiveColorMode.UseEmissiveMask;

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);

}
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
m_MaterialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
EditorGUI.indentLevel--;
EditorGUILayout.Space();

SetKeyword(material, "_TANGENTMAP", material.GetTexture(kTangentMap));
SetKeyword(material, "_ANISOTROPYMAP", material.GetTexture(kAnisotropyMap));
SetKeyword(material, "_DETAIL_MAP", material.GetTexture(kDetailMap));
SetKeyword(material, "_SUBSURFACE_RADIUS_MAP", material.GetTexture(kSubsurfaceRadiusMap));
SetKeyword(material, "_THICKNESS_MAP", material.GetTexture(kThicknessMap));
bool needUV2 = (UVDetailMapping)material.GetFloat(kUVDetail) == UVDetailMapping.UV2 && (UVBaseMapping)material.GetFloat(kUVBase) == UVBaseMapping.UV0;
bool needUV3 = (UVDetailMapping)material.GetFloat(kUVDetail) == UVDetailMapping.UV3 && (UVBaseMapping)material.GetFloat(kUVBase) == UVBaseMapping.UV0;

material.DisableKeyword("_REQUIRE_UV2");
material.DisableKeyword("_REQUIRE_UV3");
}
material.SetInt("_StencilRef", (int)material.GetFloat(kMaterialID)); // See 'StencilBits'.
}
}
} // namespace UnityEditor

12
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs


public float specular; // 0.02, 0.04, 0.16, 0.2
// SSS
[SurfaceDataAttributes("SubSurface Radius")]
public float subSurfaceRadius;
[SurfaceDataAttributes("Subsurface Radius")]
public float subsurfaceRadius;
[SurfaceDataAttributes("SubSurface Profile")]
public int subSurfaceProfile;
[SurfaceDataAttributes("Subsurface Profile")]
public int subsurfaceProfile;
// Clearcoat
[SurfaceDataAttributes("Coat Normal")]

// fold into fresnel0
// SSS
public float subSurfaceRadius;
public float subsurfaceRadius;
public int subSurfaceProfile;
public int subsurfaceProfile;
// Clearcoat
public Vector3 coatNormalWS;

16
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)

float anisotropy;
float metallic;
float specular;
float subSurfaceRadius;
float subsurfaceRadius;
int subSurfaceProfile;
int subsurfaceProfile;
float3 coatNormalWS;
float coatPerceptualSmoothness;
float3 specularColor;

float roughnessT;
float roughnessB;
float anisotropy;
float subSurfaceRadius;
float subsurfaceRadius;
int subSurfaceProfile;
int subsurfaceProfile;
float3 coatNormalWS;
float coatRoughness;
};

55
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
//-----------------------------------------------------------------------------

else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
bsdfData.diffuseColor = surfaceData.baseColor;
bsdfData.fresnel0 = 0.028; // TODO take from subSurfaceProfile
bsdfData.subSurfaceRadius = surfaceData.subSurfaceRadius;
bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile
bsdfData.subsurfaceRadius = surfaceData.subsurfaceRadius;
bsdfData.subSurfaceProfile = surfaceData.subSurfaceProfile;
bsdfData.subsurfaceProfile = surfaceData.subsurfaceProfile;
}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{

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

}
else if (surfaceData.materialId == MATERIALID_LIT_SSS)
{
outGBuffer2 = float4(surfaceData.subSurfaceRadius, surfaceData.thickness, 0.0, surfaceData.subSurfaceProfile / 8.0); // Number of profile not define yet
outGBuffer2 = float4(surfaceData.subsurfaceRadius, surfaceData.thickness, 0.0, surfaceData.subsurfaceProfile / 8.0); // Number of profile not define yet
}
else if (surfaceData.materialId == MATERIALID_LIT_CLEAR_COAT)
{

else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = 0.028; // TODO take from subSurfaceProfile
bsdfData.subSurfaceRadius = inGBuffer2.r;
bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile
bsdfData.subsurfaceRadius = inGBuffer2.r;
bsdfData.subSurfaceProfile = inGBuffer2.a * 8.0;
bsdfData.subsurfaceProfile = inGBuffer2.a * 8.0;
}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{

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

case DEBUGVIEW_LIT_SURFACEDATA_SPECULAR:
result = surfaceData.specular.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_RADIUS:
result = surfaceData.subSurfaceRadius.xxx;
case DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_RADIUS:
result = surfaceData.subsurfaceRadius.xxx;
case DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_PROFILE:
result = GetIndexColor(surfaceData.subSurfaceProfile);
case DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_PROFILE:
result = GetIndexColor(surfaceData.subsurfaceProfile);
break;
case DEBUGVIEW_LIT_SURFACEDATA_COAT_NORMAL_WS:
result = surfaceData.coatNormalWS * 0.5 + 0.5;

case DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY:
result = bsdfData.anisotropy.xxx;
break;
case DEBUGVIEW_LIT_BSDFDATA_SUB_SURFACE_RADIUS:
result = bsdfData.subSurfaceRadius.xxx;
case DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_RADIUS:
result = bsdfData.subsurfaceRadius.xxx;
case DEBUGVIEW_LIT_BSDFDATA_SUB_SURFACE_PROFILE:
result = GetIndexColor(bsdfData.subSurfaceProfile);
case DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_PROFILE:
result = GetIndexColor(bsdfData.subsurfaceProfile);
break;
case DEBUGVIEW_LIT_BSDFDATA_COAT_NORMAL_WS:
result = bsdfData.coatNormalWS * 0.5 + 0.5;

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


_BaseColorMap("BaseColorMap", 2D) = "white" {}
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_Smoothness("Smoothness", Range(0.0, 1.0)) = 1.0
_MaskMap("MaskMap", 2D) = "white" {}
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {}

_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale("_DetailSmoothnessScale", Range(-2.0, 2.0)) = 1
_DetailHeightScale("_DetailHeightScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
_SubSurfaceRadius("SubSurfaceRadius", Range(0.0, 1.0)) = 0
_SubSurfaceRadiusMap("SubSurfaceRadiusMap", 2D) = "white" {}
//_Thickness("Thickness", Range(0.0, 1.0)) = 0
//_ThicknessMap("ThicknessMap", 2D) = "white" {}
//_SubSurfaceProfile("SubSurfaceProfile", Float) = 0
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2, Specular Color, 3)] _MaterialID("MaterialId", Int) = 0
_SubsurfaceProfile("Subsurface Profile", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.004, 1.0)) = 0.5
_SubsurfaceRadiusMap("Subsurface Radius Map", 2D) = "white" {}
_Thickness("Thickness", Range(0.004, 1.0)) = 0.5
_ThicknessMap("Thickness Map", 2D) = "white" {}
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0
//_CoatCoverageMap("CoatCoverageMapMap", 2D) = "white" {}

[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode("__blendmode", 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(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
}
HLSLINCLUDE

#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 _HEIGHTMAP
#pragma shader_feature _TANGENTMAP
#pragma shader_feature _ANISOTROPYMAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _THICKNESS_MAP
//#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"

Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER

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"

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


LayerUV details1;
LayerUV details2;
LayerUV details3;
// Dedicated for blend mask
LayerUV blendMask;
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
float GetMaxDisplacement()
{
float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP)
maxDisplacement = _HeightAmplitude;
#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(_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
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"
#if defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)
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;
#endif
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);
// 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);
(...)
*/
}
else
{
ppdParam.uv = layerTexCoord.base.uv;
ParallaxOcclusionMappingLayer(layerTexCoord, numSteps, viewDirTS);
// 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);
// 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
#endif
// 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)

float3 normalTS;
float alpha = GetSurfaceData(input, layerTexCoord, surfaceData, normalTS);
GetNormalAndTangentWS(input, V, normalTS, surfaceData.normalWS, surfaceData.tangentWS);
// Done one time for all layered - cumulate with spec occ alpha for now
surfaceData.specularOcclusion *= GetHorizonOcclusion(V, surfaceData.normalWS, input.tangentToWorld[2].xyz, _HorizonFade);
// Caution: surfaceData must be fully initialize before calling GetBuiltinData
GetBuiltinData(input, surfaceData, alpha, depthOffset, builtinData);

#undef LAYER_INDEX
#undef ADD_IDX
void ComputeMaskWeights(float3 inputMasks, out float outWeights[_MAX_LAYER])
{
float masks[_MAX_LAYER];
masks[0] = 1.0; // Layer 0 is always full
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);

#define SURFACEDATA_BLEND_SCALAR(surfaceData, name, mask) BlendLayeredScalar(surfaceData##0.##name, surfaceData##1.##name, surfaceData##2.##name, surfaceData##3.##name, mask);
#define PROP_BLEND_SCALAR(name, mask) BlendLayeredScalar(name##0, name##1, name##2, name##3, mask);
float ApplyHeightBasedBlend(inout float inputFactor, float previousLayerHeight, float layerHeight, float heightOffset, float heightFactor, float edgeBlendStrength, float vertexColor)
{
float finalLayerHeight = heightFactor * layerHeight + heightOffset + _VertexColorHeightFactor * (vertexColor * 2.0 - 1.0);
edgeBlendStrength = max(0.00001, edgeBlendStrength);
if (previousLayerHeight >= finalLayerHeight)
{
inputFactor = 0.0;
}
else if (finalLayerHeight > previousLayerHeight && finalLayerHeight < previousLayerHeight + edgeBlendStrength)
{
inputFactor = inputFactor * pow((finalLayerHeight - previousLayerHeight) / edgeBlendStrength, 0.5);
}
return max(finalLayerHeight, previousLayerHeight);
}
float3 ApplyHeightBasedBlendV2(float3 inputMask, float3 inputHeight, float3 blendUsingHeight)
{
return saturate(lerp(inputMask * inputHeight * blendUsingHeight * 100, 1, inputMask * inputMask)); // 100 arbitrary scale to limit blendUsingHeight values.
}
void GetLayerTexCoord(float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3,
float3 positionWS, float3 normalWS, out LayerTexCoord layerTexCoord)
{

// one weight for each direction XYZ - Use vertex normal for triplanar
layerTexCoord.weights = ComputeTriplanarWeights(normalWS);
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(normalWS);
#endif
bool isTriplanar = false;

ComputeLayerTexCoord0( texCoord0, texCoord1, texCoord2, texCoord3,
// 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);
// Note: Our BlendMask use the same uv mapping than the base layer but with its own tiling.
// Here we get a first time the base0 but with _LayerTilingBlendMask. Save the result and recall the function regularly for the main layer.
// It is just to share code.
ComputeLayerTexCoord0( texCoord0, float2(0.0, 0.0), float2(0.0, 0.0), float2(0.0, 0.0),
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTilingBlendMask);
layerTexCoord.blendMask = layerTexCoord.base0;
ComputeLayerTexCoord0( texCoord0, float2(0.0, 0.0), float2(0.0, 0.0), float2(0.0, 0.0),
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling0);
isTriplanar = false;

positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling3);
}
void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord layerTexCoord)
#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
#endif
// 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)
#if defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)
float3 viewDirTS = TransformWorldToTangent(V, input.tangentToWorld);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
#ifndef _HEIGHTMAP0
height0 = 0.0;
#endif
#ifndef _HEIGHTMAP1
height1 = 0.0;
#endif
#ifndef _HEIGHTMAP2
height2 = 0.0;
#endif
#ifndef _HEIGHTMAP3
height3 = 0.0;
#endif
ParallaxOcclusionMappingLayer0(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer1(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer2(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer3(layerTexCoord, numSteps, viewDirTS);
#if _LAYER_COUNT < 4
height3 = 0.0;
#endif
#if _LAYER_COUNT < 3
height2 = 0.0;
float3 ComputeInheritedNormalTS(FragInputs input, float3 normalTS0, float3 normalTS1, float3 normalTS2, float3 normalTS3, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])
void ComputeMaskWeights(float4 inputMasks, out float outWeights[_MAX_LAYER])
float3 normalTS;
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
// Compute how much we want to inherit from base layer normal base on the mask. Base layer always fully inherit from "itself" if it's the visible layer.
float inheritBaseNormal = BlendLayeredScalar(1.0, _InheritBaseNormal1, _InheritBaseNormal2, _InheritBaseNormal3, weights);
// Based on this inheritance parameters, fetch a lower level of the base layer normal map so that the less we inherit the more this tends to be "vertex normal"
float maxMipBias = log2(max(_NormalMap0_TexelSize.x, _NormalMap0_TexelSize.y)) + 1.0; // TODO: Use hardware instruction here (GetDimensions) that can retunr mipmaps num ? will this be faster
float3 inheritedBaseNormalTS = GetNormalTS0(input, layerTexCoord, float3(0.0, 0.0, 0.0), 0.0, true, maxMipBias * (1.0 - inheritBaseNormal));
// 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]);
}
}
// Caution: Blend mask are Layer 1 R - Layer 2 G - Layer 3 B - Main Layer A
float4 GetBlendMask(LayerTexCoord layerTexCoord, float4 vertexColor, bool useLodSampling = false, float lod = 0)
{
// Caution:
// Blend mask are Main Layer A - Layer 1 R - Layer 2 G - Layer 3 B
// 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.blendMask, lod) : SAMPLE_LAYER_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask);
// Blend all layers but the base one. This will then be added to the "inherited" normal of base layer (that's why base layer here is tangent space vertex normal so that if it's the visible layer we add nothing in term of normal map).
float3 layersNormalTS = BlendLayeredVector3(float3(0.0, 0.0, 1.0), normalTS1, normalTS2, normalTS3, weights);
// Add the inherited normal to the blended top layers.
normalTS = BlendNormalRNM(inheritedBaseNormalTS, layersNormalTS);
#if defined(_LAYER_MASK_VERTEX_COLOR_MUL)
blendMasks *= vertexColor;
#elif defined(_LAYER_MASK_VERTEX_COLOR_ADD)
blendMasks = saturate(blendMasks + vertexColor * 2.0 - 1.0);
#endif
return normalTS;
return blendMasks;
float3 ComputeInheritedColor(float3 baseColor0, float3 baseColor1, float3 baseColor2, float3 baseColor3, float compoMask, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])
// Return the maximun amplitude use by all enabled heightmap
// use for tessellation culling and per pixel displacement
float GetMaxDisplacement()
float inheritBaseColor = BlendLayeredScalar(1.0, _InheritBaseColor1, _InheritBaseColor2, _InheritBaseColor3, weights);
float inheritBaseColorThreshold = BlendLayeredScalar(1.0, _InheritBaseColorThreshold1, _InheritBaseColorThreshold2, _InheritBaseColorThreshold3, weights);
float maxDisplacement = 0.0;
inheritBaseColor = inheritBaseColor * (1.0 - saturate(compoMask / inheritBaseColorThreshold));
#if defined(_HEIGHTMAP0)
maxDisplacement = max( _LayerHeightAmplitude0, maxDisplacement);
#endif
// We want to calculate the mean color of the texture. For this we will sample a low mipmap
float textureBias = 15.0; // Force a high number to be sure we get the lowest mip
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;
#if defined(_HEIGHTMAP1)
maxDisplacement = max( _LayerHeightAmplitude1
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
+_LayerHeightAmplitude0 * _InheritBaseHeight1
#endif
, maxDisplacement);
#endif
float3 meanColor = BlendLayeredVector3(baseMeanColor0, baseMeanColor1, baseMeanColor2, baseMeanColor3, weights);
float3 baseColor = BlendLayeredVector3(baseColor0, baseColor1, baseColor2, baseColor3, weights);
#if _LAYER_COUNT >= 3
#if defined(_HEIGHTMAP2)
maxDisplacement = max( _LayerHeightAmplitude2
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
+_LayerHeightAmplitude0 * _InheritBaseHeight2
#endif
, maxDisplacement);
#endif
#endif
// If we inherit from base layer, we will add a bit of it
return inheritBaseColor * (baseColor0 - meanColor) + baseColor;
#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;
};
float ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod)
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)
// Mask Values : Layer 1, 2, 3 are r, g, b. Always use layer0 parametrization for the mask
float3 inputMaskValues = SAMPLE_LAYER_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.base0, lod).rgb;
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 defined(_LAYER_MASK_VERTEX_COLOR_MUL)
inputMaskValues *= vertexColor.rgb;
#elif defined(_LAYER_MASK_VERTEX_COLOR_ADD)
inputMaskValues = saturate(inputMaskValues + vertexColor.rgb * 2.0 - 1.0);
#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 // _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)
{
float4 blendMasks = GetBlendMask(layerTexCoord, vertexColor, true, lod);
ComputeMaskWeights(inputMaskValues, weights);
ComputeMaskWeights(blendMasks, weights);
float height0 = SampleHeightmapLod0(layerTexCoord, lod);
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
float3 ApplyHeightBasedBlend(float3 inputMask, float3 inputHeight, float3 blendUsingHeight)
{
return saturate(lerp(inputMask * inputHeight * blendUsingHeight * 100, 1, inputMask * inputMask)); // 100 arbitrary scale to limit blendUsingHeight values.
}
// 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
// Mask Values : Layer 1, 2, 3 are r, g, b. Always use layer0 parametrization for the mask
float3 inputMaskValues = SAMPLE_LAYER_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.base0).rgb;
float4 blendMasks = GetBlendMask(layerTexCoord, input.color);
#if defined(_DENSITY_MODE)
// Note: blendMasks.argb because a is main layer
float4 minOpaParam = float4(_MinimumOpacity0, _MinimumOpacity1, _MinimumOpacity2, _MinimumOpacity3);
float4 remapedOpacity = lerp(minOpaParam, float4(1.0, 1.0, 1.0, 1.0), inputAlphaMask); // Remap opacity mask from [0..1] to [minOpa..1]
float4 opacityAsDensity = saturate((inputAlphaMask - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks.argb)) * 20.0);
float4 useOpacityAsDensityParam = float4(_OpacityAsDensity0, _OpacityAsDensity1, _OpacityAsDensity2, _OpacityAsDensity3);
blendMasks.argb = lerp(blendMasks.argb * remapedOpacity, opacityAsDensity, useOpacityAsDensityParam);
#endif
#if defined(_HEIGHT_BASED_BLEND)
#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);
float4 heights = float4(height0, height1, height2, height3);
// 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
heights.y += (heights.x * 0.0001);
#endif
#else
float4 heights = float4(0.0, 0.0, 0.0, 0.0);
#endif
#if defined(_LAYER_MASK_VERTEX_COLOR_MUL)
inputMaskValues *= input.color.rgb;
#elif defined(_LAYER_MASK_VERTEX_COLOR_ADD)
inputMaskValues = saturate(inputMaskValues + input.color.rgb * 2.0 - 1.0);
// don't apply on main layer
blendMasks.rgb = ApplyHeightBasedBlend(blendMasks.rgb, heights.yzw, float3(_BlendUsingHeight1, _BlendUsingHeight2, _BlendUsingHeight3));
float3 minOpaParam = float3(_MinimumOpacity1, _MinimumOpacity2, _MinimumOpacity3);
float3 remapedOpacity = lerp(minOpaParam, float3(1.0, 1.0, 1.0), inputAlphaMask.yzw); // Remap opacity mask from [0..1] to [minOpa..1]
float3 opacityAsDensity = saturate((inputAlphaMask.yzw - (float3(1.0, 1.0, 1.0) - inputMaskValues)) * 20.0);
ComputeMaskWeights(blendMasks, outWeights);
}
float3 useOpacityAsDensityParam = float3(_OpacityAsDensity1, _OpacityAsDensity2, _OpacityAsDensity3);
inputMaskValues = lerp(inputMaskValues * remapedOpacity, opacityAsDensity, useOpacityAsDensityParam);
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);
#if defined(_HEIGHT_BASED_BLEND)
float height0 = SampleHeightmap0(layerTexCoord);
float height1 = SampleHeightmap1(layerTexCoord, _HeightCenterOffset1, _HeightFactor1);
float height2 = SampleHeightmap2(layerTexCoord, _HeightCenterOffset2, _HeightFactor2);
float height3 = SampleHeightmap3(layerTexCoord, _HeightCenterOffset3, _HeightFactor3);
// 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));
float4 heights = float4(height0, height1, height2, height3);
// 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 !defined(_HEIGHT_BASED_BLEND_V2)
float baseLayerHeight = heights.x;
baseLayerHeight = ApplyHeightBasedBlend(inputMaskValues.r, baseLayerHeight, heights.y, _HeightOffset1, _HeightFactor1, _BlendSize1, input.color.r);
baseLayerHeight = ApplyHeightBasedBlend(inputMaskValues.g, baseLayerHeight, heights.z, _HeightOffset2 + _HeightOffset1, _HeightFactor2, _BlendSize2, input.color.g);
ApplyHeightBasedBlend(inputMaskValues.b, baseLayerHeight, heights.w, _HeightOffset3 + _HeightOffset2 + _HeightOffset1, _HeightFactor3, _BlendSize3, input.color.b);
#else
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);
// HACK, use height0 to avoid compiler error for unused sampler
// To remove once we have POM
heights.y += (heights.x * 0.0001);
float influenceFactor = BlendLayeredScalar(0.0, _InheritBaseColor1, _InheritBaseColor2, _InheritBaseColor3, weights);
float influenceThreshold = BlendLayeredScalar(1.0, _InheritBaseColorThreshold1, _InheritBaseColorThreshold2, _InheritBaseColorThreshold3, weights);
inputMaskValues = ApplyHeightBasedBlendV2(inputMaskValues, heights.yzw, float3(_BlendUsingHeight1, _BlendUsingHeight2, _BlendUsingHeight3));
#endif
#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;
ComputeMaskWeights(inputMaskValues, outWeights);
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)

float alpha2 = GetSurfaceData2(input, layerTexCoord, surfaceData2, normalTS2);
float alpha3 = GetSurfaceData3(input, layerTexCoord, surfaceData3, normalTS3);
// 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.
float weights[_MAX_LAYER];
ComputeLayerWeights(input, layerTexCoord, float4(alpha0, alpha1, alpha2, alpha3), weights);

#ifdef _ALPHATEST_ON
clip(alpha - _AlphaCutoff);
#endif
surfaceData.baseColor = ComputeInheritedColor(surfaceData0.baseColor, surfaceData1.baseColor, surfaceData2.baseColor, surfaceData3.baseColor, alpha, layerTexCoord, weights);
float3 normalTS = ComputeInheritedNormalTS(input, normalTS0, normalTS1, normalTS2, normalTS3, layerTexCoord, weights);
surfaceData.baseColor = ComputeMainBaseColorInfluence(surfaceData0.baseColor, surfaceData1.baseColor, surfaceData2.baseColor, surfaceData3.baseColor, alpha, layerTexCoord, weights);
float3 normalTS = ComputeMainNormalInfluence(input, normalTS0, normalTS1, normalTS2, normalTS3, layerTexCoord, weights);
surfaceData.specularOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, specularOcclusion, weights);
surfaceData.perceptualSmoothness = SURFACEDATA_BLEND_SCALAR(surfaceData, perceptualSmoothness, weights);
surfaceData.ambientOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, ambientOcclusion, weights);
surfaceData.metallic = SURFACEDATA_BLEND_SCALAR(surfaceData, metallic, weights);

surfaceData.materialId = 0;
surfaceData.anisotropy = 0;
surfaceData.specular = 0.04;
surfaceData.subSurfaceRadius = 1.0;
surfaceData.subsurfaceRadius = 1.0;
surfaceData.subSurfaceProfile = 0;
surfaceData.subsurfaceProfile = 0;
// Done one time for all layered - cumulate with spec occ alpha for now
surfaceData.specularOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, specularOcclusion, weights);
surfaceData.specularOcclusion *= GetHorizonOcclusion(V, surfaceData.normalWS, input.tangentToWorld[2].xyz, _HorizonFade);
GetBuiltinData(input, surfaceData, alpha, depthOffset, builtinData);
}

177
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).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)
{
float3 normalTS;

if (useBias)
{
normalTS = SAMPLE_LAYER_NORMALMAP_BIAS(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_ZERO_IDX(_NormalScale), bias);
normalTS = SAMPLE_LAYER_NORMALMAP_BIAS(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale), bias);
normalTS = SAMPLE_LAYER_NORMALMAP(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_ZERO_IDX(_NormalScale));
normalTS = SAMPLE_LAYER_NORMALMAP(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale));
}
#else // Object space
// to be able to combine object space normal with detail map we transform it to tangent space (object space normal composition is not simple).

float3 normalOS = SAMPLE_LAYER_NORMALMAP_RGB_BIAS(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_ZERO_IDX(_NormalScale), bias).rgb;
float3 normalOS = SAMPLE_LAYER_NORMALMAP_RGB_BIAS(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale), bias).rgb;
float3 normalOS = SAMPLE_LAYER_NORMALMAP_RGB(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_ZERO_IDX(_NormalScale)).rgb;
float3 normalOS = SAMPLE_LAYER_NORMALMAP_RGB(ADD_IDX(_NormalMap), ADD_ZERO_IDX(sampler_NormalMap), ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale)).rgb;
normalTS = TransformObjectToTangent(normalOS, input.tangentToWorld);
}
#endif

#endif
// Perform alha test very early to save performance (a killed pixel will not sample textures)
#ifdef _ALPHATEST_ON
#if defined(_ALPHATEST_ON) && !defined(LAYERED_LIT_SHADER)
clip(alpha - _AlphaCutoff);
#endif

// TODO: Do something. For now just take alpha channel
surfaceData.specularOcclusion = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_SpecularOcclusionMap), ADD_ZERO_IDX(sampler_SpecularOcclusionMap), ADD_IDX(layerTexCoord.base)).a;
#else
// Horizon Occlusion for Normal Mapped Reflections: http://marmosetco.tumblr.com/post/81245981087
//surfaceData.specularOcclusion = saturate(1.0 + horizonFade * dot(r, input.tangentToWorld[2].xyz);
// smooth it
//surfaceData.specularOcclusion *= surfaceData.specularOcclusion;
// The specular occlusion will be perform outside the internal loop
surfaceData.specularOcclusion = 1.0;
#endif
surfaceData.normalWS = float3(0.0, 0.0, 0.0); // Need to init this so that the compiler leaves us alone.

// This part of the code is not used in case of layered shader but we keep the same macro system for simplicity
#if !defined(LAYERED_LIT_SHADER)
surfaceData.materialId = 0; // TODO
surfaceData.materialId = _MaterialID;
// TODO: think about using BC5
#ifdef _TANGENTMAP

surfaceData.specular = 0.04;
surfaceData.subSurfaceRadius = 1.0;
surfaceData.thickness = 0.0;
surfaceData.subSurfaceProfile = 0;
surfaceData.subsurfaceProfile = _SubsurfaceProfile;
#ifdef _Subsurface_RADIUS_MAP
surfaceData.subsurfaceProfile = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_SubsurfaceRadiusMap), ADD_ZERO_IDX(sampler_SubsurfaceRadiusMap), ADD_IDX(layerTexCoord.base)).r;
#else
surfaceData.subsurfaceRadius = _SubsurfaceRadius;
#endif
#ifdef _THICKNESS_MAP
surfaceData.thickness = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_ThicknessMap), ADD_ZERO_IDX(sampler_ThicknessMap), ADD_IDX(layerTexCoord.base)).r;
#else
surfaceData.thickness = _Thickness;
#endif
surfaceData.coatNormalWS = float3(1.0, 0.0, 0.0);
surfaceData.coatPerceptualSmoothness = 1.0;

surfaceData.anisotropy = 0;
surfaceData.specular = 0.04;
surfaceData.subSurfaceRadius = 1.0;
surfaceData.subsurfaceRadius = 1.0;
surfaceData.subSurfaceProfile = 0;
surfaceData.subsurfaceProfile = 0;
surfaceData.coatNormalWS = float3(1.0, 0.0, 0.0);
surfaceData.coatPerceptualSmoothness = 1.0;

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


TEXTURE2D(_AnisotropyMap);
SAMPLER2D(sampler_AnisotropyMap);
//float _SubSurfaceRadius;
//TEXTURE2D(_SubSurfaceRadiusMap);
//SAMPLER2D(sampler_SubSurfaceRadiusMap);
// float _Thickness;
//TEXTURE2D(_ThicknessMap);
//SAMPLER2D(sampler_ThicknessMap);
int _MaterialID;
int _SubsurfaceProfile;
float _SubsurfaceRadius;
float _Thickness;
TEXTURE2D(_SubsurfaceRadiusMap);
SAMPLER2D(sampler_SubsurfaceRadiusMap);
TEXTURE2D(_ThicknessMap);
SAMPLER2D(sampler_ThicknessMap);
// float _CoatCoverage;
//TEXTURE2D(_CoatCoverageMap);

float _AlphaCutoff;
float _TexWorldScale;
float _UVMappingPlanar;
float4 _UVMappingMask;
float4 _UVDetailsMappingMask;
float _HorizonFade;
float _TexWorldScale;
float _UVMappingPlanar;
float4 _UVMappingMask;
float4 _UVDetailsMappingMask;
float _PPDMaxSamples;
float _PPDMinSamples;
float _PPDMaxSamples;
float _PPDMinSamples;
float _PPDLodThreshold;
CBUFFER_END
#else // LAYERED_LIT_SHADER

TEXTURE2D(_LayerMaskMap);
SAMPLER2D(sampler_LayerMaskMap);
float _HeightOffset1;
float _HeightOffset2;
float _HeightOffset3;
float _HeightFactor1;
float _HeightFactor2;
float _HeightFactor3;
float _BlendSize1;
float _BlendSize2;
float _BlendSize3;
float _VertexColorHeightFactor;
// Blend Properties V2
float _UseHeightBasedBlendV2;
float _HeightCenterOffset1;
float _HeightCenterOffset2;
float _HeightCenterOffset3;
PROP_DECL(float, _LayerHeightAmplitude);
PROP_DECL(float, _LayerCenterOffset);
PROP_DECL(float, _MinimumOpacity);
PROP_DECL(float, _OpacityAsDensity);
float _InheritBaseNormal1;
float _InheritBaseNormal2;
float _InheritBaseNormal3;

float _InheritBaseColorThreshold1;
float _InheritBaseColorThreshold2;
float _InheritBaseColorThreshold3;
float _MinimumOpacity1;
float _MinimumOpacity2;
float _MinimumOpacity3;
float _OpacityAsDensity1;
float _OpacityAsDensity2;
float _OpacityAsDensity3;
float _LayerTilingBlendMask;
PROP_DECL(float, _LayerTiling);
float3 _EmissiveColor;

float _AlphaCutoff;
float _HorizonFade;
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

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


_BaseColorMap("BaseColorMap", 2D) = "white" {}
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_Smoothness("Smoothness", Range(0.0, 1.0)) = 1.0
_MaskMap("MaskMap", 2D) = "white" {}
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {}

_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale("_DetailSmoothnessScale", Range(-2.0, 2.0)) = 1
_DetailHeightScale("_DetailHeightScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
_SubSurfaceRadius("SubSurfaceRadius", Range(0.0, 1.0)) = 0
_SubSurfaceRadiusMap("SubSurfaceRadiusMap", 2D) = "white" {}
//_Thickness("Thickness", Range(0.0, 1.0)) = 0
//_ThicknessMap("ThicknessMap", 2D) = "white" {}
//_SubSurfaceProfile("SubSurfaceProfile", Float) = 0
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2, Specular Color, 3)] _MaterialID("MaterialId", Int) = 0
_SubsurfaceProfile("Subsurface Profile", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.004, 1.0)) = 0.5
_SubsurfaceRadiusMap("Subsurface Radius Map", 2D) = "white" {}
_Thickness("Thickness", Range(0.004, 1.0)) = 0.5
_ThicknessMap("Thickness Map", 2D) = "white" {}
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0
//_CoatCoverageMap("CoatCoverageMapMap", 2D) = "white" {}

[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode("__blendmode", 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(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)

_TessellationFactor("Tessellation Factor", Range(0.0, 15.0)) = 4.0
_TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0
_TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 50.0
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0
_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong
_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25
[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 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 _NORMALMAP
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
#pragma shader_feature _SPECULAROCCLUSIONMAP
#pragma shader_feature _EMISSIVE_COLOR_MAP

#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _THICKNESS_MAP
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define

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

Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma hull Hull

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" }

HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// No tessellation for Meta pass
// No tessellation for Meta pass
#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

#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

Cull[_CullMode]
ZWrite On
ZWrite On
HLSLPROGRAM
#pragma hull Hull

#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
// TODO: Tesselation can't work with velocity for now...
// TODO: Tesselation can't work with velocity for now...
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitVelocityPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"

#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_FORWARD
#define SHADERPASS SHADERPASS_FORWARD
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

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"

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader


#pragma vertex Vert
#pragma fragment Frag
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#include "Common.hlsl"
#include "ImageBasedLighting.hlsl"

8
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl


#define ATTRIBUTES_NEED_TEXCOORD1
#define ATTRIBUTES_NEED_TEXCOORD2
#if defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))
#define ATTRIBUTES_NEED_COLOR
#endif
#if defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))
#define VARYINGS_NEED_COLOR
#endif
// This include will define the various Attributes/Varyings structure
#include "../../ShaderPass/VaryingMesh.hlsl"

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)

56
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/SampleLayerInternal.hlsl


// Also we use multiple inclusion to handle the various variation for lod and bias
// param can be unused, lod or bias
float4 ADD_FUNC_SUFFIX(SampleLayer)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float param)
float4 ADD_FUNC_SUFFIX(SampleLayer)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 triplanarWeights, float param)
if (weights.x > 0.0)
val += weights.x * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param);
if (weights.y > 0.0)
val += weights.y * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param);
if (weights.z > 0.0)
val += weights.z * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param);
return val;
}

// TODO: Handle BC5 format, currently this code is for DXT5nm - After the change, rename this function UnpackNormalmapRGorAG
// This version is use for the base normal map
float3 ADD_FUNC_SUFFIX(SampleLayerNormal)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float scale, float param)
float3 ADD_FUNC_SUFFIX(SampleLayerNormal)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 triplanarWeights, float scale, float param)
if (weights.x > 0.0)
val += weights.x * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param), scale);
if (weights.y > 0.0)
val += weights.y * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param), scale);
if (weights.z > 0.0)
val += weights.z * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param), scale);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param), scale);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
return normalize(val);
}

}
// This version is for normalmap with AG encoding only. Mainly use with details map.
float3 ADD_FUNC_SUFFIX(SampleLayerNormalAG)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float scale, float param)
float3 ADD_FUNC_SUFFIX(SampleLayerNormalAG)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 triplanarWeights, float scale, float param)
if (weights.x > 0.0)
val += weights.x * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param), scale);
if (weights.y > 0.0)
val += weights.y * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param), scale);
if (weights.z > 0.0)
val += weights.z * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param), scale);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param), scale);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * UnpackNormalAG(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
return normalize(val);
}

}
// This version is for normalmap with RGB encoding only, i.e uncompress or BC7. Mainly used for object space normal.
float3 ADD_FUNC_SUFFIX(SampleLayerNormalRGB)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float scale, float param)
float3 ADD_FUNC_SUFFIX(SampleLayerNormalRGB)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 triplanarWeights, float scale, float param)
if (weights.x > 0.0)
val += weights.x * UnpackNormalRGB(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param), scale);
if (weights.y > 0.0)
val += weights.y * UnpackNormalRGB(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param), scale);
if (weights.z > 0.0)
val += weights.z * UnpackNormalRGB(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * UnpackNormalRGB(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvYZ, param), scale);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * UnpackNormalRGB(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZX, param), scale);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * UnpackNormalRGB(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
return normalize(val);
}

286
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs


{
public abstract class BaseUnlitGUI : ShaderGUI
{
public enum SurfaceType
{
Opaque,
Transparent
}
public enum BlendMode
{
Lerp,
Add,
SoftAdd,
Multiply,
Premultiply
}
public enum DoubleSidedMode
{
None,
DoubleSided
}
public static string OptionText = "Options";
public static string SurfaceTypeText = "Surface Type";
public static string BlendModeText = "Blend Mode";
public static string optionText = "Options";
public static string surfaceTypeText = "Surface Type";
public static string blendModeText = "Blend Mode";
public static GUIContent distortionEnableText = new GUIContent("Distortion", "Enable distortion on this shader");
public static GUIContent distortionOnlyText = new GUIContent("Distortion Only", "This shader will only be use to render distortion");
public static GUIContent distortionDepthTestText = new GUIContent("Distortion Depth Test", "Enable the depth test for distortion");
public static readonly string[] surfaceTypeNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendModeNames = Enum.GetNames(typeof(BlendMode));

public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive");
public static GUIContent emissiveIntensityText = new GUIContent("Emissive Intensity", "Emissive");
}
MaterialProperty surfaceType = null;
MaterialProperty blendMode = null;
MaterialProperty alphaCutoff = null;
MaterialProperty alphaCutoffEnable = null;
MaterialProperty doubleSidedMode = null;
protected const string kSurfaceType = "_SurfaceType";
protected const string kBlendMode = "_BlendMode";
protected const string kAlphaCutoff = "_AlphaCutoff";
protected const string kAlphaCutoffEnabled = "_AlphaCutoffEnable";
protected const string kDoubleSidedMode = "_DoubleSidedMode";
protected MaterialEditor m_MaterialEditor;
public static GUIContent emissiveWarning = new GUIContent("Emissive value is animated but the material has not been configured to support emissive. Please make sure the material itself has some amount of emissive.");
public static GUIContent emissiveColorWarning = new GUIContent("Ensure emissive color is non-black for emission to have effect.");
public void FindCommonOptionProperties(MaterialProperty[] props)
{
surfaceType = FindProperty(kSurfaceType, props);
blendMode = FindProperty(kBlendMode, props);
alphaCutoff = FindProperty(kAlphaCutoff, props);
alphaCutoffEnable = FindProperty(kAlphaCutoffEnabled, props);
doubleSidedMode = FindProperty(kDoubleSidedMode, props);
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
public enum SurfaceType
FindCommonOptionProperties(props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
FindMaterialProperties(props);
m_MaterialEditor = materialEditor;
Material material = materialEditor.target as Material;
ShaderPropertiesGUI(material);
Opaque,
Transparent
protected void ShaderOptionsGUI()
public enum BlendMode
EditorGUI.indentLevel++;
GUILayout.Label(Styles.OptionText, EditorStyles.boldLabel);
SurfaceTypePopup();
if ((SurfaceType)surfaceType.floatValue == SurfaceType.Transparent)
{
BlendModePopup();
}
m_MaterialEditor.ShaderProperty(alphaCutoffEnable, Styles.alphaCutoffEnableText.text);
if (alphaCutoffEnable.floatValue == 1.0)
{
m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText.text);
}
m_MaterialEditor.ShaderProperty(doubleSidedMode, Styles.doubleSidedModeText.text);
EditorGUI.indentLevel--;
Lerp,
Add,
SoftAdd,
Multiply,
Premultiply
public void ShaderPropertiesGUI(Material material)
public enum DoubleSidedMode
// Use default labelWidth
EditorGUIUtility.labelWidth = 0f;
// Detect any changes to the material
EditorGUI.BeginChangeCheck();
{
ShaderOptionsGUI();
EditorGUILayout.Space();
ShaderInputOptionsGUI();
EditorGUILayout.Space();
ShaderInputGUI();
}
if (EditorGUI.EndChangeCheck())
{
foreach (var obj in m_MaterialEditor.targets)
SetupMaterialKeywords((Material)obj);
}
None,
DoubleSided
// TODO: try to setup minimun value to fall back to standard shaders and reverse
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
{
base.AssignNewShaderToMaterial(material, oldShader, newShader);
}
void SurfaceTypePopup()
void SurfaceTypePopup()
mode = (SurfaceType)EditorGUILayout.Popup(Styles.SurfaceTypeText, (int)mode, Styles.surfaceTypeNames);
mode = (SurfaceType)EditorGUILayout.Popup(Styles.surfaceTypeText, (int)mode, Styles.surfaceTypeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Surface Type");

var mode = (BlendMode)blendMode.floatValue;
EditorGUI.BeginChangeCheck();
mode = (BlendMode)EditorGUILayout.Popup(Styles.BlendModeText, (int)mode, Styles.blendModeNames);
mode = (BlendMode)EditorGUILayout.Popup(Styles.blendModeText, (int)mode, Styles.blendModeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Blend Mode");

EditorGUI.showMixedValue = false;
}
protected void ShaderOptionsGUI()
{
EditorGUI.indentLevel++;
GUILayout.Label(Styles.optionText, EditorStyles.boldLabel);
SurfaceTypePopup();
if ((SurfaceType)surfaceType.floatValue == SurfaceType.Transparent)
{
BlendModePopup();
m_MaterialEditor.ShaderProperty(distortionEnable, Styles.distortionEnableText.text);
if (distortionEnable.floatValue == 1.0)
{
m_MaterialEditor.ShaderProperty(distortionOnly, Styles.distortionOnlyText.text);
m_MaterialEditor.ShaderProperty(distortionDepthTest, Styles.distortionDepthTestText.text);
}
}
m_MaterialEditor.ShaderProperty(alphaCutoffEnable, Styles.alphaCutoffEnableText.text);
if (alphaCutoffEnable.floatValue == 1.0)
{
m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText.text);
}
m_MaterialEditor.ShaderProperty(doubleSidedMode, Styles.doubleSidedModeText.text);
EditorGUI.indentLevel--;
}
public void FindCommonOptionProperties(MaterialProperty[] props)
{
surfaceType = FindProperty(kSurfaceType, props);
blendMode = FindProperty(kBlendMode, props);
alphaCutoff = FindProperty(kAlphaCutoff, props);
alphaCutoffEnable = FindProperty(kAlphaCutoffEnabled, props);
doubleSidedMode = FindProperty(kDoubleSidedMode, props);
distortionEnable = FindProperty(kDistortionEnable, props);
distortionOnly = FindProperty(kDistortionOnly, props);
distortionDepthTest = FindProperty(kDistortionDepthTest, props);
}
protected void SetupCommonOptionsKeywords(Material material)
{
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation

SetKeyword(material, "_ALPHATEST_ON", alphaTestEnable);
// Setup lightmap emissive flags
MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
bool distortionEnable = material.GetFloat(kDistortionEnable) == 1.0;
bool distortionOnly = material.GetFloat(kDistortionOnly) == 1.0;
bool distortionDepthTest = material.GetFloat(kDistortionDepthTest) == 1.0;
if (distortionEnable)
if (ShouldEmissionBeEnabled(material))
flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
else
flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
material.SetShaderPassEnabled("DistortionVectors", true);
}
else
{
material.SetShaderPassEnabled("DistortionVectors", false);
}
material.globalIlluminationFlags = flags;
if (distortionEnable && distortionOnly)
{
// Disable all passes except dbug material
material.SetShaderPassEnabled("DebugViewMaterial", true);
material.SetShaderPassEnabled("Meta", false);
material.SetShaderPassEnabled("Forward", false);
material.SetShaderPassEnabled("ForwardOnlyOpaque", false);
}
else
{
material.SetShaderPassEnabled("DebugViewMaterial", true);
material.SetShaderPassEnabled("Meta", true);
material.SetShaderPassEnabled("Forward", true);
material.SetShaderPassEnabled("ForwardOnlyOpaque", true);
}
if (distortionDepthTest)
{
material.SetInt("_ZTestMode", (int)UnityEngine.Rendering.CompareFunction.LessEqual);
else
{
material.SetInt("_ZTestMode", (int)UnityEngine.Rendering.CompareFunction.Always);
}
SetKeyword(material, "_DISTORTION_ON", distortionEnable);
SetupEmissionGIFlags(material);
protected void SetKeyword(Material m, string keyword, bool state)
{
if (state)
m.EnableKeyword(keyword);
else
m.DisableKeyword(keyword);
}
public void ShaderPropertiesGUI(Material material)
{
// Use default labelWidth
EditorGUIUtility.labelWidth = 0f;
// Detect any changes to the material
EditorGUI.BeginChangeCheck();
{
ShaderOptionsGUI();
EditorGUILayout.Space();
ShaderInputOptionsGUI();
EditorGUILayout.Space();
ShaderInputGUI();
}
if (EditorGUI.EndChangeCheck())
{
foreach (var obj in m_MaterialEditor.targets)
SetupMaterialKeywords((Material)obj);
}
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindCommonOptionProperties(props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
FindMaterialProperties(props);
m_MaterialEditor = materialEditor;
Material material = materialEditor.target as Material;
ShaderPropertiesGUI(material);
}
// TODO: ? or remove
bool HasValidEmissiveKeyword(Material material)
{
/*

return true;
}
protected void SetKeyword(Material m, string keyword, bool state)
protected virtual void SetupEmissionGIFlags(Material material)
if (state)
m.EnableKeyword(keyword);
else
m.DisableKeyword(keyword);
// Setup lightmap emissive flags
MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
{
if (ShouldEmissionBeEnabled(material))
flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
else
flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
material.globalIlluminationFlags = flags;
}
protected MaterialEditor m_MaterialEditor;
MaterialProperty surfaceType = null;
protected const string kSurfaceType = "_SurfaceType";
MaterialProperty blendMode = null;
protected const string kBlendMode = "_BlendMode";
MaterialProperty alphaCutoff = null;
protected const string kAlphaCutoff = "_AlphaCutoff";
MaterialProperty alphaCutoffEnable = null;
protected const string kAlphaCutoffEnabled = "_AlphaCutoffEnable";
MaterialProperty doubleSidedMode = null;
protected const string kDoubleSidedMode = "_DoubleSidedMode";
MaterialProperty distortionEnable = null;
const string kDistortionEnable = "_DistortionEnable";
MaterialProperty distortionOnly = null;
const string kDistortionOnly = "_DistortionOnly";
MaterialProperty distortionDepthTest = null;
const string kDistortionDepthTest = "_DistortionDepthTest";
protected static string[] reservedProperties = new string[] { kSurfaceType, kBlendMode, kAlphaCutoff, kAlphaCutoffEnabled, kDoubleSidedMode };
protected abstract void FindMaterialProperties(MaterialProperty[] props);
protected abstract void ShaderInputGUI();

89
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader


_Color("Color", Color) = (1,1,1,1)
_ColorMap("ColorMap", 2D) = "white" {}
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0

HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
//-------------------------------------------------------------------------------------
// Variant

// variable declaration
//-------------------------------------------------------------------------------------
float4 _Color;
TEXTURE2D(_ColorMap);
SAMPLER2D(sampler_ColorMap);
float3 _EmissiveColor;
TEXTURE2D(_EmissiveColorMap);
SAMPLER2D(sampler_EmissiveColorMap);
float _EmissiveIntensity;
float _AlphaCutoff;
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitProperties.hlsl"
// All our shaders use same name for entry point
#pragma vertex Vert

Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
// ------------------------------------------------------------------
// Debug pass
Pass
{
Name "Debug"

ENDHLSL
}
// ------------------------------------------------------------------
// forward pass
Pass
{
Name "ForwardUnlit"
Tags { "LightMode" = "Forward" }
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
Cull [_CullMode]
HLSLPROGRAM
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
#include "../../Material/Material.hlsl"
#include "ShaderPass/UnlitSharePass.hlsl"
#include "UnlitData.hlsl"
#include "../../ShaderPass/ShaderPassForwardUnlit.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// ------------------------------------------------------------------
Pass
{
Name "META"

#define SHADERPASS SHADERPASS_DISTORTION
#include "../../Material/Material.hlsl"
#include "ShaderPass/UnlitSharePass.hlsl"
#include "ShaderPass/UnlitDistortionPass.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardUnlit"
Tags { "LightMode" = "Forward" }
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
Cull [_CullMode]
HLSLPROGRAM
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
#include "../../Material/Material.hlsl"
#include "ShaderPass/UnlitSharePass.hlsl"
#include "UnlitData.hlsl"
#include "../../ShaderPass/ShaderPassForwardUnlit.hlsl"
ENDHLSL
}
// Unlit opaque material need to be render with ForwardOnlyOpaque. Unlike Lit that can be both deferred and forward,
// unlit require to be forward only, that's why we need this pass. Unlit transparent will use regular Forward pass
// (Code is exactly the same as "Forward", it simply allow our system to filter objects correctly)
Pass
{
Name "ForwardUnlit"
Tags { "LightMode" = "ForwardOnlyOpaque" }
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
Cull [_CullMode]
HLSLPROGRAM
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
#include "../../Material/Material.hlsl"
#include "ShaderPass/UnlitSharePass.hlsl"
#include "UnlitData.hlsl"
#include "../../ShaderPass/ShaderPassForwardUnlit.hlsl"
ENDHLSL
}

202
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Editor/PostProcessingEditor.cs


using System;
using System.Linq.Expressions;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;

[CustomEditor(typeof(PostProcessing))]
public class PostProcessingEditor : Editor
{
#region Serialized settings
public class ColorGradingSettings
{
public SerializedProperty type;

public SerializedProperty logMax;
}
public class ChromaticAberrationSettings
{
public SerializedProperty enabled;
public SerializedProperty spectralTexture;
public SerializedProperty intensity;
}
public class VignetteSettings
{
public SerializedProperty enabled;
public SerializedProperty color;
public SerializedProperty center;
public SerializedProperty intensity;
public SerializedProperty smoothness;
}
public class BloomSettings
{
public SerializedProperty enabled;
public SerializedProperty intensity;
public SerializedProperty threshold;
public SerializedProperty softKnee;
public SerializedProperty radius;
public SerializedProperty lensTexture;
public SerializedProperty lensIntensity;
}
#endregion
public ChromaticAberrationSettings chromaSettings;
public VignetteSettings vignetteSettings;
public BloomSettings bloomSettings;
public SerializedProperty globalDithering;
SerializedProperty FindProperty<TValue>(Expression<Func<PostProcessing, TValue>> expr)
{
var path = Utilities.GetFieldPath(expr);
return serializedObject.FindProperty(path);
}
colorGrading = new ColorGradingSettings()
colorGrading = new ColorGradingSettings
type = serializedObject.FindProperty("colorGrading.type"),
exposure = serializedObject.FindProperty("colorGrading.exposure"),
type = FindProperty(x => x.colorGrading.type),
exposure = FindProperty(x => x.colorGrading.exposure),
logLut = serializedObject.FindProperty("colorGrading.logLut"),
logLut = FindProperty(x => x.colorGrading.logLut),
neutralBlackIn = serializedObject.FindProperty("colorGrading.neutralBlackIn"),
neutralWhiteIn = serializedObject.FindProperty("colorGrading.neutralWhiteIn"),
neutralBlackOut = serializedObject.FindProperty("colorGrading.neutralBlackOut"),
neutralWhiteOut = serializedObject.FindProperty("colorGrading.neutralWhiteOut"),
neutralWhiteLevel = serializedObject.FindProperty("colorGrading.neutralWhiteLevel"),
neutralWhiteClip = serializedObject.FindProperty("colorGrading.neutralWhiteClip")
neutralBlackIn = FindProperty(x => x.colorGrading.neutralBlackIn),
neutralWhiteIn = FindProperty(x => x.colorGrading.neutralWhiteIn),
neutralBlackOut = FindProperty(x => x.colorGrading.neutralBlackOut),
neutralWhiteOut = FindProperty(x => x.colorGrading.neutralWhiteOut),
neutralWhiteLevel = FindProperty(x => x.colorGrading.neutralWhiteLevel),
neutralWhiteClip = FindProperty(x => x.colorGrading.neutralWhiteClip)
eyeAdaptation = new EyeAdaptationSettings()
eyeAdaptation = new EyeAdaptationSettings
enabled = serializedObject.FindProperty("eyeAdaptation.enabled"),
showDebugHistogramInGameView = serializedObject.FindProperty("eyeAdaptation.showDebugHistogramInGameView"),
enabled = FindProperty(x => x.eyeAdaptation.enabled),
showDebugHistogramInGameView = FindProperty(x => x.eyeAdaptation.showDebugHistogramInGameView),
lowPercent = serializedObject.FindProperty("eyeAdaptation.lowPercent"),
highPercent = serializedObject.FindProperty("eyeAdaptation.highPercent"),
lowPercent = FindProperty(x => x.eyeAdaptation.lowPercent),
highPercent = FindProperty(x => x.eyeAdaptation.highPercent),
minLuminance = serializedObject.FindProperty("eyeAdaptation.minLuminance"),
maxLuminance = serializedObject.FindProperty("eyeAdaptation.maxLuminance"),
exposureCompensation = serializedObject.FindProperty("eyeAdaptation.exposureCompensation"),
minLuminance = FindProperty(x => x.eyeAdaptation.minLuminance),
maxLuminance = FindProperty(x => x.eyeAdaptation.maxLuminance),
exposureCompensation = FindProperty(x => x.eyeAdaptation.exposureCompensation),
adaptationType = serializedObject.FindProperty("eyeAdaptation.adaptationType"),
adaptationType = FindProperty(x => x.eyeAdaptation.adaptationType),
speedUp = FindProperty(x => x.eyeAdaptation.speedUp),
speedDown = FindProperty(x => x.eyeAdaptation.speedDown),
speedUp = serializedObject.FindProperty("eyeAdaptation.speedUp"),
speedDown = serializedObject.FindProperty("eyeAdaptation.speedDown"),
logMin = FindProperty(x => x.eyeAdaptation.logMin),
logMax = FindProperty(x => x.eyeAdaptation.logMax)
};
logMin = serializedObject.FindProperty("eyeAdaptation.logMin"),
logMax = serializedObject.FindProperty("eyeAdaptation.logMax")
chromaSettings = new ChromaticAberrationSettings
{
enabled = FindProperty(x => x.chromaSettings.enabled),
spectralTexture = FindProperty(x => x.chromaSettings.spectralTexture),
intensity = FindProperty(x => x.chromaSettings.intensity)
vignetteSettings = new VignetteSettings
{
enabled = FindProperty(x => x.vignetteSettings.enabled),
color = FindProperty(x => x.vignetteSettings.color),
center = FindProperty(x => x.vignetteSettings.center),
intensity = FindProperty(x => x.vignetteSettings.intensity),
smoothness = FindProperty(x => x.vignetteSettings.smoothness)
};
bloomSettings = new BloomSettings
{
enabled = FindProperty(x => x.bloomSettings.enabled),
intensity = FindProperty(x => x.bloomSettings.intensity),
threshold = FindProperty(x => x.bloomSettings.threshold),
softKnee = FindProperty(x => x.bloomSettings.softKnee),
radius = FindProperty(x => x.bloomSettings.radius),
lensTexture = FindProperty(x => x.bloomSettings.lensTexture),
lensIntensity = FindProperty(x => x.bloomSettings.lensIntensity)
};
globalDithering = FindProperty(x => x.globalDithering);
}
public override void OnInspectorGUI()

var camera = (target as PostProcessing).GetComponent<Camera>();
if (camera == null)
EditorGUILayout.HelpBox("Global post-processing settings will be overriden by local camera settings. Global settings are the only one visible in the scene view.", MessageType.Info);
Do("Color Grading", ColorGradingUI);
Do("Eye Adaptation", EyeAdaptationUI);
Do("Bloom", BloomUI);
Do("Chromatic Aberration", ChromaticAberrationUI);
Do("Vignette", VignetteUI);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(globalDithering);
EditorGUILayout.LabelField("Color Grading", EditorStyles.boldLabel);
serializedObject.ApplyModifiedProperties();
}
void Do(string header, Action func)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(header, EditorStyles.boldLabel);
if (func != null)
func();
EditorGUI.indentLevel--;
}
void ColorGradingUI()
{
var camera = (target as PostProcessing).GetComponent<Camera>();
if (camera != null)
{
using (new EditorGUILayout.HorizontalScope())

}
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}
EditorGUILayout.LabelField("Eye Adaptation", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
void EyeAdaptationUI()
{
EditorGUILayout.PropertyField(eyeAdaptation.enabled);
if (eyeAdaptation.enabled.boolValue)

EditorGUI.indentLevel--;
}
}
}
void BloomUI()
{
EditorGUILayout.PropertyField(bloomSettings.enabled);
if (bloomSettings.enabled.boolValue)
{
EditorGUILayout.PropertyField(bloomSettings.intensity);
EditorGUILayout.PropertyField(bloomSettings.threshold);
EditorGUILayout.PropertyField(bloomSettings.softKnee);
EditorGUILayout.PropertyField(bloomSettings.radius);
EditorGUILayout.PropertyField(bloomSettings.lensTexture);
EditorGUILayout.PropertyField(bloomSettings.lensIntensity);
bloomSettings.intensity.floatValue = Mathf.Max(0f, bloomSettings.intensity.floatValue);
bloomSettings.threshold.floatValue = Mathf.Max(0f, bloomSettings.threshold.floatValue);
bloomSettings.lensIntensity.floatValue = Mathf.Max(0f, bloomSettings.lensIntensity.floatValue);
}
}
EditorGUI.indentLevel--;
void ChromaticAberrationUI()
{
EditorGUILayout.PropertyField(chromaSettings.enabled);
serializedObject.ApplyModifiedProperties();
if (chromaSettings.enabled.boolValue)
{
EditorGUILayout.PropertyField(chromaSettings.spectralTexture);
EditorGUILayout.PropertyField(chromaSettings.intensity);
}
void VignetteUI()
{
EditorGUILayout.PropertyField(vignetteSettings.enabled);
if (vignetteSettings.enabled.boolValue)
{
EditorGUILayout.PropertyField(vignetteSettings.color);
EditorGUILayout.PropertyField(vignetteSettings.center);
EditorGUILayout.PropertyField(vignetteSettings.intensity);
EditorGUILayout.PropertyField(vignetteSettings.smoothness);
}
}
#region Color grading stuff
void SetLUTImportSettings()
{
var lut = (target as PostProcessing).colorGrading.logLut;

File.WriteAllBytes(path, texture.EncodeToEXR(Texture2D.EXRFlags.CompressPIZ));
AssetDatabase.Refresh();
}
#endregion
}
}

446
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.cs


using GradingType = PostProcessing.ColorGradingSettings.GradingType;
using EyeAdaptationType = PostProcessing.EyeAdaptationSettings.EyeAdaptationType;
[ExecuteInEditMode]
public sealed class PostProcessing : MonoBehaviour
[ExecuteInEditMode, ImageEffectAllowedInSceneView]
[RequireComponent(typeof(Camera))]
public sealed partial class PostProcessing : MonoBehaviour
[Serializable]
public sealed class ColorGradingSettings
// Quick & very dirty temporary wrapper used for bloom (easy porting from old school render
// texture blitting to command buffers)
struct RenderTextureWrapper
public enum GradingType
{
None,
Neutral,
Custom
}
public GradingType type = GradingType.None;
public float exposure = 0f;
public Texture logLut = null;
static int s_Counter = 0;
[Range(-0.10f, 0.1f)] public float neutralBlackIn = 0.02f;
[Range( 1.00f, 20.0f)] public float neutralWhiteIn = 10f;
[Range(-0.09f, 0.1f)] public float neutralBlackOut = 0f;
[Range( 1.00f, 19.0f)] public float neutralWhiteOut = 10f;
[Range( 0.10f, 20.0f)] public float neutralWhiteLevel = 5.3f;
[Range( 1.00f, 10.0f)] public float neutralWhiteClip = 10f;
}
public int id;
public RenderTargetIdentifier identifier;
public int width;
public int height;
public int depth;
public FilterMode filter;
public RenderTextureFormat format;
[Serializable]
public sealed class EyeAdaptationSettings
{
public enum EyeAdaptationType
internal void Release(CommandBuffer cmd)
Progressive,
Fixed
cmd.ReleaseTemporaryRT(id);
id = 0;
public bool enabled = false;
public bool showDebugHistogramInGameView = true;
[Range(1f, 99f)] public float lowPercent = 65f;
[Range(1f, 99f)] public float highPercent = 95f;
public float minLuminance = 0.03f;
public float maxLuminance = 2f;
public float exposureCompensation = 0.5f;
public EyeAdaptationType adaptationType = EyeAdaptationType.Progressive;
internal static RenderTextureWrapper Create(CommandBuffer cmd, int width, int height, int depth = 0, FilterMode filter = FilterMode.Bilinear, RenderTextureFormat format = RenderTextureFormat.DefaultHDR)
{
s_Counter++;
public float speedUp = 2f;
public float speedDown = 1f;
int id = Shader.PropertyToID("_TempRenderTexture_" + s_Counter);
cmd.GetTemporaryRT(id, width, height, depth, filter, format);
[Range(-16, -1)] public int logMin = -8;
[Range( 1, 16)] public int logMax = 4;
return new RenderTextureWrapper
{
id = id,
identifier = new RenderTargetIdentifier(id),
width = width,
height = height,
depth = depth,
filter = filter,
format = format
};
}
public ChromaticAberrationSettings chromaSettings = new ChromaticAberrationSettings();
public VignetteSettings vignetteSettings = new VignetteSettings();
public BloomSettings bloomSettings = new BloomSettings();
public bool globalDithering = false;
Material m_BloomMaterial;
int m_TempRt;
Texture m_DefaultSpectralLut;
readonly RenderTexture[] m_AutoExposurePool = new RenderTexture[2];
int m_AutoExposurePingPing;
RenderTexture m_CurrentAutoExposure;

const int k_MaxPyramidBlurLevel = 16;
readonly RenderTextureWrapper[] m_BlurBuffer1 = new RenderTextureWrapper[k_MaxPyramidBlurLevel];
readonly RenderTextureWrapper[] m_BlurBuffer2 = new RenderTextureWrapper[k_MaxPyramidBlurLevel];
RenderTextureWrapper m_BloomTex;
bool m_FirstFrame = true;
// Don't forget to update 'EyeAdaptation.cginc' if you change these values !

// Holds 64 64x64 Alpha8 textures (256kb total)
const int k_BlueNoiseTextureCount = 64;
Texture2D[] m_BlueNoiseTextures;
int m_DitheringTexIndex = 0;
m_EyeAdaptationMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/EyeAdaptation");
m_BloomMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Bloom");
m_EyeAdaptationMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/EyeAdaptation");
m_EyeCompute = Resources.Load<ComputeShader>("EyeHistogram");
m_HistogramBuffer = new ComputeBuffer(k_HistogramBins, sizeof(uint));

m_BlueNoiseTextures = new Texture2D[k_BlueNoiseTextureCount];
for (int i = 0; i < k_BlueNoiseTextureCount; i++)
m_BlueNoiseTextures[i] = Resources.Load<Texture2D>("Textures/LDR_LLL1_" + i);
m_TempRt = Shader.PropertyToID("_Source");
m_DefaultSpectralLut = Resources.Load<Texture2D>("Textures/SpectralLut_GreenPurple");
m_FirstFrame = true;
}

Utilities.Destroy(m_BloomMaterial);
Utilities.Destroy(m_FinalPassMaterial);
foreach (var rt in m_AutoExposurePool)

Utilities.SafeRelease(m_HistogramBuffer);
m_EyeAdaptationMaterial = null;
m_BloomMaterial = null;
m_FinalPassMaterial = null;
}
public void Render(Camera camera, ScriptableRenderContext context, RenderTargetIdentifier source, RenderTargetIdentifier destination)

var cmd = new CommandBuffer { name = "Final Pass" };
if (eyeAdaptation.enabled)
{
int tempRt = Shader.PropertyToID("_Source");
DoEyeAdaptation(camera, cmd, source);
// Downscale the framebuffer, we don't need an absolute precision for auto exposure
// and it helps making it more stable - should be using a previously downscaled pass
var scaleOffsetRes = GetHistogramScaleOffsetRes(camera);
if (bloomSettings.enabled)
DoBloom(camera, cmd, source);
cmd.GetTemporaryRT(tempRt, (int)scaleOffsetRes.z, (int)scaleOffsetRes.w, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf);
cmd.Blit(source, tempRt);
if (chromaSettings.enabled)
DoChromaticAberration();
// Clears the buffer on every frame as we use it to accumulate luminance values on each frame
m_HistogramBuffer.SetData(s_EmptyHistogramBuffer);
if (vignetteSettings.enabled)
DoVignette();
// Gets a log histogram
int kernel = m_EyeCompute.FindKernel("KEyeHistogram");
if (globalDithering)
DoDithering(camera);
cmd.SetComputeBufferParam(m_EyeCompute, kernel, "_Histogram", m_HistogramBuffer);
cmd.SetComputeTextureParam(m_EyeCompute, kernel, "_Source", tempRt);
cmd.SetComputeVectorParam(m_EyeCompute, "_ScaleOffsetRes", scaleOffsetRes);
cmd.DispatchCompute(m_EyeCompute, kernel, Mathf.CeilToInt(scaleOffsetRes.z / (float)k_HistogramThreadX), Mathf.CeilToInt(scaleOffsetRes.w / (float)k_HistogramThreadY), 1);
DoColorGrading();
cmd.Blit(source, destination, m_FinalPassMaterial, 0);
// Cleanup
cmd.ReleaseTemporaryRT(tempRt);
if (bloomSettings.enabled)
m_BloomTex.Release(cmd);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
Vector4 GetHistogramScaleOffsetRes(Camera camera)
{
float diff = eyeAdaptation.logMax - eyeAdaptation.logMin;
float scale = 1f / diff;
float offset = -eyeAdaptation.logMin * scale;
return new Vector4(scale, offset, Mathf.Floor(camera.pixelWidth / 2f), Mathf.Floor(camera.pixelHeight / 2f));
}
void DoEyeAdaptation(Camera camera, CommandBuffer cmd, RenderTargetIdentifier source)
{
// Downscale the framebuffer, we don't need an absolute precision for auto exposure
// and it helps making it more stable - should be using a previously downscaled pass
var scaleOffsetRes = GetHistogramScaleOffsetRes(camera);
cmd.GetTemporaryRT(m_TempRt, (int)scaleOffsetRes.z, (int)scaleOffsetRes.w, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf);
cmd.Blit(source, m_TempRt);
// Clears the buffer on every frame as we use it to accumulate luminance values on each frame
m_HistogramBuffer.SetData(s_EmptyHistogramBuffer);
// Gets a log histogram
int kernel = m_EyeCompute.FindKernel("KEyeHistogram");
// Make sure filtering values are correct to avoid apocalyptic consequences
const float kMinDelta = 1e-2f;
eyeAdaptation.highPercent = Mathf.Clamp(eyeAdaptation.highPercent, 1f + kMinDelta, 99f);
eyeAdaptation.lowPercent = Mathf.Clamp(eyeAdaptation.lowPercent, 1f, eyeAdaptation.highPercent - kMinDelta);
cmd.SetComputeBufferParam(m_EyeCompute, kernel, "_Histogram", m_HistogramBuffer);
cmd.SetComputeTextureParam(m_EyeCompute, kernel, "_Source", m_TempRt);
cmd.SetComputeVectorParam(m_EyeCompute, "_ScaleOffsetRes", scaleOffsetRes);
cmd.DispatchCompute(m_EyeCompute, kernel, Mathf.CeilToInt(scaleOffsetRes.z / (float)k_HistogramThreadX), Mathf.CeilToInt(scaleOffsetRes.w / (float)k_HistogramThreadY), 1);
// Compute auto exposure
m_EyeAdaptationMaterial.SetBuffer("_Histogram", m_HistogramBuffer);
m_EyeAdaptationMaterial.SetVector("_Params", new Vector4(eyeAdaptation.lowPercent * 0.01f, eyeAdaptation.highPercent * 0.01f, eyeAdaptation.minLuminance, eyeAdaptation.maxLuminance));
m_EyeAdaptationMaterial.SetVector("_Speed", new Vector2(eyeAdaptation.speedDown, eyeAdaptation.speedUp));
m_EyeAdaptationMaterial.SetVector("_ScaleOffsetRes", scaleOffsetRes);
m_EyeAdaptationMaterial.SetFloat("_ExposureCompensation", eyeAdaptation.exposureCompensation);
// Cleanup
cmd.ReleaseTemporaryRT(m_TempRt);
if (m_FirstFrame || !Application.isPlaying)
{
// We don't want eye adaptation when not in play mode because the GameView isn't
// animated, thus making it harder to tweak. Just use the final audo exposure value.
m_CurrentAutoExposure = m_AutoExposurePool[0];
cmd.Blit(null, m_CurrentAutoExposure, m_EyeAdaptationMaterial, (int)EyeAdaptationType.Fixed);
// Make sure filtering values are correct to avoid apocalyptic consequences
const float kMinDelta = 1e-2f;
eyeAdaptation.highPercent = Mathf.Clamp(eyeAdaptation.highPercent, 1f + kMinDelta, 99f);
eyeAdaptation.lowPercent = Mathf.Clamp(eyeAdaptation.lowPercent, 1f, eyeAdaptation.highPercent - kMinDelta);
// Copy current exposure to the other pingpong target on first frame to avoid adapting from black
cmd.Blit(m_AutoExposurePool[0], m_AutoExposurePool[1]);
} else
{
int pp = m_AutoExposurePingPing;
var src = m_AutoExposurePool[++pp % 2];
var dst = m_AutoExposurePool[++pp % 2];
cmd.Blit(src, dst, m_EyeAdaptationMaterial, (int)eyeAdaptation.adaptationType);
m_AutoExposurePingPing = ++pp % 2;
m_CurrentAutoExposure = dst;
}
// Compute auto exposure
m_EyeAdaptationMaterial.SetBuffer(Uniforms._Histogram, m_HistogramBuffer);
m_EyeAdaptationMaterial.SetVector(Uniforms._Params, new Vector4(eyeAdaptation.lowPercent * 0.01f, eyeAdaptation.highPercent * 0.01f, eyeAdaptation.minLuminance, eyeAdaptation.maxLuminance));
m_EyeAdaptationMaterial.SetVector(Uniforms._Speed, new Vector2(eyeAdaptation.speedDown, eyeAdaptation.speedUp));
m_EyeAdaptationMaterial.SetVector(Uniforms._ScaleOffsetRes, scaleOffsetRes);
m_EyeAdaptationMaterial.SetFloat(Uniforms._ExposureCompensation, eyeAdaptation.exposureCompensation);
m_FinalPassMaterial.EnableKeyword("EYE_ADAPTATION");
m_FinalPassMaterial.SetTexture("_AutoExposure", m_CurrentAutoExposure);
if (m_FirstFrame || !Application.isPlaying)
{
// We don't want eye adaptation when not in play mode because the GameView isn't
// animated, thus making it harder to tweak. Just use the final audo exposure value.
m_CurrentAutoExposure = m_AutoExposurePool[0];
cmd.Blit(null, m_CurrentAutoExposure, m_EyeAdaptationMaterial, (int)EyeAdaptationType.Fixed);
// Debug histogram visualization
if (eyeAdaptation.showDebugHistogramInGameView)
// Copy current exposure to the other pingpong target on first frame to avoid adapting from black
cmd.Blit(m_AutoExposurePool[0], m_AutoExposurePool[1]);
}
else
{
int pp = m_AutoExposurePingPing;
var src = m_AutoExposurePool[++pp % 2];
var dst = m_AutoExposurePool[++pp % 2];
cmd.Blit(src, dst, m_EyeAdaptationMaterial, (int)eyeAdaptation.adaptationType);
m_AutoExposurePingPing = ++pp % 2;
m_CurrentAutoExposure = dst;
}
m_FinalPassMaterial.EnableKeyword("EYE_ADAPTATION");
m_FinalPassMaterial.SetTexture(Uniforms._AutoExposure, m_CurrentAutoExposure);
// Debug histogram visualization
if (eyeAdaptation.showDebugHistogramInGameView)
{
if (m_DebugHistogram == null || !m_DebugHistogram.IsCreated())
if (m_DebugHistogram == null || !m_DebugHistogram.IsCreated())
m_DebugHistogram = new RenderTexture(256, 128, 0, RenderTextureFormat.ARGB32)
m_DebugHistogram = new RenderTexture(256, 128, 0, RenderTextureFormat.ARGB32)
{
filterMode = FilterMode.Point,
wrapMode = TextureWrapMode.Clamp
};
}
filterMode = FilterMode.Point,
wrapMode = TextureWrapMode.Clamp
};
}
m_EyeAdaptationMaterial.SetFloat(Uniforms._DebugWidth, m_DebugHistogram.width);
cmd.Blit(null, m_DebugHistogram, m_EyeAdaptationMaterial, 2);
}
m_FirstFrame = false;
}
void DoBloom(Camera camera, CommandBuffer cmd, RenderTargetIdentifier source)
{
m_BloomMaterial.shaderKeywords = null;
// Apply auto exposure before the prefiltering pass if needed
if (eyeAdaptation.enabled)
{
m_BloomMaterial.EnableKeyword("EYE_ADAPTATION");
m_BloomMaterial.SetTexture(Uniforms._AutoExposure, m_CurrentAutoExposure);
}
// Do bloom on a half-res buffer, full-res doesn't bring much and kills performances on
// fillrate limited platforms
int tw = camera.pixelWidth / 2;
int th = camera.pixelHeight / 2;
// Determine the iteration count
float logh = Mathf.Log(th, 2f) + bloomSettings.radius - 8f;
int logh_i = (int)logh;
int iterations = Mathf.Clamp(logh_i, 1, k_MaxPyramidBlurLevel);
// Uupdate the shader properties
float lthresh = Mathf.GammaToLinearSpace(bloomSettings.threshold);;
m_BloomMaterial.SetFloat(Uniforms._Threshold, lthresh);
float knee = lthresh * bloomSettings.softKnee + 1e-5f;
var curve = new Vector3(lthresh - knee, knee * 2f, 0.25f / knee);
m_BloomMaterial.SetVector(Uniforms._Curve, curve);
float sampleScale = 0.5f + logh - logh_i;
m_BloomMaterial.SetFloat(Uniforms._SampleScale, sampleScale);
// Prefilter pass
var prefiltered = RenderTextureWrapper.Create(cmd, tw, th, 0, FilterMode.Point);
cmd.Blit(source, prefiltered.identifier, m_BloomMaterial, 0);
var last = prefiltered;
// Construct a mip pyramid
for (int level = 0; level < iterations; level++)
{
m_BlurBuffer1[level] = RenderTextureWrapper.Create(cmd, last.width / 2, last.height / 2);
cmd.Blit(last.identifier, m_BlurBuffer1[level].identifier, m_BloomMaterial, level == 0 ? 1 : 2);
last = m_BlurBuffer1[level];
}
// Upsample and combine loop
for (int level = iterations - 2; level >= 0; level--)
{
var baseTex = m_BlurBuffer1[level];
cmd.SetGlobalTexture(Uniforms._BaseTex, baseTex.identifier); // Boooo
m_BlurBuffer2[level] = RenderTextureWrapper.Create(cmd, baseTex.width, baseTex.height);
cmd.Blit(last.identifier, m_BlurBuffer2[level].identifier, m_BloomMaterial, 3);
last = m_BlurBuffer2[level];
}
m_BloomTex = last;
// Release the temporary buffers
for (int i = 0; i < k_MaxPyramidBlurLevel; i++)
{
if (m_BlurBuffer1[i].id != 0)
m_BlurBuffer1[i].Release(cmd);
if (m_BlurBuffer2[i].id != 0 && m_BlurBuffer2[i].id != m_BloomTex.id)
m_BlurBuffer2[i].Release(cmd);
}
prefiltered.Release(cmd);
// Push everything to the uber material
m_FinalPassMaterial.EnableKeyword("BLOOM");
m_EyeAdaptationMaterial.SetFloat("_DebugWidth", m_DebugHistogram.width);
cmd.Blit(null, m_DebugHistogram, m_EyeAdaptationMaterial, 2);
}
cmd.SetGlobalTexture(Uniforms._BloomTex, m_BloomTex.identifier);
cmd.SetGlobalVector(Uniforms._Bloom_Settings, new Vector2(sampleScale, bloomSettings.intensity));
m_FirstFrame = false;
if (bloomSettings.lensIntensity > 0f && bloomSettings.lensTexture != null)
{
m_FinalPassMaterial.EnableKeyword("BLOOM_LENS_DIRT");
cmd.SetGlobalTexture(Uniforms._Bloom_DirtTex, bloomSettings.lensTexture);
cmd.SetGlobalFloat(Uniforms._Bloom_DirtIntensity, bloomSettings.lensIntensity);
}
void DoChromaticAberration()
{
var spectralLut = chromaSettings.spectralTexture == null
? m_DefaultSpectralLut
: chromaSettings.spectralTexture;
m_FinalPassMaterial.EnableKeyword("CHROMATIC_ABERRATION");
m_FinalPassMaterial.SetFloat(Uniforms._ChromaticAberration_Amount, chromaSettings.intensity * 0.03f);
m_FinalPassMaterial.SetTexture(Uniforms._ChromaticAberration_Lut, spectralLut);
}
void DoVignette()
{
m_FinalPassMaterial.EnableKeyword("VIGNETTE");
m_FinalPassMaterial.SetColor(Uniforms._Vignette_Color, vignetteSettings.color);
m_FinalPassMaterial.SetVector(Uniforms._Vignette_Settings, new Vector4(vignetteSettings.intensity * 3f, vignetteSettings.smoothness * 5f, vignetteSettings.center.x, vignetteSettings.center.y));
}
void DoDithering(Camera camera)
{
m_FinalPassMaterial.EnableKeyword("DITHERING");
if (++m_DitheringTexIndex >= k_BlueNoiseTextureCount)
m_DitheringTexIndex = 0;
var noiseTex = m_BlueNoiseTextures[m_DitheringTexIndex];
m_FinalPassMaterial.SetTexture(Uniforms._DitheringTex, noiseTex);
m_FinalPassMaterial.SetVector(Uniforms._DitheringCoords, new Vector4(
(float)camera.pixelWidth / (float)noiseTex.width,
(float)camera.pixelHeight / (float)noiseTex.height,
Random.value, Random.value
));
}
void DoColorGrading()
{
m_FinalPassMaterial.SetFloat("_Exposure", ev);
m_FinalPassMaterial.SetFloat(Uniforms._Exposure, ev);
if (colorGrading.type == GradingType.Neutral)
{

const float e = 0.02f;
const float f = 0.30f;
m_FinalPassMaterial.SetVector("_NeutralTonemapperParams1", new Vector4(a, b, c, d));
m_FinalPassMaterial.SetVector("_NeutralTonemapperParams2", new Vector4(e, f, colorGrading.neutralWhiteLevel, colorGrading.neutralWhiteClip / kScaleFactorHalf));
m_FinalPassMaterial.SetVector(Uniforms._NeutralTonemapperParams1, new Vector4(a, b, c, d));
m_FinalPassMaterial.SetVector(Uniforms._NeutralTonemapperParams2, new Vector4(e, f, colorGrading.neutralWhiteLevel, colorGrading.neutralWhiteClip / kScaleFactorHalf));
m_FinalPassMaterial.EnableKeyword("NEUTRAL_GRADING");
}
else if (colorGrading.type == GradingType.Custom)

var lut = colorGrading.logLut;
m_FinalPassMaterial.SetTexture("_LogLut", lut);
m_FinalPassMaterial.SetVector("_LogLut_Params", new Vector3(1f / lut.width, 1f / lut.height, lut.height - 1f));
m_FinalPassMaterial.SetTexture(Uniforms._LogLut, lut);
m_FinalPassMaterial.SetVector(Uniforms._LogLut_Params, new Vector3(1f / lut.width, 1f / lut.height, lut.height - 1f));
cmd.Blit(source, destination, m_FinalPassMaterial, 0);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
Vector4 GetHistogramScaleOffsetRes(Camera camera)
{
float diff = eyeAdaptation.logMax - eyeAdaptation.logMin;
float scale = 1f / diff;
float offset = -eyeAdaptation.logMin * scale;
return new Vector4(scale, offset, Mathf.Floor(camera.pixelWidth / 2f), Mathf.Floor(camera.pixelHeight / 2f));
}
void OnGUI()

var rect = new Rect(8f, 8f, m_DebugHistogram.width, m_DebugHistogram.height);
GUI.DrawTexture(rect, m_DebugHistogram);
}
// Pre-hash uniforms, no need to stress the CPU more than needed on every frame
static class Uniforms
{
internal static readonly int _Histogram = Shader.PropertyToID("_Histogram");
internal static readonly int _Params = Shader.PropertyToID("_Params");
internal static readonly int _Speed = Shader.PropertyToID("_Speed");
internal static readonly int _ScaleOffsetRes = Shader.PropertyToID("_ScaleOffsetRes");
internal static readonly int _ExposureCompensation = Shader.PropertyToID("_ExposureCompensation");
internal static readonly int _AutoExposure = Shader.PropertyToID("_AutoExposure");
internal static readonly int _DebugWidth = Shader.PropertyToID("_DebugWidth");
internal static readonly int _Threshold = Shader.PropertyToID("_Threshold");
internal static readonly int _Curve = Shader.PropertyToID("_Curve");
internal static readonly int _SampleScale = Shader.PropertyToID("_SampleScale");
internal static readonly int _BaseTex = Shader.PropertyToID("_BaseTex");
internal static readonly int _BloomTex = Shader.PropertyToID("_BloomTex");
internal static readonly int _Bloom_Settings = Shader.PropertyToID("_Bloom_Settings");
internal static readonly int _Bloom_DirtTex = Shader.PropertyToID("_Bloom_DirtTex");
internal static readonly int _Bloom_DirtIntensity = Shader.PropertyToID("_Bloom_DirtIntensity");
internal static readonly int _ChromaticAberration_Amount = Shader.PropertyToID("_ChromaticAberration_Amount");
internal static readonly int _ChromaticAberration_Lut = Shader.PropertyToID("_ChromaticAberration_Lut");
internal static readonly int _Vignette_Color = Shader.PropertyToID("_Vignette_Color");
internal static readonly int _Vignette_Settings = Shader.PropertyToID("_Vignette_Settings");
internal static readonly int _DitheringTex = Shader.PropertyToID("_DitheringTex");
internal static readonly int _DitheringCoords = Shader.PropertyToID("_DitheringCoords");
internal static readonly int _Exposure = Shader.PropertyToID("_Exposure");
internal static readonly int _NeutralTonemapperParams1 = Shader.PropertyToID("_NeutralTonemapperParams1");
internal static readonly int _NeutralTonemapperParams2 = Shader.PropertyToID("_NeutralTonemapperParams2");
internal static readonly int _LogLut = Shader.PropertyToID("_LogLut");
internal static readonly int _LogLut_Params = Shader.PropertyToID("_LogLut_Params");
}
}
}

114
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader


HLSLINCLUDE
#pragma target 4.5
#include "Color.hlsl"
#include "Bloom.hlsl"
float4 _MainTex_TexelSize;
TEXTURE2D(_AutoExposure);
SAMPLER2D(sampler_AutoExposure);

float _Exposure;
TEXTURE2D(_BloomTex);
SAMPLER2D(sampler_BloomTex);
float4 _BloomTex_TexelSize;
float2 _Bloom_Settings; // x: sampleScale, y: bloom.intensity
TEXTURE2D(_Bloom_DirtTex);
SAMPLER2D(sampler_Bloom_DirtTex);
float _Bloom_DirtIntensity;
struct Attributes
float _ChromaticAberration_Amount;
TEXTURE2D(_ChromaticAberration_Lut);
SAMPLER2D(sampler_ChromaticAberration_Lut);
float3 _Vignette_Color;
float4 _Vignette_Settings; // x: intensity, y: smoothness, zw: center (uv space)
TEXTURE2D(_DitheringTex);
SAMPLER2D(sampler_DitheringTex);
float4 _DitheringCoords;
struct Attributes
struct Varyings
struct Varyings
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;

float4 Frag(Varyings input) : SV_Target
{
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.texcoord);
float2 uv = input.texcoord;
float3 color = (0.0).xxx;
// Chromatic Aberration
// Inspired by the method described in "Rendering Inside" [Playdead 2016]
// https://twitter.com/pixelmager/status/717019757766123520
#if CHROMATIC_ABERRATION
{
float2 coords = 2.0 * uv - 1.0;
float2 end = uv - coords * dot(coords, coords) * _ChromaticAberration_Amount;
float2 diff = end - uv;
int samples = clamp(int(length(_MainTex_TexelSize.zw * diff / 2.0)), 3, 16);
float2 delta = diff / samples;
float2 pos = uv;
float3 sum = (0.0).xxx, filterSum = (0.0).xxx;
for (int i = 0; i < samples; i++)
{
float t = (i + 0.5) / samples;
float3 s = SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_MainTex, pos, 0).rgb;
float3 filter = SAMPLE_TEXTURE2D_LOD(_ChromaticAberration_Lut, sampler_ChromaticAberration_Lut, float2(t, 0.0), 0).rgb;
sum += s * filter;
filterSum += filter;
pos += delta;
}
color = sum / filterSum;
}
#else
{
color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv).rgb;
}
#endif
float autoExposure = SAMPLE_TEXTURE2D(_AutoExposure, sampler_AutoExposure, input.texcoord).r;
float autoExposure = SAMPLE_TEXTURE2D(_AutoExposure, sampler_AutoExposure, uv).r;
color.rgb *= _Exposure; // Exposure is in ev units (or 'stops'), precomputed CPU-side
#if BLOOM
{
float3 bloom = UpsampleFilter(TEXTURE2D_PARAM(_BloomTex, sampler_BloomTex), uv, _BloomTex_TexelSize.xy, _Bloom_Settings.x) * _Bloom_Settings.y; // Flipped
color += bloom;
#if BLOOM_LENS_DIRT
{
float3 dirt = SAMPLE_TEXTURE2D(_Bloom_DirtTex, sampler_Bloom_DirtTex, uv).rgb * _Bloom_DirtIntensity; // Flipped
color += bloom * dirt;
}
#endif
}
#endif
#if VIGNETTE
{
float2 d = abs(uv - _Vignette_Settings.zw) * _Vignette_Settings.x;
d.x *= _ScreenParams.x / _ScreenParams.y;
float vfactor = pow(saturate(1.0 - dot(d, d)), _Vignette_Settings.y);
color *= lerp(_Vignette_Color, (1.0).xxx, vfactor);
}
#endif
color *= _Exposure; // Exposure is in ev units (or 'stops'), precomputed CPU-side
color.rgb = NeutralTonemap(color.rgb, _NeutralTonemapperParams1, _NeutralTonemapperParams2);
color = NeutralTonemap(color, _NeutralTonemapperParams1, _NeutralTonemapperParams2);
}
#elif CUSTOM_GRADING
{

uvw.z *= _LogLut_Params.z;
half shift = floor(uvw.z);
float shift = floor(uvw.z);
SAMPLE_TEXTURE2D(_LogLut, sampler_LogLut, uvw.xy + half2(_LogLut_Params.y, 0)).rgb,
SAMPLE_TEXTURE2D(_LogLut, sampler_LogLut, uvw.xy + float2(_LogLut_Params.y, 0)).rgb,
color.rgb = uvw;
color = uvw;
}
#else
{

return color;
#if DITHERING
{
// Symmetric triangular distribution on [-1,1] with maximal density at 0
float noise = SAMPLE_TEXTURE2D(_DitheringTex, sampler_DitheringTex, uv * _DitheringCoords.xy + _DitheringCoords.zw).a * 2.0 - 1.0;
noise = sign(noise) * (1.0 - sqrt(1.0 - abs(noise)));
color = SRGBToLinear(LinearToSRGB(color) + noise / 255.0);
}
#endif
return float4(color, 1.0);
}
ENDHLSL

#pragma fragment Frag
#pragma multi_compile __ NEUTRAL_GRADING CUSTOM_GRADING
#pragma multi_compile __ EYE_ADAPTATION
#pragma multi_compile __ BLOOM
#pragma multi_compile __ BLOOM_LENS_DIRT
#pragma multi_compile __ CHROMATIC_ABERRATION
#pragma multi_compile __ VIGNETTE
#pragma multi_compile __ DITHERING
ENDHLSL
}

134
Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/CommonSettings.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System.Reflection;
[ExecuteInEditMode]
[DisallowMultipleComponent]
public class CommonSettings
: MonoBehaviour
public class CommonSettings : ScriptableObject
[SerializeField] private string m_SkyRendererTypeName = ""; // Serialize a string because serialize a Type.
[SerializeField] float m_ShadowMaxDistance = ShadowSettings.Default.maxShadowDistance;
[SerializeField] int m_ShadowCascadeCount = ShadowSettings.Default.directionalLightCascadeCount;
[SerializeField] float m_ShadowCascadeSplit0 = ShadowSettings.Default.directionalLightCascades.x;
[SerializeField] float m_ShadowCascadeSplit1 = ShadowSettings.Default.directionalLightCascades.y;
[SerializeField] float m_ShadowCascadeSplit2 = ShadowSettings.Default.directionalLightCascades.z;
public Type skyRendererType
[Serializable]
public struct Settings
set { m_SkyRendererTypeName = value != null ? value.FullName : ""; OnSkyRendererChanged(); }
get { return m_SkyRendererTypeName == "" ? null : Assembly.GetAssembly(typeof(CommonSettings)).GetType(m_SkyRendererTypeName); }
}
// Shadows
[SerializeField]
float m_ShadowMaxDistance;
[SerializeField]
int m_ShadowCascadeCount;
[SerializeField]
float m_ShadowCascadeSplit0;
[SerializeField]
float m_ShadowCascadeSplit1;
[SerializeField]
float m_ShadowCascadeSplit2;
public float shadowMaxDistance { set { m_ShadowMaxDistance = value; OnValidate(); } get { return m_ShadowMaxDistance; } }
public int shadowCascadeCount { set { m_ShadowCascadeCount = value; OnValidate(); } get { return m_ShadowCascadeCount; } }
public float shadowCascadeSplit0 { set { m_ShadowCascadeSplit0 = value; OnValidate(); } get { return m_ShadowCascadeSplit0; } }
public float shadowCascadeSplit1 { set { m_ShadowCascadeSplit1 = value; OnValidate(); } get { return m_ShadowCascadeSplit1; } }
public float shadowCascadeSplit2 { set { m_ShadowCascadeSplit2 = value; OnValidate(); } get { return m_ShadowCascadeSplit2; } }
public float shadowMaxDistance { set { m_ShadowMaxDistance = value; OnValidate(); } get { return m_ShadowMaxDistance; } }
public int shadowCascadeCount { set { m_ShadowCascadeCount = value; OnValidate(); } get { return m_ShadowCascadeCount; } }
public float shadowCascadeSplit0 { set { m_ShadowCascadeSplit0 = value; OnValidate(); } get { return m_ShadowCascadeSplit0; } }
public float shadowCascadeSplit1 { set { m_ShadowCascadeSplit1 = value; OnValidate(); } get { return m_ShadowCascadeSplit1; } }
public float shadowCascadeSplit2 { set { m_ShadowCascadeSplit2 = value; OnValidate(); } get { return m_ShadowCascadeSplit2; } }
void OnEnable()
{
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
void OnValidate()
return;
m_ShadowMaxDistance = Mathf.Max(0.0f, m_ShadowMaxDistance);
m_ShadowCascadeCount = Math.Min(4, Math.Max(1, m_ShadowCascadeCount));
m_ShadowCascadeSplit0 = Mathf.Clamp01(m_ShadowCascadeSplit0);
m_ShadowCascadeSplit1 = Mathf.Clamp01(m_ShadowCascadeSplit1);
m_ShadowCascadeSplit2 = Mathf.Clamp01(m_ShadowCascadeSplit2);
if (renderPipeline.commonSettings == null)
renderPipeline.commonSettings = this;
else if (renderPipeline.commonSettings != this)
Debug.LogWarning("Only one CommonSettings can be setup at a time.");
OnSkyRendererChanged();
}
void OnDisable()
{
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
public static readonly Settings s_Defaultsettings = new Settings
return;
}
if (renderPipeline.commonSettings == this)
renderPipeline.commonSettings = null;
m_ShadowMaxDistance = ShadowSettings.Default.maxShadowDistance,
m_ShadowCascadeCount = ShadowSettings.Default.directionalLightCascadeCount,
m_ShadowCascadeSplit0 = ShadowSettings.Default.directionalLightCascades.x,
m_ShadowCascadeSplit1 = ShadowSettings.Default.directionalLightCascades.y,
m_ShadowCascadeSplit2 = ShadowSettings.Default.directionalLightCascades.z,
};
void OnValidate()
{
m_ShadowMaxDistance = Mathf.Max(0.0f, m_ShadowMaxDistance);
m_ShadowCascadeCount = Math.Min(4, Math.Max(1, m_ShadowCascadeCount));
m_ShadowCascadeSplit0 = Mathf.Min(1.0f, Mathf.Max(0.0f, m_ShadowCascadeSplit0));
m_ShadowCascadeSplit1 = Mathf.Min(1.0f, Mathf.Max(0.0f, m_ShadowCascadeSplit1));
m_ShadowCascadeSplit2 = Mathf.Min(1.0f, Mathf.Max(0.0f, m_ShadowCascadeSplit2));
[SerializeField]
private Settings m_Settings = Settings.s_Defaultsettings;
OnSkyRendererChanged();
}
void OnSkyRendererChanged()
public Settings settings
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
{
return;
}
renderPipeline.InstantiateSkyRenderer(skyRendererType);
List<SkyParameters> result = new List<SkyParameters>();
gameObject.GetComponents<SkyParameters>(result);
Type skyParamType = renderPipeline.skyManager.GetSkyParameterType();
// Disable all incompatible sky parameters and enable the compatible one
bool found = false;
foreach (SkyParameters param in result)
{
if (param.GetType() == skyParamType)
{
// This is a workaround the fact that we can't control the order in which components are initialized.
// So it can happen that a given SkyParameter is OnEnabled before the CommonSettings and so fail the setup because the SkyRenderer is not yet initialized.
// So we disable it to for OnEnable to be called again.
param.enabled = false;
param.enabled = true;
found = true;
}
else
{
param.enabled = false;
}
}
// If it does not exist, create the parameters
if (!found && skyParamType != null)
{
gameObject.AddComponent(skyParamType);
}
get { return m_Settings; }
set { m_Settings = value; }
}
}
}

5
Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/Editor/CommonSettingsEditor.cs


public readonly int[] shadowsCascadeCountValues = new int[] { 1, 2, 3, 4 };
public readonly GUIContent shadowsCascades = new GUIContent("Cascade values");
public readonly GUIContent[] shadowSplits = new GUIContent[] { new GUIContent("Split 0"), new GUIContent("Split 1"), new GUIContent("Split 2") };
}
private static Styles s_Styles = null;

for (int i = 0; i < targets.Length; ++i)
{
CommonSettings settings = targets[i] as CommonSettings;
maxCascadeCount = Math.Max(maxCascadeCount, settings.shadowCascadeCount);
maxCascadeCount = Math.Max(maxCascadeCount, settings.settings.shadowCascadeCount);
}
EditorGUI.indentLevel++;

EditorGUI.indentLevel--;
}
/*
public override void OnInspectorGUI()
{
serializedObject.Update();

serializedObject.ApplyModifiedProperties();
}
*/
}
}

12
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


#endif // TESSELLATION_ON
void Frag( PackedVaryingsToPS packedInput,
out float4 outColor : SV_Target
#ifdef _DEPTHOFFSET_ON
, out float outputDepth : SV_Depth
#endif
)
void Frag(PackedVaryingsToPS packedInput,
out float4 outColor : SV_Target0
#ifdef _DEPTHOFFSET_ON
, out float outputDepth : SV_Depth
#endif
)
{
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);

4
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl


output.vmesh.texCoord0 = inputMesh.uv0;
output.vmesh.texCoord1 = inputMesh.uv1;
#if defined(VARYINGS_NEED_COLOR)
output.vmesh.color = inputMesh.color;
#endif
return PackVaryingsToPS(output);
}

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);

67
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

// ----------------------------------------------------------------------------
CBUFFER_START(UnityPerDraw : register(b0))
#ifdef UNITY_USE_PREMULTIPLIED_MATRICES
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
#endif
#ifdef UNITY_USE_PREMULTIPLIED_MATRICES
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
#endif
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
// light maps
float4 unity_LightmapST;
float4 unity_DynamicLightmapST;
// SH lighting environment
float4 unity_SHAr;
float4 unity_SHAg;
float4 unity_SHAb;
float4 unity_SHBr;
float4 unity_SHBg;
float4 unity_SHBb;
float4 unity_SHC;
// probe volumes
float4 unity_ProbeVolumeParams;
float4x4 unity_ProbeVolumeWorldToObject;
float3 unity_ProbeVolumeSizeInv;
float3 unity_ProbeVolumeMin;
// light maps
float4 unity_LightmapST;
float4 unity_DynamicLightmapST;
// SH lighting environment
float4 unity_SHAr;
float4 unity_SHAg;
float4 unity_SHAb;
float4 unity_SHBr;
float4 unity_SHBg;
float4 unity_SHBb;
float4 unity_SHC;
// probe volumes
float4 unity_ProbeVolumeParams;
float4x4 unity_ProbeVolumeWorldToObject;
float3 unity_ProbeVolumeSizeInv;
float3 unity_ProbeVolumeMin;
CBUFFER_END

CBUFFER_END
// Use the regular depth camera texture sampler for sampling this: sampler_CameraDepthTexture
TEXTURE2D_FLOAT(_CameraDepthTextureCopy);
SAMPLER2D(sampler_CameraDepthTextureCopy);
// Main lightmap
TEXTURE2D(unity_Lightmap);

// TODO: Change code here so probe volume use only one transform instead of all this parameters!
TEXTURE3D(unity_ProbeVolumeSH);
TEXTURE3D_FLOAT(unity_ProbeVolumeSH);
SAMPLER3D(samplerunity_ProbeVolumeSH);
CBUFFER_START(UnityVelocityPass)

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

10
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[DisallowMultipleComponent]

public Cubemap skyHDRI;
public override SkyRenderer GetRenderer()
{
return new HDRISkyRenderer(this);
}
}
}

37
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
public class HDRISkyRenderer
: SkyRenderer<HDRISkyParameters>
public class HDRISkyRenderer : SkyRenderer
Material m_SkyHDRIMaterial = null; // Renders a cubemap into a render texture (can be cube or 2D)
Material m_SkyHDRIMaterial; // Renders a cubemap into a render texture (can be cube or 2D)
private HDRISkyParameters m_HdriSkyParams;
override public void Build()
public HDRISkyRenderer(HDRISkyParameters hdriSkyParams)
m_SkyHDRIMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Sky/SkyHDRI");
m_HdriSkyParams = hdriSkyParams;
override public void Cleanup()
public override void Build()
Utilities.Destroy(m_SkyHDRIMaterial);
m_SkyHDRIMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Sky/SkyHDRI");
override public bool IsSkyValid(SkyParameters skyParameters)
public override void Cleanup()
return GetParameters(skyParameters).skyHDRI != null;
Utilities.Destroy(m_SkyHDRIMaterial);
public override void SetRenderTargets(BuiltinSkyParameters builtinParams)
{
if (builtinParams.depthBuffer == BuiltinSkyParameters.nullRT)

}
}
override public void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap)
public override void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap)
HDRISkyParameters hdriSkyParams = GetParameters(skyParameters);
m_SkyHDRIMaterial.SetTexture("_Cubemap", hdriSkyParams.skyHDRI);
m_SkyHDRIMaterial.SetVector("_SkyParam", new Vector4(hdriSkyParams.exposure, hdriSkyParams.multiplier, hdriSkyParams.rotation, 0.0f));
m_SkyHDRIMaterial.SetTexture("_Cubemap", m_HdriSkyParams.skyHDRI);
m_SkyHDRIMaterial.SetVector("_SkyParam", new Vector4(m_HdriSkyParams.exposure, m_HdriSkyParams.multiplier, m_HdriSkyParams.rotation, 0.0f));
}
public override bool IsSkyValid()
{
return m_HdriSkyParams != null && m_SkyHDRIMaterial != null;
}
}
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader


#pragma fragment Frag
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#include "Color.hlsl"
#include "Common.hlsl"

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyParameters.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[ExecuteInEditMode]

occlusionBiasSkyMie = Mathf.Clamp01(occlusionBiasSkyMie);
occlusionBiasSkyRayleigh = Mathf.Clamp01(occlusionBiasSkyRayleigh);
*/
}
public override SkyRenderer GetRenderer()
{
return new ProceduralSkyRenderer(this);
}
}
}

35
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
public class ProceduralSkyRenderer
: SkyRenderer<ProceduralSkyParameters>
public class ProceduralSkyRenderer : SkyRenderer
private ProceduralSkyParameters m_ProceduralSkyParameters;
override public void Build()
public ProceduralSkyRenderer(ProceduralSkyParameters proceduralSkyParameters)
{
m_ProceduralSkyParameters = proceduralSkyParameters;
}
public override void Build()
override public void Cleanup()
public override void Cleanup()
override public bool IsSkyValid(SkyParameters skyParameters)
public override bool IsSkyValid()
ProceduralSkyParameters allParams = GetParameters(skyParameters);
if (m_ProceduralSkyMaterial == null || m_ProceduralSkyParameters == null)
return false;
return allParams.skyHDRI != null &&
allParams.worldMieColorRamp != null &&
allParams.worldRayleighColorRamp != null;
return m_ProceduralSkyParameters.skyHDRI != null &&
m_ProceduralSkyParameters.worldMieColorRamp != null &&
m_ProceduralSkyParameters.worldRayleighColorRamp != null;
}
public override void SetRenderTargets(BuiltinSkyParameters builtinParams)

override public void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap)
{
ProceduralSkyParameters proceduralSkyParams = GetParameters(skyParameters);
SetKeywords(builtinParams, proceduralSkyParams, renderForCubemap);
SetKeywords(builtinParams, m_ProceduralSkyParameters, renderForCubemap);
SetUniforms(builtinParams, proceduralSkyParams, renderForCubemap, ref properties);
SetUniforms(builtinParams, m_ProceduralSkyParameters, renderForCubemap, ref properties);
var cmd = new CommandBuffer { name = "" };

builtinParams.renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl


SAMPLER2D(sampler_CameraDepthTexture);
#define SRL_BilinearSampler sampler_CameraDepthTexture // Used for all textures
TEXTURE2D(_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepthTexture);
TEXTURE2D(_OcclusionTexture);
float HenyeyGreensteinPhase(float g, float cosTheta) {

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader


HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma vertex Vert
#pragma fragment Frag

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader


HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma multi_compile _ USE_MIS

162
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System;
namespace UnityEngine.Experimental.Rendering.HDPipeline

bool m_useMIS = false;
SkyParameters m_SkyParameters = null;
private SkyParameters m_SkyParameters;
if(m_Renderer != null)
if (m_SkyParameters == value)
return;
if (m_Renderer != null)
if (value == null || IsSkyParameterValid(value))
{
m_SkyParametersHash = 0;
m_SkyParameters = value;
m_UpdateRequired = true;
}
else
{
Debug.LogWarning("Sky renderer needs an instance of " + GetSkyParameterType().ToString() + " to be able to render.");
}
m_Renderer.Cleanup();
m_Renderer = null;
m_SkyParametersHash = 0;
m_SkyParameters = value;
m_UpdateRequired = true;
if (value != null)
m_Renderer = value.GetRenderer();
}
public void InstantiateSkyRenderer(Type skyRendererType)
{
if(skyRendererType == null)
{
m_Renderer = null;
}
else if (m_Renderer == null || m_Renderer.GetType() != skyRendererType)
{
m_Renderer = Activator.CreateInstance(skyRendererType) as SkyRenderer;
m_Renderer.Build();
}
}
protected Mesh BuildSkyMesh(Vector3 cameraPosition, Matrix4x4 cameraInvViewProjectionMatrix, bool forceUVBottom)

public bool IsSkyValid()
{
return m_Renderer != null && m_Renderer.IsParameterValid(skyParameters) && m_Renderer.IsSkyValid(skyParameters);
return m_Renderer != null && m_Renderer.IsSkyValid();
}
private void RenderSkyToCubemap(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, RenderTexture target)

}
}
public bool IsSkyParameterValid(SkyParameters parameters)
{
return m_Renderer != null && m_Renderer.IsParameterValid(parameters);
}
public Type GetSkyParameterType()
{
return (m_Renderer == null) ? null : m_Renderer.GetSkyParameterType();
}
public void UpdateEnvironment(HDRenderPipeline.HDCamera camera, Light sunLight, ScriptableRenderContext renderContext)
public void UpdateEnvironment(HDCamera camera, Light sunLight, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Sky Environment Pass", renderContext))
using (new Utilities.ProfilingSample("Sky Environment Pass", renderContext))
if (IsSkyValid())
if (IsSkyValid())
{
m_CurrentUpdateTime += Time.deltaTime;
m_CurrentUpdateTime += Time.deltaTime;
m_BuiltinParameters.renderContext = renderContext;
m_BuiltinParameters.sunLight = sunLight;
m_BuiltinParameters.renderContext = renderContext;
m_BuiltinParameters.sunLight = sunLight;
// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed direclty but the renderloop is not (so we need to wait for the sky texture to be rendered first)
if (m_NeedLowLevelUpdateEnvironment)
{
// TODO: Properly send the cubemap to Enlighten. Currently workaround is to set the cubemap in a Skybox/cubemap material
m_StandardSkyboxMaterial.SetTexture("_Tex", m_SkyboxCubemapRT);
RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings
RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
RenderSettings.reflectionIntensity = 1.0f;
RenderSettings.customReflection = null;
DynamicGI.UpdateEnvironment();
// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed direclty but the renderloop is not (so we need to wait for the sky texture to be rendered first)
if (m_NeedLowLevelUpdateEnvironment)
{
// TODO: Properly send the cubemap to Enlighten. Currently workaround is to set the cubemap in a Skybox/cubemap material
m_StandardSkyboxMaterial.SetTexture("_Tex", m_SkyboxCubemapRT);
RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings
RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
RenderSettings.reflectionIntensity = 1.0f;
RenderSettings.customReflection = null;
DynamicGI.UpdateEnvironment();
m_NeedLowLevelUpdateEnvironment = false;
}
m_NeedLowLevelUpdateEnvironment = false;
}
if (
(skyParameters.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) ||
(skyParameters.updateMode == EnvironementUpdateMode.OnChanged && skyParameters.GetHash() != m_SkyParametersHash) ||
(skyParameters.updateMode == EnvironementUpdateMode.Realtime && m_CurrentUpdateTime > skyParameters.updatePeriod)
)
{
// Render sky into a cubemap - doesn't happen every frame, can be controlled
RenderSkyToCubemap(m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT);
// Note that m_SkyboxCubemapRT is created with auto-generate mipmap, it mean that here we have also our mipmap correctly box filtered for importance sampling.
if (
(skyParameters.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) ||
(skyParameters.updateMode == EnvironementUpdateMode.OnChanged && skyParameters.GetHash() != m_SkyParametersHash) ||
(skyParameters.updateMode == EnvironementUpdateMode.Realtime && m_CurrentUpdateTime > skyParameters.updatePeriod)
)
{
// Render sky into a cubemap - doesn't happen every frame, can be controlled
RenderSkyToCubemap(m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT);
// Note that m_SkyboxCubemapRT is created with auto-generate mipmap, it mean that here we have also our mipmap correctly box filtered for importance sampling.
// Convolve downsampled cubemap
RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// Convolve downsampled cubemap
RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
m_NeedLowLevelUpdateEnvironment = true;
m_UpdateRequired = false;
m_SkyParametersHash = skyParameters.GetHash();
m_CurrentUpdateTime = 0.0f;
}
m_NeedLowLevelUpdateEnvironment = true;
m_UpdateRequired = false;
m_SkyParametersHash = skyParameters.GetHash();
m_CurrentUpdateTime = 0.0f;
else
{
// Disabled for now.
// We need to remove RenderSkyToCubemap from the RenderCubemapGGXConvolution first as it needs the skyparameter to be valid.
//if(m_SkyParametersHash != 0)
//{
// // Clear sky light probe
// RenderSettings.skybox = null;
// RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
// RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
// RenderSettings.reflectionIntensity = 1.0f;
// RenderSettings.customReflection = null;
// DynamicGI.UpdateEnvironment();
}
else
{
// Disabled for now.
// We need to remove RenderSkyToCubemap from the RenderCubemapGGXConvolution first as it needs the skyparameter to be valid.
//if(m_SkyParametersHash != 0)
//{
// // Clear sky light probe
// RenderSettings.skybox = null;
// RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
// RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
// RenderSettings.reflectionIntensity = 1.0f;
// RenderSettings.customReflection = null;
// DynamicGI.UpdateEnvironment();
// // Clear temp cubemap and redo GGX from black
// Utilities.SetRenderTarget(renderContext, m_SkyboxCubemapRT, ClearFlag.ClearColor);
// RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// // Clear temp cubemap and redo GGX from black
// Utilities.SetRenderTarget(renderContext, m_SkyboxCubemapRT, ClearFlag.ClearColor);
// RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// m_SkyParametersHash = 0;
//}
}
// m_SkyParametersHash = 0;
//}
public void RenderSky(HDRenderPipeline.HDCamera camera, Light sunLight, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ScriptableRenderContext renderContext)
public void RenderSky(HDCamera camera, Light sunLight, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ScriptableRenderContext renderContext)
{
using (new Utilities.ProfilingSample("Sky Pass", renderContext))
{

35
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyParameters.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System.Linq;

public class SkyParameters : MonoBehaviour
public abstract class SkyParameters : ScriptableObject
{
protected class Unhashed : System.Attribute {}

protected void OnEnable()
{
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
{
return;
}
if (renderPipeline.skyManager.skyParameters == null || renderPipeline.skyManager.skyParameters.GetType() != this.GetType()) // We allow override of parameters only if the type is different. It means that we changed the Sky Renderer and might need a new set of parameters.
renderPipeline.skyManager.skyParameters = this;
else if (renderPipeline.skyManager.skyParameters != this && renderPipeline.skyManager.skyParameters.GetType() == this.GetType())
Debug.LogWarning("Tried to setup another SkyParameters component although there is already one enabled.");
protected void OnDisable()
{
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
{
return;
}
// Reset the current sky parameter on the render loop
if (renderPipeline.skyManager.skyParameters == this)
renderPipeline.skyManager.skyParameters = null;
}
public int GetHash()
{
unchecked

{
bool unhashedAttribute = p.GetCustomAttributes(typeof(Unhashed), true).Length != 0;
System.Object obj = p.GetValue(this);
object obj = p.GetValue(this);
if (obj != null && !unhashedAttribute) // Sometimes it can be a null reference.
hash = hash * 23 + obj.GetHashCode();
}

public abstract SkyRenderer GetRenderer();
}
}

35
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyRenderer.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System.Collections.Generic;
using System;

{
abstract public void Build();
abstract public void Cleanup();
abstract public void SetRenderTargets(BuiltinSkyParameters builtinParams);
public abstract void Build();
public abstract void Cleanup();
public abstract void SetRenderTargets(BuiltinSkyParameters builtinParams);
abstract public void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap);
abstract public bool IsSkyValid(SkyParameters skyParameters);
virtual public bool IsParameterValid(SkyParameters skyParameters) { return false; }
virtual public Type GetSkyParameterType() { return typeof(SkyParameters); }
}
abstract public class SkyRenderer<ParameterType> : SkyRenderer
where ParameterType : SkyParameters
{
override public bool IsParameterValid(SkyParameters skyParameters)
{
return GetParameters(skyParameters) != null;
}
override public Type GetSkyParameterType()
{
return typeof(ParameterType);
}
protected ParameterType GetParameters(SkyParameters parameters)
{
return parameters as ParameterType;
}
public abstract void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap);
public abstract bool IsSkyValid();
}
}

129
Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs


using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityObject = UnityEngine.Object;

public enum ClearFlag
{
ClearNone = 0,
ClearNone = 0,
}
[Flags]
public enum StencilBits
{
None = Lit.MaterialId.LitStandard,
SSS = Lit.MaterialId.LitSSS,
ClearCoat = Lit.MaterialId.LitClearCoat,
All = 255 // 0xff
}
public class Utilities

else
UnityObject.DestroyImmediate(obj);
#else
UnityObject.Destroy(obj);
UnityObject.Destroy(obj);
obj = null;
}
}

buffer.Release();
}
public static string GetFieldPath<TType, TValue>(Expression<Func<TType, TValue>> expr)
{
MemberExpression me;
switch (expr.Body.NodeType)
buffer.Release();
buffer = null;
case ExpressionType.Convert:
case ExpressionType.ConvertChecked:
var ue = expr.Body as UnaryExpression;
me = (ue != null ? ue.Operand : null) as MemberExpression;
break;
default:
me = expr.Body as MemberExpression;
break;
}
var members = new List<string>();
while (me != null)
{
members.Add(me.Member.Name);
me = me.Expression as MemberExpression;
}
var sb = new StringBuilder();
for (int i = members.Count - 1; i >= 0; i--)
{
sb.Append(members[i]);
if (i > 0) sb.Append('.');
}
return sb.ToString();
}
public class ProfilingSample
: IDisposable

}
public void Dispose()
{
{
Dispose(true);
}

if (disposed)
return;
return;
if (disposing)
{

return gpuVP;
}
public static HDRenderPipeline.HDCamera GetHDCamera(Camera camera)
public static HDCamera GetHDCamera(Camera camera)
HDRenderPipeline.HDCamera hdCamera = new HDRenderPipeline.HDCamera();
HDCamera hdCamera = new HDCamera();
hdCamera.camera = camera;
hdCamera.screenSize = new Vector4(camera.pixelWidth, camera.pixelHeight, 1.0f / camera.pixelWidth, 1.0f / camera.pixelHeight);

var gpuVP = gpuProj * camera.worldToCameraMatrix;
hdCamera.viewProjectionMatrix = gpuVP;
hdCamera.viewProjectionMatrix = gpuVP;
hdCamera.invProjectionMatrix = gpuProj.inverse;
public static void SetupMaterialHDCamera(HDRenderPipeline.HDCamera hdCamera, Material material)
public static void SetupMaterialHDCamera(HDCamera hdCamera, Material material)
{
material.SetVector("_ScreenSize", hdCamera.screenSize);
material.SetMatrix("_ViewProjMatrix", hdCamera.viewProjectionMatrix);

m.DisableKeyword(keyword);
}
public static void SelectKeyword(Material material, string keyword1, string keyword2, bool enableFirst)
{
material.EnableKeyword (enableFirst ? keyword1 : keyword2);
material.DisableKeyword(enableFirst ? keyword2 : keyword1);
}
public static void SelectKeyword(Material material, string[] keywords, int enabledKeywordIndex)
{
material.EnableKeyword(keywords[enabledKeywordIndex]);
for (int i = 0; i < keywords.Length; i++)
{
if (i != enabledKeywordIndex)
{
material.DisableKeyword(keywords[i]);
}
}
}
public static HDRenderPipeline GetHDRenderPipeline()
{
HDRenderPipeline renderContext = GraphicsSettings.renderPipelineAsset as HDRenderPipeline;

}
return renderContext;
}
// 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,
RenderTargetIdentifier colorBuffer,
MaterialPropertyBlock properties = null, int shaderPassID = 0)
{
SetupMaterialHDCamera(camera, material);
commandBuffer.SetRenderTarget(colorBuffer);
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,
RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthStencilBuffer,
MaterialPropertyBlock properties = null, int shaderPassID = 0)
{
SetupMaterialHDCamera(camera, material);
commandBuffer.SetRenderTarget(colorBuffer, depthStencilBuffer);
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,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthStencilBuffer,
MaterialPropertyBlock properties = null, int shaderPassID = 0)
{
SetupMaterialHDCamera(camera, material);
commandBuffer.SetRenderTarget(colorBuffers, depthStencilBuffer);
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.
// Important: the first RenderTarget must be created with 0 depth bits!
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, HDCamera camera,
RenderTargetIdentifier[] colorBuffers,
MaterialPropertyBlock properties = null, int shaderPassID = 0)
{
// It is currently not possible to have MRT without also setting a depth target.
// To work around this deficiency of the CommandBuffer.SetRenderTarget() API,
// we pass the first color target as the depth target. If it has 0 depth bits,
// no depth target ends up being bound.
DrawFullScreen(commandBuffer, material, camera, colorBuffers, colorBuffers[0], properties, shaderPassID);
}
}
}

30
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Profiling;
using System.Collections.Generic;
using System;

[System.Serializable]
[Serializable]
public class ShadowSettings
{
public bool enabled;

public int directionalLightCascadeCount;
public Vector3 directionalLightCascades;
static ShadowSettings defaultShadowSettings = null;
ShadowSettings settings = new ShadowSettings();
settings.enabled = true;
settings.shadowAtlasHeight = settings.shadowAtlasWidth = 4096;
settings.directionalLightCascadeCount = 1;
settings.directionalLightCascades = new Vector3(0.05F, 0.2F, 0.3F);
settings.directionalLightCascadeCount = 4;
settings.maxShadowDistance = 1000.0F;
return settings;
if (defaultShadowSettings == null)
{
defaultShadowSettings = new ShadowSettings();
defaultShadowSettings.enabled = true;
defaultShadowSettings.shadowAtlasHeight = defaultShadowSettings.shadowAtlasWidth = 4096;
defaultShadowSettings.directionalLightCascadeCount = 1;
defaultShadowSettings.directionalLightCascades = new Vector3(0.05F, 0.2F, 0.3F);
defaultShadowSettings.directionalLightCascadeCount = 4;
defaultShadowSettings.maxShadowDistance = 1000.0F;
}
return defaultShadowSettings;
}
}
}

int m_ShadowTexName;
const int k_DepthBuffer = 24;
public int shadowTexName
{
get { return m_ShadowTexName; }
}
public ShadowRenderPass(ShadowSettings settings)
{

if (!m_Settings.enabled)
{
ClearPackedShadows(cullResults.visibleLights, out packedShadows);
return;
}
// Pack all shadow quads into the texture

commandBuffer.Dispose();
// Render
loop.DrawShadows(settings);
loop.DrawShadows(ref settings);
}
}
}

2
Assets/ScriptableRenderLoop/ShaderLibrary/API/D3D11.hlsl


#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D

2
Assets/ScriptableRenderLoop/ShaderLibrary/API/Metal.hlsl


#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D

2
Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl


#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D

41
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.positionCS = float4(posInput.positionSS.xy * 2.0 - 1.0, posInput.depthRaw, 1.0) * posInput.depthVS;
// Just add the offset along the view vector is sufficiant for world position
posInput.positionWS += V * depthOffsetVS;
}
// Generates a triangle in homogeneous clip space, s.t.
// v0 = (-1, -1, 1), v1 = (3, -1, 1), v2 = (-1, 3, 1).
float2 GetFullScreenTriangleTexcoord(uint vertexID)
{
#if UNITY_UV_STARTS_AT_TOP
return float2((vertexID << 1) & 2, 1.0 - (vertexID & 2));
#else
return float2((vertexID << 1) & 2, vertexID & 2);
#endif
}
float4 GetFullScreenTriangleVertexPosition(uint vertexID)
{
float2 uv = float2((vertexID << 1) & 2, vertexID & 2);
return float4(uv * 2.0 - 1.0, 1.0, 1.0);
}
#endif // UNITY_COMMON_INCLUDED

13
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


}
//-----------------------------------------------------------------------------
// Lighting functions
//-----------------------------------------------------------------------------
// Ref: Horizon Occlusion for Normal Mapped Reflections: http://marmosetco.tumblr.com/post/81245981087
float GetHorizonOcclusion(float3 V, float3 normalWS, float3 vertexNormal, float horizonFade)
{
float3 R = reflect(-V, normalWS);
float specularOcclusion = saturate(1.0 + horizonFade * dot(R, vertexNormal));
// smooth it
return specularOcclusion * specularOcclusion;
}
//-----------------------------------------------------------------------------
// Helper functions
//-----------------------------------------------------------------------------

6
Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl


#endif
}
float RadicalInverse_VdC(uint bits)
float VanDerCorputBase2(uint i)
return float(ReverseBits32(bits)) * 2.3283064365386963e-10; // 0x100000000
return ReverseBits32(i) * rcp(4294967296.0); // 0x100000000
return float2(float(i) / float(sequenceLength), RadicalInverse_VdC(i));
return float2(float(i) / float(sequenceLength), VanDerCorputBase2(i));
}
static const float2 k_Hammersley2dSeq16[] = {

72
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


return roughness * lerp(saturate(NdotV * 2.0), 1.0, perceptualRoughness);
}
//-----------------------------------------------------------------------------
// Coordinate system conversion
//-----------------------------------------------------------------------------
// Transforms the unit vector from the spherical to the Cartesian (right-handed, Z up) coordinate.
float3 SphericalToCartesian(float phi, float cosTheta)
{
float sinPhi, cosPhi;
sincos(phi, sinPhi, cosPhi);
float sinTheta = sqrt(saturate(1.0 - cosTheta * cosTheta));
return float3(sinTheta * cosPhi, sinTheta * sinPhi, cosTheta);
}
// Converts Cartesian coordinates given in the right-handed coordinate system
// with Z pointing upwards (OpenGL style) to the coordinates in the left-handed
// coordinate system with Y pointing up and Z facing forward (DirectX style).
float3 TransformGLtoDX(float3 v)
{
return v.xzy;
}
// Performs conversion from equiareal map coordinates to Cartesian (DirectX cubemap) ones.
float3 ConvertEquiarealToCubemap(float u, float v)
{
float phi = TWO_PI - TWO_PI * u;
float cosTheta = 1.0 - 2.0 * v;
return TransformGLtoDX(SphericalToCartesian(phi, cosTheta));
}
// Performs uniform sampling of the unit disk.
// Ref: PBRT v3, p. 777.
float2 SampleDiskUniform(float2 u)
{
float r = sqrt(u.x);
float phi = TWO_PI * u.y;
float sinPhi, cosPhi;
sincos(phi, sinPhi, cosPhi);
return r * float2(cosPhi, sinPhi);
}
// Performs cosine-weighted sampling of the hemisphere.
// Ref: PBRT v3, p. 780.
void SampleHemisphereCosine(float2 u,
float3x3 localToWorld,
out float3 L,
out float NdotL)
{
float3 localL;
// Since we don't really care about the area distortion,
// we substitute uniform disk sampling for the concentric one.
localL.xy = SampleDiskUniform(u);
// Project the point from the disk onto the hemisphere.
localL.z = sqrt(1.0 - u.x);
NdotL = localL.z;
L = mul(localL, localToWorld);
}
void SampleGGXDir(float2 u,
float3 V,
float3x3 localToWorld,

out float NdotL,
out float weightOverPdf)
{
SampleHemisphereCosine(u, localToWorld, L, NdotL);
float3 localL = SampleHemisphereCosine(u.x, u.y);
NdotL = localL.z;
L = mul(localL, localToWorld);
// Importance sampling weight for each sample
// pdf = N.L / PI

83
Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl


}
//-----------------------------------------------------------------------------
// Coordinate system conversion
//-----------------------------------------------------------------------------
// Transforms the unit vector from the spherical to the Cartesian (right-handed, Z up) coordinate.
float3 SphericalToCartesian(float phi, float cosTheta)
{
float sinPhi, cosPhi;
sincos(phi, sinPhi, cosPhi);
float sinTheta = sqrt(saturate(1.0 - cosTheta * cosTheta));
return float3(sinTheta * cosPhi, sinTheta * sinPhi, cosTheta);
}
// Converts Cartesian coordinates given in the right-handed coordinate system
// with Z pointing upwards (OpenGL style) to the coordinates in the left-handed
// coordinate system with Y pointing up and Z facing forward (DirectX style).
float3 TransformGLtoDX(float3 v)
{
return v.xzy;
}
// Performs conversion from equiareal map coordinates to Cartesian (DirectX cubemap) ones.
float3 ConvertEquiarealToCubemap(float u, float v)
{
float phi = TWO_PI - TWO_PI * u;
float cosTheta = 1.0 - 2.0 * v;
return TransformGLtoDX(SphericalToCartesian(phi, cosTheta));
}
//-----------------------------------------------------------------------------
float3 UniformSampleSphere(float u1, float u2)
// Performs uniform sampling of the unit disk.
// Ref: PBRT v3, p. 777.
float2 SampleDiskUniform(float u1, float u2)
float r = sqrt(u1);
float cosTheta = 1.0 - 2.0 * u1;
float sinTheta = sqrt(max(0.0, 1.0 - cosTheta * cosTheta));
float sinPhi, cosPhi;
sincos(phi, sinPhi, cosPhi);
return r * float2(cosPhi, sinPhi);
}
return float3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta); // Light point backward (-Z)
// Performs cosine-weighted sampling of the hemisphere.
// Ref: PBRT v3, p. 780.
float3 SampleHemisphereCosine(float u1, float u2)
{
float3 localL;
// Since we don't really care about the area distortion,
// we substitute uniform disk sampling for the concentric one.
localL.xy = SampleDiskUniform(u1, u2);
// Project the point from the disk onto the hemisphere.
localL.z = sqrt(1.0 - u1);
return localL;
float3 UniformSampleHemisphere(float u1, float u2)
float3 SampleHemisphereUniform(float u1, float u2)
float phi = TWO_PI * u2;
float cosTheta = u1;
float sinTheta = sqrt(max(0.0, 1.0 - cosTheta * cosTheta));
float phi = TWO_PI * u2;
float cosTheta = 1.0 - u1;
return float3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta); // Light point backward (-Z)
return SphericalToCartesian(phi, cosTheta);
float3 UniformSampleDisk(float u1, float u2)
float3 SampleSphereUniform(float u1, float u2)
float r = sqrt(u1);
float phi = TWO_PI * u2;
float phi = TWO_PI * u2;
float cosTheta = 1.0 - 2.0 * u1;
return float3(r * cos(phi), r * sin(phi), 0); // Generate in XY plane as light point backward (-Z)
return SphericalToCartesian(phi, cosTheta);
}
void SampleSphere( float2 u,

float u1 = u.x;
float u2 = u.y;
Ns = UniformSampleSphere(u1, u2);
Ns = SampleSphereUniform(u1, u2);
// Transform from unit sphere to world space
P = radius * Ns + localToWorld[3].xyz;

float u2 = u.y;
// Random point at hemisphere surface
Ns = -UniformSampleHemisphere(u1, u2); // We want the y down hemisphere
Ns = -SampleHemisphereUniform(u1, u2); // We want the y down hemisphere
P = radius * Ns;
// Transform to world space

out float3 Ns)
{
// Random point at disk surface
P = UniformSampleDisk(u.x, u.y) * radius;
P = float3(radius * SampleDiskUniform(u.x, u.y), 0);
Ns = float3(0.0, 0.0, -1.0); // Light point backward (-Z)
// Transform to world space

4
Assets/ScriptableRenderLoop/core/RenderPipeline.cs


if (disposed)
throw new ObjectDisposedException(string.Format("{0} has been disposed. Do not call Render on disposed RenderLoops.", this));
}
public virtual void Dispose()
{
disposed = true;

7
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


//@TODO: need to get light probes + LPPV too?
settings.inputFilter.SetQueuesOpaque();
settings.rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe;
loop.DrawRenderers(settings);
loop.DrawRenderers(ref settings);
}
void RenderForward(CullResults cull, Camera camera, ScriptableRenderContext loop, bool opaquesOnly)

if (opaquesOnly) settings.inputFilter.SetQueuesOpaque();
else settings.inputFilter.SetQueuesTransparent();
loop.DrawRenderers(settings);
loop.DrawRenderers(ref settings);
}
static void DepthOnlyForForwardOpaques(CullResults cull, Camera camera, ScriptableRenderContext loop)

sorting = { flags = SortFlags.CommonOpaque }
};
settings.inputFilter.SetQueuesOpaque();
loop.DrawRenderers(settings);
loop.DrawRenderers(ref settings);
}
bool usingFptl

var cmd = new CommandBuffer() { name = "Build light list" };
// generate screen-space AABBs (used for both fptl and clustered).
if (numLights != 0)
{
var proj = CameraProjection(camera);
var temp = new Matrix4x4();

2
Assets/ScriptableRenderLoop/fptl/LightingConvexHullUtils.hlsl


#if 1
float3 maxZdir = float3(-sphCen.z*sphCen.x, -sphCen.z*sphCen.y, sphCen.x*sphCen.x + sphCen.y*sphCen.y); // cross(sphCen,cross(Zaxis,sphCen))
float len = length(maxZdir);
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // since len>=(maxZdir.z/len) we can use len as an approximate value when len<=epsilon
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // if len<=0.0001 then either |sphCen|<sphRadius or sphCen is very closely aligned with Z axis in which case little to no additional offs needed.
float offs = scalarProj*sphRadiusIn;
#else
float offs = sphRadiusIn; // more false positives due to larger radius but works too

6
Assets/ScriptableRenderLoop/fptl/TiledLightingUtils.hlsl


StructuredBuffer<SFiniteLightData> g_vLightData;
Buffer<uint> g_vLightListGlobal;
StructuredBuffer<uint> g_vLightListGlobal; // don't support Buffer yet in unity
void GetCountAndStartOpaque(out uint uStart, out uint uNrLights, uint2 tileIDX, int nrTilesX, int nrTilesY, float linDepth, uint model)

#include "ClusteredUtils.h"
Buffer<uint> g_vLayeredOffsetsBuffer;
Buffer<float> g_logBaseBuffer;
StructuredBuffer<uint> g_vLayeredOffsetsBuffer; // don't support Buffer yet in unity
StructuredBuffer<float> g_logBaseBuffer; // don't support Buffer yet in unity
void GetCountAndStart(out uint uStart, out uint uNrLights, uint2 tileIDX, int nrTilesX, int nrTilesY, float linDepth, uint model)

2
Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute


#define NR_THREADS 64
// output buffer
RWBuffer<uint> g_vLightList : register( u0 );
RWStructuredBuffer<uint> g_vLightList : register( u0 ); // don't support RWBuffer yet in unity
// 2kB (room for roughly 30 wavefronts)

10
Assets/ScriptableRenderLoop/fptl/lightlistbuild-clustered.compute


StructuredBuffer<SFiniteLightBound> g_data : register( t3 );
#ifdef USE_TWO_PASS_TILED_LIGHTING
Buffer<uint> g_vBigTileLightList : register( t4 );
StructuredBuffer<uint> g_vBigTileLightList : register( t4 ); // don't support Buffer yet in unity
#endif

RWBuffer<uint> g_vLayeredLightList : register( u0 );
RWBuffer<uint> g_LayeredOffset : register( u1 );
RWBuffer<uint> g_LayeredSingleIdxBuffer : register( u2 );
RWStructuredBuffer<uint> g_vLayeredLightList : register( u0 ); // don't support RWBuffer yet in unity
RWStructuredBuffer<uint> g_LayeredOffset : register( u1 ); // don't support RWBuffer yet in unity
RWStructuredBuffer<uint> g_LayeredSingleIdxBuffer : register( u2 ); // don't support RWBuffer yet in unity
RWBuffer<float> g_logBaseBuffer : register( u3 );
RWStructuredBuffer<float> g_logBaseBuffer : register( u3 ); // don't support RWBuffer yet in unity
#endif

4
Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute


StructuredBuffer<SFiniteLightBound> g_data : register( t3 );
#ifdef USE_TWO_PASS_TILED_LIGHTING
Buffer<uint> g_vBigTileLightList : register( t4 );
StructuredBuffer<uint> g_vBigTileLightList : register( t4 ); // don't support Buffer yet in unity
RWBuffer<uint> g_vLightList : register( u0 );
RWStructuredBuffer<uint> g_vLightList : register( u0 ); // don't support RWBuffer yet in unity
#define MAX_NR_COARSE_ENTRIES 64

596
Assets/TestScenes/HDTest/GlobalIlluminationTest.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.3199737, g: 0.28755516, b: 0.26444194, a: 1}
m_IndirectSpecularColor: {r: 0.3199536, g: 0.2875398, b: 0.2644253, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableBakedLightmaps: 1
serializedVersion: 6
serializedVersion: 7
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024

m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_StationaryBakeMode: 1
m_LightingDataAsset: {fileID: 0}
m_StationaryBakeMode: 0
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 112000022, guid: 3d51fc2c60f333c44b613049001dfba8,
type: 2}
m_ShadowMaskMode: 2
m_ShadowMaskMode: 0
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 32562342}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &136708337
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 136708338}
m_Layer: 0
m_Name: Base Cases
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &136708338
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 136708337}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1108908832}
- {fileID: 531912535}
- {fileID: 190482350}
- {fileID: 434333376}
m_Father: {fileID: 1027688891}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &190482349
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 190482350}
- component: {fileID: 190482351}
m_Layer: 0
m_Name: Light Probe Group
m_Name: Light Probe Group 2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 190482349}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_Father: {fileID: 1027688891}
m_RootOrder: 8
m_Father: {fileID: 136708338}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!220 &190482351
LightProbeGroup:

- {x: -1, y: 1, z: -1}
- {x: -1, y: -1, z: 1}
- {x: -1, y: -1, z: -1}
--- !u!1 &213766584
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 213766585}
- component: {fileID: 213766586}
m_Layer: 0
m_Name: SpotLight_Static
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &213766585
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 213766584}
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: -19.037, y: 3.116, z: -4.49}
m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005}
m_Children: []
m_Father: {fileID: 1790703653}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!108 &213766586
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 213766584}
m_Enabled: 1
serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Intensity: 50
m_Range: 4
m_SpotAngle: 65.6
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &371098951
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 371098952}
- component: {fileID: 371098955}
- component: {fileID: 371098954}
- component: {fileID: 371098953}
m_Layer: 0
m_Name: Ground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &371098952
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 371098951}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -15.94, y: 0, z: -4.43}
m_LocalScale: {x: 1.5594857, y: 0.76538473, z: 0.76538473}
m_Children: []
m_Father: {fileID: 1790703653}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &371098953
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 371098951}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &371098954
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 371098951}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &371098955
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 371098951}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &434333375
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 434333376}
m_Layer: 0
m_Name: Geometry
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &434333376
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 434333375}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1197900220}
- {fileID: 1330031309}
- {fileID: 841702835}
- {fileID: 1617519336}
- {fileID: 1232831964}
- {fileID: 1315831388}
- {fileID: 931864775}
- {fileID: 1543726726}
- {fileID: 696556422}
m_Father: {fileID: 136708338}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &439514135
GameObject:
m_ObjectHideFlags: 0

m_LocalPosition: {x: -0.491, y: 0.438, z: -4.858}
m_LocalScale: {x: 0.34397998, y: 0.34397998, z: 0.34397998}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 6
m_Father: {fileID: 136708338}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!220 &531912536
LightProbeGroup:

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!114 &565152817

isDoubleSided: 0
areaLightLength: 0
areaLightWidth: 0
--- !u!1 &696556421
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 696556422}
- component: {fileID: 696556425}
- component: {fileID: 696556424}
- component: {fileID: 696556423}
m_Layer: 0
m_Name: Sphere_Chrome
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &696556422
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 696556421}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -7.74, y: 1.191, z: -7.65}
m_LocalScale: {x: 1.6119599, y: 1.6119599, z: 1.6119599}
m_Children: []
m_Father: {fileID: 434333376}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &696556423
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 696556421}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 19791e90790a8ca489ddca72c4934598, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &696556424
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 696556421}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &696556425
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 696556421}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &841702834
GameObject:
m_ObjectHideFlags: 0

m_LocalPosition: {x: 0.077, y: 0.504, z: -3.264}
m_LocalScale: {x: 3.030049, y: 1.0127319, z: 0.07942477}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 3
m_Father: {fileID: 434333376}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &841702836
MeshRenderer:

m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 2a49749e551c49a44acc0033cbbf7f22, type: 2}
- {fileID: 2100000, guid: 6f11cd0e29fe831488a0ca1f02e62fbb, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_LocalPosition: {x: 3.22, y: 0.504, z: -5.45}
m_LocalScale: {x: 3.03005, y: 1.01273, z: 0.07943}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 7
m_Father: {fileID: 434333376}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &931864776
MeshRenderer:

m_LocalPosition: {x: 0, y: 0.05, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1197900220}
- {fileID: 1330031309}
- {fileID: 1108908832}
- {fileID: 841702835}
- {fileID: 1617519336}
- {fileID: 1315831388}
- {fileID: 531912535}
- {fileID: 931864775}
- {fileID: 190482350}
- {fileID: 1232831964}
- {fileID: 1543726726}
- {fileID: 1790703653}
- {fileID: 136708338}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_LocalPosition: {x: 0.1, y: 1.905, z: -6.889}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 2
m_Father: {fileID: 136708338}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 45.944004, y: 0, z: 0}
--- !u!108 &1108908833
Light:

serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 100
m_Intensity: 20
m_Range: 5
m_SpotAngle: 85
m_CookieSize: 10

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!114 &1108908834

isDoubleSided: 0
areaLightLength: 0
areaLightWidth: 0
--- !u!1 &1157828761
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1157828762}
- component: {fileID: 1157828763}
m_Layer: 0
m_Name: SpotLight_Stationnary
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1157828762
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1157828761}
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: -12.09, y: 3.116, z: -4.49}
m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005}
m_Children: []
m_Father: {fileID: 1790703653}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!108 &1157828763
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1157828761}
m_Enabled: 1
serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Intensity: 50
m_Range: 4
m_SpotAngle: 65.6
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 1
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1197900219
GameObject:
m_ObjectHideFlags: 0

m_LocalPosition: {x: 0, y: 0, z: -4.43}
m_LocalScale: {x: 1.0426999, y: 0.5117514, z: 0.5117514}
m_Children: []
m_Father: {fileID: 1027688891}
m_Father: {fileID: 434333376}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1197900221

m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6abcdf01974b58c45af2b04a9c0fdd13, type: 2}
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

- component: {fileID: 1232831966}
- component: {fileID: 1232831965}
m_Layer: 0
m_Name: Sphere_LightProbe (1)
m_Name: Sphere_LightProbe 2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_LocalPosition: {x: 3.795, y: 0.428, z: -4.97}
m_LocalScale: {x: 0.34223, y: 0.34223, z: 0.34223}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 9
m_Father: {fileID: 434333376}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1232831965
MeshRenderer:

m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6abcdf01974b58c45af2b04a9c0fdd13, type: 2}
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_LocalPosition: {x: 0.956, y: 0.428, z: -4.97}
m_LocalScale: {x: 0.34223, y: 0.34223, z: 0.34223}
m_Children: []
m_Father: {fileID: 1027688891}
m_Father: {fileID: 434333376}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!259 &1315831389

m_LightProbeUsage: 2
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6abcdf01974b58c45af2b04a9c0fdd13, type: 2}
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_LocalPosition: {x: 0.077, y: 0.504, z: -5.45}
m_LocalScale: {x: 3.0300481, y: 1.0127295, z: 0.07943236}
m_Children: []
m_Father: {fileID: 1027688891}
m_Father: {fileID: 434333376}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1330031310

m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: c569253e641dc934db7c3595b31890da, type: 2}
- {fileID: 2100000, guid: 8503d063e677b304ab3aaeae30c8f482, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_LocalPosition: {x: -6.33, y: 0.428, z: -4.84}
m_LocalScale: {x: 1.6119599, y: 1.6119599, z: 1.6119599}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 10
m_Father: {fileID: 434333376}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1543726727
MeshRenderer:

m_LightProbeUsage: 0
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6abcdf01974b58c45af2b04a9c0fdd13, type: 2}
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_LocalPosition: {x: -0.486, y: 0.428, z: -4.97}
m_LocalScale: {x: 0.34223, y: 0.34223, z: 0.34223}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 4
m_Father: {fileID: 434333376}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1617519337
MeshRenderer:

m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6abcdf01974b58c45af2b04a9c0fdd13, type: 2}
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1736468424}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1790703652
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1790703653}
m_Layer: 0
m_Name: Baked vs Realtime
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1790703653
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1790703652}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 371098952}
- {fileID: 1863610288}
- {fileID: 1157828762}
- {fileID: 213766585}
m_Father: {fileID: 1027688891}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1845946150
GameObject:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1845946150}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1863610287
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1863610288}
- component: {fileID: 1863610291}
- component: {fileID: 1863610290}
- component: {fileID: 1863610289}
m_Layer: 0
m_Name: Wall
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &1863610288
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1863610287}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: -15.94, y: 2.29, z: -0.67}
m_LocalScale: {x: 1.55949, y: 0.76537997, z: 0.48517287}
m_Children: []
m_Father: {fileID: 1790703653}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!23 &1863610289
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1863610287}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 11d1f3b10d91bf64494441fa6b2c753f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &1863610290
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1863610287}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &1863610291
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1863610287}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1879932837
GameObject:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1879932837}
m_LocalRotation: {x: 0.120674305, y: -0, z: -0, w: 0.9926922}
m_LocalPosition: {x: -0.56, y: 2.81, z: -12.59}
m_LocalRotation: {x: -0.23712413, y: 0.55119413, z: -0.1670836, w: -0.78233004}
m_LocalPosition: {x: 7.422309, y: 6.824472, z: -9.642997}
m_LocalEulerAnglesHint: {x: 13.862, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 23.241001, y: -51.745003, z: 6.676}
--- !u!114 &1879932843
MonoBehaviour:
m_ObjectHideFlags: 0

exposure: 0
multiplier: 1
resolution: 256
updateMode: 1
updateMode: 0
updatePeriod: 0
skyHDRI: {fileID: 8900000, guid: de78f930088fc194290da7400c89bfb5, type: 3}
--- !u!114 &1944423447

998
Assets/TestScenes/HDTest/GlobalIlluminationTest/LightingData.asset
文件差异内容过多而无法显示
查看文件

3
Assets/TestScenes/HDTest/GlobalIlluminationTest/LightingData.asset.meta


fileFormatVersion: 2
guid: 3d51fc2c60f333c44b613049001dfba8
timeCreated: 1484352329
timeCreated: 1485441498
mainObjectFileID: 25800000
userData:
assetBundleName:
assetBundleVariant:

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:

4
Assets/TestScenes/HDTest/GraphicTest/Two Sided/Prefabs/Materials.meta


fileFormatVersion: 2
guid: 2a83abe1ea0fe2648947e4741977d7fd
guid: 0e2aa881811d0644896d4b5a732945cc
timeCreated: 1485444498
timeCreated: 1485804900
licenseType: Pro
DefaultImporter:
userData:

453
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 6
serializedVersion: 7
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024

m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_StationaryBakeMode: 1
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 112000002, guid: 94f8793cc1c3e0248901e8f336236333,
type: 2}
m_RuntimeCPUUsage: 25

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &209784732

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &592704850

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &605581071

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 657202129}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &659590036
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 659590037}
- component: {fileID: 659590040}
- component: {fileID: 659590039}
- component: {fileID: 659590038}
m_Layer: 0
m_Name: Sphere (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &659590037
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 659590036}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.6774626, y: 0.767334, z: 2.448}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 952562495}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &659590038
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 659590036}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 9b6a8236cdeed274584a59aeff1f980c, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &659590039
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 659590036}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &659590040
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 659590036}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &663023701
GameObject:
m_ObjectHideFlags: 0

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &686566038

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &710116623

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!114 &733865596

Transform:
m_PrefabParentObject: {fileID: 485392, guid: e641a36bceddbf24a89656e94dafb3e5, type: 2}
m_PrefabInternal: {fileID: 771937532}
--- !u!1 &779296982
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 779296983}
- component: {fileID: 779296986}
- component: {fileID: 779296985}
- component: {fileID: 779296984}
m_Layer: 0
m_Name: Plane (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &779296983
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 779296982}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 952562495}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &779296984
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 779296982}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 9d65ced14251eb743ba9702a6f3c2ce8, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &779296985
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 779296982}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &779296986
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 779296982}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &782545120
GameObject:
m_ObjectHideFlags: 0

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &785457126

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &827169276

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &891124079

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 951305959}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &952562494
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 952562495}
m_Layer: 0
m_Name: Test - Unlit
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &952562495
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 952562494}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4.8500004, y: 0, z: -68.92}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 779296983}
- {fileID: 1435860839}
- {fileID: 2145183178}
- {fileID: 659590037}
m_Father: {fileID: 0}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &970745596
GameObject:
m_ObjectHideFlags: 0

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &970922731

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1124705054

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1163258123

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1220024535

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1247488469

m_Father: {fileID: 1774532633}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1435860838
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1435860839}
- component: {fileID: 1435860842}
- component: {fileID: 1435860841}
- component: {fileID: 1435860840}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1435860839
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1435860838}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.6774626, y: 0.767334, z: -2.439003}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 952562495}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1435860840
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1435860838}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 0ed60d38430daf24b86014c8ebd23b8a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &1435860841
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1435860838}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &1435860842
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1435860838}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1440897291
GameObject:
m_ObjectHideFlags: 0

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1586360511

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1640077386

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1854618466

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1968535689

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_UseCCT: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1001 &2018525354

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2132979580}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &2145183177
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 2145183178}
- component: {fileID: 2145183181}
- component: {fileID: 2145183180}
- component: {fileID: 2145183179}
m_Layer: 0
m_Name: Sphere (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2145183178
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2145183177}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.6774626, y: 0.767334, z: -0.248}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 952562495}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &2145183179
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2145183177}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 561324bab77ed964ea54ca7e596a9d09, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &2145183180
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2145183177}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &2145183181
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2145183177}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}

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:

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存