浏览代码

Update project from sratch

/stochastic_alpha_test
sebastienlagarde 7 年前
当前提交
5a6d78c4
共有 179 个文件被更改,包括 4670 次插入2193 次删除
  1. 4
      ScriptableRenderPipeline/Core/Debugging/DebugActionManager.cs
  2. 3
      ScriptableRenderPipeline/Core/Debugging/DebugItemHandler.cs
  3. 9
      ScriptableRenderPipeline/Core/Debugging/DebugPanel.cs
  4. 7
      ScriptableRenderPipeline/Core/Debugging/DebugPanelUI.cs
  5. 9
      ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/Shadow.hlsl
  6. 310
      ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  7. 46
      ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/ShadowSampling.hlsl
  8. 32
      ScriptableRenderPipeline/Core/ShaderLibrary/Wind.hlsl
  9. 3
      ScriptableRenderPipeline/Core/Shadow/AdditionalShadowData.cs
  10. 11
      ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  11. 9
      ScriptableRenderPipeline/Core/TextureCache.cs
  12. 2
      ScriptableRenderPipeline/HDRenderPipeline/AdditionalData/HDAdditionalCameraData.cs
  13. 109
      ScriptableRenderPipeline/HDRenderPipeline/AdditionalData/HDAdditionalLightData.cs
  14. 4
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  15. 18
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs.hlsl
  16. 8
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.hlsl
  17. 5
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader
  18. 38
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  19. 63
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
  20. 505
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  21. 927
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
  22. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs
  23. 14
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs
  24. 6
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
  25. 10
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute
  26. 20
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl
  27. 3
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ShadowContext.hlsl
  28. 25
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ShadowDispatch.hlsl
  29. 188
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  30. 4
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
  31. 2
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  32. 5
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/builddispatchindirect.compute
  33. 2
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-clustered.compute
  34. 6
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/scrbound.compute
  35. 2
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/VolumetricLighting.cs
  36. 72
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  37. 63
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  38. 88
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  39. 123
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  40. 14
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  41. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  42. 196
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  43. 65
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  44. 54
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  45. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  46. 26
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitReference.hlsl
  47. 120
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
  48. 78
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  49. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile.meta
  50. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl
  51. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
  52. 11
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl
  53. 20
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  54. 28
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringProfile.cs
  55. 16
      ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl
  56. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/MaterialUtilities.hlsl
  57. 56
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  58. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader
  59. 3
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultAmbientOcclusionSettings.asset
  60. 10
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultHDMaterial.mat
  61. 2
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset
  62. 2
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset.meta
  63. 60
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs
  64. 2
      ScriptableRenderPipeline/HDRenderPipeline/ShaderConfig.cs
  65. 2
      ScriptableRenderPipeline/HDRenderPipeline/ShaderConfig.cs.hlsl
  66. 17
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  67. 13
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/TessellationShare.hlsl
  68. 10
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl
  69. 49
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl
  70. 2
      ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  71. 20
      ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs
  72. 25
      ScriptableRenderPipeline/Core/ShadowIncludes.inl
  73. 8
      ScriptableRenderPipeline/Core/ShadowIncludes.inl.meta
  74. 63
      ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs
  75. 12
      ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs.meta
  76. 185
      ScriptableRenderPipeline/HDRenderPipeline/HDShaderIDs.cs
  77. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDShaderIDs.cs.meta
  78. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye.meta
  79. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric.meta
  80. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Hair.meta
  81. 265
      ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare1.hlsl
  82. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare1.hlsl.meta
  83. 601
      ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare2.hlsl
  84. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare2.hlsl.meta
  85. 9
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor.meta
  86. 353
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/BaseEyeUI.cs
  87. 12
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/BaseEyeUI.cs.meta
  88. 469
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/EyeUI.cs
  89. 12
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/EyeUI.cs.meta
  90. 284
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs
  91. 236
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs.hlsl
  92. 9
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs.hlsl.meta
  93. 12
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs.meta
  94. 174
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.hlsl
  95. 9
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.hlsl.meta
  96. 361
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.shader

4
ScriptableRenderPipeline/Core/Debugging/DebugActionManager.cs


persistent.repeatMode = DebugActionRepeatMode.Never;
AddAction(DebugAction.MakePersistent, persistent);
AddAction(DebugAction.MoveVertical, new DebugActionDesc { axisTrigger = kDPadVertical, repeatMode = DebugActionRepeatMode.Delay, repeatDelay = 0.4f });
AddAction(DebugAction.MoveHorizontal, new DebugActionDesc { axisTrigger = kDPadHorizontal, repeatMode = DebugActionRepeatMode.Delay, repeatDelay = 0.4f });
AddAction(DebugAction.MoveVertical, new DebugActionDesc { axisTrigger = kDPadVertical, repeatMode = DebugActionRepeatMode.Delay, repeatDelay = 0.2f });
AddAction(DebugAction.MoveHorizontal, new DebugActionDesc { axisTrigger = kDPadHorizontal, repeatMode = DebugActionRepeatMode.Delay, repeatDelay = 0.2f });
}
DebugActionManager()

3
ScriptableRenderPipeline/Core/Debugging/DebugItemHandler.cs


public abstract bool OnEditorGUIImpl();
public void OnEditorGUI()
{
if (m_DebugItem.runtimeOnly)
return;
if(OnEditorGUIImpl())
{
DebugMenuUI.changed = true;

9
ScriptableRenderPipeline/Core/Debugging/DebugPanel.cs


[Flags]
public enum DebugItemFlag
{
None = 0,
DynamicDisplay = 1 << 0,
EditorOnly = 1 << 1,
RuntimeOnly = 1 << 2
None,
DynamicDisplay,
EditorOnly
}
public class DebugItem

public DebugItemHandler handler { get { return m_Handler; } }
public DebugItemFlag flags { get { return m_Flags; } }
public bool readOnly { get { return m_Setter == null; } }
public bool editorOnly { get { return (flags & DebugItemFlag.EditorOnly) != 0; } }
public bool runtimeOnly { get { return (flags & DebugItemFlag.RuntimeOnly) != 0; } }
public DebugItem(string name, string panelName, Type type, Func<object> getter, Action<object> setter, DebugItemFlag flags = DebugItemFlag.None, DebugItemHandler handler = null)
{

7
ScriptableRenderPipeline/Core/Debugging/DebugPanelUI.cs


for (int i = 0; i < m_DebugPanel.itemCount; i++)
{
DebugItem item = m_DebugPanel.GetDebugItem(i);
#if UNITY_EDITOR
// We don't want runtime only items even in the "player" debug menu if we are in the editor.
if (item.runtimeOnly)
continue;
#endif
if(!item.editorOnly)
if(!((item.flags & DebugItemFlag.EditorOnly) != 0))
{
DebugItemHandler handler = item.handler; // Should never be null, we have at least the default handler
m_ItemsUI.Add(handler.BuildGUI(parent));

9
ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/Shadow.hlsl


#ifndef SHADOW_HLSL
#ifndef SHADOW_HLSL
#define SHADOW_HLSL
//
// Shadow master include header.

#define SHADOW_SUPPORTS_DYNAMIC_INDEXING 0 // only on >= sm 5.1
#define SHADOW_OPTIMIZE_REGISTER_USAGE 0 // redefine this as 1 in your ShadowContext.hlsl to optimize for register usage over instruction count
#include "../../../Core/Shadow/ShadowBase.cs.hlsl" // ShadowData definition, auto generated (don't modify)
#include "ShadowTexFetch.hlsl" // Resource sampling definitions (don't modify)

// Shadow context definition and initialization, i.e. resource binding (project header, must be kept in sync with C# runtime)
#define SHADOW_CONTEXT_INCLUDE
#include "../../ShadowIncludes.hlsl"
#include "../../ShadowIncludes.inl"
//#include "ShadowContext.hlsl"
// helper function to extract shadowmap data from the ShadowData struct
void UnpackShadowmapId( uint shadowmapId, out uint texIdx, out uint sampIdx, out float slice )

// include project specific shadow dispatcher. If this file is not empty, it MUST define which default shadows it's overriding
#define SHADOW_DISPATCH_INCLUDE
#include "../../ShadowIncludes.hlsl"
#include "../../ShadowIncludes.inl"
//#include "ShadowDispatch.hlsl"
// if shadow dispatch is empty we'll fall back to default shadow sampling implementations
#ifndef SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL

310
ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


// calc TCs
float2 posTC = posNDC * 0.5 + 0.5;
closestSampleNDC = (floor(posTC * sd.textureSize.zw) + 0.5) * sd.texelSizeRcp.zw * 2.0 - 1.0.xx;
return uint2( (posTC * sd.scaleOffset.xy + sd.scaleOffset.zw) * sd.textureSize.xy );
return (posTC * sd.scaleOffset.xy + sd.scaleOffset.zw) * sd.textureSize.xy;
}
int EvalShadow_GetCubeFaceID( float3 dir )

//
#define kMaxShadowCascades 4
#define SHADOW_REPEAT_CASCADE( _x ) _x, _x, _x, _x
int EvalShadow_GetSplitSphereIndexForDirshadows( float3 positionWS, float4 dirShadowSplitSpheres[4], out float relDistance )
{

payloadOffset++;
float4 borders = asfloat( shadowContext.payloads[payloadOffset] );
payloadOffset++;
float border = borders[shadowSplitIndex];
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border );
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex];
// normal based bias

// Be careful of this code, we need it here before the if statement otherwise the compiler screws up optimizing dirShadowSplitSpheres VGPRs away
float3 splitSphere = dirShadowSplitSpheres[shadowSplitIndex].xyz;
float3 cascadeDir = normalize( -splitSphere + dirShadowSplitSpheres[min( shadowSplitIndex+1, kMaxShadowCascades-1 )].xyz );
float3 wposDir = normalize( -splitSphere + positionWS );
float cascDot = dot( cascadeDir, wposDir );
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) );
// sample the texture
uint texIdx, sampIdx;
float slice;

UnpackShadowType( sd.shadowType, shadowType, shadowAlgorithm );
float shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sd.bias, slice, shadowAlgorithm, texIdx, sampIdx );
float shadow1 = 1.0;
float shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sd.bias, slice, shadowAlgorithm, texIdx, sampIdx );
float border = borders[shadowSplitIndex];
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border );
float shadow1 = 1.0;
float4 splitSphere = dirShadowSplitSpheres[shadowSplitIndex - 1];
float3 cascadeDir = normalize( -splitSphere.xyz + dirShadowSplitSpheres[shadowSplitIndex].xyz );
float3 wposDir = normalize( -splitSphere.xyz + positionWS );
float cascDot = dot( cascadeDir, wposDir );
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) );
[branch]
if( alpha > 0.0 )
{
sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex];

UnpackShadowmapId( sd.id, slice );
[branch]
if( all( abs( posNDC.xy ) <= (1.0 - sd.texelSizeRcp.zw * 0.5) ) )
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sd.bias, slice, shadowAlgorithm, texIdx, sampIdx );
}

}
#define EvalShadow_CascadedDepth_( _samplerType ) \
float EvalShadow_CascadedDepth_Blend( ShadowContext shadowContext, uint shadowAlgorithms[kMaxShadowCascades], Texture2DArray tex, _samplerType samp, float3 positionWS, float3 normalWS, int index, float3 L ) \
{ \
/* load the right shadow data for the current face */ \
float4 dirShadowSplitSpheres[kMaxShadowCascades]; \
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres ); \
float relDistance; \
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres, relDistance ); \
if( shadowSplitIndex < 0 ) \
return 1.0; \
\
float4 scales = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float4 borders = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float border = borders[shadowSplitIndex]; \
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border ); \
\
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
float3 orig_pos = positionWS; \
uint orig_payloadOffset = payloadOffset; \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
/* Be careful of this code, we need it here before the if statement otherwise the compiler screws up optimizing dirShadowSplitSpheres VGPRs away */ \
float3 splitSphere = dirShadowSplitSpheres[shadowSplitIndex].xyz; \
float3 cascadeDir = normalize( -splitSphere + dirShadowSplitSpheres[min( shadowSplitIndex+1, kMaxShadowCascades-1 )].xyz ); \
float3 wposDir = normalize( -splitSphere + positionWS ); \
float cascDot = dot( cascadeDir, wposDir ); \
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) ); \
\
/* get shadowmap texcoords */ \
float3 posNDC; \
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true ); \
\
/* sample the texture */ \
float slice; \
UnpackShadowmapId( sd.id, slice ); \
\
float shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sd.bias, slice, shadowAlgorithms[shadowSplitIndex], tex, samp ); \
float shadow1 = 1.0; \
\
shadowSplitIndex++; \
if( shadowSplitIndex < kMaxShadowCascades ) \
{ \
shadow1 = shadow; \
\
if( alpha > 0.0 ) \
{ \
sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
positionWS = orig_pos + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, false ); \
/* sample the texture */ \
UnpackShadowmapId( sd.id, slice ); \
\
[branch] \
if( all( abs( posNDC.xy ) <= (1.0 - sd.texelSizeRcp.zw * 0.5) ) ) \
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sd.bias, slice, shadowAlgorithms[shadowSplitIndex], tex, samp ); \
} \
} \
shadow = lerp( shadow, shadow1, alpha ); \
return shadow; \
} \
\
float EvalShadow_CascadedDepth_Blend( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, float3 positionWS, float3 normalWS, int index, float3 L ) \
{ \
uint shadowAlgorithms[kMaxShadowCascades] = { SHADOW_REPEAT_CASCADE( shadowAlgorithm ) }; \
return EvalShadow_CascadedDepth_Blend( shadowContext, shadowAlgorithms, tex, samp, positionWS, normalWS, index, L ); \
#define EvalShadow_CascadedDepth_( _samplerType ) \
float EvalShadow_CascadedDepth_Blend( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, float3 positionWS, float3 normalWS, int index, float3 L ) \
{ \
/* load the right shadow data for the current face */ \
float4 dirShadowSplitSpheres[kMaxShadowCascades]; \
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres ); \
float relDistance; \
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres, relDistance ); \
if( shadowSplitIndex < 0 ) \
return 1.0; \
\
float4 scales = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float4 borders = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
\
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
float3 orig_pos = positionWS; \
uint orig_payloadOffset = payloadOffset; \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
/* get shadowmap texcoords */ \
float3 posNDC; \
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true ); \
/* sample the texture */ \
float slice; \
UnpackShadowmapId( sd.id, slice ); \
\
float shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sd.bias, slice, shadowAlgorithm, tex, samp ); \
\
float border = borders[shadowSplitIndex]; \
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border ); \
\
shadowSplitIndex++; \
float shadow1 = 1.0; \
if( shadowSplitIndex < kMaxShadowCascades ) \
{ \
float4 splitSphere = dirShadowSplitSpheres[shadowSplitIndex - 1]; \
float3 cascadeDir = normalize( -splitSphere.xyz + dirShadowSplitSpheres[shadowSplitIndex].xyz ); \
float3 wposDir = normalize( -splitSphere.xyz + positionWS ); \
float cascDot = dot( cascadeDir, wposDir ); \
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) ); \
shadow1 = shadow; \
\
[branch] \
if( alpha > 0.0 ) \
{ \
sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
positionWS = orig_pos + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, false ); \
/* sample the texture */ \
UnpackShadowmapId( sd.id, slice ); \
\
if( all( abs( posNDC.xy ) <= (1.0 - sd.texelSizeRcp.zw * 0.5) ) ) \
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sd.bias, slice, shadowAlgorithm, tex, samp ); \
} \
} \
shadow = lerp( shadow, shadow1, alpha ); \
return shadow; \
EvalShadow_CascadedDepth_( SamplerComparisonState )
EvalShadow_CascadedDepth_( SamplerState )
#undef EvalShadow_CascadedDepth_

float EvalShadow_CascadedDepth_Dither( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int index, float3 L )
{
// load the right shadow data for the current face
float4 dirShadowSplitSpheres[kMaxShadowCascades];
float4 dirShadowSplitSpheres[4];
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres );
float relDistance;
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres, relDistance );

float3 posNDC;
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true );
int nextSplit = min( shadowSplitIndex+1, kMaxShadowCascades-1 );
float3 splitSphere = dirShadowSplitSpheres[shadowSplitIndex].xyz;
float3 cascadeDir = normalize( -splitSphere + dirShadowSplitSpheres[min( 3, shadowSplitIndex + 1 )].xyz );
float3 wposDir = normalize( -splitSphere + positionWS );
float cascDot = dot( cascadeDir, wposDir );
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) );
if( shadowSplitIndex < (kMaxShadowCascades-1) )
{
float4 splitSphere = dirShadowSplitSpheres[shadowSplitIndex];
float3 cascadeDir = normalize( -splitSphere.xyz + dirShadowSplitSpheres[shadowSplitIndex+1].xyz );
float3 wposDir = normalize( -splitSphere.xyz + positionWS );
float cascDot = dot( cascadeDir, wposDir );
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) );
if( shadowSplitIndex < nextSplit && step( EvalShadow_hash12( posTC.xy ), alpha ) )
{
sd = shadowContext.shadowDatas[index + 1 + nextSplit];
positionWS = orig_pos + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[nextSplit] * sd.texelSizeRcp.zw, sd.normalBias );
posTC = EvalShadow_GetTexcoords( sd, positionWS );
if( step( EvalShadow_hash12( posTC.xy ), alpha ) )
{
shadowSplitIndex++;
sd = shadowContext.shadowDatas[index + 2 + shadowSplitIndex];
positionWS = orig_pos + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex+1] * sd.texelSizeRcp.zw, sd.normalBias );
posTC = EvalShadow_GetTexcoords( sd, positionWS );
}
}
// sample the texture
uint texIdx, sampIdx;

return shadowSplitIndex < (kMaxShadowCascades-1) ? shadow : lerp( shadow, 1.0, alpha );
}
#define EvalShadow_CascadedDepth_( _samplerType ) \
float EvalShadow_CascadedDepth_Dither( ShadowContext shadowContext, uint shadowAlgorithms[kMaxShadowCascades], Texture2DArray tex, _samplerType samp, float3 positionWS, float3 normalWS, int index, float3 L ) \
{ \
/* load the right shadow data for the current face */ \
float4 dirShadowSplitSpheres[kMaxShadowCascades]; \
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres ); \
float relDistance; \
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres, relDistance ); \
if( shadowSplitIndex < 0 ) \
return 1.0; \
\
float4 scales = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float4 borders = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float border = borders[shadowSplitIndex]; \
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border ); \
\
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
float3 orig_pos = positionWS; \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
/* get shadowmap texcoords */ \
float3 posNDC; \
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true ); \
\
int nextSplit = min( shadowSplitIndex+1, kMaxShadowCascades-1 ); \
float3 splitSphere = dirShadowSplitSpheres[shadowSplitIndex].xyz; \
float3 cascadeDir = normalize( -splitSphere + dirShadowSplitSpheres[nextSplit].xyz ); \
float3 wposDir = normalize( -splitSphere + positionWS ); \
float cascDot = dot( cascadeDir, wposDir ); \
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) ); \
\
if( shadowSplitIndex != nextSplit && step( EvalShadow_hash12( posTC.xy ), alpha ) ) \
{ \
sd = shadowContext.shadowDatas[index + 1 + nextSplit]; \
positionWS = orig_pos + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[nextSplit] * sd.texelSizeRcp.zw, sd.normalBias ); \
posTC = EvalShadow_GetTexcoords( sd, positionWS ); \
} \
/* sample the texture */ \
float slice; \
UnpackShadowmapId( sd.id, slice ); \
float shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sd.bias, slice, shadowAlgorithms[shadowSplitIndex], tex, samp ); \
return shadowSplitIndex < (kMaxShadowCascades-1) ? shadow : lerp( shadow, 1.0, alpha ); \
} \
\
float EvalShadow_CascadedDepth_Dither( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, float3 positionWS, float3 normalWS, int index, float3 L ) \
{ \
uint shadowAlgorithms[kMaxShadowCascades] = { SHADOW_REPEAT_CASCADE( shadowAlgorithm ) }; \
return EvalShadow_CascadedDepth_Dither( shadowContext, shadowAlgorithms, tex, samp, positionWS, normalWS, index, L ); \
#define EvalShadow_CascadedDepth_( _samplerType ) \
float EvalShadow_CascadedDepth_Dither( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, float3 positionWS, float3 normalWS, int index, float3 L ) \
{ \
/* load the right shadow data for the current face */ \
float4 dirShadowSplitSpheres[kMaxShadowCascades]; \
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres ); \
float relDistance; \
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres, relDistance ); \
if( shadowSplitIndex < 0 ) \
return 1.0; \
\
float4 scales = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float4 borders = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
float border = borders[shadowSplitIndex]; \
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border ); \
\
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
float3 orig_pos = positionWS; \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
/* get shadowmap texcoords */ \
float3 posNDC; \
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true ); \
\
if( shadowSplitIndex < (kMaxShadowCascades-1) ) \
{ \
float4 splitSphere = dirShadowSplitSpheres[shadowSplitIndex]; \
float3 cascadeDir = normalize( -splitSphere.xyz + dirShadowSplitSpheres[shadowSplitIndex+1].xyz ); \
float3 wposDir = normalize( -splitSphere.xyz + positionWS ); \
float cascDot = dot( cascadeDir, wposDir ); \
alpha = cascDot > 0.0 ? alpha : lerp( alpha, 0.0, saturate( -cascDot * 4.0 ) ); \
\
if( step( EvalShadow_hash12( posTC.xy ), alpha ) ) \
{ \
sd = shadowContext.shadowDatas[index + 2 + shadowSplitIndex]; \
positionWS = orig_pos + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex+1] * sd.texelSizeRcp.zw, sd.normalBias ); \
posTC = EvalShadow_GetTexcoords( sd, positionWS ); \
} \
} \
/* sample the texture */ \
float slice; \
UnpackShadowmapId( sd.id, slice ); \
float shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sd.bias, slice, shadowAlgorithm, tex, samp ); \
return shadowSplitIndex < (kMaxShadowCascades-1) ? shadow : lerp( shadow, 1.0, alpha ); \
EvalShadow_CascadedDepth_( SamplerComparisonState )
EvalShadow_CascadedDepth_( SamplerState )
#undef EvalShadow_CascadedDepth_

float4 closestWS = mul( closestNDC, sd.shadowToWorld );
return closestWS.xyz / closestWS.w;
}
float3 EvalShadow_GetClosestSample_Cascade( ShadowContext shadowContext, Texture2DArray tex, float3 positionWS, float3 normalWS, int index, float4 L )
{
// load the right shadow data for the current face
float4 dirShadowSplitSpheres[4];
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres );
float relDistance;
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres, relDistance );
if( shadowSplitIndex < 0 )
return 1.0;
float4 scales = asfloat( shadowContext.payloads[payloadOffset] );
payloadOffset++;
float4 borders = asfloat( shadowContext.payloads[payloadOffset] );
payloadOffset++;
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex];
float4 closestNDC = { 0,0,0,1 };
uint2 texelIdx = EvalShadow_GetTexcoords( sd, positionWS, closestNDC.xy );
// load the texel
uint texIdx, sampIdx;
float slice;
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice );
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, slice, 0 ).x;
// reconstruct depth position
float4 closestWS = mul( closestNDC, sd.shadowToWorld );
return closestWS.xyz / closestWS.w;
}

46
ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/ShadowSampling.hlsl


float2 fetchesUV[9];
SampleShadow_ComputeSamples_Tent_5x5(shadowMapTexture_TexelSize, coord.xy, fetchesWeights, fetchesUV);
for( int i = 0; i < 9; i++ )
for (int i = 0; i < 9; i++)
return shadow;
}

float2 fetchesUV[16];
SampleShadow_ComputeSamples_Tent_7x7(shadowMapTexture_TexelSize, coord.xy, fetchesWeights, fetchesUV);
#if SHADOW_OPTIMIZE_REGISTER_USAGE == 1
int i;
[loop]
for( i = 0; i < 1; i++ )
{
shadow += fetchesWeights[ 0] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 0].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 1] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 1].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 2] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 2].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 3] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 3].xy, coord.z ), slice ).x;
}
[loop]
for( i = 0; i < 1; i++ )
{
shadow += fetchesWeights[ 4] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 4].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 5] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 5].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 6] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 6].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 7] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 7].xy, coord.z ), slice ).x;
}
[loop]
for( i = 0; i < 1; i++ )
for (int i = 0; i < 16; i++)
shadow += fetchesWeights[ 8] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 8].xy, coord.z ), slice ).x;
shadow += fetchesWeights[ 9] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[ 9].xy, coord.z ), slice ).x;
shadow += fetchesWeights[10] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[10].xy, coord.z ), slice ).x;
shadow += fetchesWeights[11] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[11].xy, coord.z ), slice ).x;
shadow += fetchesWeights[i] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[i].xy, coord.z ), slice ).x;
[loop]
for( i = 0; i < 1; i++ )
{
shadow += fetchesWeights[12] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[12].xy, coord.z ), slice ).x;
shadow += fetchesWeights[13] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[13].xy, coord.z ), slice ).x;
shadow += fetchesWeights[14] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[14].xy, coord.z ), slice ).x;
shadow += fetchesWeights[15] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[15].xy, coord.z ), slice ).x;
}
#else
for( int i = 0; i < 16; i++ )
{
shadow += fetchesWeights[i] * SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, float3( fetchesUV[i].xy, coord.z ), slice ).x;
}
#endif
return shadow;
}

32
ScriptableRenderPipeline/Core/ShaderLibrary/Wind.hlsl


void ApplyWindDisplacement( inout float3 positionWS,
float3 normalWS,
float3 rootWP,
float stiffness,
float drag,
float shiverDrag,
float shiverDirectionality,
float initialBend,
float shiverMask,
float4 time)
void ApplyWind( inout float3 worldPos,
inout float3 worldNormal,
float3 rootWP,
float stiffness,
float drag,
float shiverDrag,
float shiverDirectionality,
float initialBend,
float shiverMask,
float4 time)
WindData wind = GetAnalyticalWind(positionWS, rootWP, drag, shiverDrag, initialBend, time);
WindData wind = GetAnalyticalWind(worldPos, rootWP, drag, shiverDrag, initialBend, time);
if (wind.Strength > 0.0f)
if(wind.Strength > 0.0f)
float att = AttenuateTrunk(distance(positionWS, rootWP), stiffness);
float att = AttenuateTrunk(distance(worldPos, rootWP), stiffness);
positionWS = Rotate(rootWP, positionWS, rotAxis, (wind.Strength) * 0.001 * att);
worldPos = Rotate(rootWP, worldPos, rotAxis, (wind.Strength) * 0.001 * att);
float3 shiverDirection = normalize(lerp(normalWS, normalize(wind.Direction + wind.ShiverDirection), shiverDirectionality));
positionWS += wind.ShiverStrength * shiverDirection * shiverMask;
float3 shiverDirection = normalize(lerp(worldNormal, normalize(wind.Direction + wind.ShiverDirection), shiverDirectionality));
worldPos += wind.ShiverStrength * shiverDirection * shiverMask;
}
}

3
ScriptableRenderPipeline/Core/Shadow/AdditionalShadowData.cs


[HideInInspector, SerializeField]
private int shadowCascadeCount = 4;
[HideInInspector, SerializeField]
private float[] shadowCascadeRatios = new float[3] { 0.05f, 0.2f, 0.3f };
public float[] shadowCascadeRatios = new float[3] { 0.05f, 0.2f, 0.3f };
[HideInInspector, SerializeField]
private float[] shadowCascadeBorders = new float[4] { 0.2f, 0.2f, 0.2f, 0.2f };
[HideInInspector, SerializeField]

public int cascadeCount { get { return shadowCascadeCount; } }
public void GetShadowCascades(out int cascadeCount, out float[] cascadeRatios, out float[] cascadeBorders) { cascadeCount = shadowCascadeCount; cascadeRatios = shadowCascadeRatios; cascadeBorders = shadowCascadeBorders; }
public void SetShadowCascades(int cascadeCount, float[] cascadeRatios, float[] cascadeBorders) { shadowCascadeCount = cascadeCount; shadowCascadeRatios = cascadeRatios; shadowCascadeBorders = cascadeBorders; }
public void GetShadowAlgorithm(out int algorithm, out int variant, out int precision) { algorithm = shadowAlgorithm; variant = shadowVariant; precision = shadowPrecision; }
public void SetShadowAlgorithm(int algorithm, int variant, int precision, int format, int[] data)
{

11
ScriptableRenderPipeline/Core/Shadow/Shadow.cs


override public void Update( FrameId frameId, ScriptableRenderContext renderContext, CommandBuffer cmd, CullResults cullResults, List<VisibleLight> lights)
{
if (m_ActiveEntriesCount == 0)
return;
var profilingSample = new HDPipeline.Utilities.ProfilingSample(string.Format("Shadowmap{0}",m_TexSlot), cmd);
string cbName = "";

cmd.EndSample(cbName);
}
//cbName = string.Format("Shadowmap.Update - slice: {0}, vp.x: {1}, vp.y: {2}, vp.w: {3}, vp.h: {4}", curSlice, m_EntryCache[i].current.viewport.x, m_EntryCache[i].current.viewport.y, m_EntryCache[i].current.viewport.width, m_EntryCache[i].current.viewport.height);
//cmd.BeginSample(cbName);
cbName = string.Format("Shadowmap.Update - slice: {0}, vp.x: {1}, vp.y: {2}, vp.w: {3}, vp.h: {4}", curSlice, m_EntryCache[i].current.viewport.x, m_EntryCache[i].current.viewport.y, m_EntryCache[i].current.viewport.width, m_EntryCache[i].current.viewport.height);
cmd.BeginSample(cbName);
//cmd.EndSample(cbName);
cmd.EndSample(cbName);
dss.lightIndex = m_EntryCache[i].key.visibleIdx;
dss.splitData = m_EntryCache[i].current.splitData;

public override void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CommandBuffer cmd, CullResults cullResults, List<VisibleLight> lights)
{
using (new HDPipeline.Utilities.ProfilingSample("Render Shadows", cmd))
using (new HDPipeline.Utilities.ProfilingSample("Render Shadows Exp", cmd))
{
foreach( var sm in m_Shadowmaps )
{

9
ScriptableRenderPipeline/Core/TextureCache.cs


var bFoundAvailOrExistingSlice = false;
// search for existing copy
int cachedSlice;
if (m_LocatorInSliceArray.TryGetValue(texId, out cachedSlice))
if (m_LocatorInSliceArray.ContainsKey(texId))
sliceIndex = cachedSlice;
sliceIndex = m_LocatorInSliceArray[texId];
Debug.Assert(m_SliceArray[sliceIndex].texId == texId);
//assert(m_SliceArray[sliceIndex].TexID==TexID);
}
// If no existing copy found in the array

// wrap up
Debug.Assert(bFoundAvailOrExistingSlice, "The texture cache doesn't have enough space to store all textures. Please either increase the size of the texture cache, or use fewer unique textures.");
//assert(bFoundAvailOrExistingSlice);
if (bFoundAvailOrExistingSlice)
{
m_SliceArray[sliceIndex].countLRU = 0; // mark slice as in use this frame

2
ScriptableRenderPipeline/HDRenderPipeline/AdditionalData/HDAdditionalCameraData.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
namespace UnityEngine.Experimental.Rendering
{
// This struct allow to add specialized path in HDRenderPipeline (can be use to render mini map or planar reflection etc...)
public enum RenderingPathHDRP { Default, Unlit };

109
ScriptableRenderPipeline/HDRenderPipeline/AdditionalData/HDAdditionalLightData.cs


#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Serialization;
namespace UnityEngine.Experimental.Rendering.HDPipeline
namespace UnityEngine.Experimental.Rendering
// This enum extent the original LightType enum with new light type from HD
public enum LightTypeExtent
{
Punctual, // Fallback on LightShape type
Rectangle,
Line,
// Sphere,
// Disc,
};
public enum LightArchetype { Punctual, Area };
public enum SpotLightShape { Cone, Pyramid, Box };

public class HDAdditionalLightData : MonoBehaviour
{
[Range(0.0f, 100.0f)]
[FormerlySerializedAs("m_innerSpotPercent")]
public float m_InnerSpotPercent = 0.0f; // To display this field in the UI this need to be public
[Range(0.0F, 100.0F)]
public float m_innerSpotPercent = 0.0f; // To display this field in the UI this need to be public
return Mathf.Clamp(m_InnerSpotPercent, 0.0f, 100.0f) / 100.0f;
return Mathf.Clamp(m_innerSpotPercent, 0.0f, 100.0f) / 100.0f;
[Range(0.0f, 1.0f)]
[Range(0.0F, 1.0F)]
public float lightDimmer = 1.0f;
// Not used for directional lights.

public bool affectSpecular = true;
[FormerlySerializedAs("archetype")]
public LightTypeExtent lightTypeExtent = LightTypeExtent.Punctual;
public LightArchetype archetype = LightArchetype.Punctual;
public SpotLightShape spotLightShape = SpotLightShape.Cone; // Note: Only for Spotlight, should be hide for other light
// Only for Spotlight, should be hide for other light
public SpotLightShape spotLightShape = SpotLightShape.Cone;
// Only for Rectangle/Line/projector lights
[FormerlySerializedAs("lightLength")]
public float shapeLength = 0.5f;
public float lightLength = 0.0f; // Area & projector lights
// Only for Rectangle/projector lights
[FormerlySerializedAs("lightWidth")]
public float shapeWidth = 0.5f;
public float lightWidth = 0.0f; // Area & projector lights
// Only for Sphere/Disc
public float shapeRadius = 0.0f;
// Only for Spot/Point - use to cheaply fake specular spherical area light
public float maxSmoothness = 1.0f;
public float maxSmoothness = 1.0f; // this is use with punctual light to fake an area lights
// If true, we apply the smooth attenuation factor on the range attenuation to get 0 value, else the attenuation is just inverse square and never reach 0
public bool applyRangeAttenuation = true;
// This is specific for the LightEditor GUI and not use at runtime
public bool useOldInspector = false;
public bool showAdditionalSettings = true; // TODO: Maybe we can remove if if we decide to always show additional settings
#if UNITY_EDITOR
private void DrawGizmos(bool selected)
{
var light = gameObject.GetComponent<Light>();
var gizmoColor = light.color;
gizmoColor.a = selected ? 1.0f : 0.3f; // Fade for the gizmo
Gizmos.color = Handles.color = gizmoColor;
if (lightTypeExtent == LightTypeExtent.Punctual)
{
switch (light.type)
{
case LightType.Directional:
EditorLightUtilities.DrawDirectionalLightGizmo(light);
break;
case LightType.Point:
EditorLightUtilities.DrawPointlightGizmo(light, selected);
break;
case LightType.Spot:
if (spotLightShape == SpotLightShape.Cone)
EditorLightUtilities.DrawSpotlightGizmo(light, selected);
else if (spotLightShape == SpotLightShape.Pyramid)
EditorLightUtilities.DrawFrustumlightGizmo(light);
else if (spotLightShape == SpotLightShape.Box) // TODO
EditorLightUtilities.DrawFrustumlightGizmo(light);
break;
}
}
else
{
switch (lightTypeExtent)
{
case LightTypeExtent.Rectangle:
EditorLightUtilities.DrawArealightGizmo(light);
break;
case LightTypeExtent.Line:
EditorLightUtilities.DrawArealightGizmo(light);
break;
}
}
}
private void OnDrawGizmos()
{
// DrawGizmos(false);
}
private void OnDrawGizmosSelected()
{
DrawGizmos(true);
}
#endif
public bool applyRangeAttenuation = true; // If true, we apply the smooth attenuation factor on the range attenuation to get 0 value, else the attenuation is juste inverse square and never reach 0
}
}

4
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

None = 0,
Tessellation = DebugViewGbuffer.BakeDiffuseLightingWithAlbedoPlusEmissive + 1,
PerPixelDisplacement,
VertexDisplacement,
DepthOffset,
Lightmap,
}

MinLightingFullScreenDebug,
SSAO,
SSAOBeforeFiltering,
DeferredShadows,
MaxLightingFullScreenDebug,
// Rendering

18
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs. Please don't edit by hand.
//
#ifndef DEBUGDISPLAY_CS_HLSL

#define DEBUGVIEWPROPERTIES_NONE (0)
#define DEBUGVIEWPROPERTIES_TESSELLATION (12)
#define DEBUGVIEWPROPERTIES_PER_PIXEL_DISPLACEMENT (13)
#define DEBUGVIEWPROPERTIES_VERTEX_DISPLACEMENT (14)
#define DEBUGVIEWPROPERTIES_DEPTH_OFFSET (15)
#define DEBUGVIEWPROPERTIES_LIGHTMAP (16)
#define DEBUGVIEWPROPERTIES_DEPTH_OFFSET (14)
#define DEBUGVIEWPROPERTIES_LIGHTMAP (15)
//
// UnityEngine.Experimental.Rendering.HDPipeline.FullScreenDebugMode: static fields

#define FULLSCREENDEBUGMODE_SSAO (2)
#define FULLSCREENDEBUGMODE_SSAOBEFORE_FILTERING (3)
#define FULLSCREENDEBUGMODE_DEFERRED_SHADOWS (4)
#define FULLSCREENDEBUGMODE_MAX_LIGHTING_FULL_SCREEN_DEBUG (5)
#define FULLSCREENDEBUGMODE_MIN_RENDERING_FULL_SCREEN_DEBUG (6)
#define FULLSCREENDEBUGMODE_MOTION_VECTORS (7)
#define FULLSCREENDEBUGMODE_NAN_TRACKER (8)
#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (9)
#define FULLSCREENDEBUGMODE_MAX_LIGHTING_FULL_SCREEN_DEBUG (4)
#define FULLSCREENDEBUGMODE_MIN_RENDERING_FULL_SCREEN_DEBUG (5)
#define FULLSCREENDEBUGMODE_MOTION_VECTORS (6)
#define FULLSCREENDEBUGMODE_NAN_TRACKER (7)
#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (8)
#endif

8
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.hlsl


#endif
break;
case DEBUGVIEWPROPERTIES_VERTEX_DISPLACEMENT:
#ifdef _VERTEX_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD
result = float3(1.0, 0.0, 0.0);
#else
result = float3(0.0, 0.0, 0.0);
#endif
break;
case DEBUGVIEWPROPERTIES_DEPTH_OFFSET:
#ifdef _DEPTHOFFSET_ON // Caution: This define is related to a shader features (But it may become a standard features for HD
result = float3(1.0, 0.0, 0.0);

5
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader


return float4(color + d.xxx, 1.0);
}
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_DEFERRED_SHADOWS)
{
float4 color = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, input.texcoord);
return float4(color.rgb, 0.0);
}
return float4(0.0, 0.0, 0.0, 0.0);
}

38
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


// Rendering Settings
public readonly GUIContent renderingSettingsLabel = new GUIContent("Rendering Settings");
public readonly GUIContent useForwardRenderingOnly = new GUIContent("Use Forward Rendering Only");
public readonly GUIContent useDepthPrepassWithDeferredRendering = new GUIContent("Use Depth Prepass with Deferred rendering");
public readonly GUIContent renderAlphaTestOnlyInDeferredPrepass = new GUIContent("Alpha Test only");
public readonly GUIContent useDepthPrepass = new GUIContent("Use Depth Prepass");
// Texture Settings
public readonly GUIContent textureSettings = new GUIContent("Texture Settings");

// Tile pass Settings
public readonly GUIContent tileLightLoopSettings = new GUIContent("Tile Light Loop Settings");
public readonly GUIContent enableTileAndCluster = new GUIContent("Enable tile/clustered");
public readonly GUIContent enableComputeLightEvaluation = new GUIContent("Enable Compute Light Evaluation");
public readonly GUIContent enableComputeLightVariants = new GUIContent("Enable Compute Light Variants");
public readonly GUIContent enableComputeMaterialVariants = new GUIContent("Enable Compute Material Variants");
public readonly GUIContent enableClustered = new GUIContent("Enable clustered");
public readonly GUIContent enableFptlForOpaqueWhenClustered = new GUIContent("Enable Fptl For Opaque When Clustered");
public readonly GUIContent enableBigTilePrepass = new GUIContent("Enable big tile prepass");
public readonly GUIContent tileDebugByCategory = new GUIContent("Enable Debug By Category");
public readonly GUIContent enableTileAndCluster = new GUIContent("Enable tile/clustered", "Toggle");
public readonly GUIContent enableComputeLightEvaluation = new GUIContent("Enable Compute Light Evaluation", "Toggle");
public readonly GUIContent enableComputeLightVariants = new GUIContent("Enable Compute Light Variants", "Toggle");
public readonly GUIContent enableComputeMaterialVariants = new GUIContent("Enable Compute Material Variants", "Toggle");
public readonly GUIContent enableClustered = new GUIContent("Enable clustered", "Toggle");
public readonly GUIContent enableFptlForOpaqueWhenClustered = new GUIContent("Enable Fptl For Opaque When Clustered", "Toggle");
public readonly GUIContent enableBigTilePrepass = new GUIContent("Enable big tile prepass", "Toggle");
public readonly GUIContent tileDebugByCategory = new GUIContent("Enable Debug By Category", "Toggle");
// Sky Settings
public readonly GUIContent skyParams = new GUIContent("Sky Settings");

// Rendering Settings
SerializedProperty m_RenderingUseForwardOnly = null;
SerializedProperty m_RenderingUseDepthPrepass = null;
SerializedProperty m_RenderingUseDepthPrepassAlphaTestOnly = null;
// Subsurface Scattering Settings
// Old SSS Model >>>

// Rendering settings
m_RenderingUseForwardOnly = FindProperty(x => x.renderingSettings.useForwardRenderingOnly);
m_RenderingUseDepthPrepass = FindProperty(x => x.renderingSettings.useDepthPrepassWithDeferredRendering);
m_RenderingUseDepthPrepassAlphaTestOnly = FindProperty(x => x.renderingSettings.renderAlphaTestOnlyInDeferredPrepass);
m_RenderingUseDepthPrepass = FindProperty(x => x.renderingSettings.useDepthPrepass);
// Subsurface Scattering Settings
// Old SSS Model >>>

EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.renderingSettingsLabel);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_RenderingUseDepthPrepass, styles.useDepthPrepass);
if (!m_RenderingUseForwardOnly.boolValue) // If we are deferred
if (EditorGUI.EndChangeCheck())
EditorGUILayout.PropertyField(m_RenderingUseDepthPrepass, styles.useDepthPrepassWithDeferredRendering);
if(m_RenderingUseDepthPrepass.boolValue)
if (m_RenderingUseForwardOnly.boolValue && !m_RenderingUseDepthPrepass.boolValue)
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_RenderingUseDepthPrepassAlphaTestOnly, styles.renderAlphaTestOnlyInDeferredPrepass);
EditorGUI.indentLevel--;
// Force depth prepass for forward-only rendering (for FPTL, etc).
m_RenderingUseDepthPrepass.boolValue = true;
HackSetDirty(renderContext); // Repaint
EditorGUI.indentLevel--;
}

63
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs


AssetDatabase.Refresh();
}
}
[MenuItem("GameObject/HD Render Pipeline/Scene Settings", false, 10)]
static void CreateCustomGameObject(MenuCommand menuCommand)
{
GameObject sceneSettings = new GameObject("Scene Settings");
GameObjectUtility.SetParentAndAlign(sceneSettings, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo(sceneSettings, "Create " + sceneSettings.name);
Selection.activeObject = sceneSettings;
sceneSettings.AddComponent<SceneSettings>();
}
class DoCreateNewAsset<AssetType> : UnityEditor.ProjectWindowCallback.EndNameEditAction where AssetType : ScriptableObject
{
public override void Action(int instanceId, string pathName, string resourceFile)
{
var newAsset = ScriptableObject.CreateInstance<AssetType>();
newAsset.name = System.IO.Path.GetFileName(pathName);
AssetDatabase.CreateAsset(newAsset, pathName);
ProjectWindowUtil.ShowCreatedAsset(newAsset);
}
}
class DoCreateNewAssetSSSProfile : DoCreateNewAsset<SubsurfaceScatteringProfile> {}
class DoCreateNewAssetCommonSettings : DoCreateNewAsset<CommonSettings> {}
class DoCreateNewAssetHDRISkySettings : DoCreateNewAsset<HDRISkySettings> {}
class DoCreateNewAssetProceduralSkySettings : DoCreateNewAsset<ProceduralSkySettings> {}
class DoCreateNewAssetSSAOSettings : DoCreateNewAsset<ScreenSpaceAmbientOcclusionSettings> {}
[MenuItem("Assets/Create/HDRenderPipeline/Subsurface Scattering Profile", priority = 666)]
static void MenuCreateSubsurfaceScatteringProfile()
{
Texture2D icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetSSSProfile>(), "New SSS Profile.asset", icon, null);
}
[MenuItem("Assets/Create/HDRenderPipeline/Common Settings", priority = 677)]
static void MenuCreateCommonSettings()
{
Texture2D icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetCommonSettings>(), "New CommonSettings.asset", icon, null);
}
[MenuItem("Assets/Create/HDRenderPipeline/HDRISky Settings", priority = 678)]
static void MenuCreateHDRISkySettings()
{
Texture2D icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetHDRISkySettings>(), "New HDRISkySettings.asset", icon, null);
}
[MenuItem("Assets/Create/HDRenderPipeline/ProceduralSky Settings", priority = 679)]
static void MenuCreateProceduralSkySettings()
{
Texture2D icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetProceduralSkySettings>(), "New ProceduralSkySettings.asset", icon, null);
}
[MenuItem("Assets/Create/HDRenderPipeline/Ambient Occlusion Settings", priority = 680)]
static void MenuCreateSSAOSettings()
{
Texture2D icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetSSAOSettings>(), "New AmbientOcclusionSettings.asset", icon, null);
}
}
}

505
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


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

public class RenderingSettings
{
public bool useForwardRenderingOnly = false; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepassWithDeferredRendering = false;
public bool renderAlphaTestOnlyInDeferredPrepass = false;
public bool useDepthPrepass = false;
// We have to fall back to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together

Material m_CameraMotionVectorsMaterial;
// Debug material
#if UNITY_EDITOR
Material m_ErrorMaterial;
#endif
// Various buffer
readonly int m_CameraColorBuffer;

readonly int m_VelocityBuffer;
readonly int m_DistortionBuffer;
readonly int m_DeferredShadowBuffer;
// 'm_CameraColorBuffer' does not contain diffuse lighting of SSS materials until the SSS pass. It is stored within 'm_CameraSssDiffuseLightingBuffer'.
readonly RenderTargetIdentifier m_CameraColorBufferRT;
readonly RenderTargetIdentifier m_CameraSssDiffuseLightingBufferRT;

readonly RenderTargetIdentifier m_VelocityBufferRT;
readonly RenderTargetIdentifier m_DistortionBufferRT;
readonly RenderTargetIdentifier m_DeferredShadowBufferRT;
private RenderTexture m_CameraDepthStencilBuffer = null;
private RenderTexture m_CameraDepthBufferCopy = null;

All = 255 // 0xFF - 8 bit
}
RenderStateBlock m_DepthStateOpaque;
RenderStateBlock m_DepthStateOpaqueWithPrepass;
// Detect when windows size is changing
int m_CurrentWidth;
int m_CurrentHeight;

// Debugging
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock();
DebugDisplaySettings m_DebugDisplaySettings = new DebugDisplaySettings();
static DebugDisplaySettings s_NeutralDebugDisplaySettings = new DebugDisplaySettings();
DebugDisplaySettings m_CurrentDebugDisplaySettings = null;
public DebugDisplaySettings m_DebugDisplaySettings = new DebugDisplaySettings();
private int m_DebugFullScreenTempRT;
private bool m_FullScreenDebugPushed = false;

m_DistortionBuffer = HDShaderIDs._DistortionTexture;
m_DistortionBufferRT = new RenderTargetIdentifier(m_DistortionBuffer);
m_DeferredShadowBuffer = HDShaderIDs._DeferredShadowTexture;
m_DeferredShadowBufferRT = new RenderTargetIdentifier(m_DeferredShadowBuffer);
m_MaterialList.ForEach(material => material.Build(asset.renderPipelineResources));
m_LightLoop.Build(asset.renderPipelineResources, asset.tileSettings, asset.textureSettings, asset.shadowInitParams, m_ShadowSettings);

m_DebugDisplaySettings.RegisterDebug();
m_DebugFullScreenTempRT = HDShaderIDs._DebugFullScreenTexture;
InitializeRenderStateBlocks();
RegisterDebug();
}
void RegisterDebug()
{
// These need to be Runtime Only because those values are hold by the HDRenderPipeline asset so if user change them through the editor debug menu they might change the value in the asset without noticing it.
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Forward Only", () => (bool)m_Asset.renderingSettings.useForwardRenderingOnly, (value) => m_Asset.renderingSettings.useForwardRenderingOnly = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Deferred Depth Prepass", () => (bool)m_Asset.renderingSettings.useDepthPrepassWithDeferredRendering, (value) => m_Asset.renderingSettings.useDepthPrepassWithDeferredRendering = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Deferred Depth Prepass ATest Only", () => (bool)m_Asset.renderingSettings.renderAlphaTestOnlyInDeferredPrepass, (value) => m_Asset.renderingSettings.renderAlphaTestOnlyInDeferredPrepass = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Tile/Cluster", () => (bool)m_Asset.tileSettings.enableTileAndCluster, (value) => m_Asset.tileSettings.enableTileAndCluster = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Big Tile", () => (bool)m_Asset.tileSettings.enableBigTilePrepass, (value) => m_Asset.tileSettings.enableBigTilePrepass = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Cluster", () => (bool)m_Asset.tileSettings.enableClustered, (value) => m_Asset.tileSettings.enableClustered = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Compute Lighting", () => (bool)m_Asset.tileSettings.enableComputeLightEvaluation, (value) => m_Asset.tileSettings.enableComputeLightEvaluation = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Light Classification", () => (bool)m_Asset.tileSettings.enableComputeLightVariants, (value) => m_Asset.tileSettings.enableComputeLightVariants = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Material Classification", () => (bool)m_Asset.tileSettings.enableComputeMaterialVariants, (value) => m_Asset.tileSettings.enableComputeMaterialVariants = (bool)value, DebugItemFlag.RuntimeOnly);
}
void InitializeDebugMaterials()

m_DebugFullScreen = Utilities.CreateEngineMaterial(m_Asset.renderPipelineResources.debugFullScreenShader);
#if UNITY_EDITOR
m_ErrorMaterial = Utilities.CreateEngineMaterial("Hidden/InternalErrorShader");
#endif
}
public void CreateSssMaterials(bool useDisneySSS)

// <<< Old SSS Model
}
void InitializeRenderStateBlocks()
{
m_DepthStateOpaque.depthState = new DepthState(true, CompareFunction.LessEqual);
m_DepthStateOpaque.mask = RenderStateMask.Depth;
// When doing a prepass, we don't need to write the depth anymore.
// Moreover, we need to use DepthEqual because for alpha tested materials we don't do the clip in the shader anymore (otherwise HiZ does not work on PS4)
m_DepthStateOpaqueWithPrepass.depthState = new DepthState(false, CompareFunction.Equal);
m_DepthStateOpaqueWithPrepass.mask = RenderStateMask.Depth;
}
public void OnSceneLoad()
{
// Recreate the textures which went NULL

Utilities.Destroy(m_DebugViewMaterialGBuffer);
Utilities.Destroy(m_DebugDisplayLatlong);
Utilities.Destroy(m_DebugFullScreen);
#if UNITY_EDITOR
Utilities.Destroy(m_ErrorMaterial);
#endif
m_SkyManager.Cleanup();

m_HTile.Create();
m_HTileRT = new RenderTargetIdentifier(m_HTile);
}
}
void Resize(Camera camera)

}
// Broadcast SSS parameters to all shaders.
Shader.SetGlobalInt( HDShaderIDs._EnableSSSAndTransmission, m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission ? 1 : 0);
Shader.SetGlobalInt( HDShaderIDs._EnableSSSAndTransmission, m_DebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission ? 1 : 0);
Shader.SetGlobalInt( HDShaderIDs._TexturingModeFlags, (int)sssParameters.texturingModeFlags);
Shader.SetGlobalInt( HDShaderIDs._TransmissionFlags, (int)sssParameters.transmissionFlags);
Shader.SetGlobalInt( HDShaderIDs._UseDisneySSS, sssParameters.useDisneySSS ? 1 : 0);

{
// Currently, Unity does not offer a way to bind the stencil buffer as a texture in a compute shader.
// Therefore, it's manually copied using a pixel shader.
return m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission || LightLoop.GetFeatureVariantsEnabled(m_Asset.tileSettings);
return m_DebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission || LightLoop.GetFeatureVariantsEnabled(m_Asset.tileSettings);
}
bool NeedHTileCopy()

return m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission;
return m_DebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission;
}
RenderTargetIdentifier GetDepthTexture()

#if UNITY_EDITOR
SupportedRenderingFeatures.active = s_NeededFeatures;
#endif
// HD use specific GraphicsSettings. This is init here.
// TODO: This should not be set at each Frame but is there another place for these config setup ?
GraphicsSettings.lightsUseLinearIntensity = true;
GraphicsSettings.lightsUseColorTemperature = true;
if (m_FrameCount != Time.frameCount)
{

GraphicsSettings.lightsUseLinearIntensity = true;
GraphicsSettings.lightsUseColorTemperature = true;
// This is the main command buffer used for the frame.
CommandBuffer cmd = CommandBufferPool.Get("");

m_LightLoop.NewFrame();
ApplyDebugDisplaySettings();
UpdateCommonSettings();
// Set Frame constant buffer
// TODO...
// we only want to render one camera for now
// select the most main camera!

return;
}
// If we render a reflection view or a preview we should not display any debug information
// This need to be call before ApplyDebugDisplaySettings()
if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview)
{
// Neutral allow to disable all debug settings
m_CurrentDebugDisplaySettings = s_NeutralDebugDisplaySettings;
}
else
{
m_CurrentDebugDisplaySettings = m_DebugDisplaySettings;
}
ApplyDebugDisplaySettings();
UpdateCommonSettings();
// Set camera constant buffer
// TODO...
ScriptableCullingParameters cullingParams;
if (!CullResults.GetCullingParameters(camera, out cullingParams))

}
m_LightLoop.UpdateCullingParameters( ref cullingParams );
#if UNITY_EDITOR
{
}
#endif
CullResults.Cull(ref cullingParams, renderContext,ref m_CullResults);

if (additionalCameraData && additionalCameraData.renderingPath == RenderingPathHDRP.Unlit)
{
// TODO: Add another path dedicated to planar reflection / real time cubemap that implement simpler lighting
// It is up to the users to only send unlit object for this camera path
string passName = "Forward"; // It is up to the users to only send unlit object for this camera path
using (new Utilities.ProfilingSample("Forward", cmd))
using (new Utilities.ProfilingSample(passName, cmd))
ShaderPassName[] arrayShaderPassName = { HDShaderPassNames.m_ForwardName };
RenderOpaqueRenderList(m_CullResults, camera, renderContext, cmd, arrayShaderPassName);
RenderTransparentRenderList(m_CullResults, camera, renderContext, cmd, arrayShaderPassName);
RenderOpaqueRenderList(m_CullResults, camera, renderContext, cmd, passName);
RenderTransparentRenderList(m_CullResults, camera, renderContext, cmd, passName);
}
renderContext.ExecuteCommandBuffer(cmd);

RenderDepthPrepass(m_CullResults, camera, renderContext, cmd);
// Forward opaque with deferred/cluster tile require that we fill the depth buffer
// correctly to build the light list.
RenderForwardOnlyOpaqueDepthPrepass(m_CullResults, camera, renderContext, cmd);
// In both forward and deferred, everything opaque should have been rendered at this point so we can safely copy the depth buffer for later processing.
CopyDepthBufferIfNeeded(cmd);
// If full forward rendering, we did not do any rendering yet, so don't need to copy the buffer.
// If Deferred then the depth buffer is full (regular GBuffer + ForwardOnly depth prepass are done so we can copy it safely.
if (!m_Asset.renderingSettings.useForwardRenderingOnly)
{
CopyDepthBufferIfNeeded(cmd);
}
if (m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled())
if (m_DebugDisplaySettings.IsDebugMaterialDisplayEnabled())
{
RenderDebugViewMaterial(m_CullResults, hdCamera, renderContext, cmd);
}

{
// TODO: Everything here (SSAO, Shadow, Build light list, deffered shadow, material and light classification can be parallelize with Async compute)
// TODO: Everything here (SSAO, Shadow, Build light list, material and light classification can be parallelize with Async compute)
cmd.GetTemporaryRT(m_DeferredShadowBuffer, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1 , true);
m_LightLoop.RenderDeferredDirectionalShadow(hdCamera, m_DeferredShadowBufferRT, GetDepthTexture(), cmd);
PushFullScreenDebugTexture(cmd, m_DeferredShadowBuffer, hdCamera.camera, renderContext, FullScreenDebugMode.DeferredShadows);
// Don't update the sky environment if we are rendering a cubemap (it should be update already)
if (camera.cameraType != CameraType.Reflection)
{
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, cmd);
}
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, cmd);
// For opaque forward we have split rendering in two categories
// Material that are always forward and material that can be deferred or forward depends on render pipeline options (like switch to rendering forward only mode)
// Material that are always forward are unlit and complex (Like Hair) and don't require sorting, so it is ok to split them.
RenderForward(m_CullResults, camera, renderContext, cmd, true); // Render deferred or forward opaque
RenderForwardOnlyOpaque(m_CullResults, camera, renderContext, cmd);
RenderForwardOnlyOpaqueSplitLighting(m_CullResults, camera, renderContext, cmd);
RenderForward(m_CullResults, camera, renderContext, cmd, true);
#if UNITY_EDITOR
RenderForwardError(m_CullResults, camera, renderContext, cmd, true);
#endif
RenderLightingDebug(hdCamera, cmd, m_CameraColorBufferRT, m_DebugDisplaySettings);
RenderLightingDebug(hdCamera, cmd, m_CameraColorBufferRT, m_CurrentDebugDisplaySettings);
// If full forward rendering, we did just rendered everything, so we can copy the depth buffer
// If Deferred nothing needs copying anymore.
if (m_Asset.renderingSettings.useForwardRenderingOnly)
{
CopyDepthBufferIfNeeded(cmd);
}
RenderForwardTransparentDepthWrite(m_CullResults, camera, renderContext, cmd);
#if UNITY_EDITOR
RenderForwardError(m_CullResults, camera, renderContext, cmd, false);
#endif
// Render volumetric lighting
VolumetricLightingPass(hdCamera, cmd);
// Render fog.
VolumetricLightingPass(cmd, hdCamera);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, camera, renderContext, FullScreenDebugMode.NanTracker);

RenderDebug(hdCamera, cmd);
#if UNITY_EDITOR
#endif
renderContext.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);

void RenderOpaqueRenderList(CullResults cull,
Camera camera,
ScriptableRenderContext renderContext,
CommandBuffer cmd,
ShaderPassName passName,
RendererConfiguration rendererConfiguration = 0,
RenderQueueRange? inRenderQueueRange = null,
RenderStateBlock? stateBlock = null,
Material overrideMaterial = null)
private static Material m_ErrorMaterial;
private static Material errorMaterial
RenderOpaqueRenderList(cull, camera, renderContext, cmd, new ShaderPassName[] { passName }, rendererConfiguration, inRenderQueueRange, stateBlock, overrideMaterial);
get
{
if (m_ErrorMaterial == null)
m_ErrorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader"));
return m_ErrorMaterial;
}
void RenderOpaqueRenderList(CullResults cull,
Camera camera,
ScriptableRenderContext renderContext,
CommandBuffer cmd,
ShaderPassName[] passNames,
RendererConfiguration rendererConfiguration = 0,
RenderQueueRange? inRenderQueueRange = null,
RenderStateBlock? stateBlock = null,
Material overrideMaterial = null)
void RenderOpaqueRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd, string passName, RendererConfiguration rendererConfiguration = 0)
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.displayOpaqueObjects)
if (!m_DebugDisplaySettings.renderingDebugSettings.displayOpaqueObjects)
return;
// This is done here because DrawRenderers API lives outside command buffers so we need to make call this before doing any DrawRenders

var drawSettings = new DrawRendererSettings(camera, HDShaderPassNames.s_EmptyName)
var drawSettings = new DrawRendererSettings(camera, new ShaderPassName(passName))
drawSettings.SetShaderPassName(1, new ShaderPassName("SRPDefaultUnlit"));
var filterSettings = new FilterRenderersSettings(true) {renderQueueRange = RenderQueueRange.opaque};
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);
for (int i = 0; i < passNames.Length; ++i)
{
drawSettings.SetShaderPassName(i, passNames[i]);
}
if (overrideMaterial != null)
{
drawSettings.SetOverrideMaterial(overrideMaterial, 0);
}
var filterSettings = new FilterRenderersSettings(true) { renderQueueRange = inRenderQueueRange == null ? RenderQueueRange.opaque : inRenderQueueRange.Value };
if(stateBlock == null)
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);
else
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings, stateBlock.Value);
#if UNITY_EDITOR
// in editor draw invalid things with error material
ConfigureErrorDraw(ref drawSettings);
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);
#endif
void RenderTransparentRenderList( CullResults cull,
Camera camera,
ScriptableRenderContext renderContext,
CommandBuffer cmd,
ShaderPassName passName,
RendererConfiguration rendererConfiguration = 0,
RenderStateBlock? stateBlock = null,
Material overrideMaterial = null)
void RenderTransparentRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd, string passName, RendererConfiguration rendererConfiguration = 0)
RenderTransparentRenderList(cull, camera, renderContext, cmd, new ShaderPassName[] { passName }, rendererConfiguration, stateBlock, overrideMaterial);
}
void RenderTransparentRenderList( CullResults cull,
Camera camera,
ScriptableRenderContext renderContext,
CommandBuffer cmd,
ShaderPassName[] passNames,
RendererConfiguration rendererConfiguration = 0,
RenderStateBlock? stateBlock = null,
Material overrideMaterial = null)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.displayTransparentObjects)
if (!m_DebugDisplaySettings.renderingDebugSettings.displayTransparentObjects)
return;
// This is done here because DrawRenderers API lives outside command buffers so we need to make call this before doing any DrawRenders

var drawSettings = new DrawRendererSettings(camera, HDShaderPassNames.s_EmptyName)
var drawSettings = new DrawRendererSettings(camera, new ShaderPassName(passName))
for (int i = 0; i < passNames.Length; ++i)
{
drawSettings.SetShaderPassName(i, passNames[i]);
}
var filterSettings = new FilterRenderersSettings(true) {renderQueueRange = RenderQueueRange.transparent};
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);
if (overrideMaterial != null)
{
drawSettings.SetOverrideMaterial(overrideMaterial, 0);
}
#if UNITY_EDITOR
// in editor draw invalid things with error material
ConfigureErrorDraw(ref drawSettings);
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);
#endif
}
var filterSettings = new FilterRenderersSettings(true) {renderQueueRange = RenderQueueRange.transparent};
if(stateBlock == null)
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);
else
renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings, stateBlock.Value);
private static void ConfigureErrorDraw(ref DrawRendererSettings drawSettings)
{
drawSettings.SetShaderPassName(0, new ShaderPassName("Always"));
drawSettings.SetShaderPassName(1, new ShaderPassName("ForwardBase"));
drawSettings.SetShaderPassName(2, new ShaderPassName("Deferred"));
drawSettings.SetShaderPassName(3, new ShaderPassName("PrepassBase"));
drawSettings.SetShaderPassName(4, new ShaderPassName("Vertex"));
drawSettings.SetShaderPassName(5, new ShaderPassName("VertexLMRGBM"));
drawSettings.SetShaderPassName(6, new ShaderPassName("VertexLM"));
drawSettings.SetOverrideMaterial(errorMaterial, 0);
// RenderDepthPrepass render both opaque and opaque alpha tested based on engine configuration.
// Forward only renderer: We always render everything
// Deferred renderer: We render a depth prepass only if engine request it. We can decide if we render everything or only opaque alpha tested object.
// Forward opaque with deferred renderer (ForwardOnlyOpaqueDepthOnly pass): We always render everything
// Guidelines: To be able to switch from deferred to forward renderer we need to have forward opaque material with both DepthOnly and ForwardOnlyOpaqueDepthOnly pass.
// This is also required if we want to support optional depth prepass dynamically.
// This is what is assume here. But users may want to reduce number of shader combination once they have made their choice.
// In case of forward only renderer we have a depth prepass. In case of deferred renderer, it is optional
bool addDepthPrepass = m_Asset.renderingSettings.ShouldUseForwardRenderingOnly() || m_Asset.renderingSettings.useDepthPrepassWithDeferredRendering;
// In case of deferred renderer, we can have forward opaque material. These materials need to be render in the depth buffer to correctly build the light list. And they will tag the stencil to not be lit during the deferred lighting pass.
// Caution: If a DepthPrepass is enabled for deferred then the object will be rendered with the pass DepthPrepass. See guidelines. This allow to switch dynamically between both mode.
// So we don't need to render the ForwardOnlyOpaqueDepthOnly pass
// Note that an object can't be in both list
bool addForwardOnlyOpaqueDepthPrepass = !m_Asset.renderingSettings.ShouldUseForwardRenderingOnly() && !m_Asset.renderingSettings.useDepthPrepassWithDeferredRendering;
if (addDepthPrepass == false && addForwardOnlyOpaqueDepthPrepass == false)
if (!m_Asset.renderingSettings.useDepthPrepass)
using (new Utilities.ProfilingSample(addDepthPrepass ? "Depth Prepass" : "Depth Prepass forward opaque ", cmd))
using (new Utilities.ProfilingSample("Depth Prepass", cmd))
// Default depth prepass (forward and deferred) will render all opaque geometry.
RenderQueueRange renderQueueRange = RenderQueueRange.opaque;
// If we want only alpha tested geometry in prepass for deferred we change the RenderQueueRange
if (!m_Asset.renderingSettings.ShouldUseForwardRenderingOnly() && m_Asset.renderingSettings.useDepthPrepassWithDeferredRendering && m_Asset.renderingSettings.renderAlphaTestOnlyInDeferredPrepass)
renderQueueRange = new RenderQueueRange { min = (int)RenderQueue.AlphaTest, max = (int)RenderQueue.GeometryLast - 1 };
// We render first the opaque object as opaque alpha tested are more costly to render and could be reject by early-z (but not Hi-z as it is disable with clip instruction)
// This is handeled automatically with the RenderQueue value (OpaqueAlphaTested have a different value and thus are sorted after Opaque)
// TODO: Must do opaque then alpha masked for performance!
// TODO: front to back for opaque and by material for opaque tested when we split in two
// Note: addDepthPrepass and addForwardOnlyOpaqueDepthPrepass can't be both true at the same time. And if we are here both are not false
RenderOpaqueRenderList(cull, camera, renderContext, cmd, addDepthPrepass ? HDShaderPassNames.m_DepthOnlyName : HDShaderPassNames.m_ForwardOnlyOpaqueDepthOnlyName, 0, renderQueueRange);
RenderOpaqueRenderList(cull, camera, renderContext, cmd, "DepthOnly");
// RenderGBuffer do the gbuffer pass. This is solely call with deferred. If we use a depth prepass, then the depth prepass will perform the alpha testing for opaque apha tested and we don't need to do it anymore
// during Gbuffer pass. This is handled in the shader and the depth test (equal and no depth write) is done here.
using (new Utilities.ProfilingSample(m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() ? "GBufferDebugDisplay" : "GBuffer", cmd))
string passName = m_DebugDisplaySettings.IsDebugDisplayEnabled() ? "GBufferDebugDisplay" : "GBuffer";
using (new Utilities.ProfilingSample(passName, cmd))
// render opaque objects into GBuffer
RenderOpaqueRenderList(cull, camera, renderContext, cmd, passName, Utilities.kRendererConfigurationBakedLighting);
}
}
// Render opaque objects into GBuffer
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled())
{
// When doing debug display, the shader has the clip instruction regardless of the depth prepass so we can use regular depth test.
RenderOpaqueRenderList(cull, camera, renderContext, cmd, HDShaderPassNames.m_GBufferDebugDisplayName, Utilities.kRendererConfigurationBakedLighting, RenderQueueRange.opaque, m_DepthStateOpaque);
}
else
{
if (m_Asset.renderingSettings.useDepthPrepassWithDeferredRendering)
{
RenderQueueRange rangeOpaqueNoAlphaTest = new RenderQueueRange { min = (int)RenderQueue.Geometry, max = (int)RenderQueue.AlphaTest - 1 };
RenderQueueRange rangeOpaqueAlphaTest = new RenderQueueRange { min = (int)RenderQueue.AlphaTest, max = (int)RenderQueue.GeometryLast - 1 };
// This pass is use in case of forward opaque and deferred rendering. We need to render forward objects before tile lighting pass
void RenderForwardOnlyOpaqueDepthPrepass(CullResults cull, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
// If we are forward only we don't need to render ForwardOnlyOpaqueDepthOnly object
// But in case we request a prepass we render it
if (m_Asset.renderingSettings.ShouldUseForwardRenderingOnly() && !m_Asset.renderingSettings.useDepthPrepass)
return;
// When using depth prepass for opaque alpha test only we need to use regular depth test for normal opaque objects.
RenderOpaqueRenderList(cull, camera, renderContext, cmd, HDShaderPassNames.m_GBufferName, Utilities.kRendererConfigurationBakedLighting, rangeOpaqueNoAlphaTest, m_Asset.renderingSettings.renderAlphaTestOnlyInDeferredPrepass ? m_DepthStateOpaque : m_DepthStateOpaqueWithPrepass);
// but for opaque alpha tested object we use a depth equal and no depth write. And we rely on the shader pass GbufferWithDepthPrepass
RenderOpaqueRenderList(cull, camera, renderContext, cmd, HDShaderPassNames.m_GBufferWithPrepassName, Utilities.kRendererConfigurationBakedLighting, rangeOpaqueAlphaTest, m_DepthStateOpaqueWithPrepass);
}
else
{
// No depth prepass, use regular depth test - Note that we will render opaque then opaque alpha tested (based on the RenderQueue system)
RenderOpaqueRenderList(cull, camera, renderContext, cmd, HDShaderPassNames.m_GBufferName, Utilities.kRendererConfigurationBakedLighting, RenderQueueRange.opaque, m_DepthStateOpaque);
}
}
using (new Utilities.ProfilingSample("Forward opaque depth", cmd))
{
Utilities.SetRenderTarget(cmd, m_CameraDepthStencilBufferRT);
RenderOpaqueRenderList(cull, camera, renderContext, cmd, "ForwardOnlyOpaqueDepthOnly");
}
}

{
if (m_CurrentDebugDisplaySettings.materialDebugSettings.IsDebugGBufferEnabled() && !m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
if(m_DebugDisplaySettings.materialDebugSettings.IsDebugGBufferEnabled() && !m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
{
using (new Utilities.ProfilingSample("DebugViewMaterialGBuffer", cmd))
{

{
Utilities.SetRenderTarget(cmd, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, Utilities.kClearAll, Color.black);
// Render Opaque forward
RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, cmd, HDShaderPassNames.m_ForwardDisplayDebugName, Utilities.kRendererConfigurationBakedLighting);
RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, cmd, "ForwardDisplayDebug", Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, cmd, HDShaderPassNames.m_ForwardDisplayDebugName, Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, cmd, "ForwardDisplayDebug", Utilities.kRendererConfigurationBakedLighting);
}
}

LightLoop.LightingPassOptions options = new LightLoop.LightingPassOptions();
options.volumetricLightingEnabled = m_VolumetricLightingEnabled;
if (m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission)
if (m_DebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission)
m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_CurrentDebugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, depthTexture, m_DeferredShadowBuffer, options);
m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_DebugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, depthTexture, options);
m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_CurrentDebugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, depthTexture, m_DeferredShadowBuffer, options);
m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_DebugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, depthTexture, options);
}
// Combines specular lighting and diffuse lighting with subsurface scattering.

if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission || m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
if (!m_DebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission || m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
return;
using (new Utilities.ProfilingSample("Subsurface Scattering", cmd))

m_LightLoop.RenderLightingDebug(camera, cmd, colorBuffer, debugDisplaySettings);
}
// Render forward is use for both transparent and opaque objects. In case of deferred we can still render opaque object in forward.
// Guidelines: To be able to switch from deferred to forward renderer we need to have forward opaque material with both Forward and ForwardOnlyOpaque pass.
// This is what is assume here. But users may want to reduce number of shader combination once they have made their choice.
// If we are transparent, we add the forward pass. Else (Render Opaque) we add it only if we are forward rendering
bool addForwardPass = !renderOpaque || m_Asset.renderingSettings.ShouldUseForwardRenderingOnly();
// In case of deferred we can still have forward opaque object
// It mean that addForwardOnlyOpaquePass = !addForwardPass which is a simplification of: renderOpaque && !m_Asset.renderingSettings.ShouldUseForwardRenderingOnly()
// There is no need to store this case as we don't need to test for it
if (!m_Asset.renderingSettings.ShouldUseForwardRenderingOnly() && renderOpaque)
return;
ShaderPassName passName;
string profileName;
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled())
{
passName = addForwardPass ? HDShaderPassNames.m_ForwardDisplayDebugName : HDShaderPassNames.m_ForwardOnlyOpaqueDisplayDebugName;
profileName = addForwardPass ? (renderOpaque ? "Forward Opaque Display Debug" : "Forward Transparent Display Debug") : "ForwardOnlyOpaqueDisplayDebug";
}
else
{
passName = addForwardPass ? HDShaderPassNames.m_ForwardName : HDShaderPassNames.m_ForwardOnlyOpaqueName;
profileName = addForwardPass ? (renderOpaque ? "Forward Opaque" : "Forward Transparent") : "Forward Only Opaque";
}
string passName = m_DebugDisplaySettings.IsDebugDisplayEnabled() ? "ForwardDisplayDebug" : "Forward";
using (new Utilities.ProfilingSample(profileName, cmd))
using (new Utilities.ProfilingSample(passName, cmd))
// The pass "SRPDefaultUnlit" is a fallback to legacy unlit rendering and is required to support unity 2d + unity UI that render in the scene.
ShaderPassName[] arrayNames = { passName, HDShaderPassNames.m_SRPDefaultUnlitName};
// Forward opaque material always have a prepass (whether or not we use deferred) so we pass the right depth state here.
RenderOpaqueRenderList(cullResults, camera, renderContext, cmd, arrayNames, Utilities.kRendererConfigurationBakedLighting, null, m_DepthStateOpaqueWithPrepass);
RenderOpaqueRenderList(cullResults, camera, renderContext, cmd, passName, Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, arrayNames, Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, passName, Utilities.kRendererConfigurationBakedLighting);
#if UNITY_EDITOR
// This is use to Display legacy shader with an error shader
void RenderForwardError(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd, bool renderOpaque)
// Render material that are forward opaque only (like eye), this include unlit material
void RenderForwardOnlyOpaque(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
using (new Utilities.ProfilingSample("Render Forward Error", cmd))
string passName = m_DebugDisplaySettings.IsDebugDisplayEnabled() ? "ForwardOnlyOpaqueDisplayDebug" : "ForwardOnlyOpaque";
using (new Utilities.ProfilingSample(passName, cmd))
ShaderPassName[] arrayNames = { HDShaderPassNames.m_AlwaysName, HDShaderPassNames.m_ForwardBaseName, HDShaderPassNames.m_DeferredName, HDShaderPassNames.m_PrepassBaseName, HDShaderPassNames.m_VertexName, HDShaderPassNames.m_VertexLMRGBMName, HDShaderPassNames.m_VertexLMName };
m_LightLoop.RenderForward(camera, cmd, true);
if (renderOpaque)
{
RenderOpaqueRenderList(cullResults, camera, renderContext, cmd, arrayNames, 0, null, null, m_ErrorMaterial);
}
else
{
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, arrayNames, 0, null, m_ErrorMaterial);
}
RenderOpaqueRenderList(cullResults, camera, renderContext, cmd, passName, Utilities.kRendererConfigurationBakedLighting);
#endif
void RenderForwardOnlyOpaqueSplitLighting(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
string passName = "ForwardOnlyOpaqueSplitLighting";
using (new Utilities.ProfilingSample(passName, cmd))
{
RenderTargetIdentifier[] colorMRTs = new RenderTargetIdentifier[4];
colorMRTs[0] = m_CameraColorBufferRT;
colorMRTs[1] = m_CameraSssDiffuseLightingBufferRT;
colorMRTs[2] = m_gbufferManager.GetGBuffers()[0];
colorMRTs[3] = m_gbufferManager.GetGBuffers()[2];
Utilities.SetRenderTarget(cmd, colorMRTs, m_CameraDepthStencilBufferRT);
m_LightLoop.RenderForward(camera, cmd, true);
RenderOpaqueRenderList(cullResults, camera, renderContext, cmd, passName, Utilities.kRendererConfigurationBakedLighting);
}
}
void RenderForwardTransparentDepthWrite(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
string passName = "TransparentDepthWrite";
using (new Utilities.ProfilingSample("Forward transparent depth", cmd))
{
Utilities.SetRenderTarget(cmd, m_CameraDepthStencilBufferRT);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, passName);
}
}
void RenderVelocity(CullResults cullResults, HDCamera hdcam, ScriptableRenderContext renderContext, CommandBuffer cmd)
{

// TODO: Currently we can't render velocity vector into GBuffer, neither during forward pass (in case of forward opaque), so it is always a separate pass
// Note that we if we have forward only opaque with deferred rendering, it must also support the rendering of velocity vector to be correct with following test.
if ((ShaderConfig.s_VelocityInGbuffer == 1))
{
Debug.LogWarning("Velocity in Gbuffer is currently not supported");
if ((ShaderConfig.s_VelocityInGbuffer == 1) || m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
}
// These flags are still required in SRP or the engine won't compute previous model matrices...
// If the flag hasn't been set yet on this camera, motion vectors will skip a frame.

Utilities.DrawFullScreen(cmd, m_CameraMotionVectorsMaterial, m_VelocityBufferRT, null, 0);
cmd.SetRenderTarget(m_VelocityBufferRT, m_CameraDepthStencilBufferRT);
RenderOpaqueRenderList(cullResults, hdcam.camera, renderContext, cmd, HDShaderPassNames.m_MotionVectorsName, RendererConfiguration.PerObjectMotionVectors);
RenderOpaqueRenderList(cullResults, hdcam.camera, renderContext, cmd, "MotionVectors", RendererConfiguration.PerObjectMotionVectors);
PushFullScreenDebugTexture(cmd, m_VelocityBuffer, hdcam.camera, renderContext, FullScreenDebugMode.MotionVectors);
}

{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.enableDistortion)
if (!m_DebugDisplaySettings.renderingDebugSettings.enableDistortion)
return;
using (new Utilities.ProfilingSample("Distortion", cmd))

cmd.ClearRenderTarget(false, true, Color.black); // TODO: can we avoid this clear for performance ?
// Only transparent object can render distortion vectors
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.m_DistortionVectorsName);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, "DistortionVectors");
}
}

public void ApplyDebugDisplaySettings()
{
m_ShadowSettings.enabled = m_CurrentDebugDisplaySettings.lightingDebugSettings.enableShadows;
m_ShadowSettings.enabled = m_DebugDisplaySettings.lightingDebugSettings.enableShadows;
LightingDebugSettings lightingDebugSettings = m_CurrentDebugDisplaySettings.lightingDebugSettings;
LightingDebugSettings lightingDebugSettings = m_DebugDisplaySettings.lightingDebugSettings;
Shader.SetGlobalInt(HDShaderIDs._DebugViewMaterial, (int)m_CurrentDebugDisplaySettings.GetDebugMaterialIndex());
Shader.SetGlobalInt(HDShaderIDs._DebugLightingMode, (int)m_CurrentDebugDisplaySettings.GetDebugLightingMode());
Shader.SetGlobalInt(HDShaderIDs._DebugViewMaterial, (int)m_DebugDisplaySettings.GetDebugMaterialIndex());
Shader.SetGlobalInt(HDShaderIDs._DebugLightingMode, (int)m_DebugDisplaySettings.GetDebugLightingMode());
public void PushFullScreenDebugTexture(CommandBuffer cb, RenderTargetIdentifier textureID, Camera camera, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
public void PushFullScreenDebugTexture(CommandBuffer cb, int textureID, Camera camera, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
if (debugMode == m_CurrentDebugDisplaySettings.fullScreenDebugMode)
if(debugMode == m_DebugDisplaySettings.fullScreenDebugMode)
{
m_FullScreenDebugPushed = true; // We need this flag because otherwise if no fullscreen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cb.GetTemporaryRT(m_DebugFullScreenTempRT, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);

public void PushFullScreenDebugTexture(CommandBuffer cb, int textureID, Camera camera, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
{
PushFullScreenDebugTexture(cb, new RenderTargetIdentifier(textureID), camera, renderContext, debugMode);
}
void RenderDebug(HDCamera camera, CommandBuffer cmd)
{
// We don't want any overlay for these kind of rendering

Utilities.SetRenderTarget(cmd, BuiltinRenderTextureType.CameraTarget, m_CameraDepthStencilBufferRT);
// First render full screen debug texture
if (m_CurrentDebugDisplaySettings.fullScreenDebugMode != FullScreenDebugMode.None && m_FullScreenDebugPushed)
if(m_DebugDisplaySettings.fullScreenDebugMode != FullScreenDebugMode.None && m_FullScreenDebugPushed)
m_DebugFullScreen.SetFloat(HDShaderIDs._FullScreenDebugMode, (float)m_CurrentDebugDisplaySettings.fullScreenDebugMode);
m_DebugFullScreen.SetFloat(HDShaderIDs._FullScreenDebugMode, (float)m_DebugDisplaySettings.fullScreenDebugMode);
float overlayRatio = m_CurrentDebugDisplaySettings.debugOverlayRatio;
float overlayRatio = m_DebugDisplaySettings.debugOverlayRatio;
LightingDebugSettings lightingDebug = m_CurrentDebugDisplaySettings.lightingDebugSettings;
LightingDebugSettings lightingDebug = m_DebugDisplaySettings.lightingDebugSettings;
if (lightingDebug.displaySkyReflection)
{

Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.camera.pixelWidth);
}
m_LightLoop.RenderDebugOverlay(camera.camera, cmd, m_CurrentDebugDisplaySettings, ref x, ref y, overlaySize, camera.camera.pixelWidth);
m_LightLoop.RenderDebugOverlay(camera.camera, cmd, m_DebugDisplaySettings, ref x, ref y, overlaySize, camera.camera.pixelWidth);
}
}

927
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset


type: 2}
renderingSettings:
useForwardRenderingOnly: 0
useDepthPrepassWithDeferredRendering: 0
useDepthPrepass: 0
numProfiles: 2
numProfiles: 7
- {fileID: 11400000, guid: 906339bac2066fc4aa22a3652e1283ef, type: 2}
- {fileID: 11400000, guid: c722925d4b762f947938013974cf0355, type: 2}
- {fileID: 11400000, guid: 1a783144f63560747b4e5a802e88b253, type: 2}
- {fileID: 11400000, guid: 8a6adbdbd53ffb84782f55dc495ca35e, type: 2}
texturingModeFlags: 1
transmissionFlags: 5460
- {fileID: 11400000, guid: 5923a5e21213b93439facedba9fe7f2b, type: 2}
- {fileID: 11400000, guid: a28c340f5933c8447837e5d1756a9ebb, type: 2}
- {fileID: 11400000, guid: 02b61b6975432e54eae0ddc0cd7828f1, type: 2}
texturingModeFlags: 0
transmissionFlags: 5442
- {x: 0, y: 12.031147, z: 0, w: 0}
- {x: 0, y: 0.2873168, z: 0, w: 0}
- {x: 0, y: 5, z: 0, w: 0}
- {x: 0, y: 12.031147, z: 0, w: 0}
- {x: 0, y: 12.031147, z: 0, w: 0}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 1.5158079, y: 12.855332, z: 0, w: 0}
- {x: 0, y: 14.300124, z: 0, w: 0}
- {x: 0, y: 3.1851997, z: 0, w: 0}
- {x: 0, y: 10.9375, z: 0, w: 0}
- {x: 0, y: 16.40625, z: 0, w: 0}
- {x: 0.01, y: 0.09, z: 0, w: 0}
- {x: 0.30539423, y: 16.748867, z: 0, w: 0}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 0, z: 0, w: 0}
- {x: 1, y: 0, z: 0, w: 0}
- {x: 1, y: 0, z: 0, w: 0}
- {x: 1, y: 0, z: 0, w: 0}
- {x: 1, y: 0, z: 0, w: 0}
- {x: 1.3192612, y: 3.1152647, z: 4.9751244, w: 7.84603}
- {x: 2, y: 2, z: 2, w: 5.1754813}
- {x: 2, y: 2, z: 2, w: 5.1754813}
- {x: 2, y: 2, z: 2, w: 5.1754813}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 0, y: 0, z: 0, w: 0}
- {x: 2, y: 2, z: 2, w: 5.1754813}
- {x: 2, y: 2, z: 2, w: 5.1754813}
- {x: 2, y: 2, z: 2, w: 5.1754813}
- {x: 0.1892157, y: 0.08039216, z: 0.050000004, w: 0.25}
- {x: 0.21139705, y: 0.097251214, z: 0.023315849, w: 0.25}
- {x: 100, y: 0, z: 100, w: 1}
- {x: 100, y: 0, z: 100, w: 1}
- {x: 100, y: 0, z: 100, w: 1}
- {x: 100, y: 0, z: 100, w: 1}
- {x: 100, y: 0, z: 100, w: 1}
- {x: 0.25, y: 0.25, z: 0.25, w: 0.25}
- {x: 0.15715046, y: 0.17830881, z: 0.060310338, w: 0.25}
- {x: 0.25, y: 0.18103449, z: 0, w: 0.25}
- {x: 0.06193361, y: 0.07169117, z: 0.03953557, w: 0.25}
- {x: 0.24393979, y: 0.24448529, z: 0.20493619, w: 0.25}
- {x: 0.013865918, y: 1.5345725, z: 0.03667902, w: 1.5654991}
- {x: 0.04211352, y: 1.5729346, z: 0.11374626, w: 1.6734134}
- {x: 0.07107388, y: 1.6130018, z: 0.19626758, w: 1.7949444}
- {x: 0.100779116, y: 1.6548817, z: 0.28494877, w: 1.9325867}
- {x: 0.13126306, y: 1.6986896, z: 0.38062802, w: 2.0894418}
- {x: 0.16256203, y: 1.7445502, z: 0.48430943, w: 2.2694077}
- {x: 0.1947145, y: 1.7925992, z: 0.59720695, w: 2.4774427}
- {x: 0.22776169, y: 1.8429838, z: 0.72080237, w: 2.7199378}
- {x: 0.26174724, y: 1.8958628, z: 0.8569269, w: 3.005264}
- {x: 0.29671827, y: 1.9514104, z: 1.007873, w: 3.3445888}
- {x: 0.33272493, y: 2.0098157, z: 1.1765549, w: 3.7531407}
- {x: 0.369821, y: 2.0712852, z: 1.3667475, w: 4.252257}
- {x: 0.40806437, y: 2.1360447, z: 1.5834517, w: 4.872841}
- {x: 0.44751683, y: 2.2043417, z: 1.8334827, w: 5.6615734}
- {x: 0.48824534, y: 2.276447, z: 2.126473, w: 6.692844}
- {x: 0.5303216, y: 2.3526597, z: 2.4767098, w: 8.093767}
- {x: 0.5738235, y: 2.433308, z: 2.9068332, w: 10.102725}
- {x: 0.61883456, y: 2.5187542, z: 3.4562516, w: 13.228675}
- {x: 0.665446, y: 2.609401, z: 4.2041187, w: 18.793621}
- {x: 0.713756, y: 2.7056925, z: 5.3538504, w: 31.646347}
- {x: 0.763872, y: 2.808125, z: 7.84603, w: 95.44374}
- {x: 0.8159103, y: 2.91725, z: 0, w: 1}
- {x: 0.8699981, y: 3.0336854, z: 0, w: 1}
- {x: 0.9262747, y: 3.1581244, z: 0, w: 1}
- {x: 0.98489225, y: 3.2913465, z: 0, w: 1}
- {x: 1.0460185, y: 3.434234, z: 0, w: 1}
- {x: 1.1098381, y: 3.5877857, z: 0, w: 1}
- {x: 1.1765549, y: 3.7531407, z: 0, w: 1}
- {x: 1.2463952, y: 3.9316032, z: 0, w: 1}
- {x: 1.319611, y: 4.124672, z: 0, w: 1}
- {x: 1.3964823, y: 4.3340797, z: 0, w: 1}
- {x: 1.4773248, y: 4.561845, z: 0, w: 1}
- {x: 1.5624928, y: 4.810328, z: 0, w: 1}
- {x: 1.6523882, y: 5.082317, z: 0, w: 1}
- {x: 1.747467, y: 5.381122, z: 0, w: 1}
- {x: 1.8482518, y: 5.710715, z: 0, w: 1}
- {x: 1.9553448, y: 6.0759025, z: 0, w: 1}
- {x: 2.069445, y: 6.482568, z: 0, w: 1}
- {x: 2.1913698, y: 6.9379897, z: 0, w: 1}
- {x: 2.3220856, y: 7.4513016, z: 0, w: 1}
- {x: 2.4627466, y: 8.0341215, z: 0, w: 1}
- {x: 2.614747, y: 8.701484, z: 0, w: 1}
- {x: 2.7797952, y: 9.473195, z: 0, w: 1}
- {x: 2.9600194, y: 10.375936, z: 0, w: 1}
- {x: 3.1581159, y: 11.446505, z: 0, w: 1}
- {x: 3.3775842, y: 12.737201, z: 0, w: 1}
- {x: 3.6230793, y: 14.324919, z: 0, w: 1}
- {x: 3.9009922, y: 16.327562, z: 0, w: 1}
- {x: 4.220452, y: 18.935623, z: 0, w: 1}
- {x: 4.5951686, y: 22.478209, z: 0, w: 1}
- {x: 5.047148, y: 27.57712, z: 0, w: 1}
- {x: 5.615129, y: 35.564823, z: 0, w: 1}
- {x: 6.3776174, y: 49.90625, z: 0, w: 1}
- {x: 7.5374603, y: 83.30668, z: 0, w: 1}
- {x: 10.03481, y: 250.11497, z: 0, w: 1}
- {x: 0.009146384, y: 1.012251, z: 0.0241946, w: 1.0326511}
- {x: 0.02777937, y: 1.0375557, z: 0.07503051, w: 1.1038346}
- {x: 0.046882506, y: 1.0639853, z: 0.12946409, w: 1.1840003}
- {x: 0.06647699, y: 1.0916107, z: 0.18796092, w: 1.2747934}
- {x: 0.08658515, y: 1.1205076, z: 0.25107387, w: 1.3782597}
- {x: 0.107230894, y: 1.1507587, z: 0.31946534, w: 1.4969708}
- {x: 0.12843965, y: 1.1824534, z: 0.393936, w: 1.634197}
- {x: 0.15023857, y: 1.2156885, z: 0.47546333, w: 1.7941543}
- {x: 0.17265649, y: 1.2505691, z: 0.5652552, w: 1.9823642}
- {x: 0.19572444, y: 1.28721, z: 0.6648239, w: 2.2061932}
- {x: 0.21947557, y: 1.3257359, z: 0.77609164, w: 2.4756866}
- {x: 0.24394526, y: 1.366283, z: 0.90154845, w: 2.8049188}
- {x: 0.26917174, y: 1.4090004, z: 1.0444933, w: 3.2142754}
- {x: 0.29519582, y: 1.4540511, z: 1.2094214, w: 3.7345471}
- {x: 0.32206157, y: 1.5016141, z: 1.4026865, w: 4.414804}
- {x: 0.34981638, y: 1.5518863, z: 1.6337136, w: 5.3388963}
- {x: 0.37851152, y: 1.6050843, z: 1.9174361, w: 6.664067}
- {x: 0.4082022, y: 1.6614474, z: 2.2798493, w: 8.726039}
- {x: 0.4389485, y: 1.7212406, z: 2.773165, w: 12.396844}
- {x: 0.47081533, y: 1.7847576, z: 3.5315635, w: 20.874899}
- {x: 0.50387335, y: 1.8523251, z: 5.1754813, w: 62.957596}
- {x: 0.53819937, y: 1.9243073, z: 0, w: 1}
- {x: 0.5738774, y: 2.0011117, z: 0, w: 1}
- {x: 0.6109991, y: 2.0831954, z: 0, w: 1}
- {x: 0.64966506, y: 2.171073, z: 0, w: 1}
- {x: 0.6899858, y: 2.2653255, z: 0, w: 1}
- {x: 0.73208314, y: 2.3666131, z: 0, w: 1}
- {x: 0.77609164, y: 2.4756866, z: 0, w: 1}
- {x: 0.8221604, y: 2.5934057, z: 0, w: 1}
- {x: 0.87045586, y: 2.72076, z: 0, w: 1}
- {x: 0.92116255, y: 2.858892, z: 0, w: 1}
- {x: 0.9744887, y: 3.0091324, z: 0, w: 1}
- {x: 1.0306681, y: 3.1730397, z: 0, w: 1}
- {x: 1.0899659, y: 3.352452, z: 0, w: 1}
- {x: 1.1526828, y: 3.549553, z: 0, w: 1}
- {x: 1.2191633, y: 3.7669616, z: 0, w: 1}
- {x: 1.2898055, y: 4.007852, z: 0, w: 1}
- {x: 1.3650692, y: 4.2760997, z: 0, w: 1}
- {x: 1.4454945, y: 4.5765104, z: 0, w: 1}
- {x: 1.5317186, y: 4.9151063, z: 0, w: 1}
- {x: 1.6245029, y: 5.299552, z: 0, w: 1}
- {x: 1.7247669, y: 5.7397633, z: 0, w: 1}
- {x: 1.833638, y: 6.2488093, z: 0, w: 1}
- {x: 1.9525192, y: 6.844284, z: 0, w: 1}
- {x: 2.08319, y: 7.5504656, z: 0, w: 1}
- {x: 2.2279582, y: 8.40185, z: 0, w: 1}
- {x: 2.3898942, y: 9.449158, z: 0, w: 1}
- {x: 2.5732138, y: 10.770161, z: 0, w: 1}
- {x: 2.7839394, y: 12.49052, z: 0, w: 1}
- {x: 3.0311139, y: 14.827314, z: 0, w: 1}
- {x: 3.3292537, y: 18.190712, z: 0, w: 1}
- {x: 3.703911, y: 23.459646, z: 0, w: 1}
- {x: 4.2068715, y: 32.91969, z: 0, w: 1}
- {x: 4.9719396, y: 54.951633, z: 0, w: 1}
- {x: 6.6192675, y: 164.98349, z: 0, w: 1}
- {x: 0.009146384, y: 1.012251, z: 0.0241946, w: 1.0326511}
- {x: 0.02777937, y: 1.0375557, z: 0.07503051, w: 1.1038346}
- {x: 0.046882506, y: 1.0639853, z: 0.12946409, w: 1.1840003}
- {x: 0.06647699, y: 1.0916107, z: 0.18796092, w: 1.2747934}
- {x: 0.08658515, y: 1.1205076, z: 0.25107387, w: 1.3782597}
- {x: 0.107230894, y: 1.1507587, z: 0.31946534, w: 1.4969708}
- {x: 0.12843965, y: 1.1824534, z: 0.393936, w: 1.634197}
- {x: 0.15023857, y: 1.2156885, z: 0.47546333, w: 1.7941543}
- {x: 0.17265649, y: 1.2505691, z: 0.5652552, w: 1.9823642}
- {x: 0.19572444, y: 1.28721, z: 0.6648239, w: 2.2061932}
- {x: 0.21947557, y: 1.3257359, z: 0.77609164, w: 2.4756866}
- {x: 0.24394526, y: 1.366283, z: 0.90154845, w: 2.8049188}
- {x: 0.26917174, y: 1.4090004, z: 1.0444933, w: 3.2142754}
- {x: 0.29519582, y: 1.4540511, z: 1.2094214, w: 3.7345471}
- {x: 0.32206157, y: 1.5016141, z: 1.4026865, w: 4.414804}
- {x: 0.34981638, y: 1.5518863, z: 1.6337136, w: 5.3388963}
- {x: 0.37851152, y: 1.6050843, z: 1.9174361, w: 6.664067}
- {x: 0.4082022, y: 1.6614474, z: 2.2798493, w: 8.726039}
- {x: 0.4389485, y: 1.7212406, z: 2.773165, w: 12.396844}
- {x: 0.47081533, y: 1.7847576, z: 3.5315635, w: 20.874899}
- {x: 0.50387335, y: 1.8523251, z: 5.1754813, w: 62.957596}
- {x: 0.53819937, y: 1.9243073, z: 0, w: 1}
- {x: 0.5738774, y: 2.0011117, z: 0, w: 1}
- {x: 0.6109991, y: 2.0831954, z: 0, w: 1}
- {x: 0.64966506, y: 2.171073, z: 0, w: 1}
- {x: 0.6899858, y: 2.2653255, z: 0, w: 1}
- {x: 0.73208314, y: 2.3666131, z: 0, w: 1}
- {x: 0.77609164, y: 2.4756866, z: 0, w: 1}
- {x: 0.8221604, y: 2.5934057, z: 0, w: 1}
- {x: 0.87045586, y: 2.72076, z: 0, w: 1}
- {x: 0.92116255, y: 2.858892, z: 0, w: 1}
- {x: 0.9744887, y: 3.0091324, z: 0, w: 1}
- {x: 1.0306681, y: 3.1730397, z: 0, w: 1}
- {x: 1.0899659, y: 3.352452, z: 0, w: 1}
- {x: 1.1526828, y: 3.549553, z: 0, w: 1}
- {x: 1.2191633, y: 3.7669616, z: 0, w: 1}
- {x: 1.2898055, y: 4.007852, z: 0, w: 1}
- {x: 1.3650692, y: 4.2760997, z: 0, w: 1}
- {x: 1.4454945, y: 4.5765104, z: 0, w: 1}
- {x: 1.5317186, y: 4.9151063, z: 0, w: 1}
- {x: 1.6245029, y: 5.299552, z: 0, w: 1}
- {x: 1.7247669, y: 5.7397633, z: 0, w: 1}
- {x: 1.833638, y: 6.2488093, z: 0, w: 1}
- {x: 1.9525192, y: 6.844284, z: 0, w: 1}
- {x: 2.08319, y: 7.5504656, z: 0, w: 1}
- {x: 2.2279582, y: 8.40185, z: 0, w: 1}
- {x: 2.3898942, y: 9.449158, z: 0, w: 1}
- {x: 2.5732138, y: 10.770161, z: 0, w: 1}
- {x: 2.7839394, y: 12.49052, z: 0, w: 1}
- {x: 3.0311139, y: 14.827314, z: 0, w: 1}
- {x: 3.3292537, y: 18.190712, z: 0, w: 1}
- {x: 3.703911, y: 23.459646, z: 0, w: 1}
- {x: 4.2068715, y: 32.91969, z: 0, w: 1}
- {x: 4.9719396, y: 54.951633, z: 0, w: 1}
- {x: 6.6192675, y: 164.98349, z: 0, w: 1}
- {x: 0.009146384, y: 1.012251, z: 0.0241946, w: 1.0326511}
- {x: 0.02777937, y: 1.0375557, z: 0.07503051, w: 1.1038346}
- {x: 0.046882506, y: 1.0639853, z: 0.12946409, w: 1.1840003}
- {x: 0.06647699, y: 1.0916107, z: 0.18796092, w: 1.2747934}
- {x: 0.08658515, y: 1.1205076, z: 0.25107387, w: 1.3782597}
- {x: 0.107230894, y: 1.1507587, z: 0.31946534, w: 1.4969708}
- {x: 0.12843965, y: 1.1824534, z: 0.393936, w: 1.634197}
- {x: 0.15023857, y: 1.2156885, z: 0.47546333, w: 1.7941543}
- {x: 0.17265649, y: 1.2505691, z: 0.5652552, w: 1.9823642}
- {x: 0.19572444, y: 1.28721, z: 0.6648239, w: 2.2061932}
- {x: 0.21947557, y: 1.3257359, z: 0.77609164, w: 2.4756866}
- {x: 0.24394526, y: 1.366283, z: 0.90154845, w: 2.8049188}
- {x: 0.26917174, y: 1.4090004, z: 1.0444933, w: 3.2142754}
- {x: 0.29519582, y: 1.4540511, z: 1.2094214, w: 3.7345471}
- {x: 0.32206157, y: 1.5016141, z: 1.4026865, w: 4.414804}
- {x: 0.34981638, y: 1.5518863, z: 1.6337136, w: 5.3388963}
- {x: 0.37851152, y: 1.6050843, z: 1.9174361, w: 6.664067}
- {x: 0.4082022, y: 1.6614474, z: 2.2798493, w: 8.726039}
- {x: 0.4389485, y: 1.7212406, z: 2.773165, w: 12.396844}
- {x: 0.47081533, y: 1.7847576, z: 3.5315635, w: 20.874899}
- {x: 0.50387335, y: 1.8523251, z: 5.1754813, w: 62.957596}
- {x: 0.53819937, y: 1.9243073, z: 0, w: 1}
- {x: 0.5738774, y: 2.0011117, z: 0, w: 1}
- {x: 0.6109991, y: 2.0831954, z: 0, w: 1}
- {x: 0.64966506, y: 2.171073, z: 0, w: 1}
- {x: 0.6899858, y: 2.2653255, z: 0, w: 1}
- {x: 0.73208314, y: 2.3666131, z: 0, w: 1}
- {x: 0.77609164, y: 2.4756866, z: 0, w: 1}
- {x: 0.8221604, y: 2.5934057, z: 0, w: 1}
- {x: 0.87045586, y: 2.72076, z: 0, w: 1}
- {x: 0.92116255, y: 2.858892, z: 0, w: 1}
- {x: 0.9744887, y: 3.0091324, z: 0, w: 1}
- {x: 1.0306681, y: 3.1730397, z: 0, w: 1}
- {x: 1.0899659, y: 3.352452, z: 0, w: 1}
- {x: 1.1526828, y: 3.549553, z: 0, w: 1}
- {x: 1.2191633, y: 3.7669616, z: 0, w: 1}
- {x: 1.2898055, y: 4.007852, z: 0, w: 1}
- {x: 1.3650692, y: 4.2760997, z: 0, w: 1}
- {x: 1.4454945, y: 4.5765104, z: 0, w: 1}
- {x: 1.5317186, y: 4.9151063, z: 0, w: 1}
- {x: 1.6245029, y: 5.299552, z: 0, w: 1}
- {x: 1.7247669, y: 5.7397633, z: 0, w: 1}
- {x: 1.833638, y: 6.2488093, z: 0, w: 1}
- {x: 1.9525192, y: 6.844284, z: 0, w: 1}
- {x: 2.08319, y: 7.5504656, z: 0, w: 1}
- {x: 2.2279582, y: 8.40185, z: 0, w: 1}
- {x: 2.3898942, y: 9.449158, z: 0, w: 1}
- {x: 2.5732138, y: 10.770161, z: 0, w: 1}
- {x: 2.7839394, y: 12.49052, z: 0, w: 1}
- {x: 3.0311139, y: 14.827314, z: 0, w: 1}
- {x: 3.3292537, y: 18.190712, z: 0, w: 1}
- {x: 3.703911, y: 23.459646, z: 0, w: 1}
- {x: 4.2068715, y: 32.91969, z: 0, w: 1}
- {x: 4.9719396, y: 54.951633, z: 0, w: 1}
- {x: 6.6192675, y: 164.98349, z: 0, w: 1}
- {x: 0.013854082, y: 1.5332626, z: 0.036647703, w: 1.5641627}
- {x: 0.04207757, y: 1.5715919, z: 0.113649175, w: 1.671985}
- {x: 0.07101321, y: 1.611625, z: 0.19610003, w: 1.7934121}

- {x: 6.3721733, y: 49.863647, z: 0, w: 1}
- {x: 7.53103, y: 83.235695, z: 0, w: 1}
- {x: 10.026244, y: 249.90146, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0.009146384, y: 1.012251, z: 0.0241946, w: 1.0326511}
- {x: 0.02777937, y: 1.0375557, z: 0.07503051, w: 1.1038346}
- {x: 0.046882506, y: 1.0639853, z: 0.12946409, w: 1.1840003}
- {x: 0.06647699, y: 1.0916107, z: 0.18796092, w: 1.2747934}
- {x: 0.08658515, y: 1.1205076, z: 0.25107387, w: 1.3782597}
- {x: 0.107230894, y: 1.1507587, z: 0.31946534, w: 1.4969708}
- {x: 0.12843965, y: 1.1824534, z: 0.393936, w: 1.634197}
- {x: 0.15023857, y: 1.2156885, z: 0.47546333, w: 1.7941543}
- {x: 0.17265649, y: 1.2505691, z: 0.5652552, w: 1.9823642}
- {x: 0.19572444, y: 1.28721, z: 0.6648239, w: 2.2061932}
- {x: 0.21947557, y: 1.3257359, z: 0.77609164, w: 2.4756866}
- {x: 0.24394526, y: 1.366283, z: 0.90154845, w: 2.8049188}
- {x: 0.26917174, y: 1.4090004, z: 1.0444933, w: 3.2142754}
- {x: 0.29519582, y: 1.4540511, z: 1.2094214, w: 3.7345471}
- {x: 0.32206157, y: 1.5016141, z: 1.4026865, w: 4.414804}
- {x: 0.34981638, y: 1.5518863, z: 1.6337136, w: 5.3388963}
- {x: 0.37851152, y: 1.6050843, z: 1.9174361, w: 6.664067}
- {x: 0.4082022, y: 1.6614474, z: 2.2798493, w: 8.726039}
- {x: 0.4389485, y: 1.7212406, z: 2.773165, w: 12.396844}
- {x: 0.47081533, y: 1.7847576, z: 3.5315635, w: 20.874899}
- {x: 0.50387335, y: 1.8523251, z: 5.1754813, w: 62.957596}
- {x: 0.53819937, y: 1.9243073, z: 0, w: 1}
- {x: 0.5738774, y: 2.0011117, z: 0, w: 1}
- {x: 0.6109991, y: 2.0831954, z: 0, w: 1}
- {x: 0.64966506, y: 2.171073, z: 0, w: 1}
- {x: 0.6899858, y: 2.2653255, z: 0, w: 1}
- {x: 0.73208314, y: 2.3666131, z: 0, w: 1}
- {x: 0.77609164, y: 2.4756866, z: 0, w: 1}
- {x: 0.8221604, y: 2.5934057, z: 0, w: 1}
- {x: 0.87045586, y: 2.72076, z: 0, w: 1}
- {x: 0.92116255, y: 2.858892, z: 0, w: 1}
- {x: 0.9744887, y: 3.0091324, z: 0, w: 1}
- {x: 1.0306681, y: 3.1730397, z: 0, w: 1}
- {x: 1.0899659, y: 3.352452, z: 0, w: 1}
- {x: 1.1526828, y: 3.549553, z: 0, w: 1}
- {x: 1.2191633, y: 3.7669616, z: 0, w: 1}
- {x: 1.2898055, y: 4.007852, z: 0, w: 1}
- {x: 1.3650692, y: 4.2760997, z: 0, w: 1}
- {x: 1.4454945, y: 4.5765104, z: 0, w: 1}
- {x: 1.5317186, y: 4.9151063, z: 0, w: 1}
- {x: 1.6245029, y: 5.299552, z: 0, w: 1}
- {x: 1.7247669, y: 5.7397633, z: 0, w: 1}
- {x: 1.833638, y: 6.2488093, z: 0, w: 1}
- {x: 1.9525192, y: 6.844284, z: 0, w: 1}
- {x: 2.08319, y: 7.5504656, z: 0, w: 1}
- {x: 2.2279582, y: 8.40185, z: 0, w: 1}
- {x: 2.3898942, y: 9.449158, z: 0, w: 1}
- {x: 2.5732138, y: 10.770161, z: 0, w: 1}
- {x: 2.7839394, y: 12.49052, z: 0, w: 1}
- {x: 3.0311139, y: 14.827314, z: 0, w: 1}
- {x: 3.3292537, y: 18.190712, z: 0, w: 1}
- {x: 3.703911, y: 23.459646, z: 0, w: 1}
- {x: 4.2068715, y: 32.91969, z: 0, w: 1}
- {x: 4.9719396, y: 54.951633, z: 0, w: 1}
- {x: 6.6192675, y: 164.98349, z: 0, w: 1}
- {x: 0.009146384, y: 1.012251, z: 0.0241946, w: 1.0326511}
- {x: 0.02777937, y: 1.0375557, z: 0.07503051, w: 1.1038346}
- {x: 0.046882506, y: 1.0639853, z: 0.12946409, w: 1.1840003}
- {x: 0.06647699, y: 1.0916107, z: 0.18796092, w: 1.2747934}
- {x: 0.08658515, y: 1.1205076, z: 0.25107387, w: 1.3782597}
- {x: 0.107230894, y: 1.1507587, z: 0.31946534, w: 1.4969708}
- {x: 0.12843965, y: 1.1824534, z: 0.393936, w: 1.634197}
- {x: 0.15023857, y: 1.2156885, z: 0.47546333, w: 1.7941543}
- {x: 0.17265649, y: 1.2505691, z: 0.5652552, w: 1.9823642}
- {x: 0.19572444, y: 1.28721, z: 0.6648239, w: 2.2061932}
- {x: 0.21947557, y: 1.3257359, z: 0.77609164, w: 2.4756866}
- {x: 0.24394526, y: 1.366283, z: 0.90154845, w: 2.8049188}
- {x: 0.26917174, y: 1.4090004, z: 1.0444933, w: 3.2142754}
- {x: 0.29519582, y: 1.4540511, z: 1.2094214, w: 3.7345471}
- {x: 0.32206157, y: 1.5016141, z: 1.4026865, w: 4.414804}
- {x: 0.34981638, y: 1.5518863, z: 1.6337136, w: 5.3388963}
- {x: 0.37851152, y: 1.6050843, z: 1.9174361, w: 6.664067}
- {x: 0.4082022, y: 1.6614474, z: 2.2798493, w: 8.726039}
- {x: 0.4389485, y: 1.7212406, z: 2.773165, w: 12.396844}
- {x: 0.47081533, y: 1.7847576, z: 3.5315635, w: 20.874899}
- {x: 0.50387335, y: 1.8523251, z: 5.1754813, w: 62.957596}
- {x: 0.53819937, y: 1.9243073, z: 0, w: 1}
- {x: 0.5738774, y: 2.0011117, z: 0, w: 1}
- {x: 0.6109991, y: 2.0831954, z: 0, w: 1}
- {x: 0.64966506, y: 2.171073, z: 0, w: 1}
- {x: 0.6899858, y: 2.2653255, z: 0, w: 1}
- {x: 0.73208314, y: 2.3666131, z: 0, w: 1}
- {x: 0.77609164, y: 2.4756866, z: 0, w: 1}
- {x: 0.8221604, y: 2.5934057, z: 0, w: 1}
- {x: 0.87045586, y: 2.72076, z: 0, w: 1}
- {x: 0.92116255, y: 2.858892, z: 0, w: 1}
- {x: 0.9744887, y: 3.0091324, z: 0, w: 1}
- {x: 1.0306681, y: 3.1730397, z: 0, w: 1}
- {x: 1.0899659, y: 3.352452, z: 0, w: 1}
- {x: 1.1526828, y: 3.549553, z: 0, w: 1}
- {x: 1.2191633, y: 3.7669616, z: 0, w: 1}
- {x: 1.2898055, y: 4.007852, z: 0, w: 1}
- {x: 1.3650692, y: 4.2760997, z: 0, w: 1}
- {x: 1.4454945, y: 4.5765104, z: 0, w: 1}
- {x: 1.5317186, y: 4.9151063, z: 0, w: 1}
- {x: 1.6245029, y: 5.299552, z: 0, w: 1}
- {x: 1.7247669, y: 5.7397633, z: 0, w: 1}
- {x: 1.833638, y: 6.2488093, z: 0, w: 1}
- {x: 1.9525192, y: 6.844284, z: 0, w: 1}
- {x: 2.08319, y: 7.5504656, z: 0, w: 1}
- {x: 2.2279582, y: 8.40185, z: 0, w: 1}
- {x: 2.3898942, y: 9.449158, z: 0, w: 1}
- {x: 2.5732138, y: 10.770161, z: 0, w: 1}
- {x: 2.7839394, y: 12.49052, z: 0, w: 1}
- {x: 3.0311139, y: 14.827314, z: 0, w: 1}
- {x: 3.3292537, y: 18.190712, z: 0, w: 1}
- {x: 3.703911, y: 23.459646, z: 0, w: 1}
- {x: 4.2068715, y: 32.91969, z: 0, w: 1}
- {x: 4.9719396, y: 54.951633, z: 0, w: 1}
- {x: 6.6192675, y: 164.98349, z: 0, w: 1}
- {x: 0.009146384, y: 1.012251, z: 0.0241946, w: 1.0326511}
- {x: 0.02777937, y: 1.0375557, z: 0.07503051, w: 1.1038346}
- {x: 0.046882506, y: 1.0639853, z: 0.12946409, w: 1.1840003}
- {x: 0.06647699, y: 1.0916107, z: 0.18796092, w: 1.2747934}
- {x: 0.08658515, y: 1.1205076, z: 0.25107387, w: 1.3782597}
- {x: 0.107230894, y: 1.1507587, z: 0.31946534, w: 1.4969708}
- {x: 0.12843965, y: 1.1824534, z: 0.393936, w: 1.634197}
- {x: 0.15023857, y: 1.2156885, z: 0.47546333, w: 1.7941543}
- {x: 0.17265649, y: 1.2505691, z: 0.5652552, w: 1.9823642}
- {x: 0.19572444, y: 1.28721, z: 0.6648239, w: 2.2061932}
- {x: 0.21947557, y: 1.3257359, z: 0.77609164, w: 2.4756866}
- {x: 0.24394526, y: 1.366283, z: 0.90154845, w: 2.8049188}
- {x: 0.26917174, y: 1.4090004, z: 1.0444933, w: 3.2142754}
- {x: 0.29519582, y: 1.4540511, z: 1.2094214, w: 3.7345471}
- {x: 0.32206157, y: 1.5016141, z: 1.4026865, w: 4.414804}
- {x: 0.34981638, y: 1.5518863, z: 1.6337136, w: 5.3388963}
- {x: 0.37851152, y: 1.6050843, z: 1.9174361, w: 6.664067}
- {x: 0.4082022, y: 1.6614474, z: 2.2798493, w: 8.726039}
- {x: 0.4389485, y: 1.7212406, z: 2.773165, w: 12.396844}
- {x: 0.47081533, y: 1.7847576, z: 3.5315635, w: 20.874899}
- {x: 0.50387335, y: 1.8523251, z: 5.1754813, w: 62.957596}
- {x: 0.53819937, y: 1.9243073, z: 0, w: 1}
- {x: 0.5738774, y: 2.0011117, z: 0, w: 1}
- {x: 0.6109991, y: 2.0831954, z: 0, w: 1}
- {x: 0.64966506, y: 2.171073, z: 0, w: 1}
- {x: 0.6899858, y: 2.2653255, z: 0, w: 1}
- {x: 0.73208314, y: 2.3666131, z: 0, w: 1}
- {x: 0.77609164, y: 2.4756866, z: 0, w: 1}
- {x: 0.8221604, y: 2.5934057, z: 0, w: 1}
- {x: 0.87045586, y: 2.72076, z: 0, w: 1}
- {x: 0.92116255, y: 2.858892, z: 0, w: 1}
- {x: 0.9744887, y: 3.0091324, z: 0, w: 1}
- {x: 1.0306681, y: 3.1730397, z: 0, w: 1}
- {x: 1.0899659, y: 3.352452, z: 0, w: 1}
- {x: 1.1526828, y: 3.549553, z: 0, w: 1}
- {x: 1.2191633, y: 3.7669616, z: 0, w: 1}
- {x: 1.2898055, y: 4.007852, z: 0, w: 1}
- {x: 1.3650692, y: 4.2760997, z: 0, w: 1}
- {x: 1.4454945, y: 4.5765104, z: 0, w: 1}
- {x: 1.5317186, y: 4.9151063, z: 0, w: 1}
- {x: 1.6245029, y: 5.299552, z: 0, w: 1}
- {x: 1.7247669, y: 5.7397633, z: 0, w: 1}
- {x: 1.833638, y: 6.2488093, z: 0, w: 1}
- {x: 1.9525192, y: 6.844284, z: 0, w: 1}
- {x: 2.08319, y: 7.5504656, z: 0, w: 1}
- {x: 2.2279582, y: 8.40185, z: 0, w: 1}
- {x: 2.3898942, y: 9.449158, z: 0, w: 1}
- {x: 2.5732138, y: 10.770161, z: 0, w: 1}
- {x: 2.7839394, y: 12.49052, z: 0, w: 1}
- {x: 3.0311139, y: 14.827314, z: 0, w: 1}
- {x: 3.3292537, y: 18.190712, z: 0, w: 1}
- {x: 3.703911, y: 23.459646, z: 0, w: 1}
- {x: 4.2068715, y: 32.91969, z: 0, w: 1}
- {x: 4.9719396, y: 54.951633, z: 0, w: 1}
- {x: 6.6192675, y: 164.98349, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}

- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
- {x: 0, y: 1, z: 0, w: 1}
useDisneySSS: 1
useDisneySSS: 0
- {x: 2.4691355, y: 12.5, z: 12.5, w: 2.4691355}
- {x: 2.4691355, y: 2.4691355, z: 2.4691355, w: 2.4691355}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 0.5713599, y: 2.133362, z: 3.8963845, w: 0.5713599}
- {x: 0.5285655, y: 0.8427385, z: 2.1031168, w: 0.5285655}
- {x: 0.79028434, y: 0.6540282, z: 7.2735033, w: 0.6540282}
- {x: 31.999985, y: 0.61951655, z: 2.5774732, w: 0.5966356}
- {x: 0.6422222, y: 2.1390593, z: 3.6646283, w: 0.6422222}
- {x: 2.404222, y: 0.5, z: 3.459464, w: 0.5}
- {x: 0.93345416, y: 0.5, z: 5.9573803, w: 0.5}
- {x: 0.5, y: 1.125, z: 1.125, w: 2}
- {x: 0.125, y: 1.125, z: 1.125, w: 2}
- {x: 0.5, y: 0.5, z: 0.5, w: 2}
- {x: 0.125, y: 0.125, z: 0.125, w: 2}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 1, y: 1, z: 1, w: 1}
- {x: 0.050800785, y: 0.09028809, z: 0.14681427, w: 2.448}
- {x: 0.05242631, y: 2.4994626, z: 18, w: 1.552}
- {x: 0.051603947, y: 0.06494681, z: 0.179108, w: 1.6559999}
- {x: 0.045, y: 0.08528993, z: 0.19699885, w: 2.344}
- {x: 0.064044334, y: 0.045, z: 0.07269805, w: 1.152}
- {x: 0.07432745, y: 0.06635205, z: 18, w: 2.848}
- {x: 18, y: 0.070886634, z: 0.065182865, w: 2}
- {x: 1.1249995, y: 0.045, z: 18, w: 2}
- {x: 0.045, y: 0.07265123, z: 0.14409974, w: 2}
- {x: 0.076952666, y: 1.3899577, z: 1.3899577, w: 2}
- {x: 18, y: 0.045, z: 0.08918137, w: 2}
- {x: 0.060551997, y: 0.045, z: 18, w: 2}
- {x: 0.12430031, y: 0.045, z: 0.16055556, w: 2}
- {x: 0.060551997, y: 0.045, z: 18, w: 2}
- {x: 0.09090909, y: 0.21162307, z: 0.21162307, w: -0.000000048879357}
- {x: 0.09090909, y: 0.18990478, z: 0.18990478, w: -0.11381993}
- {x: 0.09090909, y: 0.13233659, z: 0.13233659, w: -0.23580086}
- {x: 0.09090909, y: 0.061445467, z: 0.061445467, w: -0.37865555}
- {x: 0.09090909, y: 0.010501689, z: 0.010501689, w: -0.57677805}
- {x: 0.09090909, y: 2.9458339e-10, z: 2.9458339e-10, w: -1.3907351}
- {x: 0.09090909, y: 0.18990476, z: 0.18990476, w: 0.11382001}
- {x: 0.09090909, y: 0.13233659, z: 0.13233659, w: 0.23580086}
- {x: 0.09090909, y: 0.061445467, z: 0.061445467, w: 0.37865555}
- {x: 0.09090909, y: 0.010501689, z: 0.010501689, w: 0.57677805}
- {x: 0.09090909, y: 2.9456845e-10, z: 2.9456845e-10, w: 1.3907368}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.000000048879357}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.11381993}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.23580086}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.37865555}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.57677805}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -1.3907351}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.11382001}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.23580086}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.37865555}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.57677805}
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 1.3907368}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 0.09090909, y: 0.3549372, z: 0.62032396, w: -0.00000010161156}
- {x: 0.09090909, y: 0.1394659, z: 0.0729, w: -0.23661155}
- {x: 0.09090909, y: 0.0741939, z: 0.059959605, w: -0.49018836}
- {x: 0.09090909, y: 0.062650315, z: 0.040111523, w: -0.787158}
- {x: 0.09090909, y: 0.044008475, z: 0.016855853, w: -1.1990197}
- {x: 0.09090909, y: 0.0022128348, z: 0.000010975074, w: -2.8910928}
- {x: 0.09090909, y: 0.13946578, z: 0.07289999, w: 0.23661171}
- {x: 0.09090909, y: 0.0741939, z: 0.059959605, w: 0.49018836}
- {x: 0.09090909, y: 0.062650315, z: 0.040111523, w: 0.787158}
- {x: 0.09090909, y: 0.044008475, z: 0.016855853, w: 1.1990197}
- {x: 0.09090909, y: 0.0022128152, z: 0.000010974841, w: 2.8910964}
- {x: 0.09090909, y: 0.12860332, z: 0.19932733, w: -0.00000010564491}
- {x: 0.09090909, y: 0.12606405, z: 0.18118364, w: -0.24600355}
- {x: 0.09090909, y: 0.11808681, z: 0.13236322, w: -0.50964576}
- {x: 0.09090909, y: 0.10336209, z: 0.06943409, w: -0.8184033}
- {x: 0.09090909, y: 0.07805614, z: 0.017355237, w: -1.2466133}
- {x: 0.09090909, y: 0.0101293055, z: 0.00000017975648, w: -3.005851}
- {x: 0.09090909, y: 0.12606405, z: 0.18118362, w: 0.24600372}
- {x: 0.09090909, y: 0.11808681, z: 0.13236322, w: 0.50964576}
- {x: 0.09090909, y: 0.10336209, z: 0.06943409, w: 0.8184033}
- {x: 0.09090909, y: 0.07805614, z: 0.017355237, w: 1.2466133}
- {x: 0.09090909, y: 0.010129253, z: 0.00000017975019, w: 3.0058548}
- {x: 0.108844265, y: 0.09090909, z: 0.83236396, w: -0.00000009497291}
- {x: 0.10822373, y: 0.09090909, z: 0.02077576, w: -0.22115286}
- {x: 0.10619134, y: 0.09090909, z: 0.020295212, w: -0.4581626}
- {x: 0.10205879, y: 0.09090909, z: 0.019414678, w: -0.7357302}
- {x: 0.09338251, y: 0.09090909, z: 0.017568886, w: -1.1206834}
- {x: 0.03572154, y: 0.09090909, z: 0.005763524, w: -2.7022073}
- {x: 0.10822373, y: 0.09090909, z: 0.020775758, w: 0.22115302}
- {x: 0.10619134, y: 0.09090909, z: 0.020295212, w: 0.4581626}
- {x: 0.10205879, y: 0.09090909, z: 0.019414678, w: 0.7357302}
- {x: 0.09338251, y: 0.09090909, z: 0.017568886, w: 1.1206834}
- {x: 0.03572142, y: 0.09090909, z: 0.0057635033, w: 2.7022104}
- {x: 0.80777204, y: 0.09359261, z: 0.68372005, w: -0.00000009943595}
- {x: 0.08547327, y: 0.0934052, z: 0.038611647, w: -0.23154545}
- {x: 0.010500608, y: 0.09280598, z: 0.03789803, w: -0.47969294}
- {x: 0.00014014184, y: 0.09165698, z: 0.036454275, w: -0.77030414}
- {x: 0.000000012631319, y: 0.08955232, z: 0.033336643, w: -1.1733475}
- {x: 5.7e-43, y: 0.0857832, z: 0.011839465, w: -2.8291914}
- {x: 0.08547319, y: 0.0934052, z: 0.038611654, w: 0.23154561}
- {x: 0.010500608, y: 0.09280598, z: 0.03789803, w: 0.47969294}
- {x: 0.00014014184, y: 0.09165698, z: 0.036454275, w: 0.77030414}
- {x: 0.000000012631319, y: 0.08955232, z: 0.033336643, w: 1.1733475}
- {x: 5.7e-43, y: 0.0857832, z: 0.011839423, w: 2.829195}
- {x: 0.09090909, y: 0.30021238, z: 0.32215917, w: -0.000000095841884}
- {x: 0.09090909, y: 0.17281094, z: 0.1919523, w: -0.22317633}
- {x: 0.09090909, y: 0.065019615, z: 0.0751061, w: -0.4623546}
- {x: 0.09090909, y: 0.052514445, z: 0.04762411, w: -0.7424618}
- {x: 0.09090909, y: 0.047544196, z: 0.024191903, w: -1.1309372}
- {x: 0.09090909, y: 0.012004702, z: 0.00004603639, w: -2.7269316}
- {x: 0.09090909, y: 0.1728108, z: 0.19195217, w: 0.22317648}
- {x: 0.09090909, y: 0.065019615, z: 0.0751061, w: 0.4623546}
- {x: 0.09090909, y: 0.052514445, z: 0.04762411, w: 0.7424618}
- {x: 0.09090909, y: 0.047544196, z: 0.024191903, w: 1.1309372}
- {x: 0.09090909, y: 0.012004641, z: 0.000046035475, w: 2.726935}
- {x: 0.70741075, y: 0.09090909, z: 0.7167323, w: -0.000000108620796}
- {x: 0.03835611, y: 0.09090909, z: 0.045676768, w: -0.25293317}
- {x: 0.036983497, y: 0.09090909, z: 0.041188624, w: -0.5240019}
- {x: 0.034314502, y: 0.09090909, z: 0.03329373, w: -0.8414567}
- {x: 0.029196186, y: 0.09090909, z: 0.021041194, w: -1.2817289}
- {x: 0.007444311, y: 0.09090909, z: 0.0004335138, w: -3.0905223}
- {x: 0.03835611, y: 0.09090909, z: 0.045676757, w: 0.25293335}
- {x: 0.036983497, y: 0.09090909, z: 0.041188624, w: 0.5240019}
- {x: 0.034314502, y: 0.09090909, z: 0.03329373, w: 0.8414567}
- {x: 0.029196186, y: 0.09090909, z: 0.021041194, w: 1.2817289}
- {x: 0.007444282, y: 0.09090909, z: 0.00043350866, w: 3.090526}
- {x: 0.14188822, y: 0.09090909, z: 0.7295173, w: -0.000000108620796}
- {x: 0.13666683, y: 0.09090909, z: 0.05799081, w: -0.25293317}
- {x: 0.121228255, y: 0.09090909, z: 0.04424968, w: -0.5240019}
- {x: 0.096386485, y: 0.09090909, z: 0.025363024, w: -0.8414567}
- {x: 0.06356, y: 0.09090909, z: 0.007637588, w: -1.2817289}
- {x: 0.011214385, y: 0.09090909, z: 0.00000029721932, w: -3.0905223}
- {x: 0.13666683, y: 0.09090909, z: 0.05799081, w: 0.25293335}
- {x: 0.121228255, y: 0.09090909, z: 0.04424968, w: 0.5240019}
- {x: 0.096386485, y: 0.09090909, z: 0.025363024, w: 0.8414567}
- {x: 0.06356, y: 0.09090909, z: 0.007637588, w: 1.2817289}
- {x: 0.01121434, y: 0.09090909, z: 0.00000029721042, w: 3.090526}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}
- {x: 1, y: 1, z: 1, w: 0}

- {x: 1, y: 1, z: 1, w: 0}
tileSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightEvaluation: 0
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableClustered: 1

specularGlobalDimmer: 1
shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasWidth: 8192
spotCookieSize: 128
spotCookieSize: 512
pointCookieSize: 512
reflectionCubemapSize: 128
m_DefaultDiffuseMaterial: {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17,

6
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs


public class HDRenderPipelineAsset : RenderPipelineAsset
{
#if UNITY_EDITOR
const string k_HDRenderPipelinePath = "Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset";
AssetDatabase.CreateAsset(instance, Utilities.GetHDRenderPipelinePath() + "HDRenderPipelineAsset.asset");
AssetDatabase.CreateAsset(instance, k_HDRenderPipelinePath);
instance.renderPipelineResources = AssetDatabase.LoadAssetAtPath<RenderPipelineResources>(RenderPipelineResources.GetRenderPipelineResourcesPath());
instance.renderPipelineResources = AssetDatabase.LoadAssetAtPath<RenderPipelineResources>(RenderPipelineResources.renderPipelineResourcesPath);
}
#endif

14
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs


Line, // Keep Line lights before Rectangle. This is needed because of a compiler bug (see LightLoop.hlsl)
Rectangle,
// Currently not supported in real time (just use for reference)
// Sphere,
// Disk,
Sphere,
Disk,
Hemisphere,
Cylinder
};
// These structures share between C# and hlsl need to be align on float4, so we pad them.

public Vector3 forward;
public int cookieIndex; // -1 if unused
public Vector3 right; // Rescaled by (2 / shapeLenght)
public Vector3 right; // Rescaled by (2 / lightLength)
public Vector3 up; // Rescaled by (2 / shapeWidth)
public Vector3 up; // Rescaled by (2 / lightWidth)
public float diffuseScale;
};

public Vector3 forward;
public int cookieIndex; // -1 if unused
public Vector3 right; // If spot: rescaled by cot(outerHalfAngle); if projector: rescaled by (2 / shapeLenght)
public Vector3 right; // If spot: rescaled by cot(outerHalfAngle); if projector: rescaled by (2 / lightLength)
public Vector3 up; // If spot: rescaled by cot(outerHalfAngle); if projector: rescaled by * (2 / shapeWidth)
public Vector3 up; // If spot: rescaled by cot(outerHalfAngle); if projector: rescaled by * (2 / lightWidth)
public float diffuseScale;
public float angleScale; // Spot light

6
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs. Please don't edit by hand.
//
#ifndef LIGHTDEFINITION_CS_HLSL

#define GPULIGHTTYPE_PROJECTOR_PYRAMID (4)
#define GPULIGHTTYPE_LINE (5)
#define GPULIGHTTYPE_RECTANGLE (6)
#define GPULIGHTTYPE_SPHERE (7)
#define GPULIGHTTYPE_DISK (8)
#define GPULIGHTTYPE_HEMISPHERE (9)
#define GPULIGHTTYPE_CYLINDER (10)
//
// UnityEngine.Experimental.Rendering.HDPipeline.EnvShapeType: static fields

10
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute


#pragma kernel Deferred_Indirect_Fptl_Variant24 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant24 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=24
#pragma kernel Deferred_Indirect_Fptl_Variant25 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant25 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=25
#pragma kernel Deferred_Indirect_Fptl_Variant26 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant26 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=26
#pragma kernel Deferred_Indirect_Fptl_Variant27 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant27 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=27
#pragma kernel Deferred_Indirect_Fptl_Variant28 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant28 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=28
#pragma kernel Deferred_Indirect_Fptl_Variant29 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant29 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=29
#pragma kernel Deferred_Indirect_Fptl_Variant30 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant30 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=30
/* Tag: SUPPORT_COMPUTE_CLUSTER_OPAQUE - Uncomment this if you want to do cluster opaque with compute shader (by default we support only fptl on opaque)
#pragma kernel Deferred_Indirect_Clustered_Variant0 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant0 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=0

#pragma kernel Deferred_Indirect_Clustered_Variant24 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant24 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=24
#pragma kernel Deferred_Indirect_Clustered_Variant25 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant25 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=25
#pragma kernel Deferred_Indirect_Clustered_Variant26 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant26 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=26
#pragma kernel Deferred_Indirect_Clustered_Variant27 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant27 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=27
#pragma kernel Deferred_Indirect_Clustered_Variant28 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant28 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=28
#pragma kernel Deferred_Indirect_Clustered_Variant29 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant29 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=29
#pragma kernel Deferred_Indirect_Clustered_Variant30 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant30 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=30
*/
#define LIGHTLOOP_TILE_PASS 1

float3 specularLighting;
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting);
if (_EnableSSSAndTransmission != 0 && bsdfData.materialId == MATERIALID_LIT_SSS && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_SSS))
if (_EnableSSSAndTransmission != 0 && bsdfData.materialId == MATERIALID_LIT_SSS)
{
// We SSSSS is enabled with use split lighting.
// SSSSS algorithm need to know which pixels contribute to SSS and which doesn't. We could use the stencil for that but it mean that it will increase the cost of SSSSS

20
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl


vE0 = p1-p0;
}
void GetHullQuad(out float3 p0, out float3 p1, out float3 p2, out float3 p3, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex)
void GetQuad(out float3 p0, out float3 p1, out float3 p2, out float3 p3, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex)
{
//const int iAbsSide = (sideIndex == 0 || sideIndex == 1) ? 0 : ((sideIndex == 2 || sideIndex == 3) ? 1 : 2);
const int iAbsSide = min(sideIndex>>1, 2);

p3 = center + (vA2 + vB2 + vC);
}
void GetHullPlane(out float3 p0, out float3 n0, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex)
void GetPlane(out float3 p0, out float3 vN, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex)
{
//const int iAbsSide = (sideIndex == 0 || sideIndex == 1) ? 0 : ((sideIndex == 2 || sideIndex == 3) ? 1 : 2);
const int iAbsSide = min(sideIndex>>1, 2);

if (bIsSideQuad) { vA2 *= (iAbsSide == 0 ? scaleXY.x : scaleXY.y); vB2 *= (iAbsSide == 0 ? scaleXY.y : scaleXY.x); }
float3 vN = cross(vB2, 0.5 * (vA - vA2) - vC); // +/- normal
float3 v0 = vA + vB - vC; // vector from center to p0
p0 = center + v0; // center + vA is center of face when scaleXY is 1.0
n0 = dot(vN,v0) < 0.0 ? (-vN) : vN;
p0 = center + (vA + vB - vC); // center + vA is center of face when scaleXY is 1.0
float3 vNout = cross( vB2, 0.5*(vA-vA2) - vC );
#if USE_LEFT_HAND_CAMERA_SPACE
vNout = -vNout;
#endif
vN = vNout;
float4 GetHullPlaneEq(const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex)
float4 GetPlaneEq(const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex)
GetHullPlane(p0, vN, boxX, boxY, boxZ, center, scaleXY, sideIndex);
GetPlane(p0, vN, boxX, boxY, boxZ, center, scaleXY, sideIndex);
return float4(vN, -dot(vN,p0));
}

3
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ShadowContext.hlsl


#define SHADOWCONTEXT_MAX_SAMPLER 3
#define SHADOWCONTEXT_MAX_COMPSAMPLER 1
#undef SHADOW_OPTIMIZE_REGISTER_USAGE
#define SHADOW_OPTIMIZE_REGISTER_USAGE 1
SHADOWCONTEXT_DECLARE( SHADOWCONTEXT_MAX_TEX2DARRAY, SHADOWCONTEXT_MAX_TEXCUBEARRAY, SHADOWCONTEXT_MAX_COMPSAMPLER, SHADOWCONTEXT_MAX_SAMPLER );
TEXTURE2D_ARRAY(_ShadowmapExp_VSM_0);

25
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ShadowDispatch.hlsl


// and that on the C# side the shadowContext bindDelegate binds the correct resource to the correct texture id.
#define SHADOW_DISPATCH_USE_CUSTOM_DIRECTIONAL // enables hardcoded resources and algorithm for directional lights
#define SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL // enables hardcoded resources and algorithm for punctual lights
//#define SHADOW_DISPATCH_USE_SEPARATE_CASCADE_ALGOS // enables separate cascade sampling variants for each cascade
//#define SHADOW_DISPATCH_USE_SEPARATE_PUNC_ALGOS // enables separate resources and algorithms for spot and point lights
#define SHADOW_DISPATCH_USE_CUSTOM_DIRECTIONAL // enables hardcoded resources and algorithm for directional lights
#define SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL // enables hardcoded resources and algorithm for punctual lights
//#define SHADOW_DISPATCH_USE_SEPARATE_PUNC_ALGOS // enables separate resources and algorithms for spot and point lights
#define SHADOW_DISPATCH_DIR_ALG GPUSHADOWALGORITHM_PCF_TENT_5X5 // all cascades
#define SHADOW_DISPATCH_DIR_ALG_0 GPUSHADOWALGORITHM_PCF_TENT_7X7 // 1st cascade
#define SHADOW_DISPATCH_DIR_ALG_1 GPUSHADOWALGORITHM_PCF_TENT_5X5 // 2nd cascade
#define SHADOW_DISPATCH_DIR_ALG_2 GPUSHADOWALGORITHM_PCF_TENT_3X3 // 3rd cascade
#define SHADOW_DISPATCH_DIR_ALG_3 GPUSHADOWALGORITHM_PCF_1TAP // 4th cascade
#define SHADOW_DISPATCH_DIR_ALG GPUSHADOWALGORITHM_PCF_TENT_7X7
// point
#define SHADOW_DISPATCH_POINT_TEX 3
#define SHADOW_DISPATCH_POINT_SMP 0

//punctual
#define SHADOW_DISPATCH_PUNC_TEX 3
#define SHADOW_DISPATCH_PUNC_SMP 0
#define SHADOW_DISPATCH_PUNC_ALG GPUSHADOWALGORITHM_PCF_9TAP
#define SHADOW_DISPATCH_PUNC_ALG GPUSHADOWALGORITHM_PCF_TENT_7X7
// example of overriding directional lights
#ifdef SHADOW_DISPATCH_USE_CUSTOM_DIRECTIONAL

SamplerComparisonState compSamp = shadowContext.compSamplers[SHADOW_DISPATCH_DIR_SMP];
#ifdef SHADOW_DISPATCH_USE_SEPARATE_CASCADE_ALGOS
uint algo[kMaxShadowCascades] = { SHADOW_DISPATCH_DIR_ALG_0, SHADOW_DISPATCH_DIR_ALG_1, SHADOW_DISPATCH_DIR_ALG_2, SHADOW_DISPATCH_DIR_ALG_3 };
#else
uint algo = SHADOW_DISPATCH_DIR_ALG;
#endif
uint algo = SHADOW_DISPATCH_DIR_ALG;
return EvalShadow_CascadedDepth_Blend( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, L );
}

#undef SHADOW_DISPATCH_DIR_TEX
#undef SHADOW_DISPATCH_DIR_SMP
#undef SHADOW_DISPATCH_DIR_ALG
#undef SHADOW_DISPATCH_DIR_ALG_0
#undef SHADOW_DISPATCH_DIR_ALG_1
#undef SHADOW_DISPATCH_DIR_ALG_2
#undef SHADOW_DISPATCH_DIR_ALG_3
#undef SHADOW_DISPATCH_POINT_TEX
#undef SHADOW_DISPATCH_POINT_SMP
#undef SHADOW_DISPATCH_POINT_ALG

188
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


GPUShadowType shadowType = GPUShadowType.Unknown;
switch (ald.lightTypeExtent)
switch (ald.archetype)
case LightTypeExtent.Punctual:
case LightArchetype.Punctual:
// Area and projector not supported yet
}

public static int s_TileSizeClustered = 32;
// feature variants
public static int s_NumFeatureVariants = 27;
public static int s_NumFeatureVariants = 31;
// Following define the maximum number of bits use in each feature category.
public static uint s_LightFeatureMaskFlags = 0xFF00;

static Texture2DArray m_DefaultTexture2DArray;
TextureCacheCubemap m_CubeReflTexArray;
int m_CubeReflTexArraySize = 128;
int m_CookieTexArraySize = 16;
int m_CubeCookieTexArraySize = 16;
public class LightList
{

private ComputeShader buildDispatchIndirectShader { get { return m_Resources.buildDispatchIndirectShader; } }
private ComputeShader clearDispatchIndirectShader { get { return m_Resources.clearDispatchIndirectShader; } }
private ComputeShader deferredComputeShader { get { return m_Resources.deferredComputeShader; } }
private ComputeShader deferredDirectionalShadowComputeShader { get { return m_Resources.deferredDirectionalShadowComputeShader; } }
static int s_GenAABBKernel;
static int s_GenListPerTileKernel;

//static int[] s_shadeOpaqueIndirectClusteredKernels = new int[LightDefinitions.s_NumFeatureVariants];
static int[] s_shadeOpaqueIndirectFptlKernels = new int[LightDefinitions.s_NumFeatureVariants];
static int s_deferredDirectionalShadowKernel;
static ComputeBuffer s_LightVolumeDataBuffer = null;
static ComputeBuffer s_ConvexBoundsBuffer = null;
static ComputeBuffer s_AABBBoundsBuffer = null;

static ComputeBuffer s_GlobalLightListAtomic = null;
// clustered light list specific buffers and data end
private static GameObject s_DefaultAdditionalLightDataGameObject;
private static HDAdditionalLightData s_DefaultAdditionalLightData;
bool usingFptl
{
get

}
}
private static HDAdditionalLightData DefaultAdditionalLightData
{
get
{
if (s_DefaultAdditionalLightDataGameObject == null)
{
s_DefaultAdditionalLightDataGameObject = new GameObject("Default Light Data");
s_DefaultAdditionalLightDataGameObject.hideFlags = HideFlags.HideAndDontSave;
s_DefaultAdditionalLightData = s_DefaultAdditionalLightDataGameObject.AddComponent<HDAdditionalLightData>();
s_DefaultAdditionalLightDataGameObject.SetActive(false);
}
return s_DefaultAdditionalLightData;
}
}
Material m_DeferredAllMaterialSRT = null;
Material m_DeferredAllMaterialMRT = null;

Material m_SingleDeferredMaterialMRT = null;
Light m_CurrentSunLight = null;
int m_CurrentSunLightShadowIndex = -1;
public Light GetCurrentSunLight() { return m_CurrentSunLight; }
// shadow related stuff

s_shadowDatas = new ComputeBuffer(k_MaxCascadeCount + k_MaxShadowOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(ShadowData)));
m_CookieTexArray = new TextureCache2D();
m_CookieTexArray.AllocTextureArray(m_CookieTexArraySize, textureSettings.spotCookieSize, textureSettings.spotCookieSize, TextureFormat.RGBA32, true);
m_CookieTexArray.AllocTextureArray(8, textureSettings.spotCookieSize, textureSettings.spotCookieSize, TextureFormat.RGBA32, true);
m_CubeCookieTexArray.AllocTextureArray(m_CubeCookieTexArraySize, textureSettings.pointCookieSize, TextureFormat.RGBA32, true);
m_CubeCookieTexArray.AllocTextureArray(4, textureSettings.pointCookieSize, TextureFormat.RGBA32, true);
m_CubeReflTexArray.AllocTextureArray(m_CubeReflTexArraySize, textureSettings.reflectionCubemapSize, TextureCache.GetPreferredHdrCompressedTextureFormat, true);
m_CubeReflTexArray.AllocTextureArray(32, textureSettings.reflectionCubemapSize, TextureCache.GetPreferredHdrCompressedTextureFormat, true);
s_GenAABBKernel = buildScreenAABBShader.FindKernel("ScreenBoundsAABB");

s_shadeOpaqueDirectFptlKernel = deferredComputeShader.FindKernel("Deferred_Direct_Fptl");
s_shadeOpaqueDirectClusteredDebugDisplayKernel = deferredComputeShader.FindKernel("Deferred_Direct_Clustered_DebugDisplay");
s_shadeOpaqueDirectFptlDebugDisplayKernel = deferredComputeShader.FindKernel("Deferred_Direct_Fptl_DebugDisplay");
s_deferredDirectionalShadowKernel = deferredDirectionalShadowComputeShader.FindKernel("DeferredDirectionalShadow");
for (int variant = 0; variant < LightDefinitions.s_NumFeatureVariants; variant++)
{

Utilities.Destroy(m_SingleDeferredMaterialSRT);
Utilities.Destroy(m_SingleDeferredMaterialMRT);
Utilities.Destroy(s_DefaultAdditionalLightDataGameObject);
s_DefaultAdditionalLightDataGameObject = null;
s_DefaultAdditionalLightData = null;
}
public void NewFrame()

// Light direction for directional is opposite to the forward direction
directionalLightData.forward = light.light.transform.forward;
// Rescale for cookies and windowing.
directionalLightData.up = light.light.transform.up * 2 / additionalData.shapeWidth;
directionalLightData.right = light.light.transform.right * 2 / additionalData.shapeLength;
directionalLightData.up = light.light.transform.up * 2 / additionalData.lightWidth;
directionalLightData.right = light.light.transform.right * 2 / additionalData.lightLength;
directionalLightData.positionWS = light.light.transform.position;
directionalLightData.color = GetLightColor(light);
directionalLightData.diffuseScale = additionalData.affectDiffuse ? diffuseDimmer : 0.0f;

{
directionalLightData.shadowIndex = shadowIdx;
m_CurrentSunLight = light.light;
m_CurrentSunLightShadowIndex = shadowIdx;
}
m_CurrentSunLight = m_CurrentSunLight == null ? light.light : m_CurrentSunLight;

lightData.up = light.light.transform.up;
lightData.right = light.light.transform.right;
lightData.size = new Vector2(additionalLightData.shapeLength, additionalLightData.shapeWidth);
lightData.size = new Vector2(additionalLightData.lightLength, additionalLightData.lightWidth);
lightData.right *= 2 / additionalLightData.shapeLength;
lightData.up *= 2 / additionalLightData.shapeWidth;
lightData.right *= 2 / additionalLightData.lightLength;
lightData.up *= 2 / additionalLightData.lightWidth;
}
if (lightData.lightType == GPULightType.Spot)

}
else if (gpuLightType == GPULightType.Point)
{
bool isNegDeterminant = Vector3.Dot(worldToView.GetColumn(0), Vector3.Cross(worldToView.GetColumn(1), worldToView.GetColumn(2))) < 0.0f; // 3x3 Determinant.
bound.center = positionVS;
bound.boxAxisX.Set(range, 0, 0);
bound.boxAxisY.Set(0, range, 0);
bound.boxAxisZ.Set(0, 0, isNegDeterminant ? (-range) : range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = range;
// represents a left hand coordinate system in world space since det(worldToView)<0
bound.center = positionVS;
bound.boxAxisX = vx * range;
bound.boxAxisY = vy * range;
bound.boxAxisZ = vz * range;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = range;
// fill up ldata
lightVolumeData.lightAxisX = vx;
lightVolumeData.lightAxisY = vy;

// We only process light with additional data
var additionalData = light.light.GetComponent<HDAdditionalLightData>();
// Debug.Assert(additionalData == null, "Missing HDAdditionalData on a light - Should have been create by HDLightEditor");
return;
additionalData = DefaultAdditionalLightData;
if (additionalData.lightTypeExtent == LightTypeExtent.Punctual)
// Note: LightType.Area is offline only, use for baking, no need to test it
if (additionalData.archetype == LightArchetype.Punctual)
case LightType.Point:
if (punctualLightcount >= k_MaxPunctualLightsOnScreen)
continue;
gpuLightType = GPULightType.Point;
lightVolumeType = LightVolumeType.Sphere;
break;
case LightType.Spot:
if (punctualLightcount >= k_MaxPunctualLightsOnScreen)
continue;

lightVolumeType = LightVolumeType.Count; // Count is none
break;
case LightType.Point:
if (punctualLightcount >= k_MaxPunctualLightsOnScreen)
continue;
gpuLightType = GPULightType.Point;
lightVolumeType = LightVolumeType.Sphere;
break;
else
else // LightArchetype.Area
lightCategory = LightCategory.Area;
switch (additionalData.lightTypeExtent)
{
case LightTypeExtent.Rectangle:
if (areaLightCount >= k_MaxAreaLightsOnScreen)
continue;
gpuLightType = GPULightType.Rectangle;
lightVolumeType = LightVolumeType.Box;
break;
case LightTypeExtent.Line:
if (areaLightCount >= k_MaxAreaLightsOnScreen)
continue;
gpuLightType = GPULightType.Line;
lightVolumeType = LightVolumeType.Box;
break;
default:
Debug.Assert(false, "Encountered an unknown LightType.");
break;
}
if (areaLightCount >= k_MaxAreaLightsOnScreen) { continue; }
lightCategory = LightCategory.Area;
gpuLightType = (additionalData.lightWidth > 0) ? GPULightType.Rectangle : GPULightType.Line;
lightVolumeType = LightVolumeType.Box;
}
uint shadow = m_ShadowIndices.ContainsKey(lightIndex) ? 1u : 0;

// The lightLoop is in charge, not the shadow pass.
// For now we will still apply the maximum of shadow here but we don't apply the sorting by priority + slot allocation yet
m_CurrentSunLight = null;
m_CurrentSunLightShadowIndex = -1;
// 2. Go through all lights, convert them to GPU format.
// Create simultaneously data for culling (LigthVolumeData and rendering)

int lightIndex = (int)(sortKey & 0xFFFF);
var light = cullResults.visibleLights[lightIndex];
var additionalLightData = light.light.GetComponent<HDAdditionalLightData>();
var additionalLightData = light.light.GetComponent<HDAdditionalLightData>() ?? DefaultAdditionalLightData;
var additionalShadowData = light.light.GetComponent<AdditionalShadowData>(); // Can be null
// Directional rendering side, it is separated as it is always visible so no volume to handle here

if (probe.texture == null || envLightCount >= k_MaxEnvLightsOnScreen)
continue;
// Work around the culling issues. TODO: fix culling in C++.
if (probe.probe == null || !probe.probe.isActiveAndEnabled)
continue;
// Work around the data issues.
if (probe.localToWorld.determinant == 0)
{
Debug.LogError("Reflection probe " + probe.probe.name + " has an invalid local frame and needs to be fixed.");
continue;
}
// TODO: Support LightVolumeType.Sphere, currently in UI there is no way to specify a sphere influence volume
LightVolumeType lightVolumeType = probe.boxProjection != 0 ? LightVolumeType.Box : LightVolumeType.Box;
++envLightCount;

public void BuildGPULightLists(Camera camera, CommandBuffer cmd, RenderTargetIdentifier cameraDepthBufferRT, RenderTargetIdentifier stencilTextureRT)
{
cmd.BeginSample("Build Light List");
var w = camera.pixelWidth;
var h = camera.pixelHeight;
var numBigTilesX = (w + 63) / 64;

if (enableFeatureVariants)
{
// material classification
if (m_TileSettings.enableComputeMaterialVariants)
if(m_TileSettings.enableComputeMaterialVariants)
{
int buildMaterialFlagsKernel = s_BuildMaterialFlagsOrKernel;

cmd.SetComputeIntParam(buildDispatchIndirectShader, HDShaderIDs.g_NumTilesX, numTilesX);
cmd.DispatchCompute(buildDispatchIndirectShader, s_BuildDispatchIndirectKernel, (numTiles + 63) / 64, 1, 1);
}
cmd.EndSample("Build Light List");
}
// This is a workaround for global properties not being accessible from compute.

public bool volumetricLightingEnabled;
}
public void RenderDeferredDirectionalShadow(HDCamera hdCamera, RenderTargetIdentifier deferredShadowRT, RenderTargetIdentifier depthTexture, CommandBuffer cmd)
{
if (m_CurrentSunLight == null)
return;
using (new Utilities.ProfilingSample("Deferred Directional", cmd))
{
hdCamera.SetupComputeShader(deferredDirectionalShadowComputeShader, cmd);
m_ShadowMgr.BindResources(cmd, deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel);
cmd.SetComputeFloatParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalShadowIndex, (float)m_CurrentSunLightShadowIndex);
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, HDShaderIDs._DeferredShadowTextureUAV, deferredShadowRT);
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, HDShaderIDs._MainDepthTexture, depthTexture);
int deferredShadowTileSize = 16; // Must match DeferreDirectionalShadow.compute
int numTilesX = (hdCamera.camera.pixelWidth + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
int numTilesY = (hdCamera.camera.pixelHeight + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
cmd.DispatchCompute(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, numTilesX, numTilesY, 1);
}
}
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthStencilBuffer, RenderTargetIdentifier depthTexture, RenderTargetIdentifier deferredShadowTexture,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthStencilBuffer, RenderTargetIdentifier depthTexture,
LightingPassOptions options)
{
var bUseClusteredForDeferred = !usingFptl;

Texture ltcGGXMatrix = Shader.GetGlobalTexture(HDShaderIDs._LtcGGXMatrix);
Texture ltcDisneyDiffuseMatrix = Shader.GetGlobalTexture(HDShaderIDs._LtcDisneyDiffuseMatrix);
Texture ltcMultiGGXFresnelDisneyDiffuse = Shader.GetGlobalTexture(HDShaderIDs._LtcMultiGGXFresnelDisneyDiffuse);
Texture gBufferTexture0 = Shader.GetGlobalTexture(HDShaderIDs._GBufferTexture0);
Texture gBufferTexture1 = Shader.GetGlobalTexture(HDShaderIDs._GBufferTexture1);
Texture gBufferTexture2 = Shader.GetGlobalTexture(HDShaderIDs._GBufferTexture2);
Texture gBufferTexture3 = Shader.GetGlobalTexture(HDShaderIDs._GBufferTexture3);
Texture ambientOcclusionTexture = Shader.GetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture);
Matrix4x4 invScrProjection = Shader.GetGlobalMatrix(HDShaderIDs.g_mInvScrProjection);
int useTileLightList = Shader.GetGlobalInt(HDShaderIDs._UseTileLightList);

cmd.SetComputeBufferParam(deferredComputeShader, kernel, HDShaderIDs.g_vLightListGlobal, bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._DeferredShadowTexture, deferredShadowTexture);
// TODO: Don't know why but If we use Shader.GetGlobalTexture(HDShaderIDs._GBufferTexture0) instead of HDShaderIDs._GBufferTexture0 the screen start to flicker in SceneView...
// Need to investigate what is happening. But this may be unnecessary as development of SetGlobalTexture for compute shader have begin
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture0, HDShaderIDs._GBufferTexture0);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture1, HDShaderIDs._GBufferTexture1);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture2, HDShaderIDs._GBufferTexture2);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture3, HDShaderIDs._GBufferTexture3);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._AmbientOcclusionTexture, HDShaderIDs._AmbientOcclusionTexture);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture0, gBufferTexture0);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture1, gBufferTexture1);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture2, gBufferTexture2);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._GBufferTexture3, gBufferTexture3);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._AmbientOcclusionTexture, ambientOcclusionTexture);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._LtcData, ltcData);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._PreIntegratedFGD, preIntegratedFGD);

4
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs. Please don't edit by hand.
//
#ifndef TILEPASS_CS_HLSL

#define USE_LEFT_HAND_CAMERA_SPACE (1)
#define TILE_SIZE_FPTL (16)
#define TILE_SIZE_CLUSTERED (32)
#define NUM_FEATURE_VARIANTS (27)
#define NUM_FEATURE_VARIANTS (31)
#define LIGHT_FEATURE_MASK_FLAGS (65280)
#define MATERIAL_FEATURE_MASK_FLAGS (255)

2
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl


TEXTURE2D(_AmbientOcclusionTexture);
TEXTURE2D(_DeferredShadowTexture);
CBUFFER_START(UnityPerLightLoop)
uint _DirectionalLightCount;
uint _PunctualLightCount;

5
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/builddispatchindirect.compute


uint tileY = (dispatchThreadId + 0.5f) / (float)g_NumTilesX; // Integer division is extremely expensive, so we better avoid it
uint tileX = dispatchThreadId - tileY * g_NumTilesX;
// Check if there is no material (means it is a sky/background pixel).
// Note that we can have no lights, yet we still need to render geometry with precomputed illumination.
if ((featureFlags & MATERIAL_FEATURE_MASK_FLAGS) != 0)
// Check if there is no light or no material (mean we are sky/background pixel) / Both test as we can enable/disable light/material classification
if ((featureFlags & LIGHT_FEATURE_MASK_FLAGS) != 0 && (featureFlags & MATERIAL_FEATURE_MASK_FLAGS) != 0)
{
uint variant = FeatureFlagsToTileVariant(featureFlags);
uint offset;

2
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-clustered.compute


const float radius = lgtDat.radius;
const float2 scaleXY = lgtDat.scaleXY;
return GetHullPlaneEq(boxX, boxY, boxZ, center, scaleXY, p);
return GetPlaneEq(boxX, boxY, boxZ, center, scaleXY, p);
}

6
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/scrbound.compute


if(sideIndex<6 && lgtIndex<(int) g_iNrVisibLights) // mask 2 out of 8 threads
{
float3 q0, q1, q2, q3;
GetHullQuad(q0, q1, q2, q3, boxX, boxY, boxZ, center, scaleXY, sideIndex);
GetQuad(q0, q1, q2, q3, boxX, boxY, boxZ, center, scaleXY, sideIndex);
const float4 vP0 = mul(g_mProjection, float4(q0, 1));

for(f=0; f<6; f++)
{
float3 q0, q1, q2, q3;
GetHullQuad(q0, q1, q2, q3, boxX, boxY, boxZ, center, scaleXY, f);
GetQuad(q0, q1, q2, q3, boxX, boxY, boxZ, center, scaleXY, f);
// 4 vertices to a quad of the convex hull in post projection space
const float4 vP0 = mul(g_mProjection, float4(q0, 1));

for(f=0; f<6; f++)
{
float3 vP0, vN;
GetHullPlane(vP0, vN, boxX, boxY, boxZ, center, scaleXY, f);
GetPlane(vP0, vN, boxX, boxY, boxZ, center, scaleXY, f);
for(i=0; i<8; i++)
{

2
ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/VolumetricLighting.cs


return (globalFogComponent != null);
}
void VolumetricLightingPass(HDCamera hdCamera, CommandBuffer cmd)
void VolumetricLightingPass(CommandBuffer cmd, HDCamera hdCamera)
{
if (!SetGlobalVolumeProperties(m_VolumetricLightingEnabled, cmd, m_VolumetricLightingCS)) { return; }

72
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


private class StylesLayer
{
public readonly Color[] layerColors =
{
Color.white,
Color.red,
Color.green,
Color.blue
};
public readonly GUIContent[] layerLabels =
{
new GUIContent("Main layer"),

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 layerCountText = new GUIContent("Layer Count", "Number of layers.");
public readonly GUIContent layerTilingBlendMaskText = new GUIContent("Tiling", "Tiling for the blend mask.");
public readonly GUIContent objectScaleAffectTileText = new GUIContent("Lock layers 0123 tiling with object Scale", "Tiling of each layers will be affected by the object scale.");
public readonly GUIContent objectScaleAffectTileText2 = new GUIContent("Lock layers 123 tiling with object Scale", "Tiling of each influenced layers (all except main layer) will be affected by the object scale.");
public readonly GUIContent objectScaleAffectTileText = new GUIContent("Lock layers tiling and object Scale", "Tiling of each layers will be affected by the object scale.");
public readonly GUIContent objectScaleAffectTileText2 = new GUIContent("Lock influenced layers tiling and object Scale", "Tiling of each influenced layers (all except main layer) will be affected by the object scale.");
public readonly GUIContent layerTexWorldScaleText = new GUIContent("World Scale", "Tiling factor applied to Planar/Trilinear mapping");
public readonly GUIContent UVBlendMaskText = new GUIContent("BlendMask UV Mapping", "Base UV Mapping mode of the layer.");

public readonly GUIContent useHeightBasedBlendText = new GUIContent("Use Height Based Blend", "Layer will be blended with the underlying layer based on the height.");
public readonly GUIContent useMainLayerInfluenceModeText = new GUIContent("Main Layer Influence", "Switch between regular layers mode and base/layers mode");
public readonly GUIContent opacityAsDensityText = new GUIContent("Opacity map use as Density map", "Use opacity map as (alpha channel of base color) as Density map.");
public readonly GUIContent opacityAsDensityText = new GUIContent("Use Opacity as Density", "Use Opacity as Density.");
public readonly GUIContent inheritBaseNormalText = new GUIContent("Normal influence", "Inherit the normal from the base layer.");
public readonly GUIContent inheritBaseHeightText = new GUIContent("Heightmap influence", "Inherit the height from the base layer.");
public readonly GUIContent inheritBaseColorText = new GUIContent("BaseColor influence", "Inherit the base color from the base layer.");

public StylesLayer()
{
layerLabelColors[0].normal.textColor = layerColors[0];
layerLabelColors[1].normal.textColor = layerColors[1];
layerLabelColors[2].normal.textColor = layerColors[2];
layerLabelColors[3].normal.textColor = layerColors[3];
layerLabelColors[0].normal.textColor = Color.white;
layerLabelColors[1].normal.textColor = Color.red;
layerLabelColors[2].normal.textColor = Color.green;
layerLabelColors[3].normal.textColor = Color.blue;
}
}

const string kHeightTransition = "_HeightTransition";
// UI
MaterialProperty showMaterialReferences = null;
const string kShowMaterialReferences = "_ShowMaterialReferences";
MaterialProperty[] showLayer = new MaterialProperty[kMaxLayerCount];
const string kShowLayer = "_ShowLayer";

useMainLayerInfluence = FindProperty(kkUseMainLayerInfluence, props);
useHeightBasedBlend = FindProperty(kUseHeightBasedBlend, props);
heightTransition = FindProperty(kHeightTransition, props);
showMaterialReferences = FindProperty(kShowMaterialReferences, props);
for (int i = 0; i < kMaxLayerCount; ++i)
{

bool DoMaterialReferencesGUI(AssetImporter materialImporter)
{
showMaterialReferences.floatValue = EditorGUILayout.Foldout(showMaterialReferences.floatValue != 0.0f, styles.materialReferencesText, styles.layerLabelColors[0]) ? 1.0f : 0.0f;
if (showMaterialReferences.floatValue == 0.0f)
return false;
EditorGUILayout.LabelField(styles.materialReferencesText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
Color originalContentColor = GUI.contentColor;
GUI.contentColor = styles.layerColors[layerIndex];
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true);
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, false);
}
GUI.contentColor = originalContentColor;
GUILayout.BeginHorizontal();
GUILayout.BeginHorizontal();
{
GUILayout.FlexibleSpace();
if (GUILayout.Button(styles.syncAllButUVButtonText))
GUILayout.FlexibleSpace();
if (GUILayout.Button(styles.syncAllButUVButtonText))
{
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true);
layersChanged = true;
}
if (GUILayout.Button(styles.syncAllButtonText))
{
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, false);
layersChanged = true;
}
SynchronizeAllLayersProperties(true);
layersChanged = true;
}
if (GUILayout.Button(styles.syncAllButtonText))
{
SynchronizeAllLayersProperties(false);
layersChanged = true;
GUILayout.EndHorizontal();
GUILayout.EndHorizontal();
EditorGUI.indentLevel--;
return layersChanged;
}

EditorGUILayout.Space();
layerChanged |= DoMaterialReferencesGUI(materialImporter);
EditorGUILayout.Space();
for (int i = 0; i < numLayer; i++)
{
layerChanged |= DoLayerGUI(materialImporter, i);

layerChanged |= DoMaterialReferencesGUI(materialImporter);
layerChanged |= GUI.changed;
GUI.changed = false;

63
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
[ToggleOff] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0
_EmissiveColor("EmissiveColor", Color) = (0, 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
[ToggleOff] _PerPixelDisplacementObjectScale("Per pixel displacement object scale", Float) = 1.0
// Displacement map
[ToggleOff] _EnableVertexDisplacement("Enable vertex displacement", Float) = 0.0
[ToggleOff] _VertexDisplacementObjectScale("Vertex displacement object scale", Float) = 1.0
[ToggleOff] _VertexDisplacementTilingScale("Vertex displacement tiling height scale", Float) = 1.0
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.

[HideInInspector] _UVDetailsMappingMask2("_UVDetailsMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask3("_UVDetailsMappingMask3", Color) = (1, 0, 0, 0)
[HideInInspector] _ShowMaterialReferences("_ShowMaterialReferences", Float) = 0
[HideInInspector] _ShowLayer0("_ShowLayer0", Float) = 0
[HideInInspector] _ShowLayer1("_ShowLayer1", Float) = 0
[HideInInspector] _ShowLayer2("_ShowLayer2", Float) = 0

#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT
#pragma shader_feature _VERTEX_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT_TILING_SCALE
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE
#pragma shader_feature _ _LAYER_MAPPING_PLANAR_BLENDMASK _LAYER_MAPPING_TRIPLANAR_BLENDMASK

#pragma shader_feature _DENSITY_MODE
#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _VERTEX_WIND
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED

#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
// This shader support vertex modification
#define HAVE_VERTEX_MODIFICATION
//-------------------------------------------------------------------------------------
// Include

HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// This pass is the same as GBuffer only it does not do alpha test (the clip instruction is removed)
// This is due to the fact that on GCN, any shader with a clip instruction cannot benefit from HiZ so when we do a prepass, in order to get the most performance, we need to make a special case in the subsequent GBuffer pass.
Pass
{
Name "GBufferWithPrepass" // Name is not used
Tags { "LightMode" = "GBufferWithPrepass" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER
#define _BYPASS_ALPHA_TEST
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"

88
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
[ToggleOff] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0
_EmissiveColor("EmissiveColor", Color) = (0, 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
[ToggleOff] _PerPixelDisplacementObjectScale("Per pixel displacement object scale", Float) = 1.0
// Displacement map
[ToggleOff] _EnableVertexDisplacement("Enable vertex displacement", Float) = 0.0
[ToggleOff] _VertexDisplacementObjectScale("Vertex displacement object scale", Float) = 1.0
[ToggleOff] _VertexDisplacementTilingScale("Vertex displacement tiling height scale", Float) = 1.0
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.

[HideInInspector] _UVDetailsMappingMask2("_UVDetailsMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask3("_UVDetailsMappingMask3", Color) = (1, 0, 0, 0)
[HideInInspector] _ShowMaterialReferences("_ShowMaterialReferences", Float) = 0
[HideInInspector] _ShowLayer0("_ShowLayer0", Float) = 0
[HideInInspector] _ShowLayer1("_ShowLayer1", Float) = 0
[HideInInspector] _ShowLayer2("_ShowLayer2", Float) = 0
[HideInInspector] _ShowLayer3("_ShowLayer3", Float) = 0
// Tessellation specific
[Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0
// Tesselation specific
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 1
_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

[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0
[ToggleOff] _TessellationTilingScale("Tessellation tiling scale", Float) = 1.0
[HideInInspector] _ShowLayer0("_ShowLayer0", Float) = 0
[HideInInspector] _ShowLayer1("_ShowLayer1", Float) = 0
[HideInInspector] _ShowLayer2("_ShowLayer2", Float) = 0
[HideInInspector] _ShowLayer3("_ShowLayer3", Float) = 0
}
HLSLINCLUDE

#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT
#pragma shader_feature _VERTEX_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT_TILING_SCALE
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _TESSELLATION_PHONG
// Default is _TESSELLATION_PHONG
#pragma shader_feature _ _TESSELLATION_DISPLACEMENT _TESSELLATION_DISPLACEMENT_PHONG
#pragma shader_feature _TESSELLATION_OBJECT_SCALE
#pragma shader_feature _TESSELLATION_TILING_SCALE
#pragma shader_feature _LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE
#pragma shader_feature _ _LAYER_MAPPING_PLANAR_BLENDMASK _LAYER_MAPPING_TRIPLANAR_BLENDMASK

#pragma shader_feature _DENSITY_MODE
#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _VERTEX_WIND
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED

#define TESSELLATION_ON
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
// This shader support vertex modification
#define HAVE_VERTEX_MODIFICATION
#define HAVE_TESSELLATION_MODIFICATION
//-------------------------------------------------------------------------------------
// Include

#pragma domain Domain
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// This pass is the same as GBuffer only it does not do alpha test (the clip instruction is removed)
// This is due to the fact that on GCN, any shader with a clip instruction cannot benefit from HiZ so when we do a prepass, in order to get the most performance, we need to make a special case in the subsequent GBuffer pass.
Pass
{
Name "GBufferWithPrepass" // Name is not used
Tags { "LightMode" = "GBufferWithPrepass" } // 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 SHADERPASS SHADERPASS_GBUFFER
#define _BYPASS_ALPHA_TEST
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"

123
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


public static GUIContent ppdMinSamplesText = new GUIContent("Minimum steps", "Minimum steps (texture sample) to use with per pixel displacement mapping");
public static GUIContent ppdMaxSamplesText = new GUIContent("Maximum steps", "Maximum steps (texture sample) to use with per pixel displacement mapping");
public static GUIContent ppdLodThresholdText = new GUIContent("Fading mip level start", "Starting heightmap mipmap lod number where the parallax occlusion mapping effect start to disappear");
public static GUIContent perPixelDisplacementObjectScaleText = new GUIContent("Lock with object scale", "Per Pixel displacement will take into account the tiling scale - Only work with uniform positive scale");
// Vertex displacement
public static string vertexDisplacementText = "Vertex displacement";
public static GUIContent enableVertexDisplacementText = new GUIContent("Enable vertex displacement", "Use heightmap as a displacement map. Displacement map is use to move vertex position in local space");
public static GUIContent vertexDisplacementObjectScaleText = new GUIContent("Lock with object scale", "Vertex displacement will take into account the object scale - Only work with uniform positive scale");
public static GUIContent vertexDisplacementTilingScaleText = new GUIContent("Lock with heightmap tiling", "Vertex displacement will take into account the tiling scale - Only work with uniform positive scale");
// Tessellation
public static string tessellationModeText = "Tessellation Mode";

public static GUIContent tessellationFactorTriangleSizeText = new GUIContent("Triangle size", "Desired screen space sized of triangle (in pixel). Smaller value mean smaller triangle.");
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");
// Vertex animation
public static string vertexAnimation = "Vertex animation";
public static GUIContent tessellationObjectScaleText = new GUIContent("Lock with object scale", "Tessellation displacement will take into account the object scale - Only work with uniform positive scale");
public static GUIContent tessellationTilingScaleText = new GUIContent("Lock with heightmap tiling", "Tessellation displacement will take into account the tiling scale - Only work with uniform positive scale");
// Wind
public static GUIContent windText = new GUIContent("Enable Wind");

public static GUIContent windShiverDragText = new GUIContent("Shiver Drag");
public static GUIContent windShiverDirectionalityText = new GUIContent("Shiver Directionality");
public static string vertexAnimation = "Vertex Animation";
}
public enum DoubleSidedNormalMode

public enum TessellationMode
{
None,
Phong
Phong,
Displacement,
DisplacementPhong,
}
protected MaterialProperty doubleSidedNormalMode = null;

protected const string kStencilRef = "_StencilRef";
// 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 MaterialProperty perPixelDisplacementObjectScale = null;
protected const string kPerPixelDisplacementObjectScale = "_PerPixelDisplacementObjectScale";
// Vertex displacement
protected MaterialProperty enableVertexDisplacement = null;
protected const string kEnableVertexDisplacement = "_EnableVertexDisplacement";
protected MaterialProperty vertexDisplacementObjectScale = null;
protected const string kVertexDisplacementObjectScale = "_VertexDisplacementObjectScale";
protected MaterialProperty vertexDisplacementTilingScale = null;
protected const string kVertexDisplacementTilingScale = "_VertexDisplacementTilingScale";
// Wind
protected MaterialProperty windEnable = null;
protected const string kWindEnabled = "_EnableWind";

protected MaterialProperty windShiverDirectionality = null;
protected const string kWindShiverDirectionality = "_ShiverDirectionality";
// 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";
// tessellation params
protected MaterialProperty tessellationMode = null;
protected const string kTessellationMode = "_TessellationMode";

protected const string kTessellationShapeFactor = "_TessellationShapeFactor";
protected MaterialProperty tessellationBackFaceCullEpsilon = null;
protected const string kTessellationBackFaceCullEpsilon = "_TessellationBackFaceCullEpsilon";
protected MaterialProperty tessellationObjectScale = null;
protected const string kTessellationObjectScale = "_TessellationObjectScale";
protected MaterialProperty tessellationTilingScale = null;
protected const string kTessellationTilingScale = "_TessellationTilingScale";
protected override void FindBaseMaterialProperties(MaterialProperty[] props)
{

ppdMinSamples = FindProperty(kPpdMinSamples, props);
ppdMaxSamples = FindProperty(kPpdMaxSamples, props);
ppdLodThreshold = FindProperty(kPpdLodThreshold, props);
perPixelDisplacementObjectScale = FindProperty(kPerPixelDisplacementObjectScale, props);
// vertex displacement
enableVertexDisplacement = FindProperty(kEnableVertexDisplacement, props);
vertexDisplacementObjectScale = FindProperty(kVertexDisplacementObjectScale, props);
vertexDisplacementTilingScale = FindProperty(kVertexDisplacementTilingScale, props);
// tessellation specific, silent if not found
tessellationMode = FindProperty(kTessellationMode, props, false);

tessellationFactorTriangleSize = FindProperty(kTessellationFactorTriangleSize, props, false);
tessellationShapeFactor = FindProperty(kTessellationShapeFactor, props, false);
tessellationBackFaceCullEpsilon = FindProperty(kTessellationBackFaceCullEpsilon, props, false);
tessellationObjectScale = FindProperty(kTessellationObjectScale, props, false);
tessellationTilingScale = FindProperty(kTessellationTilingScale, props, false);
// Wind
windEnable = FindProperty(kWindEnabled, props);

m_MaterialEditor.ShaderProperty(ppdMaxSamples, StylesBaseLit.ppdMaxSamplesText);
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
m_MaterialEditor.ShaderProperty(ppdLodThreshold, StylesBaseLit.ppdLodThresholdText);
//m_MaterialEditor.ShaderProperty(perPixelDisplacementObjectScale, StylesBaseLit.perPixelDisplacementObjectScaleText);
m_MaterialEditor.ShaderProperty(depthOffsetEnable, StylesBaseLit.depthOffsetEnableText);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
// Vertex displacement options
EditorGUILayout.Space();
EditorGUILayout.LabelField(StylesBaseLit.vertexDisplacementText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(enableVertexDisplacement, StylesBaseLit.enableVertexDisplacementText);
if (enableVertexDisplacement.floatValue > 0.0f)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(vertexDisplacementObjectScale, StylesBaseLit.vertexDisplacementObjectScaleText);
m_MaterialEditor.ShaderProperty(vertexDisplacementTilingScale, StylesBaseLit.vertexDisplacementTilingScaleText);
m_MaterialEditor.ShaderProperty(depthOffsetEnable, StylesBaseLit.depthOffsetEnableText);
EditorGUI.indentLevel--;
}

// clamp min distance to be below max distance
tessellationFactorMinDistance.floatValue = Math.Min(tessellationFactorMaxDistance.floatValue, tessellationFactorMinDistance.floatValue);
m_MaterialEditor.ShaderProperty(tessellationFactorTriangleSize, StylesBaseLit.tessellationFactorTriangleSizeText);
if ((TessellationMode)tessellationMode.floatValue == TessellationMode.Phong)
if ((TessellationMode)tessellationMode.floatValue == TessellationMode.Phong ||
(TessellationMode)tessellationMode.floatValue == TessellationMode.DisplacementPhong)
{
m_MaterialEditor.ShaderProperty(tessellationShapeFactor, StylesBaseLit.tessellationShapeFactorText);
}

}
m_MaterialEditor.ShaderProperty(tessellationObjectScale, StylesBaseLit.tessellationObjectScaleText);
m_MaterialEditor.ShaderProperty(tessellationTilingScale, StylesBaseLit.tessellationTilingScaleText);
EditorGUI.indentLevel--;
}
}

bool enablePerPixelDisplacement = material.GetFloat(kEnablePerPixelDisplacement) > 0.0f;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT", enablePerPixelDisplacement);
bool perPixelDisplacementObjectScale = material.GetFloat(kPerPixelDisplacementObjectScale) > 0.0;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT_OBJECT_SCALE", perPixelDisplacementObjectScale && enablePerPixelDisplacement);
if (material.HasProperty(kTessellationMode))
{
TessellationMode tessMode = (TessellationMode)material.GetFloat(kTessellationMode);
bool enableVertexDisplacement = material.GetFloat(kEnableVertexDisplacement) > 0.0f;
SetKeyword(material, "_VERTEX_DISPLACEMENT", enableVertexDisplacement);
if (tessMode == TessellationMode.Phong)
{
material.DisableKeyword("_TESSELLATION_DISPLACEMENT");
material.DisableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
else if (tessMode == TessellationMode.Displacement)
{
material.EnableKeyword("_TESSELLATION_DISPLACEMENT");
material.DisableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
else
{
material.DisableKeyword("_TESSELLATION_DISPLACEMENT");
material.EnableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
bool vertexDisplacementObjectScaleEnable = material.GetFloat(kVertexDisplacementObjectScale) > 0.0;
SetKeyword(material, "_VERTEX_DISPLACEMENT_OBJECT_SCALE", vertexDisplacementObjectScaleEnable && enableVertexDisplacement);
bool tessellationObjectScaleEnable = material.GetFloat(kTessellationObjectScale) > 0.0;
SetKeyword(material, "_TESSELLATION_OBJECT_SCALE", tessellationObjectScaleEnable);
bool vertexDisplacementTilingScaleEnable = material.GetFloat(kVertexDisplacementTilingScale) > 0.0;
SetKeyword(material, "_VERTEX_DISPLACEMENT_TILING_SCALE", vertexDisplacementTilingScaleEnable && enableVertexDisplacement);
bool tessellationTilingScaleEnable = material.GetFloat(kTessellationTilingScale) > 0.0;
SetKeyword(material, "_TESSELLATION_TILING_SCALE", tessellationTilingScaleEnable);
}
if (material.HasProperty(kTessellationMode))
{
TessellationMode tessMode = (TessellationMode)material.GetFloat(kTessellationMode);
SetKeyword(material, "_TESSELLATION_PHONG", tessMode == TessellationMode.Phong);
}
}
static public void SetupBaseLitMaterialPass(Material material)

14
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs


{
LitSSS = 0,
LitStandard = 1,
LitAniso = 2,
LitClearCoat = 3,
LitClearCoat = 2,
LitUnused = 3,
// We don't store any materialId for aniso but instead deduce it from LitStandard + value of specular + anisotropy parameters
// Consequence is that when querying materialId alone, it will read 2 RT and not only one. This may be a performance hit when only materialId is desired (like in material classification pass)
// Alternative is to use a materialId slot, if any are available.
LitAniso = 4,
LitSpecular = 4,
LitSpecular = 5,
};
// If change, be sure it match what is done in Lit.hlsl: MaterialFeatureFlagsFromGBuffer

{
LitSSS = 1 << MaterialId.LitSSS,
LitStandard = 1 << MaterialId.LitStandard,
LitClearCoat = 1 << MaterialId.LitClearCoat,
LitUnused = 1 << MaterialId.LitUnused,
LitClearCoat = 1 << MaterialId.LitClearCoat,
};
[GenerateHLSL]

public static int s_GBufferLitStandardSpecularColorId = 1;
public static int s_GBufferLitStandardAnisotropicId = 2;
public static float s_DefaultSpecularValue = 0.04f;
public static float s_SkinSpecularValue = 0.028f;

15
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs. Please don't edit by hand.
//
#ifndef LIT_CS_HLSL

//
#define MATERIALID_LIT_SSS (0)
#define MATERIALID_LIT_STANDARD (1)
#define MATERIALID_LIT_ANISO (2)
#define MATERIALID_LIT_CLEAR_COAT (3)
#define MATERIALID_LIT_SPECULAR (4)
#define MATERIALID_LIT_CLEAR_COAT (2)
#define MATERIALID_LIT_UNUSED (3)
#define MATERIALID_LIT_ANISO (4)
#define MATERIALID_LIT_SPECULAR (5)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialFeatureFlags: static fields

#define MATERIALFEATUREFLAGS_LIT_ANISO (4)
#define MATERIALFEATUREFLAGS_LIT_CLEAR_COAT (8)
#define MATERIALFEATUREFLAGS_LIT_CLEAR_COAT (4)
#define MATERIALFEATUREFLAGS_LIT_UNUSED (8)
#define MATERIALFEATUREFLAGS_LIT_ANISO (16)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+StandardDefinitions: static fields

#define GBUFFER_LIT_STANDARD_ANISOTROPIC_ID (2)
#define DEFAULT_SPECULAR_VALUE (0.04)
#define SKIN_SPECULAR_VALUE (0.028)

196
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


// If a user do a lighting architecture without material classification, this can be remove
#include "../../Lighting/TilePass/TilePass.cs.hlsl"
static int g_FeatureFlags = 0xFFFFFFFF;
// This method allows us to know at compile time what shader features should be removed from the code when the materialID cannot be known on the whole tile (any combination of 2 or more differnet materials in the same tile)
// This is only useful for classification during lighting, so it's not needed in EncodeIntoGBuffer and ConvertSurfaceDataToBSDFData (where we always know exactly what the MaterialID is)
bool HasMaterialFeatureFlag(int flag)
{
return ((g_FeatureFlags & flag) != 0);
}
// Precomputed illumination (no dynamic lights) for all material types (except for the clear coat)
/* 0 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_ENV | (MATERIAL_FEATURE_MASK_FLAGS & (~MATERIALFEATUREFLAGS_LIT_CLEAR_COAT)),
// Standard>Specular
/* 1 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 2 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 3 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 4 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 5 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_STANDARD,
// Standard
/* 0 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 1 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 2 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 3 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 4 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 6 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_SSS,
/* 7 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_SSS,
/* 8 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS,
/* 9 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS,
/* 10 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_SSS,
/* 5 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_SSS,
/* 6 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_SSS,
/* 7 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS,
/* 8 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS,
/* 9 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_SSS,
// Aniso
/* 11 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 12 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 13 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 14 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 15 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_ANISO,
// Specular/Aniso
/* 10 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 11 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 12 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 13 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_ANISO,
/* 14 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_ANISO,
// With foliage or crowd with SSS and standard can overlap a lot, better to have a dedicated combination
/* 16 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 17 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 18 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 19 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 20 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
// SSS is a superset of material standard. With foliage or crowd SSS and standard can overlap a lot, better to have a dedicated combination
/* 15 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 16 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 17 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 18 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 19 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_SSS,
/* 21 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 22 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 23 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 24 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 25 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 20 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 21 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 22 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 23 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 24 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_CLEAR_COAT,
/* 26 */ LIGHT_FEATURE_MASK_FLAGS | MATERIAL_FEATURE_MASK_FLAGS, // Catch all case with MATERIAL_FEATURE_MASK_FLAGS is needed in case we disable material classification
// Future usage
/* 25 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_UNUSED,
/* 26 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_UNUSED,
/* 27 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_UNUSED,
/* 28 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_UNUSED,
/* 29 */ LIGHT_FEATURE_MASK_FLAGS | MATERIALFEATUREFLAGS_LIT_UNUSED,
/* 30 */ LIGHT_FEATURE_MASK_FLAGS | MATERIAL_FEATURE_MASK_FLAGS, // Catch all case with MATERIAL_FEATURE_MASK_FLAGS is needed in case we disable material classification
};
uint FeatureFlagsToTileVariant(uint featureFlags)

bsdfData.diffuseColor = surfaceData.baseColor;
bsdfData.fresnel0 = surfaceData.specularColor;
}
else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
FillMaterialIdSSSData(surfaceData.baseColor, surfaceData.subsurfaceProfile, surfaceData.subsurfaceRadius, surfaceData.thickness, bsdfData);
}
}
else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
FillMaterialIdSSSData(surfaceData.baseColor, surfaceData.subsurfaceProfile, surfaceData.subsurfaceRadius, surfaceData.thickness, bsdfData);
}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{

outGBuffer1.a = PackMaterialId(MATERIALID_LIT_STANDARD); // Encode MATERIALID_LIT_SPECULAR as MATERIALID_LIT_STANDARD + GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID value in GBuffer2
outGBuffer2 = float4(surfaceData.specularColor, PackFloatInt8bit(0.0, GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID, 4.0));
}
else if (surfaceData.materialId == MATERIALID_LIT_SSS)
{
outGBuffer2 = float4(surfaceData.subsurfaceRadius, surfaceData.thickness, 0.0, PackByte(surfaceData.subsurfaceProfile));
}
outGBuffer1.a = PackMaterialId(MATERIALID_LIT_STANDARD); // Encode MATERIALID_LIT_SPECULAR as MATERIALID_LIT_STANDARD + GBUFFER_LIT_STANDARD_ANISOTROPIC_ID value in GBuffer2
outGBuffer2 = float4(octTangentWS * 0.5 + 0.5, surfaceData.anisotropy, PackFloatInt8bit(surfaceData.metallic, 0.0, 4.0));
outGBuffer2 = float4(octTangentWS * 0.5 + 0.5, surfaceData.anisotropy, PackFloatInt8bit(surfaceData.metallic, GBUFFER_LIT_STANDARD_ANISOTROPIC_ID, 4.0));
}
else if (surfaceData.materialId == MATERIALID_LIT_SSS)
{
outGBuffer2 = float4(surfaceData.subsurfaceRadius, surfaceData.thickness, 0.0, PackByte(surfaceData.subsurfaceProfile));
}
else if (surfaceData.materialId == MATERIALID_LIT_CLEAR_COAT)
{

out float3 bakeDiffuseLighting)
{
ZERO_INITIALIZE(BSDFData, bsdfData);
g_FeatureFlags = featureFlags;
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
float4 inGBuffer0, inGBuffer1, inGBuffer2, inGBuffer3;

// The material features system for material classification must allow compile time optimization (i.e everything should be static)
// Note that as we store materialId for Aniso based on content of RT2 we need to add few extra condition.
// The code is also call from MaterialFeatureFlagsFromGBuffer, so must work fully dynamic if featureFlags is 0xFFFFFFFF
int supportsStandard = HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_STANDARD);
int supportsSSS = HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_SSS);
int supportsAniso = HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_ANISO);
int supportClearCoat = HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT);
int supportsStandard = (featureFlags & (MATERIALFEATUREFLAGS_LIT_STANDARD | MATERIALFEATUREFLAGS_LIT_ANISO)) != 0;
int supportsSSS = (featureFlags & (MATERIALFEATUREFLAGS_LIT_SSS)) != 0;
int supportClearCoat = (featureFlags & (MATERIALFEATUREFLAGS_LIT_CLEAR_COAT)) != 0;
if (supportsStandard + supportsSSS + supportsAniso + supportClearCoat > 1)
if (supportsStandard + supportsSSS + supportClearCoat > 1)
{
// only fetch materialid if it is not statically known from feature flags
bsdfData.materialId = UnpackMaterialId(inGBuffer1.a);

bsdfData.materialId = MATERIALID_LIT_STANDARD;
else if (supportsSSS)
bsdfData.materialId = MATERIALID_LIT_SSS;
else if (supportsAniso)
bsdfData.materialId = MATERIALID_LIT_ANISO;
if (bsdfData.materialId == MATERIALID_LIT_STANDARD && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_STANDARD))
if (bsdfData.materialId == MATERIALID_LIT_STANDARD)
float anisotropy = inGBuffer2.b;
if (materialIdExtent == GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID)
if (featureFlags & (MATERIAL_FEATURE_MASK_FLAGS) == MATERIALFEATUREFLAGS_LIT_STANDARD)
// Note: Specular is not a material id but just a way to parameterize the standard materialid, thus we reset materialId to MATERIALID_LIT_STANDARD
// For material classification it will be consider as Standard as well, thus no need to create special case
bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = inGBuffer2.rgb;
if (materialIdExtent == GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID)
{
// Note: Specular is not a material id but just a way to parameterize the standard materialid, thus we reset materialId to MATERIALID_LIT_STANDARD
// For material classification it will be consider as Standard as well, thus no need to create special case
bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = inGBuffer2.rgb;
}
else
{
FillMaterialIdStandardData(baseColor, metallic, bsdfData);
}
else // GBUFFER_LIT_STANDARD_REGULAR_ID
else if (featureFlags & (MATERIAL_FEATURE_MASK_FLAGS) == MATERIALFEATUREFLAGS_LIT_ANISO)
bsdfData.materialId = MATERIALID_LIT_ANISO;
float3 tangentWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
FillMaterialIdAnisoData(bsdfData.roughness, bsdfData.normalWS, tangentWS, anisotropy, bsdfData);
}
else // either MATERIAL_FEATURE_MASK_FLAGS or MATERIALFEATUREFLAGS_LIT_STANDARD | MATERIALFEATUREFLAGS_LIT_ANISO
{
if (materialIdExtent == GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID)
{
// Note: Specular is not a material id but just a way to parameterize the standard materialid, thus we reset materialId to MATERIALID_LIT_STANDARD
// For material classification it will be consider as Standard as well, thus no need to create special case
bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = inGBuffer2.rgb;
}
else if (materialIdExtent == GBUFFER_LIT_STANDARD_ANISOTROPIC_ID)
{
bsdfData.materialId = MATERIALID_LIT_ANISO;
FillMaterialIdStandardData(baseColor, metallic, bsdfData);
float3 tangentWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
FillMaterialIdAnisoData(bsdfData.roughness, bsdfData.normalWS, tangentWS, anisotropy, bsdfData);
}
else // GBUFFER_LIT_STANDARD_REGULAR_ID
{
FillMaterialIdStandardData(baseColor, metallic, bsdfData);
}
else if (bsdfData.materialId == MATERIALID_LIT_SSS && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_SSS))
else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
float subsurfaceRadius = inGBuffer2.x;
float thickness = inGBuffer2.y;

}
else if (bsdfData.materialId == MATERIALID_LIT_ANISO && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_ANISO))
{
float metallic;
int unused;
UnpackFloatInt8bit(inGBuffer2.a, 4.0, metallic, unused);
FillMaterialIdStandardData(baseColor, metallic, bsdfData);
float3 tangentWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
float anisotropy = inGBuffer2.b;
FillMaterialIdAnisoData(bsdfData.roughness, bsdfData.normalWS, tangentWS, anisotropy, bsdfData);
}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
else //if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
// We have swap the encoding of the normal to have more precision for coat normal as it is more smooth
float3 coatNormalWS = bsdfData.normalWS;

{
PreLightData preLightData;
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
float ieta = 1.0 / bsdfData.coatIOR; // inverse eta
preLightData.ieta = ieta;

// GGX aniso
preLightData.TdotV = 0.0;
preLightData.BdotV = 0.0;
if (bsdfData.materialId == MATERIALID_LIT_ANISO && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_ANISO))
if (bsdfData.materialId == MATERIALID_LIT_ANISO)
{
preLightData.TdotV = dot(bsdfData.tangentWS, V);
preLightData.BdotV = dot(bsdfData.bitangentWS, V);

// IBL
GetPreIntegratedFGD(NdotV, bsdfData.perceptualRoughness, bsdfData.fresnel0, preLightData.specularFGD, preLightData.diffuseFGD);
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
// Update the roughness and the IBL miplevel
// Bottom layer is affected by upper layer BRDF, result can't be more sharp than input (it is to mimic what a path tracer will do)

// TODO: the fit seems rather poor. The scaling factor of 0.5 allows us
// to match the reference for rough metals, but further darkens dielectrics.
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
// Change the Fresnel term to account for transmission through Clear Coat and reflection on the base layer
float F = F_Schlick(preLightData.coatFresnel0, preLightData.coatNdotV);

float3 F = 1.0;
specularLighting = float3(0.0, 0.0, 0.0);
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) )
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
// Optimized math. Ref: PBR Diffuse Lighting for GGX + Smith Microsurfaces (slide 114).
float NdotL = saturate(dot(bsdfData.coatNormalWS, L));

float Vis;
float D;
if (bsdfData.materialId == MATERIALID_LIT_ANISO && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_ANISO))
if (bsdfData.materialId == MATERIALID_LIT_ANISO)
{
float3 H = (L + V) * invLenLV;
// For anisotropy we must not saturate these values

[branch] if (lightData.shadowIndex >= 0)
{
#ifdef SURFACE_TYPE_TRANSPARENT
#else
shadow = LOAD_TEXTURE2D(_DeferredShadowTexture, posInput.unPositionSS).x;
#endif
illuminance *= shadow;
}

}
// Evaluate the coat part
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
// TODO
// ltcValue = LTCEvaluate(P1, P2, B, preLightData.ltcXformClearCoat);

}
// Evaluate the coat part
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
// TODO
// ltcValue = LTCEvaluate(lightVerts, V, bsdfData.coatNormalWS, preLightData.coatNdotV, preLightData.ltcXformClearCoat);

R = (positionWS + dist * R) - lightData.positionWS;
// Test again for clear code
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
dirLS = mul(coatR, worldToLocal);
dist = SphereRayIntersectSimple(positionLS, dirLS, sphereOuterDistance);

// TODO: add distance based roughness
// Test again for clear code
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
dirLS = mul(coatR, worldToLocal);
dist = BoxRayIntersectSimple(positionLS, dirLS, -boxOuterDistance, boxOuterDistance);

specularLighting = float3(0.0, 0.0, 0.0);
// Evaluate the Clear Coat component if needed and change the BSDF roughness to match Fresnel transmission
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
F = F_Schlick(preLightData.coatFresnel0, preLightData.coatNdotV);

65
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Following options are for the GUI inspector and different from the input parameters above

[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, ClearCoat, 3, Specular Color, 4)] _MaterialID("MaterialId", Int) = 1 // MaterialId.RegularLighting
// Note: 2 and 3 are currently unused
[Enum(Subsurface Scattering, 0, Standard, 1, ClearCoat, 2, Anisotropy, 4, Specular Color, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.RegularLighting
[ToggleOff] _PerPixelDisplacementObjectScale("Per pixel displacement object scale", Float) = 1.0
// Displacement map
[ToggleOff] _EnableVertexDisplacement("Enable vertex displacement", Float) = 0.0
[ToggleOff] _VertexDisplacementObjectScale("Vertex displacement object scale", Float) = 1.0
[ToggleOff] _VertexDisplacementTilingScale("Vertex displacement tiling height scale", Float) = 1.0
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.

#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT
#pragma shader_feature _VERTEX_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT_TILING_SCALE
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
#pragma shader_feature _NORMALMAP_TANGENT_SPACE

#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _THICKNESSMAP
#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _VERTEX_WIND
// MaterialId are used as shader feature to allow compiler to optimize properly
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD

#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
// This shader support vertex modification
#define HAVE_VERTEX_MODIFICATION
//-------------------------------------------------------------------------------------
// Include

HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// This pass is the same as GBuffer only it does not do alpha test (the clip instruction is removed)
// This is due to the fact that on GCN, any shader with a clip instruction cannot benefit from HiZ so when we do a prepass, in order to get the most performance, we need to make a special case in the subsequent GBuffer pass.
Pass
{
Name "GBufferWithPrepass" // Name is not used
Tags { "LightMode" = "GBufferWithPrepass" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER
#define _BYPASS_ALPHA_TEST
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"

54
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


#include "../../../Core/ShaderLibrary/SampleUVMapping.hlsl"
#include "../MaterialUtilities.hlsl"
void DoAlphaTest(float alpha, float alphaCutoff)
{
// For Deferred:
// If we have a prepass, we need to remove the clip from the GBuffer pass (otherwise HiZ does not work on PS4)
// For Forward (Full forward or ForwardOnlyOpaque in deferred):
// Opaque geometry always has a depth pre-pass so we never want to do the clip here. For transparent we perform the clip as usual.
#if ((SHADER_PASS == SHADERPASS_GBUFFER) && !defined(_BYPASS_ALPHA_TEST)) || (SHADER_PASS == SHADERPASS_FORWARD && defined(SURFACE_TYPE_TRANSPARENT))
clip(alpha - alphaCutoff);
#endif
}
// TODO: move this function to commonLighting.hlsl once validated it work correctly
float GetSpecularOcclusionFromBentAO(float3 V, float3 bentNormalWS, SurfaceData surfaceData)
{

// Emissive Intensity is only use here, but is part of BuiltinData to enforce UI parameters as we want the users to fill one color and one intensity
builtinData.emissiveIntensity = _EmissiveIntensity; // We still store intensity here so we can reuse it with debug code
builtinData.emissiveColor = _EmissiveColor * builtinData.emissiveIntensity * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive);
builtinData.emissiveColor = _EmissiveColor * builtinData.emissiveIntensity * lerp(1.0, surfaceData.baseColor, _AlbedoAffectEmissive);
#ifdef _EMISSIVE_COLOR_MAP
builtinData.emissiveColor *= SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, input.texCoord0).rgb;
#endif

{
float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP)
maxDisplacement = abs(_HeightAmplitude); // _HeightAmplitude can be negative if min and max are inverted, but the max displacement must be positive
maxDisplacement = _HeightAmplitude;
#endif
return maxDisplacement;
}

// Note: The TBN is not normalize as it is based on mikkt. We should normalize it, but POM is always use on simple enough surfarce that mean it is not required (save 2 normalize). Tag: SURFACE_GRADIENT
float3 viewDirTS = isPlanar ? float3(uvXZ, V.y) : TransformWorldToTangent(V, worldToTangent);
NdotV = viewDirTS.z;
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);

float ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod)
{
float height = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap, sampler_HeightMap, layerTexCoord.base, lod).r - _HeightCenter) * _HeightAmplitude;
#ifdef _VERTEX_DISPLACEMENT_TILING_SCALE
#ifdef _TESSELLATION_TILING_SCALE
// When we change the tiling, we have want to conserve the ratio with the displacement (and this is consistent with per pixel displacement)
// IDEA: precompute the tiling scale? MOV-MUL vs MOV-MOV-MAX-RCP-MUL.
float tilingScale = rcp(max(_BaseColorMap_ST.x, _BaseColorMap_ST.y));

input.positionWS, input.worldToTangent[2].xyz, layerTexCoord);
}
void ApplyDisplacementTileScale(inout float height0, inout float height1, inout float height2, inout float height3)
void ApplyTessellationTileScale(inout float height0, inout float height1, inout float height2, inout float height3)
#ifdef _VERTEX_DISPLACEMENT_TILING_SCALE
#ifdef _TESSELLATION_TILING_SCALE
float tileObjectScale = 1.0;
#ifdef _LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE
// Extract scaling from world transform

{
float maxDisplacement = 0.0;
// _HeightAmplitudeX can be negative if min and max are inverted, but the max displacement must be positive, take abs()
maxDisplacement = abs(_HeightAmplitude0);
maxDisplacement = _HeightAmplitude0;
maxDisplacement = max( abs(_HeightAmplitude1)
maxDisplacement = max( _HeightAmplitude1
+ abs(_HeightAmplitude0) * _InheritBaseHeight1
+_HeightAmplitude0 * _InheritBaseHeight1
#endif
, maxDisplacement);
#endif

maxDisplacement = max( abs(_HeightAmplitude2)
maxDisplacement = max( _HeightAmplitude2
+ abs(_HeightAmplitude0) * _InheritBaseHeight2
+_HeightAmplitude0 * _InheritBaseHeight2
#endif
, maxDisplacement);
#endif

#if defined(_HEIGHTMAP3)
maxDisplacement = max( abs(_HeightAmplitude3)
maxDisplacement = max( _HeightAmplitude3
+ abs(_HeightAmplitude0) * _InheritBaseHeight3
+_HeightAmplitude0 * _InheritBaseHeight3
#endif
, maxDisplacement);
#endif

float verticalDisplacement = maxHeight - height * maxHeight;
// IDEA: precompute the tiling scale? MOV-MUL vs MOV-MOV-MAX-RCP-MUL.
float tilingScale = rcp(max(_BaseColorMap0_ST.x, _BaseColorMap0_ST.y));
return tilingScale * verticalDisplacement / max(NdotV, 0.001);
return tilingScale * verticalDisplacement / NdotV;
}
return 0.0;

float height1 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1, lod).r - _HeightCenter1) * _HeightAmplitude1;
float height2 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2, lod).r - _HeightCenter2) * _HeightAmplitude2;
float height3 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3, lod).r - _HeightCenter3) * _HeightAmplitude3;
ApplyDisplacementTileScale(height0, height1, height2, height3); // Only apply with per vertex displacement
ApplyTessellationTileScale(height0, height1, height2, height3); // Only apply with per vertex displacement
SetEnabledHeightByLayer(height0, height1, height2, height3);
float4 resultBlendMasks = inputBlendMasks;

float influenceFactor = BlendLayeredScalar(0.0, _InheritBaseNormal1, _InheritBaseNormal2, _InheritBaseNormal3, weights) * influenceMask;
// We will add smoothly the contribution of the normal map by lerping between vertex normal ( (0,0,1) in tangent space) and the actual normal from the main layer depending on the influence factor.
// Note: that we don't take details map into account here.
#ifdef SURFACE_GRADIENT
float3 neutralNormalTS = float3(0.0, 0.0, 0.0);
#else
float3 neutralNormalTS = float3(0.0, 0.0, 1.0);
#endif
float3 mainNormalTS = lerp(neutralNormalTS, normalTS0, influenceFactor);
float3 mainNormalTS = lerp(float3(0.0, 0.0, 1.0), normalTS0, influenceFactor);
// Add on our regular normal a bit of Main Layer normal base on influence factor. Note that this affect only the "visible" normal.
#ifdef SURFACE_GRADIENT

// (baseColor - meanColor) + lerp(meanColor, baseColor0, inheritBaseColor) simplify to
// saturate(influenceFactor * (baseColor0 - meanColor) + baseColor);
// There is a special case when baseColor < meanColor to avoid getting negative values.
float3 factor = baseColor > meanColor ? (baseColor0 - meanColor) : (baseColor0 * baseColor / max(meanColor, 0.001) - baseColor); // max(to avoid divide by 0)
float3 factor = baseColor > meanColor ? (baseColor0 - meanColor) : (baseColor0 * baseColor / meanColor - baseColor);
return influenceFactor * factor + baseColor;
}

float alpha = PROP_BLEND_SCALAR(alpha, weights);
#ifdef _ALPHATEST_ON
DoAlphaTest(alpha, _AlphaCutoff);
clip(alpha - _AlphaCutoff);
#endif
float3 normalTS;

#endif // #ifndef LAYERED_LIT_SHADER
#ifdef TESSELLATION_ON
#endif

15
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


// Apply tiling options
ADD_IDX(layerTexCoord.base).uv = TRANSFORM_TEX(uvBase, ADD_IDX(_BaseColorMap));
// Detail map tiling option inherit from the tiling of the base
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(TRANSFORM_TEX(uvDetails, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(uvDetails, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXZ = TRANSFORM_TEX(TRANSFORM_TEX(uvXZ, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(TRANSFORM_TEX(uvXY, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZY = TRANSFORM_TEX(TRANSFORM_TEX(uvZY, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXZ = TRANSFORM_TEX(uvXZ, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(uvXY, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZY = TRANSFORM_TEX(uvZY, ADD_IDX(_DetailMap));
#ifdef SURFACE_GRADIENT
// This part is only relevant for normal mapping with UV_MAPPING_UVSET

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

surfaceData.baseColor = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).rgb * ADD_IDX(_BaseColor).rgb;
#ifdef _DETAIL_MAP_IDX
surfaceData.baseColor *= LerpWhiteTo(2.0 * saturate(detailAlbedo * ADD_IDX(_DetailAlbedoScale)), detailMask);
surfaceData.baseColor *= LerpWhiteTo(lerp(1, detailAlbedo, ADD_IDX(_DetailAlbedoScale)), detailMask);
#endif
surfaceData.specularOcclusion = 1.0; // Will be setup outside of this function

26
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitReference.hlsl


switch (lightData.lightType)
{
//case GPULIGHTTYPE_SPHERE:
// SampleSphere(u, localToWorld, lightData.size.x, lightPdf, P, Ns);
// break;
//case GPULIGHTTYPE_HEMISPHERE:
// SampleHemisphere(u, localToWorld, lightData.size.x, lightPdf, P, Ns);
// break;
//case GPULIGHTTYPE_CYLINDER:
// SampleCylinder(u, localToWorld, lightData.size.x, lightData.size.y, lightPdf, P, Ns);
// break;
case GPULIGHTTYPE_SPHERE:
SampleSphere(u, localToWorld, lightData.size.x, lightPdf, P, Ns);
break;
case GPULIGHTTYPE_HEMISPHERE:
SampleHemisphere(u, localToWorld, lightData.size.x, lightPdf, P, Ns);
break;
case GPULIGHTTYPE_CYLINDER:
SampleCylinder(u, localToWorld, lightData.size.x, lightData.size.y, lightPdf, P, Ns);
break;
//case GPULIGHTTYPE_DISK:
// SampleDisk(u, localToWorld, lightData.size.x, lightPdf, P, Ns);
// break;
case GPULIGHTTYPE_DISK:
SampleDisk(u, localToWorld, lightData.size.x, lightPdf, P, Ns);
break;
// case GPULIGHTTYPE_LINE: handled by a separate function.
}

}
return acc / sampleCount;
}
}

120
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.hlsl


float3 GetVertexDisplacement(float3 positionWS, float3 normalWS, float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3, float4 vertexColor, float3 objectScale)
{
// This call will work for both LayeredLit and Lit shader
LayerTexCoord layerTexCoord;
ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
GetLayerTexCoord(texCoord0, texCoord1, texCoord2, texCoord3, positionWS, normalWS, layerTexCoord);
// TODO: do this algorithm for lod fetching as lod not available in vertex/domain shader
// http://www.sebastiansylvan.com/post/the-problem-with-tessellation-in-directx-11/
float lod = 0.0;
float height = ComputePerVertexDisplacement(layerTexCoord, vertexColor, lod);
float3 displ = height * normalWS;
// Applying scaling of the object if requested
displ *= objectScale;
return displ;
}
void ApplyVertexModification(AttributesMesh input, float3 normalWS, float3 objectScale, inout float3 positionWS)
{
// If tessellation is enabled we apply displacement map after tessellation
#if defined(_VERTEX_DISPLACEMENT) && !defined(TESSELLATION_ON)
positionWS += GetVertexDisplacement(positionWS, normalWS,
#ifdef ATTRIBUTES_NEED_TEXCOORD0
input.uv0,
#else
float2(0.0, 0.0),
#endif
#ifdef ATTRIBUTES_NEED_TEXCOORD1
input.uv1,
#else
float2(0.0, 0.0),
#endif
#ifdef ATTRIBUTES_NEED_TEXCOORD2
input.uv2,
#else
float2(0.0, 0.0),
#endif
#ifdef ATTRIBUTES_NEED_TEXCOORD3
input.uv3,
#else
float2(0.0, 0.0),
#endif
#ifdef ATTRIBUTES_NEED_COLOR
input.color,
#else
float4(0.0, 0.0, 0.0, 0.0),
#endif
objectScale);
#endif
#ifdef _VERTEX_WIND
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
ApplyWindDisplacement(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, input.color.a, _Time);
#endif
}
#ifdef TESSELLATION_ON
float4 GetTessellationFactors(float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2)
{
float maxDisplacement = GetMaxDisplacement();

// y - 2->0 edge
// z - 0->1 edge
// w - inside tessellation factor
void ApplyTessellationModification(VaryingsMeshToDS input, float3 normalWS, float3 objectScale, inout float3 positionWS)
float3 GetTessellationDisplacement(VaryingsMeshToDS input)
#if defined(_VERTEX_DISPLACEMENT)
positionWS += GetVertexDisplacement(positionWS, normalWS,
#ifdef VARYINGS_DS_NEED_TEXCOORD0
// This call will work for both LayeredLit and Lit shader
LayerTexCoord layerTexCoord;
ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
GetLayerTexCoord(
#ifdef VARYINGS_DS_NEED_TEXCOORD0
#else
#else
#endif
#ifdef VARYINGS_DS_NEED_TEXCOORD1
#endif
#ifdef VARYINGS_DS_NEED_TEXCOORD1
#else
#else
#endif
#ifdef VARYINGS_DS_NEED_TEXCOORD2
#endif
#ifdef VARYINGS_DS_NEED_TEXCOORD2
#else
#else
#endif
#ifdef VARYINGS_DS_NEED_TEXCOORD3
#endif
#ifdef VARYINGS_DS_NEED_TEXCOORD3
#else
#else
#endif
#ifdef VARYINGS_DS_NEED_COLOR
input.color,
#else
float4(0.0, 0.0, 0.0, 0.0),
#endif
objectScale);
#endif // _VERTEX_DISPLACEMENT
}
#endif
input.positionWS,
input.normalWS,
layerTexCoord);
#endif // #ifdef TESSELLATION_ON
// 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
vertexColor = input.color;
#endif
float height = ComputePerVertexDisplacement(layerTexCoord, vertexColor, lod);
float3 displ = height * input.normalWS;
// Applying scaling of the object if requested
#ifdef _TESSELLATION_OBJECT_SCALE
displ *= input.objectScale;
#endif
return displ;
}

78
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Following options are for the GUI inspector and different from the input parameters above

[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, ClearCoat, 3, Specular Color, 4)] _MaterialID("MaterialId", Int) = 1 // MaterialId.RegularLighting
// Note: 2 and 3 are currently unused
[Enum(Subsurface Scattering, 0, Standard, 1, ClearCoat, 2, Anisotropy, 4, Specular Color, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.RegularLighting
[ToggleOff] _PerPixelDisplacementObjectScale("Per pixel displacement object scale", Float) = 1.0
// Displacement map
[ToggleOff] _EnableVertexDisplacement("Enable vertex displacement", Float) = 0.0
[ToggleOff] _VertexDisplacementObjectScale("Vertex displacement object scale", Float) = 1.0
[ToggleOff] _VertexDisplacementTilingScale("Vertex displacement tiling height scale", Float) = 1.0
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.

// Tessellation specific
[Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 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

[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0
[ToggleOff] _TessellationTilingScale("Tessellation tiling height scale", Float) = 1.0
// TODO: Handle culling mode for backface culling
}

#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT
#pragma shader_feature _VERTEX_DISPLACEMENT_OBJECT_SCALE
#pragma shader_feature _VERTEX_DISPLACEMENT_TILING_SCALE
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _TESSELLATION_PHONG
// Default is _TESSELLATION_PHONG
#pragma shader_feature _ _TESSELLATION_DISPLACEMENT _TESSELLATION_DISPLACEMENT_PHONG
#pragma shader_feature _TESSELLATION_OBJECT_SCALE
#pragma shader_feature _TESSELLATION_TILING_SCALE
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
#pragma shader_feature _NORMALMAP_TANGENT_SPACE

#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _THICKNESSMAP
#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _VERTEX_WIND
// MaterialId are used as shader feature to allow compiler to optimize properly
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD

#define TESSELLATION_ON
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
// This shader support vertex modification
#define HAVE_VERTEX_MODIFICATION
#define HAVE_TESSELLATION_MODIFICATION
//-------------------------------------------------------------------------------------
// Include

#pragma domain Domain
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// This pass is the same as GBuffer only it does not do alpha test (the clip instruction is removed)
// This is due to the fact that on GCN, any shader with a clip instruction cannot benefit from HiZ so when we do a prepass, in order to get the most performance, we need to make a special case in the subsequent GBuffer pass.
Pass
{
Name "GBufferWithPrepass" // Name is not used
Tags { "LightMode" = "GBufferWithPrepass" } // 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 SHADERPASS SHADERPASS_GBUFFER
#define _BYPASS_ALPHA_TEST
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"

1
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile.meta


timeCreated: 1493162006
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

15
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl


#endif
// Attributes
#define REQUIRE_UV_FOR_TESSELATION (defined(TESSELLATION_ON) && (defined(_TESSELLATION_DISPLACEMENT) || defined(_TESSELLATION_DISPLACEMENT_PHONG)))
#define REQUIRE_VERTEX_COLOR_FOR_TESSELATION REQUIRE_UV_FOR_TESSELATION
#define REQUIRE_NORMAL defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD || defined(_VERTEX_WIND) || defined(_VERTEX_DISPLACEMENT)
#define REQUIRE_VERTEX_COLOR (defined(_VERTEX_DISPLACEMENT) && defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))) || defined(_VERTEX_WIND)
#if REQUIRE_NORMAL
#if defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD
#if REQUIRE_VERTEX_COLOR
#define ATTRIBUTES_NEED_COLOR
#endif
// About UV
// If we have a lit shader, only the UV0 is available for opacity or heightmap

#if defined(_VERTEX_DISPLACEMENT) || REQUIRE_TANGENT_TO_WORLD || defined(_ALPHATEST_ON)
#if REQUIRE_UV_FOR_TESSELATION || REQUIRE_TANGENT_TO_WORLD || defined(_ALPHATEST_ON)
#define ATTRIBUTES_NEED_TEXCOORD0
#ifdef LAYERED_LIT_SHADER
#define ATTRIBUTES_NEED_TEXCOORD1

#define ATTRIBUTES_NEED_TEXCOORD3
#endif
#endif
#endif
#if REQUIRE_VERTEX_COLOR_FOR_TESSELATION
#define ATTRIBUTES_NEED_COLOR
#endif
// Varying - Use for pixel shader

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl


// This first set of define allow to say which attributes will be use by the mesh in the vertex and domain shader (for tesselation)
// Tesselation require normal
#if defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD || defined(_VERTEX_WIND)
#if defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD
#endif
#ifdef _VERTEX_WIND
#define ATTRIBUTES_NEED_COLOR
#endif
// About UV

11
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl


#define ATTRIBUTES_NEED_TEXCOORD1
#define ATTRIBUTES_NEED_TEXCOORD2
#ifdef _VERTEX_WIND
#define ATTRIBUTES_NEED_COLOR
#define ATTRIBUTES_NEED_NORMAL
#endif
#define REQUIRE_VERTEX_COLOR defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))
#if REQUIRE_VERTEX_COLOR
#if defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))
#define ATTRIBUTES_NEED_COLOR
#endif

#if REQUIRE_VERTEX_COLOR
#if defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))
#define VARYINGS_NEED_COLOR
#endif

20
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl


// conflict with the normal in the semantic. This need to be fix! Also no per pixel displacement is possible either.
// Attributes
#define REQUIRE_TANGENT_TO_WORLD 0 /* (defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)) */
#define REQUIRE_NORMAL 0 /* defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD || defined(_VERTEX_WIND) || defined(_VERTEX_DISPLACEMENT) */
#define REQUIRE_VERTEX_COLOR (defined(_VERTEX_DISPLACEMENT) && defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))) || defined(_VERTEX_WIND)
#define REQUIRE_UV_FOR_TESSELATION (defined(TESSELLATION_ON) && (defined(_TESSELLATION_DISPLACEMENT) || defined(_TESSELLATION_DISPLACEMENT_PHONG)))
#define REQUIRE_VERTEX_COLOR_FOR_TESSELATION REQUIRE_UV_FOR_TESSELATION
#define REQUIRE_TANGENT_TO_WORLD 0 /* (defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)) */
#if REQUIRE_NORMAL
#define ATTRIBUTES_NEED_NORMAL
#if defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD
// #define ATTRIBUTES_NEED_NORMAL - When reenable, think to also enable code in VertMesh.hlsl
#if REQUIRE_VERTEX_COLOR
#define ATTRIBUTES_NEED_COLOR
#endif
// About UV
// If we have a lit shader, only the UV0 is available for opacity or heightmap

#if defined(_VERTEX_DISPLACEMENT) || REQUIRE_TANGENT_TO_WORLD || defined(_ALPHATEST_ON)
#if defined(_ALPHATEST_ON)
#define ATTRIBUTES_NEED_TEXCOORD0
#ifdef LAYERED_LIT_SHADER
#define ATTRIBUTES_NEED_TEXCOORD1

#endif
#endif
#if REQUIRE_VERTEX_COLOR_FOR_TESSELATION
#define ATTRIBUTES_NEED_COLOR
#endif
// Varying - Use for pixel shader
// This second set of define allow to say which varyings will be output in the vertex (no more tesselation)

#define VARYINGS_NEED_POSITION_WS // Required to get view vector
#define VARYINGS_NEED_TANGENT_TO_WORLD
#endif

28
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringProfile.cs


}
#if UNITY_EDITOR
public class SubsurfaceScatteringProfileFactory
{
[MenuItem("Assets/Create/HDRenderPipeline/Subsurface Scattering Profile", priority = 666)]
static void MenuCreateSubsurfaceScatteringProfile()
{
Texture2D icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0,
ScriptableObject.CreateInstance<DoCreateSubsurfaceScatteringProfile>(),
"New SSS Profile.asset", icon, null);
}
public static SubsurfaceScatteringProfile CreateSssProfileAtPath(string path)
{
var profile = ScriptableObject.CreateInstance<SubsurfaceScatteringProfile>();
profile.name = System.IO.Path.GetFileName(path);
AssetDatabase.CreateAsset(profile, path);
return profile;
}
}
class DoCreateSubsurfaceScatteringProfile : UnityEditor.ProjectWindowCallback.EndNameEditAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
{
var profiles = SubsurfaceScatteringProfileFactory.CreateSssProfileAtPath(pathName);
ProjectWindowUtil.ShowCreatedAsset(profiles);
}
}
[CustomEditor(typeof(SubsurfaceScatteringProfile))]
public class SubsurfaceScatteringProfileEditor : Editor

16
ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl


#include "../../Core/ShaderLibrary/ImageBasedLighting.hlsl"
//-----------------------------------------------------------------------------
// Blending
//-----------------------------------------------------------------------------
// This should match the possible blending modes in any material .shader file (lit/layeredlit/unlit etc)
#if defined(_BLENDMODE_LERP) || defined(_BLENDMODE_ADD) || defined(_BLENDMODE_SOFT_ADD) || defined(_BLENDMODE_MULTIPLY) || defined(_BLENDMODE_PRE_MULTIPLY)
# define SURFACE_TYPE_TRANSPARENT
#else
# define SURFACE_TYPE_OPAQUE
#endif
//-----------------------------------------------------------------------------
// BuiltinData
//-----------------------------------------------------------------------------

#include "Unlit/Unlit.hlsl"
#elif defined(UNITY_MATERIAL_IRIDESCENCE)
//#include "Iridescence/Iridescence.hlsl"
#elif defined(UNITY_MATERIAL_HAIR)
#include "Hair/Hair.hlsl"
#elif defined(UNITY_MATERIAL_EYE)
#include "Eye/Eye.hlsl"
#elif defined(UNITY_MATERIAL_FABRIC)
#include "Fabric/Fabric.hlsl"
#endif
//-----------------------------------------------------------------------------

10
ScriptableRenderPipeline/HDRenderPipeline/Material/MaterialUtilities.hlsl


float3 bakeDiffuseLighting = float3(0.0, 0.0, 0.0);
#ifdef UNITY_LIGHTMAP_FULL_HDR
bool useRGBMLightmap = false;
#else
bool useRGBMLightmap = true;
#endif
uvStaticLightmap, unity_LightmapST, normalWS, useRGBMLightmap);
uvStaticLightmap, unity_LightmapST, normalWS, true);
bakeDiffuseLighting += SampleSingleLightmap(TEXTURE2D_PARAM(unity_Lightmap, samplerunity_Lightmap), uvStaticLightmap, unity_LightmapST, useRGBMLightmap);
bakeDiffuseLighting += SampleSingleLightmap(TEXTURE2D_PARAM(unity_Lightmap, samplerunity_Lightmap), uvStaticLightmap, unity_LightmapST, true);
#endif
#endif

56
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs


public static GUIContent alphaCutoffEnableText = new GUIContent("Alpha Cutoff Enable", "Threshold for alpha cutoff");
public static GUIContent alphaCutoffText = new GUIContent("Alpha Cutoff", "Threshold for alpha cutoff");
public static GUIContent alphaCutoffShadowText = new GUIContent("Alpha Cutoff Shadow", "Threshold for alpha cutoff");
public static GUIContent alphaCutoffPrepassText = new GUIContent("Alpha Cutoff Prepass", "Threshold for alpha cutoff");
public static GUIContent alphaCutoffOpacityThresholdText = new GUIContent("Alpha Cutoff Opacity Threshold", "Threshold for alpha cutoff");
public static GUIContent transparentDepthWritePrepassEnableText = new GUIContent("Enable transparent depth write prepass", "Threshold for alpha cutoff");
public static GUIContent doubleSidedEnableText = new GUIContent("Double Sided", "This will render the two face of the objects (disable backface culling) and flip/mirror normal");
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");

protected const string kAlphaCutoffEnabled = "_AlphaCutoffEnable";
protected MaterialProperty alphaCutoff = null;
protected const string kAlphaCutoff = "_AlphaCutoff";
protected MaterialProperty alphaCutoffShadow = null;
protected const string kAlphaCutoffShadow = "_AlphaCutoffShadow";
protected MaterialProperty alphaCutoffPrepass = null;
protected const string kAlphaCutoffPrepass = "_AlphaCutoffPrepass";
protected MaterialProperty alphaCutoffOpacityThreshold = null;
protected const string kAlphaCutoffOpacityThreshold = "_AlphaCutoffOpacityThreshold";
protected MaterialProperty transparentDepthWritePrepassEnable = null;
protected const string kTransparentDepthWritePrepassEnable = "_TransparentDepthWritePrepassEnable";
protected MaterialProperty doubleSidedEnable = null;
protected const string kDoubleSidedEnable = "_DoubleSidedEnable";
protected MaterialProperty blendMode = null;

protected virtual void FindBaseMaterialProperties(MaterialProperty[] props)
{
surfaceType = FindProperty(kSurfaceType, props);
alphaCutoffEnable = FindProperty(kAlphaCutoffEnabled, props);
alphaCutoffEnable = FindProperty(kAlphaCutoffEnabled, props, false);
alphaCutoffShadow = FindProperty(kAlphaCutoffShadow, props, false);
alphaCutoffPrepass = FindProperty(kAlphaCutoffPrepass, props, false);
alphaCutoffOpacityThreshold = FindProperty(kAlphaCutoffOpacityThreshold, props, false);
transparentDepthWritePrepassEnable = FindProperty(kTransparentDepthWritePrepassEnable, props, false);
doubleSidedEnable = FindProperty(kDoubleSidedEnable, props);
blendMode = FindProperty(kBlendMode, props);
distortionEnable = FindProperty(kDistortionEnable, props, false);

}
}
}
m_MaterialEditor.ShaderProperty(alphaCutoffEnable, StylesBaseUnlit.alphaCutoffEnableText);
if (alphaCutoffEnable.floatValue == 1.0f)
if (alphaCutoffEnable != null)
m_MaterialEditor.ShaderProperty(alphaCutoff, StylesBaseUnlit.alphaCutoffText);
m_MaterialEditor.ShaderProperty(alphaCutoffEnable, StylesBaseUnlit.alphaCutoffEnableText);
if (alphaCutoffEnable.floatValue == 1.0f)
{
m_MaterialEditor.ShaderProperty(alphaCutoff, StylesBaseUnlit.alphaCutoffText);
}
// This function must finish with double sided option (see LitUI.cs)
m_MaterialEditor.ShaderProperty(doubleSidedEnable, StylesBaseUnlit.doubleSidedEnableText);

// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if ocde change
static public void SetupBaseUnlitKeywords(Material material)
{
bool alphaTestEnable = material.GetFloat(kAlphaCutoffEnabled) > 0.0f;
bool alphaTestEnable = false;
if (material.HasProperty(kAlphaCutoffEnabled))
{
alphaTestEnable = material.GetFloat(kAlphaCutoffEnabled) > 0.0f;
}
SurfaceType surfaceType = (SurfaceType)material.GetFloat(kSurfaceType);
BlendMode blendMode = (BlendMode)material.GetFloat(kBlendMode);

material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_ZWrite", 0);
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
SetKeyword(material, "_BLENDMODE_LERP", BlendMode.Lerp == blendMode);
SetKeyword(material, "_BLENDMODE_ADD", BlendMode.Add == blendMode);
SetKeyword(material, "_BLENDMODE_SOFT_ADD", BlendMode.SoftAdd == blendMode);
SetKeyword(material, "_BLENDMODE_MULTIPLY", BlendMode.Multiply == blendMode);
SetKeyword(material, "_BLENDMODE_PRE_MULTIPLY", BlendMode.Premultiply == blendMode);
switch (blendMode)
{

}
SetKeyword(material, "_DISTORTION_ON", distortionEnable);
}
if (material.HasProperty(kTransparentDepthWritePrepassEnable))
{
bool depthWriteEnable = (material.GetFloat(kTransparentDepthWritePrepassEnable) > 0.0f) && ((SurfaceType)material.GetFloat(kSurfaceType) == SurfaceType.Transparent);
if (depthWriteEnable)
{
material.SetShaderPassEnabled("TransparentDepthWrite", true);
}
else
{
material.SetShaderPassEnabled("TransparentDepthWrite", false);
}
}
// A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader


#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------

3
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultAmbientOcclusionSettings.asset


m_EditorClassIdentifier:
m_Settings:
m_Enable: 1
m_AffectDirectLigthingStrenght: 0
m_Radius: 0.2
m_Radius: 1
m_SampleCount: 8
m_Downsampling: 1

10
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultHDMaterial.mat


m_PrefabInternal: {fileID: 0}
m_Name: DefaultHDMaterial
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _NORMALMAP_TANGENT_SPACE
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF _DISTORTIONDEPTHTEST_OFF
_DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _DOUBLESIDEDENABLE_OFF _ENABLEPERPIXELDISPLACEMENT_OFF
_ENABLEWIND_OFF _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 502977a8db6d68c4c803669208fcdab0, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:

- _Parallax: 0.02
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 0.5
- _Smoothness: 1
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SmoothnessTextureChannel: 0

- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.72794116, g: 0.72794116, b: 0.72794116, a: 1}
- _BaseColor: {r: 1, g: 0, b: 0.47586203, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

2
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset


type: 3}
deferredComputeShader: {fileID: 7200000, guid: 0b64f79746d2daf4198eaf6eab9af259,
type: 3}
deferredDirectionalShadowComputeShader: {fileID: 7200000, guid: fbde6fae193b2a94e9fd97c163c204f4,
type: 3}
cameraMotionVectors: {fileID: 4800000, guid: 035941b63024d1943af48811c1db20d9, type: 3}
blitCubemap: {fileID: 4800000, guid: d05913e251bed7a4992c921c62e1b647, type: 3}
buildProbabilityTables: {fileID: 7200000, guid: b9f26cf340afe9145a699753531b2a4c,

2
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset.meta


fileFormatVersion: 2
guid: 42086e81f4f0c724f96f7f09cc995354
timeCreated: 1505146899
timeCreated: 1505345916
licenseType: Pro
NativeFormatImporter:
externalObjects: {}

60
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
namespace UnityEngine.Experimental.Rendering.HDPipeline
public static string GetRenderPipelineResourcesPath()
{
return Utilities.GetHDRenderPipelinePath() + "RenderPipelineResources/HDRenderPipelineResources.asset";
}
public const string renderPipelineResourcesPath = "Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset";
// TODO skybox/cubemap

var instance = CreateInstance<RenderPipelineResources>();
string HDRenderPipelinePath = Utilities.GetHDRenderPipelinePath();
instance.debugDisplayLatlongShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Debug/DebugDisplayLatlong.Shader");
instance.debugViewMaterialGBufferShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Debug/DebugViewMaterialGBuffer.Shader");
instance.debugViewTilesShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Debug/DebugViewTiles.Shader");
instance.debugFullScreenShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Debug/DebugFullScreen.Shader");
instance.debugDisplayLatlongShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayLatlong.Shader");
instance.debugViewMaterialGBufferShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewMaterialGBuffer.Shader");
instance.debugViewTilesShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewTiles.Shader");
instance.debugFullScreenShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.Shader");
instance.deferredShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Lighting/Deferred.Shader");
instance.screenSpaceAmbientOcclusionShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusion.Shader");
instance.subsurfaceScatteringCS = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Material/Lit/Resources/SubsurfaceScattering.compute");
instance.volumetricLightingCS = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/Volumetrics/Resources/VolumetricLighting.compute");
instance.deferredShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Deferred.Shader");
instance.screenSpaceAmbientOcclusionShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusion.Shader");
instance.subsurfaceScatteringCS = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute");
instance.volumetricLightingCS = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/Resources/VolumetricLighting.compute");
instance.clearDispatchIndirectShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/cleardispatchindirect.compute");
instance.buildDispatchIndirectShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/builddispatchindirect.compute");
instance.buildScreenAABBShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/scrbound.compute");
instance.buildPerTileLightListShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/lightlistbuild.compute");
instance.buildPerBigTileLightListShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/lightlistbuild-bigtile.compute");
instance.buildPerVoxelLightListShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/lightlistbuild-clustered.compute");
instance.buildMaterialFlagsShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/materialflags.compute");
instance.deferredComputeShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/Deferred.compute");
instance.deferredDirectionalShadowComputeShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Lighting/TilePass/DeferredDirectionalShadow.compute");
instance.clearDispatchIndirectShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/cleardispatchindirect.compute");
instance.buildDispatchIndirectShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/builddispatchindirect.compute");
instance.buildScreenAABBShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/scrbound.compute");
instance.buildPerTileLightListShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild.compute");
instance.buildPerBigTileLightListShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-bigtile.compute");
instance.buildPerVoxelLightListShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-clustered.compute");
instance.buildMaterialFlagsShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/materialflags.compute");
instance.deferredComputeShader = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute");
// instance.drawSssProfile = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "SceneSettings/DrawSssProfile.shader");
// instance.drawTransmittanceGraphShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "SceneSettings/DrawTransmittanceGraph.shader");
// instance.drawSssProfile = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/DrawSssProfile.shader");
// instance.drawTransmittanceGraphShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/DrawTransmittanceGraph.shader");
instance.cameraMotionVectors = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "RenderPipelineResources/CameraMotionVectors.shader");
instance.cameraMotionVectors = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CameraMotionVectors.shader");
instance.blitCubemap = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Sky/BlitCubemap.shader");
instance.buildProbabilityTables = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Sky/BuildProbabilityTables.compute");
instance.computeGgxIblSampleData = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(HDRenderPipelinePath + "Sky/ComputeGgxIblSampleData.compute");
instance.GGXConvolve = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(HDRenderPipelinePath + "Sky/GGXConvolve.shader");
instance.blitCubemap = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/BlitCubemap.shader");
instance.buildProbabilityTables = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/BuildProbabilityTables.compute");
instance.computeGgxIblSampleData = UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ComputeGgxIblSampleData.compute");
instance.GGXConvolve = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/GGXConvolve.shader");
UnityEditor.AssetDatabase.CreateAsset(instance, GetRenderPipelineResourcesPath());
UnityEditor.AssetDatabase.CreateAsset(instance, renderPipelineResourcesPath);
UnityEditor.AssetDatabase.SaveAssets();
UnityEditor.AssetDatabase.Refresh();
}

public ComputeShader buildPerVoxelLightListShader; // clustered
public ComputeShader buildMaterialFlagsShader;
public ComputeShader deferredComputeShader;
public ComputeShader deferredDirectionalShadowComputeShader;
// SceneSettings
// These shaders don't need to be reference by RenderPipelineResource as they are not use at runtime (only to draw in editor)

2
ScriptableRenderPipeline/HDRenderPipeline/ShaderConfig.cs


VelocityInGBuffer = 0, // Change to 1 to enable the feature, then regenerate hlsl headers.
// TODO: not working yet, waiting for UINT16 RT format support
PackGBufferInU16 = 0,
CameraRelativeRendering = 1 // Rendering sets the origin of the world to the position of the primary (scene view) camera
CameraRelativeRendering = 0 // Rendering sets the origin of the world to the position of the primary (scene view) camera
};
// Note: #define can't be use in include file in C# so we chose this way to configure both C# and hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/ShaderConfig.cs.hlsl


//
#define SHADEROPTIONS_VELOCITY_IN_GBUFFER (0)
#define SHADEROPTIONS_PACK_GBUFFER_IN_U16 (0)
#define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (1)
#define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (0)
#endif

17
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


#endif // TESSELLATION_ON
void Frag(PackedVaryingsToPS packedInput,
out float4 outColor : SV_Target0
#ifdef FORWARD_SPLIT_LIGHTING
out float4 outColor : SV_Target0, // this is outSpecular
out float4 outDiffuse : SV_Target1,
out float4 outGbuffer0 : SV_Target2,
out float4 outGbuffer2 : SV_Target3
#else
out float4 outColor : SV_Target0
#endif
#ifdef _DEPTHOFFSET_ON
, out float outputDepth : SV_Depth
#endif

float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData);
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting);
#ifdef FORWARD_SPLIT_LIGHTING
outColor = float4(specularLighting, 1.0);
outDiffuse = float4(diffuseLighting, 1.0);
outGbuffer0 = EncodeSplitLightingGBuffer0(surfaceData);
outGbuffer2 = EncodeSplitLightingGBuffer1(surfaceData);
#else
#endif
}
#ifdef _DEPTHOFFSET_ON

13
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/TessellationShare.hlsl


VaryingsToDS varying = InterpolateWithBaryCoordsToDS(varying0, varying1, varying2, baryCoords);
// We have Phong tessellation in all case where we don't have displacement only
#ifdef _TESSELLATION_PHONG
#ifndef _TESSELLATION_DISPLACEMENT
float3 p0 = varying0.vmesh.positionWS;
float3 p1 = varying1.vmesh.positionWS;

baryCoords, _TessellationShapeFactor);
#endif
#ifdef HAVE_TESSELLATION_MODIFICATION
// TODO: This should be an uniform for the object, this code should be remove (and is specific to Lit.shader) once we have it. - Workaround for now
// Extract scaling from world transform
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
float3 objectScale = varying.vmesh.objectScale;
#else
float3 objectScale = float3(1.0, 1.0, 1.0);
#endif
ApplyTessellationModification(varying.vmesh, varying.vmesh.normalWS, objectScale, varying.vmesh.positionWS);
#if defined(_TESSELLATION_DISPLACEMENT) || defined(_TESSELLATION_DISPLACEMENT_PHONG)
varying.vmesh.positionWS += GetTessellationDisplacement(varying.vmesh);
#endif
return VertTesselation(varying);

10
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl


#ifdef VARYINGS_DS_NEED_COLOR
float4 color;
#endif
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
#ifdef _TESSELLATION_OBJECT_SCALE
float3 objectScale;
#endif
};

float4 interpolators5 : TEXCOORD2;
#endif
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
#ifdef _TESSELLATION_OBJECT_SCALE
float3 interpolators6 : TEXCOORD3;
#endif
};

#ifdef VARYINGS_DS_NEED_COLOR
output.interpolators5 = input.color;
#endif
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
#ifdef _TESSELLATION_OBJECT_SCALE
output.interpolators6 = input.objectScale;
#endif

#ifdef VARYINGS_DS_NEED_COLOR
output.color = input.interpolators5;
#endif
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
#ifdef _TESSELLATION_OBJECT_SCALE
output.objectScale = input.interpolators6;
#endif
return output;

TESSELLATION_INTERPOLATE_BARY(color, baryCoords);
#endif
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
#ifdef _TESSELLATION_OBJECT_SCALE
// objectScale doesn't change for the whole object.
ouput.objectScale = input0.objectScale;
#endif

49
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl


VaryingsMeshType output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
#ifdef ATTRIBUTES_NEED_NORMAL
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
#else
float3 normalWS = float3(0.0, 0.0, 0.0); // We need this case to be able to compile ApplyVertexModification that doesn't use normal.
float3 normalWS = float3(0.0, 0.0, 0.0);
float4 tangentWS = float4(0.0, 0.0, 0.0, 0.0);
float4 vertexColor = float4(0.0, 0.0, 0.0, 0.0);
#if (defined(VARYINGS_NEED_TANGENT_TO_WORLD) || defined(TESSELLATION_ON)) && (SHADERPASS != SHADERPASS_VELOCITY)
normalWS = TransformObjectToWorldNormal(input.normalOS);
#ifdef ATTRIBUTES_NEED_TANGENT
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
#if defined(VARYINGS_NEED_TANGENT_TO_WORLD) || defined(VARYINGS_DS_NEED_TANGENT)
tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
// TODO: This should be an uniform for the object, this code should be remove (and is specific to Lit.shader) once we have it. - Workaround for now
// Extract scaling from world transform
#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
float3 objectScale;
float4x4 worldTransform = GetObjectToWorldMatrix();
objectScale.x = length(float3(worldTransform._m00, worldTransform._m01, worldTransform._m02));
objectScale.y = length(float3(worldTransform._m10, worldTransform._m11, worldTransform._m12));
objectScale.z = length(float3(worldTransform._m20, worldTransform._m21, worldTransform._m22));
#else
float3 objectScale = float3(1.0, 1.0, 1.0);
#if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR)
vertexColor = input.color;
// TODO: deal with camera center rendering and instancing (This is the reason why we always perform two steps transform to clip space + instancing matrix)
// This code is disabled for velocity pass for now because at the moment we cannot have Normals with the velocity pass (this attributes holds last frame data)
// TODO: Remove the velocity pass test when velocity is properly handled.
#if defined(HAVE_VERTEX_MODIFICATION) && (SHADERPASS != SHADERPASS_VELOCITY)
ApplyVertexModification(input, normalWS, objectScale, positionWS);
#if _VERTEX_WIND
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
ApplyWind(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, vertexColor.a, _Time);
#endif
positionWS = GetCameraRelativePositionWS(positionWS);

#ifdef _VERTEX_DISPLACEMENT_OBJECT_SCALE
// TODO: This should be an uniform for the object, this code should be remove (and is specific to Lit.shader) once we have it. - Workaround for now
output.objectScale = objectScale;
#ifdef _TESSELLATION_OBJECT_SCALE
// Extract scaling from world transform
float4x4 worldTransform = GetObjectToWorldMatrix();
output.objectScale.x = length(float3(worldTransform._m00, worldTransform._m01, worldTransform._m02));
output.objectScale.y = length(float3(worldTransform._m10, worldTransform._m11, worldTransform._m12));
output.objectScale.z = length(float3(worldTransform._m20, worldTransform._m21, worldTransform._m22));
// TODO: deal with camera center rendering and instancing (This is the reason why we always perform tow steps transform to clip space + instancing matrix)
// TODO: TEMP: Velocity has a flow as it doens't have normal. This need to be fix. In the mean time, generate fix normal so compiler doesn't complain - When fix, think to also enable ATTRIBUTES_NEED_NORMAL in LitVelocityPass.hlsl
#if SHADERPASS == SHADERPASS_VELOCITY
output.normalWS = float3(0.0, 0.0, 1.0);

output.tangentWS = tangentWS;
#endif
#else
// TODO deal with camera center rendering and instancing (This is the reason why we always perform tow steps transform to clip space + instancing matrix)
#ifdef VARYINGS_NEED_POSITION_WS
output.positionWS = positionWS;
#endif

output.texCoord3 = input.uv3;
#endif
#if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR)
output.color = input.color;
output.color = vertexColor;
#endif
return output;

2
ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


{
// 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 = IsSkyValid() ? m_StandardSkyboxMaterial : null; // Setup this material as the default to be use in RenderSettings
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;

20
ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs


using System.Reflection;
using UnityEngine.Rendering.PostProcessing;
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
#endif
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[Flags]

public class Utilities
{
#if UNITY_EDITOR
public static string GetHDRenderPipelinePath()
{
// User can create their own directory for SRP, so we need to find the current path that they use.
// We know that DefaultHDMaterial exist and we know where it is, let's use that to find the current directory.
var guid = AssetDatabase.FindAssets("DefaultHDMaterial t:material");
string path = AssetDatabase.GUIDToAssetPath(guid[0]);
path = Path.GetDirectoryName(path); // Asset is in HDRenderPipeline/RenderPipelineResources/DefaultHDMaterial.mat
path = path.Replace("RenderPipelineResources", ""); // Keep only path with HDRenderPipeline
return path;
}
#endif
public static List<RenderPipelineMaterial> GetRenderPipelineMaterialList()
{
List<RenderPipelineMaterial> materialList = new List<RenderPipelineMaterial>();

25
ScriptableRenderPipeline/Core/ShadowIncludes.inl


// This file is inlined by ShaderLibrary/Shadow/Shadow.hlsl twice.
// Each time either SHADOW_CONTEXT_INCLUDE or SHADOW_DISPATCH_INCLUDE is defined.
// In the case of SHADOW_CONTEXT_INCLUDE a valid path must be given to a file that contains
// the code to initialize a shadow context.
// SHADOW_DISPATCH_INCLUDE is optional.
#ifdef SHADOW_CONTEXT_INCLUDE
# ifdef SHADOW_TILEPASS
# include "../HDRenderPipeline/Lighting/TilePass/ShadowContext.hlsl"
# elif defined( SHADOW_FPTL )
# include "../../TestbedPipelines/fptl/ShadowContext.hlsl"
# else
# error "No valid path to the shadow context has been given."
# endif
#endif
#ifdef SHADOW_DISPATCH_INCLUDE
# ifdef SHADOW_TILEPASS
# include "../HDRenderPipeline/Lighting/TilePass/ShadowDispatch.hlsl"
# elif defined( SHADOW_FPTL )
# include "../../TestbedPipelines/fptl/ShadowDispatch.hlsl"
# else
// It's ok not to have a dispatcher include as it only acts as an override
# endif
#endif

8
ScriptableRenderPipeline/Core/ShadowIncludes.inl.meta


fileFormatVersion: 2
guid: cbc2765f95de56a47a8f39f5f1badd58
timeCreated: 1491314187
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

63
ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class SceneSettingsManagementWindow : EditorWindow
{
[MenuItem("HDRenderPipeline/Scene Settings Management")]
static void SceneSettingsManagement()
{
GetWindow<SceneSettingsManagementWindow>().Show();
}
static private string m_LastCreationPath = "Assets";
void CreateAsset<AssetType>(string assetName) where AssetType : ScriptableObject
{
string assetPath = EditorUtility.SaveFilePanel("Create new Asset", m_LastCreationPath, assetName, "asset");
if (!string.IsNullOrEmpty(assetPath))
{
assetPath = assetPath.Substring(assetPath.LastIndexOf("Assets"));
m_LastCreationPath = System.IO.Path.GetDirectoryName(assetPath);
var instance = CreateInstance<AssetType>();
AssetDatabase.CreateAsset(instance, assetPath);
}
}
void OnGUI()
{
// Keep it there temporarily until it's back to an "engine" setting in the HDRenderPipeline asset.
EditorGUILayout.Space();
if (GUILayout.Button("Create new Common Settings"))
{
CreateAsset<CommonSettings>("NewCommonSettings");
}
if (GUILayout.Button("Create new HDRI Sky Settings"))
{
CreateAsset<HDRISkySettings>("NewHDRISkySettings");
}
if (GUILayout.Button("Create new Procedural Sky Settings"))
{
CreateAsset<ProceduralSkySettings>("NewProceduralSkySettings");
}
if (GUILayout.Button("Create new Ambient Occlusion Settings"))
{
CreateAsset<ScreenSpaceAmbientOcclusionSettings>("NewAmbientOcclusionSettings");
}
EditorGUILayout.Space();
if (GUILayout.Button("Create Scene Settings"))
{
var manager = new GameObject();
manager.name = "Scene Settings";
manager.AddComponent<SceneSettings>();
}
}
}
}

12
ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs.meta


fileFormatVersion: 2
guid: a6a2e8d7ee3eb2c46962c9b49ff6c8ef
timeCreated: 1485262288
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

185
ScriptableRenderPipeline/HDRenderPipeline/HDShaderIDs.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
// Pre-hashed shader ids - naming conventions are a bit off in this file as we use the same
// fields names as in the shaders for ease of use... Would be nice to clean this up at some
// point.
static class HDShaderIDs
{
internal static readonly int _ShadowDatasExp = Shader.PropertyToID("_ShadowDatasExp");
internal static readonly int _ShadowPayloads = Shader.PropertyToID("_ShadowPayloads");
internal static readonly int _ShadowmapExp_VSM_0 = Shader.PropertyToID("_ShadowmapExp_VSM_0");
internal static readonly int _ShadowmapExp_VSM_1 = Shader.PropertyToID("_ShadowmapExp_VSM_1");
internal static readonly int _ShadowmapExp_VSM_2 = Shader.PropertyToID("_ShadowmapExp_VSM_2");
internal static readonly int _ShadowmapExp_PCF = Shader.PropertyToID("_ShadowmapExp_PCF");
internal static readonly int g_LayeredSingleIdxBuffer = Shader.PropertyToID("g_LayeredSingleIdxBuffer");
internal static readonly int _EnvLightIndexShift = Shader.PropertyToID("_EnvLightIndexShift");
internal static readonly int g_isOrthographic = Shader.PropertyToID("g_isOrthographic");
internal static readonly int g_iNrVisibLights = Shader.PropertyToID("g_iNrVisibLights");
internal static readonly int g_mScrProjection = Shader.PropertyToID("g_mScrProjection");
internal static readonly int g_mInvScrProjection = Shader.PropertyToID("g_mInvScrProjection");
internal static readonly int g_iLog2NumClusters = Shader.PropertyToID("g_iLog2NumClusters");
internal static readonly int g_fNearPlane = Shader.PropertyToID("g_fNearPlane");
internal static readonly int g_fFarPlane = Shader.PropertyToID("g_fFarPlane");
internal static readonly int g_fClustScale = Shader.PropertyToID("g_fClustScale");
internal static readonly int g_fClustBase = Shader.PropertyToID("g_fClustBase");
internal static readonly int g_depth_tex = Shader.PropertyToID("g_depth_tex");
internal static readonly int g_vLayeredLightList = Shader.PropertyToID("g_vLayeredLightList");
internal static readonly int g_LayeredOffset = Shader.PropertyToID("g_LayeredOffset");
internal static readonly int g_vBigTileLightList = Shader.PropertyToID("g_vBigTileLightList");
internal static readonly int g_logBaseBuffer = Shader.PropertyToID("g_logBaseBuffer");
internal static readonly int g_vBoundsBuffer = Shader.PropertyToID("g_vBoundsBuffer");
internal static readonly int _LightVolumeData = Shader.PropertyToID("_LightVolumeData");
internal static readonly int g_data = Shader.PropertyToID("g_data");
internal static readonly int g_mProjection = Shader.PropertyToID("g_mProjection");
internal static readonly int g_mInvProjection = Shader.PropertyToID("g_mInvProjection");
internal static readonly int g_viDimensions = Shader.PropertyToID("g_viDimensions");
internal static readonly int g_vLightList = Shader.PropertyToID("g_vLightList");
internal static readonly int g_BaseFeatureFlags = Shader.PropertyToID("g_BaseFeatureFlags");
internal static readonly int g_TileFeatureFlags = Shader.PropertyToID("g_TileFeatureFlags");
internal static readonly int _GBufferTexture0 = Shader.PropertyToID("_GBufferTexture0");
internal static readonly int _GBufferTexture1 = Shader.PropertyToID("_GBufferTexture1");
internal static readonly int _GBufferTexture2 = Shader.PropertyToID("_GBufferTexture2");
internal static readonly int _GBufferTexture3 = Shader.PropertyToID("_GBufferTexture3");
internal static readonly int g_DispatchIndirectBuffer = Shader.PropertyToID("g_DispatchIndirectBuffer");
internal static readonly int g_TileList = Shader.PropertyToID("g_TileList");
internal static readonly int g_NumTiles = Shader.PropertyToID("g_NumTiles");
internal static readonly int g_NumTilesX = Shader.PropertyToID("g_NumTilesX");
internal static readonly int _NumTiles = Shader.PropertyToID("_NumTiles");
internal static readonly int _CookieTextures = Shader.PropertyToID("_CookieTextures");
internal static readonly int _CookieCubeTextures = Shader.PropertyToID("_CookieCubeTextures");
internal static readonly int _EnvTextures = Shader.PropertyToID("_EnvTextures");
internal static readonly int _DirectionalLightDatas = Shader.PropertyToID("_DirectionalLightDatas");
internal static readonly int _DirectionalLightCount = Shader.PropertyToID("_DirectionalLightCount");
internal static readonly int _LightDatas = Shader.PropertyToID("_LightDatas");
internal static readonly int _PunctualLightCount = Shader.PropertyToID("_PunctualLightCount");
internal static readonly int _AreaLightCount = Shader.PropertyToID("_AreaLightCount");
internal static readonly int g_vLightListGlobal = Shader.PropertyToID("g_vLightListGlobal");
internal static readonly int _EnvLightDatas = Shader.PropertyToID("_EnvLightDatas");
internal static readonly int _EnvLightCount = Shader.PropertyToID("_EnvLightCount");
internal static readonly int _ShadowDatas = Shader.PropertyToID("_ShadowDatas");
internal static readonly int _DirShadowSplitSpheres = Shader.PropertyToID("_DirShadowSplitSpheres");
internal static readonly int _NumTileFtplX = Shader.PropertyToID("_NumTileFtplX");
internal static readonly int _NumTileFtplY = Shader.PropertyToID("_NumTileFtplY");
internal static readonly int _NumTileClusteredX = Shader.PropertyToID("_NumTileClusteredX");
internal static readonly int _NumTileClusteredY = Shader.PropertyToID("_NumTileClusteredY");
internal static readonly int g_isLogBaseBufferEnabled = Shader.PropertyToID("g_isLogBaseBufferEnabled");
internal static readonly int g_vLayeredOffsetsBuffer = Shader.PropertyToID("g_vLayeredOffsetsBuffer");
internal static readonly int _ViewTilesFlags = Shader.PropertyToID("_ViewTilesFlags");
internal static readonly int _MousePixelCoord = Shader.PropertyToID("_MousePixelCoord");
internal static readonly int _DebugViewMaterial = Shader.PropertyToID("_DebugViewMaterial");
internal static readonly int _DebugLightingMode = Shader.PropertyToID("_DebugLightingMode");
internal static readonly int _DebugLightingAlbedo = Shader.PropertyToID("_DebugLightingAlbedo");
internal static readonly int _DebugLightingSmoothness = Shader.PropertyToID("_DebugLightingSmoothness");
internal static readonly int _AmbientOcclusionTexture = Shader.PropertyToID("_AmbientOcclusionTexture");
internal static readonly int _UseTileLightList = Shader.PropertyToID("_UseTileLightList");
internal static readonly int _Time = Shader.PropertyToID("_Time");
internal static readonly int _SinTime = Shader.PropertyToID("_SinTime");
internal static readonly int _CosTime = Shader.PropertyToID("_CosTime");
internal static readonly int unity_DeltaTime = Shader.PropertyToID("unity_DeltaTime");
internal static readonly int _EnvLightSkyEnabled = Shader.PropertyToID("_EnvLightSkyEnabled");
internal static readonly int _AmbientOcclusionDirectLightStrenght = Shader.PropertyToID("_AmbientOcclusionDirectLightStrenght");
internal static readonly int _SkyTexture = Shader.PropertyToID("_SkyTexture");
internal static readonly int _UseDisneySSS = Shader.PropertyToID("_UseDisneySSS");
internal static readonly int _EnableSSSAndTransmission = Shader.PropertyToID("_EnableSSSAndTransmission");
internal static readonly int _TexturingModeFlags = Shader.PropertyToID("_TexturingModeFlags");
internal static readonly int _TransmissionFlags = Shader.PropertyToID("_TransmissionFlags");
internal static readonly int _ThicknessRemaps = Shader.PropertyToID("_ThicknessRemaps");
internal static readonly int _ShapeParams = Shader.PropertyToID("_ShapeParams");
internal static readonly int _HalfRcpVariancesAndWeights = Shader.PropertyToID("_HalfRcpVariancesAndWeights");
internal static readonly int _TransmissionTints = Shader.PropertyToID("_TransmissionTints");
internal static readonly int specularLightingUAV = Shader.PropertyToID("specularLightingUAV");
internal static readonly int diffuseLightingUAV = Shader.PropertyToID("diffuseLightingUAV");
internal static readonly int g_TileListOffset = Shader.PropertyToID("g_TileListOffset");
internal static readonly int _LtcData = Shader.PropertyToID("_LtcData");
internal static readonly int _PreIntegratedFGD = Shader.PropertyToID("_PreIntegratedFGD");
internal static readonly int _LtcGGXMatrix = Shader.PropertyToID("_LtcGGXMatrix");
internal static readonly int _LtcDisneyDiffuseMatrix = Shader.PropertyToID("_LtcDisneyDiffuseMatrix");
internal static readonly int _LtcMultiGGXFresnelDisneyDiffuse = Shader.PropertyToID("_LtcMultiGGXFresnelDisneyDiffuse");
internal static readonly int _MainDepthTexture = Shader.PropertyToID("_MainDepthTexture");
internal static readonly int unity_OrthoParams = Shader.PropertyToID("unity_OrthoParams");
internal static readonly int _ZBufferParams = Shader.PropertyToID("_ZBufferParams");
internal static readonly int _ScreenParams = Shader.PropertyToID("_ScreenParams");
internal static readonly int _ProjectionParams = Shader.PropertyToID("_ProjectionParams");
internal static readonly int _WorldSpaceCameraPos = Shader.PropertyToID("_WorldSpaceCameraPos");
internal static readonly int _StencilRef = Shader.PropertyToID("_StencilRef");
internal static readonly int _StencilCmp = Shader.PropertyToID("_StencilCmp");
internal static readonly int _SrcBlend = Shader.PropertyToID("_SrcBlend");
internal static readonly int _DstBlend = Shader.PropertyToID("_DstBlend");
internal static readonly int _HTile = Shader.PropertyToID("_HTile");
internal static readonly int _StencilTexture = Shader.PropertyToID("_StencilTexture");
internal static readonly int _ViewMatrix = Shader.PropertyToID("_ViewMatrix");
internal static readonly int _InvViewMatrix = Shader.PropertyToID("_InvViewMatrix");
internal static readonly int _ProjMatrix = Shader.PropertyToID("_ProjMatrix");
internal static readonly int _InvProjMatrix = Shader.PropertyToID("_InvProjMatrix");
internal static readonly int _NonJitteredViewProjMatrix = Shader.PropertyToID("_NonJitteredViewProjMatrix");
internal static readonly int _ViewProjMatrix = Shader.PropertyToID("_ViewProjMatrix");
internal static readonly int _InvViewProjMatrix = Shader.PropertyToID("_InvViewProjMatrix");
internal static readonly int _InvProjParam = Shader.PropertyToID("_InvProjParam");
internal static readonly int _ScreenSize = Shader.PropertyToID("_ScreenSize");
internal static readonly int _PrevViewProjMatrix = Shader.PropertyToID("_PrevViewProjMatrix");
internal static readonly int _FrustumPlanes = Shader.PropertyToID("_FrustumPlanes");
internal static readonly int _DepthTexture = Shader.PropertyToID("_DepthTexture");
internal static readonly int _CameraColorTexture = Shader.PropertyToID("_CameraColorTexture");
internal static readonly int _CameraSssDiffuseLightingBuffer = Shader.PropertyToID("_CameraSssDiffuseLightingTexture");
internal static readonly int _CameraFilteringBuffer = Shader.PropertyToID("_CameraFilteringTexture");
internal static readonly int _IrradianceSource = Shader.PropertyToID("_IrradianceSource");
internal static readonly int _VelocityTexture = Shader.PropertyToID("_VelocityTexture");
internal static readonly int _DistortionTexture = Shader.PropertyToID("_DistortionTexture");
internal static readonly int _DebugFullScreenTexture = Shader.PropertyToID("_DebugFullScreenTexture");
internal static readonly int _WorldScales = Shader.PropertyToID("_WorldScales");
internal static readonly int _FilterKernels = Shader.PropertyToID("_FilterKernels");
internal static readonly int _FilterKernelsBasic = Shader.PropertyToID("_FilterKernelsBasic");
internal static readonly int _HalfRcpWeightedVariances = Shader.PropertyToID("_HalfRcpWeightedVariances");
internal static readonly int _CameraPosDiff = Shader.PropertyToID("_CameraPosDiff");
internal static readonly int _CameraDepthTexture = Shader.PropertyToID("_CameraDepthTexture");
internal static readonly int _CameraMotionVectorsTexture = Shader.PropertyToID("_CameraMotionVectorsTexture");
internal static readonly int _FullScreenDebugMode = Shader.PropertyToID("_FullScreenDebugMode");
internal static readonly int _InputCubemap = Shader.PropertyToID("_InputCubemap");
internal static readonly int _Mipmap = Shader.PropertyToID("_Mipmap");
internal static readonly int _MaxRadius = Shader.PropertyToID("_MaxRadius");
internal static readonly int _ShapeParam = Shader.PropertyToID("_ShapeParam");
internal static readonly int _StdDev1 = Shader.PropertyToID("_StdDev1");
internal static readonly int _StdDev2 = Shader.PropertyToID("_StdDev2");
internal static readonly int _LerpWeight = Shader.PropertyToID("_LerpWeight");
internal static readonly int _HalfRcpVarianceAndWeight1 = Shader.PropertyToID("_HalfRcpVarianceAndWeight1");
internal static readonly int _HalfRcpVarianceAndWeight2 = Shader.PropertyToID("_HalfRcpVarianceAndWeight2");
internal static readonly int _TransmissionTint = Shader.PropertyToID("_TransmissionTint");
internal static readonly int _ThicknessRemap = Shader.PropertyToID("_ThicknessRemap");
internal static readonly int _Cubemap = Shader.PropertyToID("_Cubemap");
internal static readonly int _SkyParam = Shader.PropertyToID("_SkyParam");
internal static readonly int _PixelCoordToViewDirWS = Shader.PropertyToID("_PixelCoordToViewDirWS");
internal static readonly int _GlobalFog_Extinction = Shader.PropertyToID("_GlobalFog_Extinction");
internal static readonly int _GlobalFog_Asymmetry = Shader.PropertyToID("_GlobalFog_Asymmetry");
internal static readonly int _GlobalFog_Scattering = Shader.PropertyToID("_GlobalFog_Scattering");
}
}

13
ScriptableRenderPipeline/HDRenderPipeline/HDShaderIDs.cs.meta


fileFormatVersion: 2
guid: a586982c0c38ee64095f06495d043462
timeCreated: 1501072635
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

10
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye.meta


fileFormatVersion: 2
guid: 99b28ae1899c34841bb5edf61823d22d
folderAsset: yes
timeCreated: 1504677840
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

10
ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric.meta


fileFormatVersion: 2
guid: 6bee56a72daba3d479259196d046864c
folderAsset: yes
timeCreated: 1504677840
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

10
ScriptableRenderPipeline/HDRenderPipeline/Material/Hair.meta


fileFormatVersion: 2
guid: dfab746be3b7dc34ebec9f9c63bc9a74
folderAsset: yes
timeCreated: 1504677840
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

265
ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare1.hlsl


// Area light textures specific constant
SamplerState ltc_linear_clamp_sampler;
// TODO: This one should be set into a constant Buffer at pass frequency (with _Screensize)
TEXTURE2D(_PreIntegratedFGD);
TEXTURE2D_ARRAY(_LtcData); // We pack the 3 Ltc data inside a texture array
#define LTC_GGX_MATRIX_INDEX 0 // RGBA
#define LTC_DISNEY_DIFFUSE_MATRIX_INDEX 1 // RGBA
#define LTC_MULTI_GGX_FRESNEL_DISNEY_DIFFUSE_INDEX 2 // RGB, A unused
#define LTC_LUT_SIZE 64
#define LTC_LUT_SCALE ((LTC_LUT_SIZE - 1) * rcp(LTC_LUT_SIZE))
#define LTC_LUT_OFFSET (0.5 * rcp(LTC_LUT_SIZE))
#define MIN_N_DOT_V 0.0001 // The minimum value of 'NdotV'
#ifdef WANT_SSS_CODE
// Subsurface scattering specific constant
#define SSS_WRAP_ANGLE (PI/12) // Used for wrap lighting
#define SSS_WRAP_LIGHT cos(PI/2 - SSS_WRAP_ANGLE)
CBUFFER_START(UnitySSSParameters)
uint _EnableSSSAndTransmission; // Globally toggles subsurface and transmission scattering on/off
uint _TexturingModeFlags; // 1 bit/profile; 0 = PreAndPostScatter, 1 = PostScatter
uint _TransmissionFlags; // 2 bit/profile; 0 = inf. thick, 1 = thin, 2 = regular
// Old SSS Model >>>
uint _UseDisneySSS;
float4 _HalfRcpVariancesAndWeights[SSS_N_PROFILES][2]; // 2x Gaussians in RGB, A is interpolation weights
// <<< Old SSS Model
// Use float4 to avoid any packing issue between compute and pixel shaders
float4 _ThicknessRemaps[SSS_N_PROFILES]; // R: start, G = end - start, BA unused
float4 _ShapeParams[SSS_N_PROFILES]; // RGB = S = 1 / D, A = filter radius
float4 _TransmissionTints[SSS_N_PROFILES]; // RGB = 1/4 * color, A = unused
CBUFFER_END
#endif
void ApplyDebugToSurfaceData(inout SurfaceData surfaceData)
{
#ifdef DEBUG_DISPLAY
if (_DebugLightingMode == DEBUGLIGHTINGMODE_SPECULAR_LIGHTING)
{
bool overrideSmoothness = _DebugLightingSmoothness.x != 0.0;
float overrideSmoothnessValue = _DebugLightingSmoothness.y;
if (overrideSmoothness)
{
surfaceData.perceptualSmoothness = overrideSmoothnessValue;
}
}
if (_DebugLightingMode == DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING)
{
surfaceData.baseColor = _DebugLightingAlbedo.xyz;
}
#endif
}
//-----------------------------------------------------------------------------
// Debug method (use to display values)
//-----------------------------------------------------------------------------
void GetSurfaceDataDebug(uint paramId, SurfaceData surfaceData, inout float3 result, inout bool needLinearToSRGB)
{
GetGeneratedSurfaceDataDebug(paramId, surfaceData, result, needLinearToSRGB);
}
void GetBSDFDataDebug(uint paramId, BSDFData bsdfData, inout float3 result, inout bool needLinearToSRGB)
{
GetGeneratedBSDFDataDebug(paramId, bsdfData, result, needLinearToSRGB);
}
#ifdef WANT_SSS_CODE
void FillMaterialIdSSSData(float3 baseColor, int subsurfaceProfile, float subsurfaceRadius, float thickness, inout BSDFData bsdfData)
{
bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile instead
bsdfData.subsurfaceProfile = subsurfaceProfile;
bsdfData.subsurfaceRadius = subsurfaceRadius;
bsdfData.thickness = _ThicknessRemaps[subsurfaceProfile].x + _ThicknessRemaps[subsurfaceProfile].y * thickness;
uint transmissionMode = BitFieldExtract(_TransmissionFlags, 2u, 2u * subsurfaceProfile);
bsdfData.enableTransmission = transmissionMode != SSS_TRSM_MODE_NONE && (_EnableSSSAndTransmission > 0);
bsdfData.useThinObjectMode = transmissionMode == SSS_TRSM_MODE_THIN;
bool performPostScatterTexturing = IsBitSet(_TexturingModeFlags, subsurfaceProfile);
#if defined(SHADERPASS) && (SHADERPASS == SHADERPASS_LIGHT_TRANSPORT) // In case of GI pass don't modify the diffuseColor
bool enableSssAndTransmission = false;
#elif defined(SHADERPASS) && (SHADERPASS == SHADERPASS_SUBSURFACE_SCATTERING)
bool enableSssAndTransmission = true;
#else
bool enableSssAndTransmission = _EnableSSSAndTransmission != 0;
#endif
if (enableSssAndTransmission) // If we globally disable SSS effect, don't modify diffuseColor
{
// We modify the albedo here as this code is used by all lighting (including light maps and GI).
if (performPostScatterTexturing)
{
#if !defined(SHADERPASS) || (SHADERPASS != SHADERPASS_SUBSURFACE_SCATTERING)
bsdfData.diffuseColor = float3(1.0, 1.0, 1.0);
#endif
}
else
{
bsdfData.diffuseColor = sqrt(bsdfData.diffuseColor);
}
}
if (bsdfData.enableTransmission)
{
if (_UseDisneySSS)
{
bsdfData.transmittance = ComputeTransmittance(_ShapeParams[subsurfaceProfile].rgb,
_TransmissionTints[subsurfaceProfile].rgb,
bsdfData.thickness, bsdfData.subsurfaceRadius);
}
else
{
bsdfData.transmittance = ComputeTransmittanceJimenez(_HalfRcpVariancesAndWeights[subsurfaceProfile][0].rgb,
_HalfRcpVariancesAndWeights[subsurfaceProfile][0].a,
_HalfRcpVariancesAndWeights[subsurfaceProfile][1].rgb,
_HalfRcpVariancesAndWeights[subsurfaceProfile][1].a,
_TransmissionTints[subsurfaceProfile].rgb,
bsdfData.thickness, bsdfData.subsurfaceRadius);
}
bsdfData.transmittance *= bsdfData.diffuseColor; // Premultiply
}
}
#endif
// For image based lighting, a part of the BSDF is pre-integrated.
// This is done both for specular and diffuse (in case of DisneyDiffuse)
void GetPreIntegratedFGD(float NdotV, float perceptualRoughness, float3 fresnel0, out float3 specularFGD, out float diffuseFGD)
{
// Pre-integrate GGX FGD
// _PreIntegratedFGD.x = Gv * (1 - Fc) with Fc = (1 - H.L)^5
// _PreIntegratedFGD.y = Gv * Fc
// Pre integrate DisneyDiffuse FGD:
// _PreIntegratedFGD.z = DisneyDiffuse
float3 preFGD = SAMPLE_TEXTURE2D_LOD(_PreIntegratedFGD, ltc_linear_clamp_sampler, float2(NdotV, perceptualRoughness), 0).xyz;
// f0 * Gv * (1 - Fc) + Gv * Fc
specularFGD = fresnel0 * preFGD.x + preFGD.y;
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
diffuseFGD = 1.0;
#else
diffuseFGD = preFGD.z;
#endif
}
// Precomputed lighting data to send to the various lighting functions
struct PreLightData
{
// General
float NdotV; // Geometric version (could be negative)
// GGX iso
float ggxLambdaV;
// GGX Aniso
float TdotV;
float BdotV;
float anisoGGXLambdaV;
// IBL
float3 iblDirWS; // Dominant specular direction, used for IBL in EvaluateBSDF_Env()
float iblMipLevel;
float3 specularFGD; // Store preconvoled BRDF for both specular and diffuse
float diffuseFGD;
// Area lights (17 VGPRs)
float3x3 orthoBasisViewNormal; // Right-handed view-dependent orthogonal basis around the normal (6x VGPRs)
float3x3 ltcTransformDiffuse; // Inverse transformation for Lambertian or Disney Diffuse (4x VGPRs)
float3x3 ltcTransformSpecular; // Inverse transformation for GGX (4x VGPRs)
float ltcMagnitudeDiffuse;
float3 ltcMagnitudeFresnel;
};
PreLightData GetPreLightData(float3 V, PositionInputs posInput, BSDFData bsdfData)
{
PreLightData preLightData;
preLightData.NdotV = dot(bsdfData.normalWS, V); // Store the unaltered (geometric) version
float NdotV = preLightData.NdotV;
// In the case of IBL we want shift a bit the normal that are not toward the viewver to reduce artifact
float3 iblNormalWS = GetViewShiftedNormal(bsdfData.normalWS, V, NdotV, MIN_N_DOT_V); // Use non clamped NdotV
float3 iblR = reflect(-V, iblNormalWS);
NdotV = max(NdotV, MIN_N_DOT_V); // Use the modified (clamped) version
// GGX iso
preLightData.ggxLambdaV = GetSmithJointGGXLambdaV(NdotV, bsdfData.roughness);
// GGX aniso
preLightData.TdotV = 0.0;
preLightData.BdotV = 0.0;
if (bsdfData.materialId == MATERIALID_LIT_ANISO)
{
preLightData.TdotV = dot(bsdfData.tangentWS, V);
preLightData.BdotV = dot(bsdfData.bitangentWS, V);
preLightData.anisoGGXLambdaV = GetSmithJointGGXAnisoLambdaV(preLightData.TdotV, preLightData.BdotV, NdotV, bsdfData.roughnessT, bsdfData.roughnessB);
// Tangent = highlight stretch (anisotropy) direction. Bitangent = grain (brush) direction.
float3 anisoIblNormalWS = GetAnisotropicModifiedNormal(bsdfData.bitangentWS, iblNormalWS, V, bsdfData.anisotropy);
// NOTE: If we follow the theory we should use the modified normal for the different calculation implying a normal (like NdotV) and use iblNormalWS
// into function like GetSpecularDominantDir(). However modified normal is just a hack. The goal is just to stretch a cubemap, no accuracy here.
// With this in mind and for performance reasons we chose to only use modified normal to calculate R.
iblR = reflect(-V, anisoIblNormalWS);
}
// IBL
GetPreIntegratedFGD(NdotV, bsdfData.perceptualRoughness, bsdfData.fresnel0, preLightData.specularFGD, preLightData.diffuseFGD);
preLightData.iblDirWS = GetSpecularDominantDir(iblNormalWS, iblR, bsdfData.roughness, NdotV);
preLightData.iblMipLevel = PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness);
// Area light
// UVs for sampling the LUTs
float theta = FastACos(NdotV); // For Area light - UVs for sampling the LUTs
float2 uv = LTC_LUT_OFFSET + LTC_LUT_SCALE * float2(bsdfData.perceptualRoughness, theta * INV_HALF_PI);
// Note we load the matrix transpose (avoid to have to transpose it in shader)
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
preLightData.ltcTransformDiffuse = k_identity3x3;
#else
// Get the inverse LTC matrix for Disney Diffuse
preLightData.ltcTransformDiffuse = 0.0;
preLightData.ltcTransformDiffuse._m22 = 1.0;
preLightData.ltcTransformDiffuse._m00_m02_m11_m20 = SAMPLE_TEXTURE2D_ARRAY_LOD(_LtcData, ltc_linear_clamp_sampler, uv, LTC_DISNEY_DIFFUSE_MATRIX_INDEX, 0);
#endif
// Get the inverse LTC matrix for GGX
// Note we load the matrix transpose (avoid to have to transpose it in shader)
preLightData.ltcTransformSpecular = 0.0;
preLightData.ltcTransformSpecular._m22 = 1.0;
preLightData.ltcTransformSpecular._m00_m02_m11_m20 = SAMPLE_TEXTURE2D_ARRAY_LOD(_LtcData, ltc_linear_clamp_sampler, uv, LTC_GGX_MATRIX_INDEX, 0);
// Construct a right-handed view-dependent orthogonal basis around the normal
preLightData.orthoBasisViewNormal[0] = normalize(V - bsdfData.normalWS * preLightData.NdotV);
preLightData.orthoBasisViewNormal[2] = bsdfData.normalWS;
preLightData.orthoBasisViewNormal[1] = normalize(cross(preLightData.orthoBasisViewNormal[2], preLightData.orthoBasisViewNormal[0]));
float3 ltcMagnitude = SAMPLE_TEXTURE2D_ARRAY_LOD(_LtcData, ltc_linear_clamp_sampler, uv, LTC_MULTI_GGX_FRESNEL_DISNEY_DIFFUSE_INDEX, 0).rgb;
float ltcGGXFresnelMagnitudeDiff = ltcMagnitude.r; // The difference of magnitudes of GGX and Fresnel
float ltcGGXFresnelMagnitude = ltcMagnitude.g;
float ltcDisneyDiffuseMagnitude = ltcMagnitude.b;
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
preLightData.ltcMagnitudeDiffuse = 1;
#else
preLightData.ltcMagnitudeDiffuse = ltcDisneyDiffuseMagnitude;
#endif
// TODO: the fit seems rather poor. The scaling factor of 0.5 allows us
// to match the reference for rough metals, but further darkens dielectrics.
preLightData.ltcMagnitudeFresnel = bsdfData.fresnel0 * ltcGGXFresnelMagnitudeDiff + (float3)ltcGGXFresnelMagnitude;
return preLightData;
}

10
ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare1.hlsl.meta


fileFormatVersion: 2
guid: 0f24f4070ad17d14196c6ed72276a144
timeCreated: 1504900828
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

601
ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare2.hlsl


#ifdef HAS_LIGHTLOOP
#ifdef WANT_SSS_CODE
// Currently, we only model diffuse transmission. Specular transmission is not yet supported.
// We assume that the back side of the object is a uniformly illuminated infinite plane
// with the reversed normal (and the view vector) of the current sample.
float3 EvaluateTransmission(BSDFData bsdfData, float intensity, float shadow)
{
// For low thickness, we can reuse the shadowing status for the back of the object.
shadow = bsdfData.useThinObjectMode ? shadow : 1;
float backLight = intensity * shadow;
return backLight * bsdfData.transmittance; // Premultiplied with the diffuse color
}
#endif
//-----------------------------------------------------------------------------
// EvaluateBSDF_Directional (supports directional and box projector lights)
//-----------------------------------------------------------------------------
float4 EvaluateCookie_Directional(LightLoopContext lightLoopContext, DirectionalLightData lightData,
float3 lighToSample)
{
// Compute the NDC position (in [-1, 1]^2) by projecting 'positionWS' onto the near plane.
// 'lightData.right' and 'lightData.up' are pre-scaled on CPU.
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3 positionLS = mul(lighToSample, transpose(lightToWorld));
float2 positionNDC = positionLS.xy;
bool isInBounds;
// Remap the texture coordinates from [-1, 1]^2 to [0, 1]^2.
float2 coord = positionNDC * 0.5 + 0.5;
if (lightData.tileCookie)
{
// Tile the texture if the 'repeat' wrap mode is enabled.
coord = frac(coord);
isInBounds = true;
}
else
{
isInBounds = Max3(abs(positionNDC.x), abs(positionNDC.y), 1 - positionLS.z) <= 1;
}
// We let the sampler handle tiling or clamping to border.
// Note: tiling (the repeat mode) is not currently supported.
float4 cookie = SampleCookie2D(lightLoopContext, coord, lightData.cookieIndex);
cookie.a = isInBounds ? cookie.a : 0;
return cookie;
}
void EvaluateBSDF_Directional(LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput, PreLightData preLightData,
DirectionalLightData lightData, BSDFData bsdfData,
out float3 diffuseLighting,
out float3 specularLighting)
{
float3 positionWS = posInput.positionWS;
float3 L = -lightData.forward; // Lights are pointing backward in Unity
float NdotL = dot(bsdfData.normalWS, L);
float illuminance = saturate(NdotL);
diffuseLighting = float3(0, 0, 0); // TODO: check whether using 'out' instead of 'inout' increases the VGPR pressure
specularLighting = float3(0, 0, 0); // TODO: check whether using 'out' instead of 'inout' increases the VGPR pressure
float shadow = 1;
[branch] if (lightData.shadowIndex >= 0)
{
shadow = GetDirectionalShadowAttenuation(lightLoopContext.shadowContext, positionWS, bsdfData.normalWS, lightData.shadowIndex, L, posInput.unPositionSS);
illuminance *= shadow;
}
[branch] if (lightData.cookieIndex >= 0)
{
float3 lightToSurface = positionWS - lightData.positionWS;
float4 cookie = EvaluateCookie_Directional(lightLoopContext, lightData, lightToSurface);
// Premultiply.
lightData.color *= cookie.rgb;
lightData.diffuseScale *= cookie.a;
lightData.specularScale *= cookie.a;
}
[branch] if (illuminance > 0.0)
{
BSDF(V, L, positionWS, preLightData, bsdfData, diffuseLighting, specularLighting);
diffuseLighting *= illuminance * lightData.diffuseScale;
specularLighting *= illuminance * lightData.specularScale;
}
#ifdef WANT_SSS_CODE
[branch] if (bsdfData.enableTransmission)
{
// We apply wrapped lighting instead of the regular Lambertian diffuse
// to compensate for approximations within EvaluateTransmission().
float illuminance = Lambert() * ComputeWrappedDiffuseLighting(-NdotL, SSS_WRAP_LIGHT);
// We use diffuse lighting for accumulation since it is going to be blurred during the SSS pass.
diffuseLighting += EvaluateTransmission(bsdfData, illuminance * lightData.diffuseScale, shadow);
}
#endif
// Save ALU by applying 'lightData.color' only once.
diffuseLighting *= lightData.color;
specularLighting *= lightData.color;
}
//-----------------------------------------------------------------------------
// EvaluateBSDF_Punctual (supports spot, point and projector lights)
//-----------------------------------------------------------------------------
float4 EvaluateCookie_Punctual(LightLoopContext lightLoopContext, LightData lightData,
float3 lighToSample)
{
int lightType = lightData.lightType;
// Translate and rotate 'positionWS' into the light space.
// 'lightData.right' and 'lightData.up' are pre-scaled on CPU.
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3 positionLS = mul(lighToSample, transpose(lightToWorld));
float4 cookie;
[branch] if (lightType == GPULIGHTTYPE_POINT)
{
cookie = SampleCookieCube(lightLoopContext, positionLS, lightData.cookieIndex);
}
else
{
// Compute the NDC position (in [-1, 1]^2) by projecting 'positionWS' onto the plane at 1m distance.
// Box projector lights require no perspective division.
float perspectiveZ = (lightType != GPULIGHTTYPE_PROJECTOR_BOX) ? positionLS.z : 1;
float2 positionNDC = positionLS.xy / perspectiveZ;
bool isInBounds = Max3(abs(positionNDC.x), abs(positionNDC.y), 1 - positionLS.z) <= 1;
// Remap the texture coordinates from [-1, 1]^2 to [0, 1]^2.
float2 coord = positionNDC * 0.5 + 0.5;
// We let the sampler handle clamping to border.
cookie = SampleCookie2D(lightLoopContext, coord, lightData.cookieIndex);
cookie.a = isInBounds ? cookie.a : 0;
}
return cookie;
}
float GetPunctualShapeAttenuation(LightData lightData, float3 L, float distSq)
{
// Note: lightData.invSqrAttenuationRadius is 0 when applyRangeAttenuation is false
float attenuation = GetDistanceAttenuation(distSq, lightData.invSqrAttenuationRadius);
// Reminder: lights are oriented backward (-Z)
return attenuation * GetAngleAttenuation(L, -lightData.forward, lightData.angleScale, lightData.angleOffset);
}
void EvaluateBSDF_Punctual( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput, PreLightData preLightData, LightData lightData, BSDFData bsdfData,
out float3 diffuseLighting,
out float3 specularLighting)
{
float3 positionWS = posInput.positionWS;
int lightType = lightData.lightType;
// All punctual light type in the same formula, attenuation is neutral depends on light type.
// light.positionWS is the normalize light direction in case of directional light and invSqrAttenuationRadius is 0
// mean dot(unL, unL) = 1 and mean GetDistanceAttenuation() will return 1
// For point light and directional GetAngleAttenuation() return 1
float3 lightToSurface = positionWS - lightData.positionWS;
float3 unL = -lightToSurface;
float distSq = dot(unL, unL);
float dist = sqrt(distSq);
float3 L = (lightType != GPULIGHTTYPE_PROJECTOR_BOX) ? unL * rsqrt(distSq) : -lightData.forward;
float NdotL = dot(bsdfData.normalWS, L);
float illuminance = saturate(NdotL);
float attenuation = GetPunctualShapeAttenuation(lightData, L, distSq);
// Premultiply.
lightData.diffuseScale *= attenuation;
lightData.specularScale *= attenuation;
diffuseLighting = float3(0, 0, 0); // TODO: check whether using 'out' instead of 'inout' increases the VGPR pressure
specularLighting = float3(0, 0, 0); // TODO: check whether using 'out' instead of 'inout' increases the VGPR pressure
float shadow = 1;
[branch] if (lightData.shadowIndex >= 0)
{
// TODO: make projector lights cast shadows.
float3 offset = float3(0.0, 0.0, 0.0); // GetShadowPosOffset(nDotL, normal);
float4 L_dist = { L, dist };
shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, positionWS + offset, bsdfData.normalWS, lightData.shadowIndex, L_dist, posInput.unPositionSS);
shadow = lerp(1.0, shadow, lightData.shadowDimmer);
illuminance *= shadow;
}
// Projector lights always have a cookies, so we can perform clipping inside the if().
[branch] if (lightData.cookieIndex >= 0)
{
float4 cookie = EvaluateCookie_Punctual(lightLoopContext, lightData, lightToSurface);
// Premultiply.
lightData.color *= cookie.rgb;
lightData.diffuseScale *= cookie.a;
lightData.specularScale *= cookie.a;
}
[branch] if (illuminance > 0.0)
{
bsdfData.roughness = max(bsdfData.roughness, lightData.minRoughness); // Simulate that a punctual ligth have a radius with this hack
BSDF(V, L, positionWS, preLightData, bsdfData, diffuseLighting, specularLighting);
diffuseLighting *= illuminance * lightData.diffuseScale;
specularLighting *= illuminance * lightData.specularScale;
}
#ifdef WANT_SSS_CODE
[branch] if (bsdfData.enableTransmission)
{
// We apply wrapped lighting instead of the regular Lambertian diffuse
// to compensate for approximations within EvaluateTransmission().
float illuminance = Lambert() * ComputeWrappedDiffuseLighting(-NdotL, SSS_WRAP_LIGHT);
// We use diffuse lighting for accumulation since it is going to be blurred during the SSS pass.
diffuseLighting += EvaluateTransmission(bsdfData, illuminance * lightData.diffuseScale, shadow);
}
#endif
// Save ALU by applying 'lightData.color' only once.
diffuseLighting *= lightData.color;
specularLighting *= lightData.color;
}
#include "Lit/LitReference.hlsl"
//-----------------------------------------------------------------------------
// EvaluateBSDF_Line - Approximation with Linearly Transformed Cosines
//-----------------------------------------------------------------------------
void EvaluateBSDF_Line(LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, LightData lightData, BSDFData bsdfData,
out float3 diffuseLighting, out float3 specularLighting)
{
float3 positionWS = posInput.positionWS;
#ifdef LIT_DISPLAY_REFERENCE_AREA
IntegrateBSDF_LineRef(V, positionWS, preLightData, lightData, bsdfData,
diffuseLighting, specularLighting);
#else
diffuseLighting = float3(0.0, 0.0, 0.0);
specularLighting = float3(0.0, 0.0, 0.0);
float len = lightData.size.x;
float3 T = lightData.right;
float3 unL = lightData.positionWS - positionWS;
// Pick the major axis of the ellipsoid.
float3 axis = lightData.right;
// We define the ellipsoid s.t. r1 = (r + len / 2), r2 = r3 = r.
// TODO: This could be precomputed.
float radius = rsqrt(lightData.invSqrAttenuationRadius);
float invAspectRatio = radius / (radius + (0.5 * len));
// Compute the light attenuation.
float intensity = GetEllipsoidalDistanceAttenuation(unL, lightData.invSqrAttenuationRadius,
axis, invAspectRatio);
// Terminate if the shaded point is too far away.
if (intensity == 0.0) return;
lightData.diffuseScale *= intensity;
lightData.specularScale *= intensity;
// Translate the light s.t. the shaded point is at the origin of the coordinate system.
lightData.positionWS -= positionWS;
// TODO: some of this could be precomputed.
float3 P1 = lightData.positionWS - T * (0.5 * len);
float3 P2 = lightData.positionWS + T * (0.5 * len);
// Rotate the endpoints into the local coordinate system.
P1 = mul(P1, transpose(preLightData.orthoBasisViewNormal));
P2 = mul(P2, transpose(preLightData.orthoBasisViewNormal));
// Compute the binormal in the local coordinate system.
float3 B = normalize(cross(P1, P2));
float ltcValue;
// Evaluate the diffuse part
{
ltcValue = LTCEvaluate(P1, P2, B, preLightData.ltcTransformDiffuse);
ltcValue *= lightData.diffuseScale;
diffuseLighting = bsdfData.diffuseColor * (preLightData.ltcMagnitudeDiffuse * ltcValue);
}
#ifdef WANT_SSS_CODE
[branch] if (bsdfData.enableTransmission)
{
// Flip the view vector and the normal. The bitangent stays the same.
float3x3 flipMatrix = float3x3(-1, 0, 0,
0, 1, 0,
0, 0, -1);
// Use the Lambertian approximation for performance reasons.
// The matrix multiplication should not generate any extra ALU on GCN.
ltcValue = LTCEvaluate(P1, P2, B, mul(flipMatrix, k_identity3x3));
ltcValue *= lightData.diffuseScale;
// We use diffuse lighting for accumulation since it is going to be blurred during the SSS pass.
diffuseLighting += EvaluateTransmission(bsdfData, ltcValue, 1);
}
#endif
// Evaluate the specular part
{
ltcValue = LTCEvaluate(P1, P2, B, preLightData.ltcTransformSpecular);
ltcValue *= lightData.specularScale;
specularLighting += preLightData.ltcMagnitudeFresnel * ltcValue;
}
// Save ALU by applying 'lightData.color' only once.
diffuseLighting *= lightData.color;
specularLighting *= lightData.color;
#endif // LIT_DISPLAY_REFERENCE_AREA
}
//-----------------------------------------------------------------------------
// EvaluateBSDF_Area - Approximation with Linearly Transformed Cosines
//-----------------------------------------------------------------------------
// #define ELLIPSOIDAL_ATTENUATION
void EvaluateBSDF_Rect( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, LightData lightData, BSDFData bsdfData,
out float3 diffuseLighting, out float3 specularLighting)
{
float3 positionWS = posInput.positionWS;
#ifdef LIT_DISPLAY_REFERENCE_AREA
IntegrateBSDF_AreaRef(V, positionWS, preLightData, lightData, bsdfData,
diffuseLighting, specularLighting);
#else
diffuseLighting = float3(0.0, 0.0, 0.0);
specularLighting = float3(0.0, 0.0, 0.0);
float3 unL = lightData.positionWS - positionWS;
[branch]
if (dot(lightData.forward, unL) >= 0.0001)
{
// The light is back-facing.
return;
}
// Rotate the light direction into the light space.
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, -lightData.forward);
unL = mul(unL, transpose(lightToWorld));
// TODO: This could be precomputed.
float halfWidth = lightData.size.x * 0.5;
float halfHeight = lightData.size.y * 0.5;
// Define the dimensions of the attenuation volume.
// TODO: This could be precomputed.
float radius = rsqrt(lightData.invSqrAttenuationRadius);
float3 invHalfDim = rcp(float3(radius + halfWidth,
radius + halfHeight,
radius));
// Compute the light attenuation.
#ifdef ELLIPSOIDAL_ATTENUATION
// The attenuation volume is an axis-aligned ellipsoid s.t.
// r1 = (r + w / 2), r2 = (r + h / 2), r3 = r.
float intensity = GetEllipsoidalDistanceAttenuation(unL, invHalfDim);
#else
// The attenuation volume is an axis-aligned box s.t.
// hX = (r + w / 2), hY = (r + h / 2), hZ = r.
float intensity = GetBoxDistanceAttenuation(unL, invHalfDim);
#endif
// Terminate if the shaded point is too far away.
if (intensity == 0.0) return;
lightData.diffuseScale *= intensity;
lightData.specularScale *= intensity;
// Translate the light s.t. the shaded point is at the origin of the coordinate system.
lightData.positionWS -= positionWS;
float4x3 lightVerts;
// TODO: some of this could be precomputed.
lightVerts[0] = lightData.positionWS + lightData.right * halfWidth + lightData.up * halfHeight;
lightVerts[1] = lightData.positionWS + lightData.right * halfWidth + lightData.up * -halfHeight;
lightVerts[2] = lightData.positionWS + lightData.right * -halfWidth + lightData.up * -halfHeight;
lightVerts[3] = lightData.positionWS + lightData.right * -halfWidth + lightData.up * halfHeight;
// Rotate the endpoints into the local coordinate system.
lightVerts = mul(lightVerts, transpose(preLightData.orthoBasisViewNormal));
float ltcValue;
// Evaluate the diffuse part
{
// Polygon irradiance in the transformed configuration.
ltcValue = PolygonIrradiance(mul(lightVerts, preLightData.ltcTransformDiffuse));
ltcValue *= lightData.diffuseScale;
diffuseLighting = bsdfData.diffuseColor * (preLightData.ltcMagnitudeDiffuse * ltcValue);
}
#ifdef WANT_SSS_CODE
[branch] if (bsdfData.enableTransmission)
{
// Flip the view vector and the normal. The bitangent stays the same.
float3x3 flipMatrix = float3x3(-1, 0, 0,
0, 1, 0,
0, 0, -1);
// Use the Lambertian approximation for performance reasons.
// The matrix multiplication should not generate any extra ALU on GCN.
float3x3 ltcTransform = mul(flipMatrix, k_identity3x3);
// Polygon irradiance in the transformed configuration.
ltcValue = PolygonIrradiance(mul(lightVerts, ltcTransform));
ltcValue *= lightData.diffuseScale;
// We use diffuse lighting for accumulation since it is going to be blurred during the SSS pass.
diffuseLighting += EvaluateTransmission(bsdfData, ltcValue, 1);
}
#endif
// Evaluate the specular part
{
// Polygon irradiance in the transformed configuration.
ltcValue = PolygonIrradiance(mul(lightVerts, preLightData.ltcTransformSpecular));
ltcValue *= lightData.specularScale;
specularLighting += preLightData.ltcMagnitudeFresnel * ltcValue;
}
// Save ALU by applying 'lightData.color' only once.
diffuseLighting *= lightData.color;
specularLighting *= lightData.color;
#endif // LIT_DISPLAY_REFERENCE_AREA
}
void EvaluateBSDF_Area(LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, LightData lightData, BSDFData bsdfData, int GPULightType,
out float3 diffuseLighting, out float3 specularLighting)
{
if (GPULightType == GPULIGHTTYPE_LINE)
{
EvaluateBSDF_Line(lightLoopContext, V, posInput, preLightData, lightData, bsdfData, diffuseLighting, specularLighting);
}
else
{
EvaluateBSDF_Rect(lightLoopContext, V, posInput, preLightData, lightData, bsdfData, diffuseLighting, specularLighting);
}
}
//-----------------------------------------------------------------------------
// EvaluateBSDF_Env
// ----------------------------------------------------------------------------
// _preIntegratedFGD and _CubemapLD are unique for each BRDF
void EvaluateBSDF_Env( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput, PreLightData preLightData, EnvLightData lightData, BSDFData bsdfData,
out float3 diffuseLighting, out float3 specularLighting, out float2 weight)
{
float3 positionWS = posInput.positionWS;
#ifdef LIT_DISPLAY_REFERENCE_IBL
specularLighting = IntegrateSpecularGGXIBLRef(lightLoopContext, V, preLightData, lightData, bsdfData);
/*
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
diffuseLighting = IntegrateLambertIBLRef(lightData, V, bsdfData);
#else
diffuseLighting = IntegrateDisneyDiffuseIBLRef(lightLoopContext, V, preLightData, lightData, bsdfData);
#endif
*/
diffuseLighting = float3(0.0, 0.0, 0.0);
weight = float2(0.0, 1.0);
#else
// TODO: factor this code in common, so other material authoring don't require to rewrite everything,
// also think about how such a loop can handle 2 cubemap at the same time as old unity. Macro can allow to do that
// but we need to have UNITY_SAMPLE_ENV_LOD replace by a true function instead that is define by the lighting arcitecture.
// Also not sure how to deal with 2 intersection....
// Box and sphere are related to light property (but we have also distance based roughness etc...)
// TODO: test the strech from Tomasz
// float shrinkedRoughness = AnisotropicStrechAtGrazingAngle(bsdfData.roughness, bsdfData.perceptualRoughness, NdotV);
// In this code we redefine a bit the behavior of the reflcetion proble. We separate the projection volume (the proxy of the scene) form the influence volume (what pixel on the screen is affected)
// 1. First determine the projection volume
// In Unity the cubemaps are capture with the localToWorld transform of the component.
// This mean that location and oritention matter. So after intersection of proxy volume we need to convert back to world.
// CAUTION: localToWorld is the transform use to convert the cubemap capture point to world space (mean it include the offset)
// the center of the bounding box is thus in locals space: positionLS - offsetLS
// We use this formulation as it is the one of legacy unity that was using only AABB box.
float3 R = preLightData.iblDirWS;
float3x3 worldToLocal = transpose(float3x3(lightData.right, lightData.up, lightData.forward)); // worldToLocal assume no scaling
float3 positionLS = positionWS - lightData.positionWS;
positionLS = mul(positionLS, worldToLocal).xyz - lightData.offsetLS; // We want to calculate the intersection from the center of the bounding box.
if (lightData.envShapeType == ENVSHAPETYPE_SPHERE)
{
float3 dirLS = mul(R, worldToLocal);
float sphereOuterDistance = lightData.innerDistance.x + lightData.blendDistance;
float dist = SphereRayIntersectSimple(positionLS, dirLS, sphereOuterDistance);
R = (positionWS + dist * R) - lightData.positionWS;
}
else if (lightData.envShapeType == ENVSHAPETYPE_BOX)
{
float3 dirLS = mul(R, worldToLocal);
float3 boxOuterDistance = lightData.innerDistance + float3(lightData.blendDistance, lightData.blendDistance, lightData.blendDistance);
float dist = BoxRayIntersectSimple(positionLS, dirLS, -boxOuterDistance, boxOuterDistance);
// No need to normalize for fetching cubemap
// We can reuse dist calculate in LS directly in WS as there is no scaling. Also the offset is already include in lightData.positionWS
R = (positionWS + dist * R) - lightData.positionWS;
// TODO: add distance based roughness
}
// 2. Apply the influence volume (Box volume is used for culling whatever the influence shape)
// TODO: In the future we could have an influence volume inside the projection volume (so with a different transform, in this case we will need another transform)
weight.y = 1.0;
if (lightData.envShapeType == ENVSHAPETYPE_SPHERE)
{
float distFade = max(length(positionLS) - lightData.innerDistance.x, 0.0);
weight.y = saturate(1.0 - distFade / max(lightData.blendDistance, 0.0001)); // avoid divide by zero
}
else if (lightData.envShapeType == ENVSHAPETYPE_BOX ||
lightData.envShapeType == ENVSHAPETYPE_NONE)
{
// Calculate falloff value, so reflections on the edges of the volume would gradually blend to previous reflection.
float distFade = DistancePointBox(positionLS, -lightData.innerDistance, lightData.innerDistance);
weight.y = saturate(1.0 - distFade / max(lightData.blendDistance, 0.0001)); // avoid divide by zero
}
// Smooth weighting
weight.x = 0.0;
weight.y = Smoothstep01(weight.y);
float3 F = 1.0;
specularLighting = float3(0.0, 0.0, 0.0);
float4 preLD = SampleEnv(lightLoopContext, lightData.envIndex, R, preLightData.iblMipLevel);
specularLighting += F * preLD.rgb * preLightData.specularFGD;
diffuseLighting = float3(0.0, 0.0, 0.0);
#endif
}
//-----------------------------------------------------------------------------
// PostEvaluateBSDF
// ----------------------------------------------------------------------------
void PostEvaluateBSDF( LightLoopContext lightLoopContext, PreLightData preLightData, BSDFData bsdfData, LightLoopAccumulatedLighting accLighting, float3 bakeDiffuseLighting,
out float3 diffuseLighting, out float3 specularLighting)
{
// Add indirect diffuse + emissive (if any) - Ambient occlusion is multiply by emissive which is wrong but not a big deal
bakeDiffuseLighting *= GTAOMultiBounce(lightLoopContext.indirectAmbientOcclusion, bsdfData.diffuseColor);
float specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(preLightData.NdotV, lightLoopContext.indirectAmbientOcclusion, bsdfData.roughness);
// Try to mimic multibounce with specular color. Not the point of the original formula but ok result.
// Take the min of screenspace specular occlusion and visibility cone specular occlusion
accLighting.envSpecularLighting *= GTAOMultiBounce(min(bsdfData.specularOcclusion, specularOcclusion), bsdfData.fresnel0);
// TODO: we could call a function like PostBSDF that will apply albedo and divide by PI once for the loop
// envDiffuseLighting is not used in our case
diffuseLighting = (accLighting.dirDiffuseLighting + accLighting.punctualDiffuseLighting + accLighting.areaDiffuseLighting) * GTAOMultiBounce(lightLoopContext.directAmbientOcclusion, bsdfData.diffuseColor) + bakeDiffuseLighting;
specularLighting = accLighting.dirSpecularLighting + accLighting.punctualSpecularLighting + accLighting.areaSpecularLighting + accLighting.envSpecularLighting;
}
#endif // #ifdef HAS_LIGHTLOOP

10
ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare2.hlsl.meta


fileFormatVersion: 2
guid: a5ae278c101d602428cf78a26d2444e9
timeCreated: 1504900828
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor.meta


fileFormatVersion: 2
guid: 5cacfca84329cc344aab142e0642329b
folderAsset: yes
timeCreated: 1497326931
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

353
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/BaseEyeUI.cs


using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
// A Material can be authored from the shader graph or by hand. When written by hand we need to provide an inspector.
// Such a Material will share some properties between it various variant (shader graph variant or hand authored variant).
// This is the purpose of BaseLitGUI. It contain all properties that are common to all Material based on Lit template.
// For the default hand written Lit material see LitUI.cs that contain specific properties for our default implementation.
public abstract class BaseEyeGUI : BaseUnlitGUI
{
protected static class StylesBaseLit
{
public static GUIContent doubleSidedNormalModeText = new GUIContent("Normal mode", "This will modify the normal base on the selected mode. None: untouch, Mirror: Mirror the normal with vertex normal plane, Flip: Flip the normal");
public static GUIContent depthOffsetEnableText = new GUIContent("Enable Depth Offset", "EnableDepthOffset on this shader (Use with heightmap)");
// Per pixel displacement
public static GUIContent enablePerPixelDisplacementText = new GUIContent("Enable Per Pixel Displacement", "");
public static GUIContent ppdMinSamplesText = new GUIContent("Minimum samples", "Minimum samples to use with per pixel displacement mapping");
public static GUIContent ppdMaxSamplesText = new GUIContent("Maximum samples", "Maximum samples to use with per pixel displacement mapping");
public static GUIContent ppdLodThresholdText = new GUIContent("Fading LOD start", "Starting Lod where the parallax occlusion mapping effect start to disappear");
// Tessellation
public static string tessellationModeText = "Tessellation Mode";
public static readonly string[] tessellationModeNames = Enum.GetNames(typeof(TessellationMode));
public static GUIContent tessellationText = new GUIContent("Tessellation options", "Tessellation options");
public static GUIContent tessellationFactorText = new GUIContent("Tessellation factor", "This value is the tessellation factor use for tessellation, higher mean more tessellated");
public static GUIContent tessellationFactorMinDistanceText = new GUIContent("Start fade distance", "Distance (in unity unit) at which the tessellation start to fade out. Must be inferior at Max distance");
public static GUIContent tessellationFactorMaxDistanceText = new GUIContent("End fade distance", "Maximum distance (in unity unit) to the camera where triangle are tessellated");
public static GUIContent tessellationFactorTriangleSizeText = new GUIContent("Triangle size", "Desired screen space sized of triangle (in pixel). Smaller value mean smaller triangle.");
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", "Tessellation displacement will take into account the object scale - Only work with uniform positive scale");
public static GUIContent tessellationTilingScaleText = new GUIContent("Enable tiling scale", "Tessellation displacement will take into account the tiling scale - Only work with uniform positive scale");
// Wind
public static GUIContent windText = new GUIContent("Enable Wind");
public static GUIContent windInitialBendText = new GUIContent("Initial Bend");
public static GUIContent windStiffnessText = new GUIContent("Stiffness");
public static GUIContent windDragText = new GUIContent("Drag");
public static GUIContent windShiverDragText = new GUIContent("Shiver Drag");
public static GUIContent windShiverDirectionalityText = new GUIContent("Shiver Directionality");
public static string vertexAnimation = "Vertex Animation";
}
public enum DoubleSidedNormalMode
{
None,
Mirror,
Flip
}
public enum TessellationMode
{
Phong,
Displacement,
DisplacementPhong,
}
protected MaterialProperty doubleSidedNormalMode = null;
protected const string kDoubleSidedNormalMode = "_DoubleSidedNormalMode";
protected MaterialProperty depthOffsetEnable = null;
protected const string kDepthOffsetEnable = "_DepthOffsetEnable";
// Properties
// Material ID
protected MaterialProperty materialID = null;
protected const string kMaterialID = "_MaterialID";
protected const string kStencilRef = "_StencilRef";
// Wind
protected MaterialProperty windEnable = null;
protected const string kWindEnabled = "_EnableWind";
protected MaterialProperty windInitialBend = null;
protected const string kWindInitialBend = "_InitialBend";
protected MaterialProperty windStiffness = null;
protected const string kWindStiffness = "_Stiffness";
protected MaterialProperty windDrag = null;
protected const string kWindDrag = "_Drag";
protected MaterialProperty windShiverDrag = null;
protected const string kWindShiverDrag = "_ShiverDrag";
protected MaterialProperty windShiverDirectionality = null;
protected const string kWindShiverDirectionality = "_ShiverDirectionality";
// 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";
// tessellation params
protected MaterialProperty tessellationMode = null;
protected const string kTessellationMode = "_TessellationMode";
protected MaterialProperty tessellationFactor = null;
protected const string kTessellationFactor = "_TessellationFactor";
protected MaterialProperty tessellationFactorMinDistance = null;
protected const string kTessellationFactorMinDistance = "_TessellationFactorMinDistance";
protected MaterialProperty tessellationFactorMaxDistance = null;
protected const string kTessellationFactorMaxDistance = "_TessellationFactorMaxDistance";
protected MaterialProperty tessellationFactorTriangleSize = null;
protected const string kTessellationFactorTriangleSize = "_TessellationFactorTriangleSize";
protected MaterialProperty tessellationShapeFactor = null;
protected const string kTessellationShapeFactor = "_TessellationShapeFactor";
protected MaterialProperty tessellationBackFaceCullEpsilon = null;
protected const string kTessellationBackFaceCullEpsilon = "_TessellationBackFaceCullEpsilon";
protected MaterialProperty tessellationObjectScale = null;
protected const string kTessellationObjectScale = "_TessellationObjectScale";
protected MaterialProperty tessellationTilingScale = null;
protected const string kTessellationTilingScale = "_TessellationTilingScale";
protected override void FindBaseMaterialProperties(MaterialProperty[] props)
{
base.FindBaseMaterialProperties(props);
doubleSidedNormalMode = FindProperty(kDoubleSidedNormalMode, props);
depthOffsetEnable = FindProperty(kDepthOffsetEnable, props);
// MaterialID
materialID = FindProperty(kMaterialID, props, false); // LayeredLit is force to be standard for now, so materialID could not exist
// Per pixel displacement
enablePerPixelDisplacement = FindProperty(kEnablePerPixelDisplacement, props);
ppdMinSamples = FindProperty(kPpdMinSamples, props);
ppdMaxSamples = FindProperty(kPpdMaxSamples, props);
ppdLodThreshold = FindProperty(kPpdLodThreshold, props);
// tessellation specific, silent if not found
tessellationMode = FindProperty(kTessellationMode, props, false);
tessellationFactor = FindProperty(kTessellationFactor, props, false);
tessellationFactorMinDistance = FindProperty(kTessellationFactorMinDistance, props, false);
tessellationFactorMaxDistance = FindProperty(kTessellationFactorMaxDistance, props, false);
tessellationFactorTriangleSize = FindProperty(kTessellationFactorTriangleSize, props, false);
tessellationShapeFactor = FindProperty(kTessellationShapeFactor, props, false);
tessellationBackFaceCullEpsilon = FindProperty(kTessellationBackFaceCullEpsilon, props, false);
tessellationObjectScale = FindProperty(kTessellationObjectScale, props, false);
tessellationTilingScale = FindProperty(kTessellationTilingScale, props, false);
// Wind
windEnable = FindProperty(kWindEnabled, props);
windInitialBend = FindProperty(kWindInitialBend, props);
windStiffness = FindProperty(kWindStiffness, props);
windDrag = FindProperty(kWindDrag, props);
windShiverDrag = FindProperty(kWindShiverDrag, props);
windShiverDirectionality = FindProperty(kWindShiverDirectionality, props);
}
void TessellationModePopup()
{
EditorGUI.showMixedValue = tessellationMode.hasMixedValue;
var mode = (TessellationMode)tessellationMode.floatValue;
EditorGUI.BeginChangeCheck();
mode = (TessellationMode)EditorGUILayout.Popup(StylesBaseLit.tessellationModeText, (int)mode, StylesBaseLit.tessellationModeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Tessellation Mode");
tessellationMode.floatValue = (float)mode;
}
EditorGUI.showMixedValue = false;
}
protected override void BaseMaterialPropertiesGUI()
{
base.BaseMaterialPropertiesGUI();
// This follow double sided option
if (doubleSidedEnable.floatValue > 0.0f)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(doubleSidedNormalMode, StylesBaseLit.doubleSidedNormalModeText);
EditorGUI.indentLevel--;
}
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, StylesBaseLit.enablePerPixelDisplacementText);
if (enablePerPixelDisplacement.floatValue > 0.0f)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(ppdMinSamples, StylesBaseLit.ppdMinSamplesText);
m_MaterialEditor.ShaderProperty(ppdMaxSamples, StylesBaseLit.ppdMaxSamplesText);
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
m_MaterialEditor.ShaderProperty(ppdLodThreshold, StylesBaseLit.ppdLodThresholdText);
m_MaterialEditor.ShaderProperty(depthOffsetEnable, StylesBaseLit.depthOffsetEnableText);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
// Display tessellation option if it exist
if (tessellationMode != null)
{
GUILayout.Label(StylesBaseLit.tessellationText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
TessellationModePopup();
m_MaterialEditor.ShaderProperty(tessellationFactor, StylesBaseLit.tessellationFactorText);
m_MaterialEditor.ShaderProperty(tessellationFactorMinDistance, StylesBaseLit.tessellationFactorMinDistanceText);
m_MaterialEditor.ShaderProperty(tessellationFactorMaxDistance, StylesBaseLit.tessellationFactorMaxDistanceText);
// clamp min distance to be below max distance
tessellationFactorMinDistance.floatValue = Math.Min(tessellationFactorMaxDistance.floatValue, tessellationFactorMinDistance.floatValue);
m_MaterialEditor.ShaderProperty(tessellationFactorTriangleSize, StylesBaseLit.tessellationFactorTriangleSizeText);
if ((TessellationMode)tessellationMode.floatValue == TessellationMode.Phong ||
(TessellationMode)tessellationMode.floatValue == TessellationMode.DisplacementPhong)
{
m_MaterialEditor.ShaderProperty(tessellationShapeFactor, StylesBaseLit.tessellationShapeFactorText);
}
if (doubleSidedEnable.floatValue == 0.0)
{
m_MaterialEditor.ShaderProperty(tessellationBackFaceCullEpsilon, StylesBaseLit.tessellationBackFaceCullEpsilonText);
}
m_MaterialEditor.ShaderProperty(tessellationObjectScale, StylesBaseLit.tessellationObjectScaleText);
m_MaterialEditor.ShaderProperty(tessellationTilingScale, StylesBaseLit.tessellationTilingScaleText);
EditorGUI.indentLevel--;
}
}
protected override void VertexAnimationPropertiesGUI()
{
GUILayout.Label(StylesBaseLit.vertexAnimation, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(windEnable, StylesBaseLit.windText);
if (!windEnable.hasMixedValue && windEnable.floatValue > 0.0f)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(windInitialBend, StylesBaseLit.windInitialBendText);
m_MaterialEditor.ShaderProperty(windStiffness, StylesBaseLit.windStiffnessText);
m_MaterialEditor.ShaderProperty(windDrag, StylesBaseLit.windDragText);
m_MaterialEditor.ShaderProperty(windShiverDrag, StylesBaseLit.windShiverDragText);
m_MaterialEditor.ShaderProperty(windShiverDirectionality, StylesBaseLit.windShiverDirectionalityText);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
static public void SetupBaseLitKeywords(Material material)
{
SetupBaseUnlitKeywords(material);
bool doubleSidedEnable = material.GetFloat(kDoubleSidedEnable) > 0.0f;
if (doubleSidedEnable)
{
DoubleSidedNormalMode doubleSidedNormalMode = (DoubleSidedNormalMode)material.GetFloat(kDoubleSidedNormalMode);
switch (doubleSidedNormalMode)
{
case DoubleSidedNormalMode.None:
material.SetVector("_DoubleSidedConstants", new Vector4(1.0f, 1.0f, 1.0f, 0.0f));
break;
case DoubleSidedNormalMode.Mirror: // Mirror mode (in tangent space)
material.SetVector("_DoubleSidedConstants", new Vector4(1.0f, 1.0f, -1.0f, 0.0f));
break;
case DoubleSidedNormalMode.Flip: // Flip mode (in tangent space)
material.SetVector("_DoubleSidedConstants", new Vector4(-1.0f, -1.0f, -1.0f, 0.0f));
break;
}
}
// Depth offset is only enabled if per pixel displacement is
bool depthOffsetEnable = (material.GetFloat(kDepthOffsetEnable) > 0.0f) && (material.GetFloat(kEnablePerPixelDisplacement) > 0.0f);
SetKeyword(material, "_DEPTHOFFSET_ON", depthOffsetEnable);
// Set the reference value for the stencil test.
int stencilRef = (int)StencilLightingUsage.RegularLighting;
if (material.HasProperty(kMaterialID))
{
if ((int)material.GetFloat(kMaterialID) == (int)UnityEngine.Experimental.Rendering.HDPipeline.Lit.MaterialId.LitSSS)
{
stencilRef = (int)StencilLightingUsage.SplitLighting;
}
}
material.SetInt(kStencilRef, stencilRef);
bool enablePerPixelDisplacement = material.GetFloat(kEnablePerPixelDisplacement) > 0.0f;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT", enablePerPixelDisplacement);
if (material.HasProperty(kTessellationMode))
{
TessellationMode tessMode = (TessellationMode)material.GetFloat(kTessellationMode);
if (tessMode == TessellationMode.Phong)
{
material.DisableKeyword("_TESSELLATION_DISPLACEMENT");
material.DisableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
else if (tessMode == TessellationMode.Displacement)
{
material.EnableKeyword("_TESSELLATION_DISPLACEMENT");
material.DisableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
else
{
material.DisableKeyword("_TESSELLATION_DISPLACEMENT");
material.EnableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
bool tessellationObjectScaleEnable = material.GetFloat(kTessellationObjectScale) > 0.0;
SetKeyword(material, "_TESSELLATION_OBJECT_SCALE", tessellationObjectScaleEnable);
bool tessellationTilingScaleEnable = material.GetFloat(kTessellationTilingScale) > 0.0;
SetKeyword(material, "_TESSELLATION_TILING_SCALE", tessellationTilingScaleEnable);
}
bool windEnabled = material.GetFloat(kWindEnabled) > 0.0f;
SetKeyword(material, "_VERTEX_WIND", windEnabled);
}
static public void SetupBaseLitMaterialPass(Material material)
{
bool distortionEnable = material.GetFloat(kDistortionEnable) > 0.0f;
bool distortionOnly = material.GetFloat(kDistortionOnly) > 0.0f;
if (distortionEnable && distortionOnly)
{
// Disable all passes except distortion (setup in BaseUnlitUI.cs) and debug passes (to visualize distortion)
material.SetShaderPassEnabled("GBuffer", false);
material.SetShaderPassEnabled("GBufferDisplayDebug", true);
material.SetShaderPassEnabled("Meta", false);
material.SetShaderPassEnabled("ShadowCaster", false);
material.SetShaderPassEnabled("DepthOnly", false);
material.SetShaderPassEnabled("MotionVectors", false);
material.SetShaderPassEnabled("Forward", false);
material.SetShaderPassEnabled("ForwardDisplayDebug", true);
}
else
{
// Enable all passes except distortion (setup in BaseUnlitUI.cs)
material.SetShaderPassEnabled("GBuffer", true);
material.SetShaderPassEnabled("GBufferDisplayDebug", true);
material.SetShaderPassEnabled("Meta", true);
material.SetShaderPassEnabled("ShadowCaster", true);
material.SetShaderPassEnabled("DepthOnly", true);
material.SetShaderPassEnabled("MotionVectors", true);
material.SetShaderPassEnabled("Forward", true);
material.SetShaderPassEnabled("ForwardDisplayDebug", true);
}
}
}
} // namespace UnityEditor

12
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/BaseEyeUI.cs.meta


fileFormatVersion: 2
guid: df9022cd736930941a20c626564bef21
timeCreated: 1497326875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

469
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/EyeUI.cs


using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
class EyeGUI : BaseEyeGUI
{
protected static class Styles
{
public static string InputsText = "Inputs";
public static GUIContent baseColorText = new GUIContent("Base Color + Opacity", "Albedo (RGB) and Opacity (A)");
public static GUIContent baseColorSmoothnessText = new GUIContent("Base Color + Smoothness", "Albedo (RGB) and Smoothness (A)");
public static GUIContent smoothnessMapChannelText = new GUIContent("Smoothness Source", "Smoothness texture and channel");
public static GUIContent smoothnessText = new GUIContent("Smoothness", "Smoothness scale factor");
public static GUIContent maskMapESText = new GUIContent("Iris Mask", "Mask map");
public static GUIContent maskMapSText = new GUIContent("Iris Mask", "Mask map");
public static GUIContent irisDepthText = new GUIContent("IrisDepth", "Iris Depth factor");
public static GUIContent irisRadiusText = new GUIContent("IrisRadius", "Iris Radius factor");
public static GUIContent iorText = new GUIContent("IOR", "IOR factor");
public static GUIContent normalMapSpaceText = new GUIContent("Normal/Tangent Map space", "");
public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map (BC7/BC5/DXT5(nm))");
public static GUIContent normalMapOSText = new GUIContent("Normal Map OS", "Normal Map (BC7/DXT1/RGB)");
public static GUIContent specularOcclusionMapText = new GUIContent("Specular Occlusion Map (RGBA)", "Specular Occlusion Map");
public static GUIContent heightMapText = new GUIContent("Height Map (R)", "Height Map");
public static GUIContent heightMapAmplitudeText = new GUIContent("Height Map Amplitude", "Height Map amplitude in world units.");
public static GUIContent heightMapCenterText = new GUIContent("Height Map Center", "Center of the heightmap in the texture (between 0 and 1)");
public static GUIContent tangentMapText = new GUIContent("Tangent Map", "Tangent Map (BC7/BC5/DXT5(nm))");
public static GUIContent tangentMapOSText = new GUIContent("Tangent Map OS", "Tangent Map (BC7/DXT1/RGB)");
public static GUIContent anisotropyText = new GUIContent("Anisotropy", "Anisotropy scale factor");
public static GUIContent anisotropyMapText = new GUIContent("Anisotropy Map (B)", "Anisotropy");
public static string textureControlText = "Input textures control";
public static GUIContent UVBaseMappingText = new GUIContent("Base UV mapping", "");
public static GUIContent UVHeightMappingText = new GUIContent("Height UV mapping", "");
public static GUIContent texWorldScaleText = new GUIContent("World scale", "Tiling factor applied to Planar/Trilinear mapping");
// Subsurface
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 (R)", "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 (R)", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
// Specular color
public static GUIContent specularColorText = new GUIContent("Specular Color", "Specular color (RGB)");
// Emissive
public static string lightingText = "Inputs Lighting";
public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive");
public static GUIContent emissiveIntensityText = new GUIContent("Emissive Intensity", "Emissive");
public static GUIContent emissiveColorModeText = new GUIContent("Emissive Color Usage", "Use emissive color or emissive mask");
public static GUIContent normalMapSpaceWarning = new GUIContent("Object space normal can't be use with triplanar mapping.");
}
public enum UVBaseMapping
{
UV0,
Planar,
Triplanar
}
public enum UVHeightMapping
{
UV0,
Planar,
Triplanar
}
public enum NormalMapSpace
{
TangentSpace,
ObjectSpace,
}
public enum HeightmapMode
{
Parallax,
Displacement,
}
public enum UVDetailMapping
{
UV0,
UV1,
UV2,
UV3
}
public enum EmissiveColorMode
{
UseEmissiveColor,
UseEmissiveMask,
}
protected MaterialProperty UVBase = null;
protected const string kUVBase = "_UVBase";
protected MaterialProperty TexWorldScale = null;
protected const string kTexWorldScale = "_TexWorldScale";
protected MaterialProperty UVMappingMask = null;
protected const string kUVMappingMask = "_UVMappingMask";
protected MaterialProperty baseColor = null;
protected const string kBaseColor = "_BaseColor";
protected MaterialProperty baseColorMap = null;
protected const string kBaseColorMap = "_BaseColorMap";
protected MaterialProperty smoothness = null;
protected const string kSmoothness = "_Smoothness";
protected MaterialProperty maskMap = null;
protected const string kMaskMap = "_MaskMap";
protected MaterialProperty specularOcclusionMap = null;
protected const string kSpecularOcclusionMap = "_SpecularOcclusionMap";
protected MaterialProperty normalMap = null;
protected const string kNormalMap = "_NormalMap";
protected MaterialProperty normalMapOS = null;
protected const string kNormalMapOS = "_NormalMapOS";
protected MaterialProperty normalScale = null;
protected const string kNormalScale = "_NormalScale";
protected MaterialProperty normalMapSpace = null;
protected const string kNormalMapSpace = "_NormalMapSpace";
protected MaterialProperty heightMap = null;
protected const string kHeightMap = "_HeightMap";
protected MaterialProperty heightAmplitude = null;
protected const string kHeightAmplitude = "_HeightAmplitude";
protected MaterialProperty heightCenter = null;
protected const string kHeightCenter = "_HeightCenter";
protected MaterialProperty tangentMap = null;
protected const string kTangentMap = "_TangentMap";
protected MaterialProperty tangentMapOS = null;
protected const string kTangentMapOS = "_TangentMapOS";
protected MaterialProperty specularColor = null;
protected const string kSpecularColor = "_SpecularColor";
protected MaterialProperty specularColorMap = null;
protected const string kSpecularColorMap = "_SpecularColorMap";
protected MaterialProperty irisDepth = null;
protected const string kIrisDepth = "_IrisDepth";
protected MaterialProperty irisRadius = null;
protected const string kIrisRadius = "_IrisRadius";
protected MaterialProperty ior = null;
protected const string kIor = "_Ior";
protected MaterialProperty UVDetail = null;
protected const string kUVDetail = "_UVDetail";
protected MaterialProperty UVDetailsMappingMask = null;
protected const string kUVDetailsMappingMask = "_UVDetailsMappingMask";
protected MaterialProperty detailMap = null;
protected const string kDetailMap = "_DetailMap";
protected MaterialProperty detailMask = null;
protected const string kDetailMask = "_DetailMask";
protected MaterialProperty detailFuzz1 = null;
protected const string kDetailFuzz1 = "_DetailFuzz1";
protected MaterialProperty detailAlbedoScale = null;
protected const string kDetailAlbedoScale = "_DetailAlbedoScale";
protected MaterialProperty detailNormalScale = null;
protected const string kDetailNormalScale = "_DetailNormalScale";
protected MaterialProperty detailSmoothnessScale = null;
protected const string kDetailSmoothnessScale = "_DetailSmoothnessScale";
protected SubsurfaceScatteringProfile subsurfaceProfile = null;
protected MaterialProperty subsurfaceProfileID = null;
protected const string kSubsurfaceProfileID = "_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";
protected MaterialProperty emissiveColorMode = null;
protected const string kEmissiveColorMode = "_EmissiveColorMode";
protected MaterialProperty emissiveColor = null;
protected const string kEmissiveColor = "_EmissiveColor";
protected MaterialProperty emissiveColorMap = null;
protected const string kEmissiveColorMap = "_EmissiveColorMap";
protected MaterialProperty emissiveIntensity = null;
protected const string kEmissiveIntensity = "_EmissiveIntensity";
protected override void FindMaterialProperties(MaterialProperty[] props)
{
UVBase = FindProperty(kUVBase, props);
TexWorldScale = FindProperty(kTexWorldScale, props);
UVMappingMask = FindProperty(kUVMappingMask, props);
baseColor = FindProperty(kBaseColor, props);
baseColorMap = FindProperty(kBaseColorMap, props);
smoothness = FindProperty(kSmoothness, props);
maskMap = FindProperty(kMaskMap, props);
specularOcclusionMap = FindProperty(kSpecularOcclusionMap, props);
normalMap = FindProperty(kNormalMap, props);
normalMapOS = FindProperty(kNormalMapOS, props);
normalScale = FindProperty(kNormalScale, props);
normalMapSpace = FindProperty(kNormalMapSpace, props);
heightMap = FindProperty(kHeightMap, props);
heightAmplitude = FindProperty(kHeightAmplitude, props);
heightCenter = FindProperty(kHeightCenter, props);
tangentMap = FindProperty(kTangentMap, props);
tangentMapOS = FindProperty(kTangentMapOS, props);
specularColor = FindProperty(kSpecularColor, props);
specularColorMap = FindProperty(kSpecularColorMap, props);
//eye
irisDepth = FindProperty(kIrisDepth, props);
irisRadius = FindProperty(kIrisRadius, props);
ior = FindProperty(kIor, props);
// Sub surface
subsurfaceProfileID = FindProperty(kSubsurfaceProfileID, props);
subsurfaceRadius = FindProperty(kSubsurfaceRadius, props);
subsurfaceRadiusMap = FindProperty(kSubsurfaceRadiusMap, props);
thickness = FindProperty(kThickness, props);
thicknessMap = FindProperty(kThicknessMap, props);
// Emissive
emissiveColorMode = FindProperty(kEmissiveColorMode, props);
emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
}
protected void ShaderSSSInputGUI(Material material)
{
HDRenderPipeline hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
if (subsurfaceProfile == null)
{
// Attempt to load the profile from the SSS Settings.
int profileID = (int)subsurfaceProfileID.floatValue;
if (0 <= profileID && profileID < hdPipeline.sssSettings.profiles.Length &&
hdPipeline.sssSettings.profiles[profileID] != null)
{
// This is a valid profile ID.
subsurfaceProfile = hdPipeline.sssSettings.profiles[profileID];
// Refresh the ID of the profile.
hdPipeline.sssSettings.OnValidate();
}
}
subsurfaceProfile = EditorGUILayout.ObjectField(Styles.subsurfaceProfileText, subsurfaceProfile, typeof(SubsurfaceScatteringProfile), false) as SubsurfaceScatteringProfile;
bool validProfile = false;
// Set the profile ID.
if (subsurfaceProfile != null)
{
// Load the profile from the GUI field.
int profileID = subsurfaceProfile.settingsIndex;
if (0 <= profileID && profileID < hdPipeline.sssSettings.profiles.Length &&
hdPipeline.sssSettings.profiles[profileID] != null &&
hdPipeline.sssSettings.profiles[profileID] == subsurfaceProfile)
{
validProfile = true;
material.SetInt("_SubsurfaceProfile", profileID);
}
else
{
subsurfaceProfile = null;
Debug.LogError("The SSS Profile assigned to the material has an invalid index. First, add the Profile to the SSS Settings, and then reassign it to the material.");
}
}
if (!validProfile)
{
// Disable SSS for this object.
material.SetInt("_SubsurfaceProfile", SssConstants.SSS_NEUTRAL_PROFILE_ID);
}
m_MaterialEditor.ShaderProperty(subsurfaceRadius, Styles.subsurfaceRadiusText);
m_MaterialEditor.TexturePropertySingleLine(Styles.subsurfaceRadiusMapText, subsurfaceRadiusMap);
}
protected void ShaderStandardInputGUI()
{
if ((NormalMapSpace)normalMapSpace.floatValue == NormalMapSpace.TangentSpace)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);
}
else
{
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapOSText, tangentMapOS);
}
}
protected override void MaterialPropertiesGUI(Material material)
{
GUILayout.Label("Eye Options", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.indentLevel--;
bool useEmissiveMask = (EmissiveColorMode)emissiveColorMode.floatValue == EmissiveColorMode.UseEmissiveMask;
GUILayout.Label(Styles.InputsText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap, baseColor);
m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
m_MaterialEditor.ShaderProperty(irisDepth, Styles.irisDepthText);
m_MaterialEditor.ShaderProperty(irisRadius, Styles.irisRadiusText);
m_MaterialEditor.ShaderProperty(ior, Styles.iorText);
if (useEmissiveMask)
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapESText, maskMap);
else
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapSText, maskMap);
m_MaterialEditor.TexturePropertySingleLine(Styles.specularOcclusionMapText, specularOcclusionMap);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText);
// Triplanar only work with tangent space normal
if ((NormalMapSpace)normalMapSpace.floatValue == NormalMapSpace.ObjectSpace && ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Triplanar))
{
EditorGUILayout.HelpBox(Styles.normalMapSpaceWarning.text, MessageType.Error);
}
// We have two different property for object space and tangent space normal map to allow
// 1. to go back and forth
// 2. to avoid the warning that ask to fix the object normal map texture (normalOS are just linear RGB texture
if ((NormalMapSpace)normalMapSpace.floatValue == NormalMapSpace.TangentSpace)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
}
else
{
// No scaling in object space
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapOSText, normalMapOS);
}
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap);
if (!heightMap.hasMixedValue && heightMap.textureValue != null)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightAmplitude, Styles.heightMapAmplitudeText);
heightAmplitude.floatValue = Math.Max(0.0f, heightAmplitude.floatValue); // Must be positive
m_MaterialEditor.ShaderProperty(heightCenter, Styles.heightMapCenterText);
EditorGUI.showMixedValue = false;
EditorGUI.indentLevel--;
}
ShaderSSSInputGUI(material); /*
switch ((Lit.MaterialId)materialID.floatValue)
{
case Lit.MaterialId.LitSSS:
ShaderSSSInputGUI(material);
break;
case Lit.MaterialId.LitStandard:
ShaderStandardInputGUI();
break;
case Lit.MaterialId.LitSpecular:
m_MaterialEditor.TexturePropertySingleLine(Styles.specularColorText, specularColorMap, specularColor);
break;
default:
Debug.Assert(false, "Encountered an unsupported MaterialID.");
break;
}*/
EditorGUILayout.Space();
GUILayout.Label(" " + Styles.textureControlText, EditorStyles.label);
m_MaterialEditor.ShaderProperty(UVBase, Styles.UVBaseMappingText);
// UVSet0 is always set, planar and triplanar will override it.
UVMappingMask.colorValue = new Color(1.0f, 0.0f, 0.0f, 0.0f); // This is override in the shader anyway but just in case.
if (((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Planar) || ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Triplanar))
{
m_MaterialEditor.ShaderProperty(TexWorldScale, Styles.texWorldScaleText);
}
m_MaterialEditor.TextureScaleOffsetProperty(baseColorMap);
// Setup the UVSet for detail, if planar/triplanar is use for base, it will override the mapping of detail (See shader code)
EditorGUI.indentLevel--;
EditorGUILayout.Space();
GUILayout.Label(Styles.lightingText, EditorStyles.boldLabel);
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText);
if (!useEmissiveMask)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
}
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
// The parent Base.ShaderPropertiesGUI will call DoEmissionArea
}
protected override bool ShouldEmissionBeEnabled(Material mat)
{
return mat.GetFloat(kEmissiveIntensity) > 0.0f;
}
protected override void SetupMaterialKeywordsAndPassInternal(Material material)
{
SetupMaterialKeywordsAndPass(material);
}
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
static public void SetupMaterialKeywordsAndPass(Material material)
{
SetupBaseLitKeywords(material);
SetupBaseLitMaterialPass(material);
NormalMapSpace normalMapSpace = (NormalMapSpace)material.GetFloat(kNormalMapSpace);
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
// (MaterialProperty value might come from renderer material property block)
SetKeyword(material, "_MAPPING_PLANAR", ((UVBaseMapping)material.GetFloat(kUVBase)) == UVBaseMapping.Planar);
SetKeyword(material, "_MAPPING_TRIPLANAR", ((UVBaseMapping)material.GetFloat(kUVBase)) == UVBaseMapping.Triplanar);
SetKeyword(material, "_NORMALMAP_TANGENT_SPACE", (normalMapSpace == NormalMapSpace.TangentSpace));
SetKeyword(material, "_EMISSIVE_COLOR", ((EmissiveColorMode)material.GetFloat(kEmissiveColorMode)) == EmissiveColorMode.UseEmissiveColor);
if (normalMapSpace == NormalMapSpace.TangentSpace)
{
// With details map, we always use a normal map and Unity provide a default (0, 0, 1) normal map for it
SetKeyword(material, "_NORMALMAP", material.GetTexture(kNormalMap) || material.GetTexture(kDetailMap));
SetKeyword(material, "_TANGENTMAP", material.GetTexture(kTangentMap));
}
else // Object space
{
// With details map, we always use a normal map but in case of objects space there is no good default, so the result will be weird until users fix it
SetKeyword(material, "_NORMALMAP", material.GetTexture(kNormalMapOS) || material.GetTexture(kDetailMap));
SetKeyword(material, "_TANGENTMAP", material.GetTexture(kTangentMapOS));
}
SetKeyword(material, "_MASKMAP", material.GetTexture(kMaskMap));
SetKeyword(material, "_SPECULAROCCLUSIONMAP", material.GetTexture(kSpecularOcclusionMap));
SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap));
SetKeyword(material, "_HEIGHTMAP", material.GetTexture(kHeightMap));
SetKeyword(material, "_DETAIL_MAP", material.GetTexture(kDetailMap));
SetKeyword(material, "_SUBSURFACE_RADIUS_MAP", material.GetTexture(kSubsurfaceRadiusMap));
SetKeyword(material, "_THICKNESSMAP", material.GetTexture(kThicknessMap));
SetKeyword(material, "_SPECULARCOLORMAP", material.GetTexture(kSpecularColorMap));
bool needUV2 = (UVBaseMapping)material.GetFloat(kUVBase) == UVBaseMapping.UV0;
bool needUV3 = (UVBaseMapping)material.GetFloat(kUVBase) == UVBaseMapping.UV0;
if (needUV3)
{
material.DisableKeyword("_REQUIRE_UV2");
material.EnableKeyword("_REQUIRE_UV3");
}
else if (needUV2)
{
material.EnableKeyword("_REQUIRE_UV2");
material.DisableKeyword("_REQUIRE_UV3");
}
else
{
material.DisableKeyword("_REQUIRE_UV2");
material.DisableKeyword("_REQUIRE_UV3");
}
}
}
} // namespace UnityEditor

12
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Editor/EyeUI.cs.meta


fileFormatVersion: 2
guid: 41d12be52f312cb47a51902cccbcf67e
timeCreated: 1497327220
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

284
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs


using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public partial class Eye : RenderPipelineMaterial
{
[GenerateHLSL(PackingRules.Exact)]
public enum MaterialId
{
LitSSS = 0,
LitStandard = 1,
LitUnused0 = 2,
LitUnused1 = 3,
LitAniso = 4, // Should be the last as it is not setup by the users but generated based on anisotropy property
LitSpecular = 5, // Should be the last as it is not setup by the users but generated based on anisotropy property and specular
};
[GenerateHLSL]
public enum MaterialFeatureFlags
{
LitSSS = 1 << 12,
LitStandard = 1 << 13,
LitAniso = 1 << 14,
LitSpecular = 1 << 15
}
//-----------------------------------------------------------------------------
// SurfaceData
//-----------------------------------------------------------------------------
// Main structure that store the user data (i.e user input of master node in material graph)
[GenerateHLSL(PackingRules.Exact, false, true, 1000)]
public struct SurfaceData
{
[SurfaceDataAttributes("Base Color", false, true)]
public Vector3 baseColor;
[SurfaceDataAttributes("Specular Occlusion")]
public float specularOcclusion;
[SurfaceDataAttributes("Normal", true)]
public Vector3 normalWS;
[SurfaceDataAttributes("Smoothness")]
public float perceptualSmoothness;
[SurfaceDataAttributes("Material ID")]
public int materialId;
[SurfaceDataAttributes("Ambient Occlusion")]
public float ambientOcclusion;
// standard
[SurfaceDataAttributes("Tangent", true)]
public Vector3 tangentWS;
[SurfaceDataAttributes("Anisotropy")]
public float anisotropy; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction)
[SurfaceDataAttributes("Specular")]
public float specular; // 0.02, 0.04, 0.16, 0.2
// SSS
[SurfaceDataAttributes("Subsurface Radius")]
public float subsurfaceRadius;
[SurfaceDataAttributes("Thickness")]
public float thickness;
[SurfaceDataAttributes("Subsurface Profile")]
public int subsurfaceProfile;
// SpecColor
[SurfaceDataAttributes("Specular Color", false, true)]
public Vector3 specularColor;
};
//-----------------------------------------------------------------------------
// BSDFData
//-----------------------------------------------------------------------------
[GenerateHLSL(PackingRules.Exact)]
public enum TransmissionType
{
None = 0,
Regular = 1,
ThinObject = 2,
};
[GenerateHLSL(PackingRules.Exact, false, true, 1030)]
public struct BSDFData
{
[SurfaceDataAttributes("", false, true)]
public Vector3 diffuseColor;
public Vector3 fresnel0;
public float specularOcclusion;
[SurfaceDataAttributes("", true)]
public Vector3 normalWS;
public float perceptualRoughness;
public float roughness;
public int materialId;
// standard
[SurfaceDataAttributes("", true)]
public Vector3 tangentWS;
[SurfaceDataAttributes("", true)]
public Vector3 bitangentWS;
public float roughnessT;
public float roughnessB;
public float anisotropy;
// fold into fresnel0
// SSS
public float subsurfaceRadius;
public float thickness;
public int subsurfaceProfile;
public bool enableTransmission; // Read from the SSS profile
public bool useThinObjectMode; // Read from the SSS profile
public Vector3 transmittance;
// SpecColor
// fold into fresnel0
};
//-----------------------------------------------------------------------------
// RenderLoop management
//-----------------------------------------------------------------------------
[GenerateHLSL(PackingRules.Exact)]
public enum GBufferMaterial
{
// Note: This count doesn't include the velocity buffer. On shader and csharp side the velocity buffer will be added by the framework
Count = (ShaderConfig.k_PackgbufferInU16 == 1) ? 2 : 4
};
//-----------------------------------------------------------------------------
// GBuffer management
//-----------------------------------------------------------------------------
public override int GetMaterialGBufferCount() { return (int)GBufferMaterial.Count; }
public override void GetMaterialGBufferDescription(out RenderTextureFormat[] RTFormat, out RenderTextureReadWrite[] RTReadWrite)
{
RTFormat = new RenderTextureFormat[(int)GBufferMaterial.Count];
RTReadWrite = new RenderTextureReadWrite[(int)GBufferMaterial.Count];
if (ShaderConfig.s_PackgbufferInU16 == 1)
{
// TODO: Just discovered that Unity doesn't support unsigned 16 RT format.
RTFormat[0] = RenderTextureFormat.ARGBInt; RTReadWrite[0] = RenderTextureReadWrite.Linear;
RTFormat[1] = RenderTextureFormat.ARGBInt; RTReadWrite[1] = RenderTextureReadWrite.Linear;
}
else
{
RTFormat[0] = RenderTextureFormat.ARGB32; RTReadWrite[0] = RenderTextureReadWrite.sRGB;
RTFormat[1] = RenderTextureFormat.ARGB2101010; RTReadWrite[1] = RenderTextureReadWrite.Linear;
RTFormat[2] = RenderTextureFormat.ARGB32; RTReadWrite[2] = RenderTextureReadWrite.Linear;
RTFormat[3] = RenderTextureFormat.RGB111110Float; RTReadWrite[3] = RenderTextureReadWrite.Linear;
}
}
//-----------------------------------------------------------------------------
// Init precomputed texture
//-----------------------------------------------------------------------------
bool m_isInit;
// For image based lighting
Material m_InitPreFGD;
RenderTexture m_PreIntegratedFGD;
// For area lighting - We pack all texture inside a texture array to reduce the number of resource required
Texture2DArray m_LtcData; // 0: m_LtcGGXMatrix - RGBA, 2: m_LtcDisneyDiffuseMatrix - RGBA, 3: m_LtcMultiGGXFresnelDisneyDiffuse - RGB, A unused
const int k_LtcLUTMatrixDim = 3; // size of the matrix (3x3)
const int k_LtcLUTResolution = 64;
// Load LUT with one scalar in alpha of a tex2D
void LoadLUT(Texture2DArray tex, int arrayElement, TextureFormat format, float[] LUTScalar)
{
const int count = k_LtcLUTResolution * k_LtcLUTResolution;
Color[] pixels = new Color[count];
for (int i = 0; i < count; i++)
{
pixels[i] = new Color(0, 0, 0, LUTScalar[i]);
}
tex.SetPixels(pixels, arrayElement);
}
// Load LUT with 3x3 matrix in RGBA of a tex2D (some part are zero)
void LoadLUT(Texture2DArray tex, int arrayElement, TextureFormat format, double[,] LUTTransformInv)
{
const int count = k_LtcLUTResolution * k_LtcLUTResolution;
Color[] pixels = new Color[count];
for (int i = 0; i < count; i++)
{
// Both GGX and Disney Diffuse BRDFs have zero values in columns 1, 3, 5, 7.
// Column 8 contains only ones.
pixels[i] = new Color((float)LUTTransformInv[i, 0],
(float)LUTTransformInv[i, 2],
(float)LUTTransformInv[i, 4],
(float)LUTTransformInv[i, 6]);
}
tex.SetPixels(pixels, arrayElement);
}
// Special-case function for 'm_LtcMultiGGXFresnelDisneyDiffuse'.
void LoadLUT(Texture2DArray tex, int arrayElement, TextureFormat format, float[] LtcGGXMagnitudeData,
float[] LtcGGXFresnelData,
float[] LtcDisneyDiffuseMagnitudeData)
{
const int count = k_LtcLUTResolution * k_LtcLUTResolution;
Color[] pixels = new Color[count];
for (int i = 0; i < count; i++)
{
// We store the result of the subtraction as a run-time optimization.
// See the footnote 2 of "LTC Fresnel Approximation" by Stephen Hill.
pixels[i] = new Color(LtcGGXMagnitudeData[i] - LtcGGXFresnelData[i],
LtcGGXFresnelData[i], LtcDisneyDiffuseMagnitudeData[i], 1);
}
tex.SetPixels(pixels, arrayElement);
}
public Eye() { }
public override void Build(RenderPipelineResources renderPipelineResources)
{
m_InitPreFGD = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/PreIntegratedFGD");
// For DisneyDiffuse integration values goes from (0.5 to 1.53125). GGX need 0 to 1. Use float format.
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear);
m_PreIntegratedFGD.filterMode = FilterMode.Bilinear;
m_PreIntegratedFGD.wrapMode = TextureWrapMode.Clamp;
m_PreIntegratedFGD.hideFlags = HideFlags.DontSave;
m_PreIntegratedFGD.Create();
m_LtcData = new Texture2DArray(k_LtcLUTResolution, k_LtcLUTResolution, 3, TextureFormat.RGBAHalf, false /*mipmap*/, true /* linear */)
{
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Bilinear
};
LoadLUT(m_LtcData, 0, TextureFormat.RGBAHalf, Lit.s_LtcGGXMatrixData);
LoadLUT(m_LtcData, 1, TextureFormat.RGBAHalf, Lit.s_LtcDisneyDiffuseMatrixData);
// TODO: switch to RGBA64 when it becomes available.
LoadLUT(m_LtcData, 2, TextureFormat.RGBAHalf, Lit.s_LtcGGXMagnitudeData, Lit.s_LtcGGXFresnelData, Lit.s_LtcDisneyDiffuseMagnitudeData);
m_LtcData.Apply();
m_isInit = false;
}
public override void Cleanup()
{
Utilities.Destroy(m_InitPreFGD);
// TODO: how to delete RenderTexture ? or do we need to do it ?
m_isInit = false;
}
public override void RenderInit(CommandBuffer cmd)
{
if (m_isInit)
return;
using (new Utilities.ProfilingSample("Init PreFGD", cmd))
{
Utilities.DrawFullScreen(cmd, m_InitPreFGD, new RenderTargetIdentifier(m_PreIntegratedFGD));
}
m_isInit = true;
}
public override void Bind()
{
Shader.SetGlobalTexture("_PreIntegratedFGD", m_PreIntegratedFGD);
Shader.SetGlobalTexture("_LtcData", m_LtcData);
}
}
}

236
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs. Please don't edit by hand.
//
#ifndef EYE_CS_HLSL
#define EYE_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Eye+MaterialId: static fields
//
#define MATERIALID_LIT_SSS (0)
#define MATERIALID_LIT_STANDARD (1)
#define MATERIALID_LIT_UNUSED0 (2)
#define MATERIALID_LIT_UNUSED1 (3)
#define MATERIALID_LIT_ANISO (4)
#define MATERIALID_LIT_SPECULAR (5)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Eye+MaterialFeatureFlags: static fields
//
#define MATERIALFEATUREFLAGS_LIT_SSS (4096)
#define MATERIALFEATUREFLAGS_LIT_STANDARD (8192)
#define MATERIALFEATUREFLAGS_LIT_ANISO (16384)
#define MATERIALFEATUREFLAGS_LIT_SPECULAR (32768)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Eye+SurfaceData: static fields
//
#define DEBUGVIEW_EYE_SURFACEDATA_BASE_COLOR (1000)
#define DEBUGVIEW_EYE_SURFACEDATA_SPECULAR_OCCLUSION (1001)
#define DEBUGVIEW_EYE_SURFACEDATA_NORMAL_WS (1002)
#define DEBUGVIEW_EYE_SURFACEDATA_PERCEPTUAL_SMOOTHNESS (1003)
#define DEBUGVIEW_EYE_SURFACEDATA_MATERIAL_ID (1004)
#define DEBUGVIEW_EYE_SURFACEDATA_AMBIENT_OCCLUSION (1005)
#define DEBUGVIEW_EYE_SURFACEDATA_TANGENT_WS (1006)
#define DEBUGVIEW_EYE_SURFACEDATA_ANISOTROPY (1007)
#define DEBUGVIEW_EYE_SURFACEDATA_SPECULAR (1008)
#define DEBUGVIEW_EYE_SURFACEDATA_SUBSURFACE_RADIUS (1009)
#define DEBUGVIEW_EYE_SURFACEDATA_THICKNESS (1010)
#define DEBUGVIEW_EYE_SURFACEDATA_SUBSURFACE_PROFILE (1011)
#define DEBUGVIEW_EYE_SURFACEDATA_SPECULAR_COLOR (1012)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Eye+TransmissionType: static fields
//
#define TRANSMISSIONTYPE_NONE (0)
#define TRANSMISSIONTYPE_REGULAR (1)
#define TRANSMISSIONTYPE_THIN_OBJECT (2)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Eye+BSDFData: static fields
//
#define DEBUGVIEW_EYE_BSDFDATA_DIFFUSE_COLOR (1030)
#define DEBUGVIEW_EYE_BSDFDATA_FRESNEL0 (1031)
#define DEBUGVIEW_EYE_BSDFDATA_SPECULAR_OCCLUSION (1032)
#define DEBUGVIEW_EYE_BSDFDATA_NORMAL_WS (1033)
#define DEBUGVIEW_EYE_BSDFDATA_PERCEPTUAL_ROUGHNESS (1034)
#define DEBUGVIEW_EYE_BSDFDATA_ROUGHNESS (1035)
#define DEBUGVIEW_EYE_BSDFDATA_MATERIAL_ID (1036)
#define DEBUGVIEW_EYE_BSDFDATA_TANGENT_WS (1037)
#define DEBUGVIEW_EYE_BSDFDATA_BITANGENT_WS (1038)
#define DEBUGVIEW_EYE_BSDFDATA_ROUGHNESS_T (1039)
#define DEBUGVIEW_EYE_BSDFDATA_ROUGHNESS_B (1040)
#define DEBUGVIEW_EYE_BSDFDATA_ANISOTROPY (1041)
#define DEBUGVIEW_EYE_BSDFDATA_SUBSURFACE_RADIUS (1042)
#define DEBUGVIEW_EYE_BSDFDATA_THICKNESS (1043)
#define DEBUGVIEW_EYE_BSDFDATA_SUBSURFACE_PROFILE (1044)
#define DEBUGVIEW_EYE_BSDFDATA_ENABLE_TRANSMISSION (1045)
#define DEBUGVIEW_EYE_BSDFDATA_USE_THIN_OBJECT_MODE (1046)
#define DEBUGVIEW_EYE_BSDFDATA_TRANSMITTANCE (1047)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Eye+GBufferMaterial: static fields
//
#define GBUFFERMATERIAL_COUNT (4)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Eye+SurfaceData
// PackingRules = Exact
struct SurfaceData
{
float3 baseColor;
float specularOcclusion;
float3 normalWS;
float perceptualSmoothness;
int materialId;
float ambientOcclusion;
float3 tangentWS;
float anisotropy;
float specular;
float subsurfaceRadius;
float thickness;
int subsurfaceProfile;
float3 specularColor;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Eye+BSDFData
// PackingRules = Exact
struct BSDFData
{
float3 diffuseColor;
float3 fresnel0;
float specularOcclusion;
float3 normalWS;
float perceptualRoughness;
float roughness;
int materialId;
float3 tangentWS;
float3 bitangentWS;
float roughnessT;
float roughnessB;
float anisotropy;
float subsurfaceRadius;
float thickness;
int subsurfaceProfile;
bool enableTransmission;
bool useThinObjectMode;
float3 transmittance;
};
//
// Debug functions
//
void GetGeneratedSurfaceDataDebug(uint paramId, SurfaceData surfacedata, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{
case DEBUGVIEW_EYE_SURFACEDATA_BASE_COLOR:
result = surfacedata.baseColor;
needLinearToSRGB = true;
break;
case DEBUGVIEW_EYE_SURFACEDATA_SPECULAR_OCCLUSION:
result = surfacedata.specularOcclusion.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_NORMAL_WS:
result = surfacedata.normalWS * 0.5 + 0.5;
break;
case DEBUGVIEW_EYE_SURFACEDATA_PERCEPTUAL_SMOOTHNESS:
result = surfacedata.perceptualSmoothness.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_MATERIAL_ID:
result = GetIndexColor(surfacedata.materialId);
break;
case DEBUGVIEW_EYE_SURFACEDATA_AMBIENT_OCCLUSION:
result = surfacedata.ambientOcclusion.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_TANGENT_WS:
result = surfacedata.tangentWS * 0.5 + 0.5;
break;
case DEBUGVIEW_EYE_SURFACEDATA_ANISOTROPY:
result = surfacedata.anisotropy.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_SPECULAR:
result = surfacedata.specular.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_SUBSURFACE_RADIUS:
result = surfacedata.subsurfaceRadius.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_THICKNESS:
result = surfacedata.thickness.xxx;
break;
case DEBUGVIEW_EYE_SURFACEDATA_SUBSURFACE_PROFILE:
result = GetIndexColor(surfacedata.subsurfaceProfile);
break;
case DEBUGVIEW_EYE_SURFACEDATA_SPECULAR_COLOR:
result = surfacedata.specularColor;
needLinearToSRGB = true;
break;
}
}
//
// Debug functions
//
void GetGeneratedBSDFDataDebug(uint paramId, BSDFData bsdfdata, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{
case DEBUGVIEW_EYE_BSDFDATA_DIFFUSE_COLOR:
result = bsdfdata.diffuseColor;
needLinearToSRGB = true;
break;
case DEBUGVIEW_EYE_BSDFDATA_FRESNEL0:
result = bsdfdata.fresnel0;
break;
case DEBUGVIEW_EYE_BSDFDATA_SPECULAR_OCCLUSION:
result = bsdfdata.specularOcclusion.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_NORMAL_WS:
result = bsdfdata.normalWS * 0.5 + 0.5;
break;
case DEBUGVIEW_EYE_BSDFDATA_PERCEPTUAL_ROUGHNESS:
result = bsdfdata.perceptualRoughness.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_ROUGHNESS:
result = bsdfdata.roughness.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_MATERIAL_ID:
result = GetIndexColor(bsdfdata.materialId);
break;
case DEBUGVIEW_EYE_BSDFDATA_TANGENT_WS:
result = bsdfdata.tangentWS * 0.5 + 0.5;
break;
case DEBUGVIEW_EYE_BSDFDATA_BITANGENT_WS:
result = bsdfdata.bitangentWS * 0.5 + 0.5;
break;
case DEBUGVIEW_EYE_BSDFDATA_ROUGHNESS_T:
result = bsdfdata.roughnessT.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_ROUGHNESS_B:
result = bsdfdata.roughnessB.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_ANISOTROPY:
result = bsdfdata.anisotropy.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_SUBSURFACE_RADIUS:
result = bsdfdata.subsurfaceRadius.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_THICKNESS:
result = bsdfdata.thickness.xxx;
break;
case DEBUGVIEW_EYE_BSDFDATA_SUBSURFACE_PROFILE:
result = GetIndexColor(bsdfdata.subsurfaceProfile);
break;
case DEBUGVIEW_EYE_BSDFDATA_ENABLE_TRANSMISSION:
result = (bsdfdata.enableTransmission) ? float3(1.0, 1.0, 1.0) : float3(0.0, 0.0, 0.0);
break;
case DEBUGVIEW_EYE_BSDFDATA_USE_THIN_OBJECT_MODE:
result = (bsdfdata.useThinObjectMode) ? float3(1.0, 1.0, 1.0) : float3(0.0, 0.0, 0.0);
break;
case DEBUGVIEW_EYE_BSDFDATA_TRANSMITTANCE:
result = bsdfdata.transmittance;
break;
}
}
#endif

9
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs.hlsl.meta


fileFormatVersion: 2
guid: 3ea703cf2ae98674b85f343ad45a0eca
timeCreated: 1497329223
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

12
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.cs.meta


fileFormatVersion: 2
guid: d1de5b761a16187448117d2400903cb2
timeCreated: 1497326983
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

174
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.hlsl


//-----------------------------------------------------------------------------
// SurfaceData and BSDFData
//-----------------------------------------------------------------------------
// SurfaceData is define in Eye.cs which generate Eye.cs.hlsl
#include "Eye.cs.hlsl"
#include "../Lit/SubsurfaceScatteringProfile.cs.hlsl"
#define WANT_SSS_CODE
#include "../LightEvaluationShare1.hlsl"
void FillMaterialIdStandardData(float3 baseColor, float specular, float metallic, float roughness, float3 normalWS, float3 tangentWS, float anisotropy, inout BSDFData bsdfData)
{
bsdfData.diffuseColor = baseColor*0.5;
bsdfData.fresnel0 =1;
// TODO: encode specular
bsdfData.tangentWS = tangentWS;
bsdfData.bitangentWS = cross(normalWS, tangentWS);
ConvertAnisotropyToRoughness(roughness, anisotropy, bsdfData.roughnessT, bsdfData.roughnessB);
bsdfData.anisotropy = 0;
}
//-----------------------------------------------------------------------------
// conversion function for forward
//-----------------------------------------------------------------------------
BSDFData ConvertSurfaceDataToBSDFData(SurfaceData surfaceData)
{
ApplyDebugToSurfaceData(surfaceData);
BSDFData bsdfData;
ZERO_INITIALIZE(BSDFData, bsdfData);
bsdfData.specularOcclusion = surfaceData.specularOcclusion;
bsdfData.normalWS = surfaceData.normalWS;
bsdfData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness);
bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
bsdfData.materialId = surfaceData.materialId;
FillMaterialIdStandardData(surfaceData.baseColor, surfaceData.specular, 0, bsdfData.roughness, surfaceData.normalWS, surfaceData.tangentWS, surfaceData.anisotropy, bsdfData);
bsdfData.materialId = surfaceData.anisotropy > 0.0 ? MATERIALID_LIT_ANISO : bsdfData.materialId;
FillMaterialIdSSSData(surfaceData.baseColor, surfaceData.subsurfaceProfile, surfaceData.subsurfaceRadius, surfaceData.thickness, bsdfData);
return bsdfData;
}
float4 EncodeSplitLightingGBuffer0(SurfaceData surfaceData)
{
return float4(surfaceData.baseColor, 1.0);
}
float4 EncodeSplitLightingGBuffer1(SurfaceData surfaceData)
{
return float4(surfaceData.subsurfaceRadius, 1.0, 0.0, PackByte(surfaceData.subsurfaceProfile)); //TODO: Eye UI
}
//-----------------------------------------------------------------------------
// bake lighting function
//-----------------------------------------------------------------------------
// GetBakedDiffuseLigthing function compute the bake lighting + emissive color to be store in emissive buffer (Deferred case)
// In forward it must be add to the final contribution.
// This function require the 3 structure surfaceData, builtinData, bsdfData because it may require both the engine side data, and data that will not be store inside the gbuffer.
float3 GetBakedDiffuseLigthing(SurfaceData surfaceData, BuiltinData builtinData, BSDFData bsdfData, PreLightData preLightData)
{
// Premultiply bake diffuse lighting information with DisneyDiffuse pre-integration
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * surfaceData.ambientOcclusion * bsdfData.diffuseColor + builtinData.emissiveColor;
}
//-----------------------------------------------------------------------------
// light transport functions
//-----------------------------------------------------------------------------
LightTransportData GetLightTransportData(SurfaceData surfaceData, BuiltinData builtinData, BSDFData bsdfData)
{
LightTransportData lightTransportData;
// diffuseColor for lightmapping should basically be diffuse color.
// But rough metals (black diffuse) still scatter quite a lot of light around, so
// we want to take some of that into account too.
lightTransportData.diffuseColor = bsdfData.diffuseColor;
lightTransportData.emissiveColor = builtinData.emissiveColor;
return lightTransportData;
}
//-----------------------------------------------------------------------------
// LightLoop related function (Only include if required)
// HAS_LIGHTLOOP is define in Lighting.hlsl
//-----------------------------------------------------------------------------
#ifdef HAS_LIGHTLOOP
//-----------------------------------------------------------------------------
// BSDF share between directional light, punctual light and area light (reference)
//-----------------------------------------------------------------------------
#define BSDF BSDF_EYE
void BSDF_EYE(float3 V, float3 L, float3 positionWS, PreLightData preLightData, BSDFData bsdfData,
out float3 diffuseLighting,
out float3 specularLighting)
{
// Optimized math. Ref: PBR Diffuse Lighting for GGX + Smith Microsurfaces (slide 114).
float NdotL = saturate(dot(bsdfData.normalWS, L)); // Must have the same value without the clamp
float NdotV = preLightData.NdotV; // Get the unaltered (geometric) version
float LdotV = dot(L, V);
float invLenLV = rsqrt(abs(2 * LdotV + 2)); // invLenLV = rcp(length(L + V))
float NdotH = saturate((NdotL + NdotV) * invLenLV);
float LdotH = saturate(invLenLV * LdotV + invLenLV);
NdotV = max(NdotV, MIN_N_DOT_V); // Use the modified (clamped) version
float3 F = F_Schlick(bsdfData.fresnel0, LdotH);
float Vis;
float D;
// TODO: this way of handling aniso may not be efficient, or maybe with material classification, need to check perf here
// Maybe always using aniso maybe a win ?
if (bsdfData.materialId == MATERIALID_LIT_ANISO)
{
float3 H = (L + V) * invLenLV;
// For anisotropy we must not saturate these values
float TdotH = dot(bsdfData.tangentWS, H);
float TdotL = dot(bsdfData.tangentWS, L);
float BdotH = dot(bsdfData.bitangentWS, H);
float BdotL = dot(bsdfData.bitangentWS, L);
bsdfData.roughnessT = ClampRoughnessForAnalyticalLights(bsdfData.roughnessT);
bsdfData.roughnessB = ClampRoughnessForAnalyticalLights(bsdfData.roughnessB);
#ifdef LIT_USE_BSDF_PRE_LAMBDAV
Vis = V_SmithJointGGXAnisoLambdaV(preLightData.TdotV, preLightData.BdotV, NdotV, TdotL, BdotL, NdotL,
bsdfData.roughnessT, bsdfData.roughnessB, preLightData.anisoGGXLambdaV);
#else
// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
Vis = V_SmithJointGGXAniso(preLightData.TdotV, preLightData.BdotV, NdotV, TdotL, BdotL, NdotL,
bsdfData.roughnessT, bsdfData.roughnessB);
#endif
D = D_GGXAniso(TdotH, BdotH, NdotH, bsdfData.roughnessT, bsdfData.roughnessB);
}
else
{
bsdfData.roughness = ClampRoughnessForAnalyticalLights(bsdfData.roughness);
#ifdef LIT_USE_BSDF_PRE_LAMBDAV
Vis = V_SmithJointGGX(NdotL, NdotV, bsdfData.roughness, preLightData.ggxLambdaV);
#else
Vis = V_SmithJointGGX(NdotL, NdotV, bsdfData.roughness);
#endif
D = D_GGX(NdotH, bsdfData.roughness);
}
specularLighting = 10*F * (Vis * D);
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
float diffuseTerm = Lambert();
#elif LIT_DIFFUSE_GGX_BRDF
float3 diffuseTerm = DiffuseGGX(bsdfData.diffuseColor, NdotV, NdotL, NdotH, LdotV, bsdfData.perceptualRoughness);
#else
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotH, bsdfData.perceptualRoughness);
#endif
diffuseLighting = bsdfData.diffuseColor * diffuseTerm;
}
#endif // #ifdef HAS_LIGHTLOOP
#include "../LightEvaluationShare2.hlsl"

9
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.hlsl.meta


fileFormatVersion: 2
guid: 04104d8f9ef87224fa781b53467029a1
timeCreated: 1497327754
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

361
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.shader


Shader "HDRenderPipeline/ExperimentalEye"
{
Properties
{
// Following set of parameters represent the parameters node inside the MaterialGraph.
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist.
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear
_BaseColor("BaseColor", Color) = (1,1,1,1)
_BaseColorMap("BaseColorMap", 2D) = "white" {}
_Smoothness("Smoothness", Range(0.0, 1.0)) = 1.0
_MaskMap("MaskMap", 2D) = "white" {}
_IrisDepth("Iris Depth", Range(0.0, 1.0)) = 0.5
_IrisRadius("Iris Radius", Range(0.0, 1.0)) = 0.5
_Ior("IOR", Range(0.0, 1.0)) = 0.5
_frontNormalWS("Eye Front Normal",Vector) = (0,0,-1)
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {}
_NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map
_NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value
_NormalScale("NormalScale", Range(0.0, 2.0)) = 1
_HeightMap("HeightMap", 2D) = "black" {}
_HeightAmplitude("Height Amplitude", Float) = 0.01 // In world units
_HeightCenter("Height Center", Float) = 0.5 // In texture space
_DetailMap("DetailMap", 2D) = "black" {}
_DetailMask("DetailMask", 2D) = "white" {}
_DetailFuzz1("DetailFuzz1", Range(0.0, 1.0)) = 1
_DetailAlbedoScale("DetailAlbedoScale", Range(0.0, 1.0)) = 1
_DetailNormalScale("DetailNormalScale", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale("DetailSmoothnessScale", Range(-2.0, 2.0)) = 1
_TangentMap("TangentMap", 2D) = "bump" {}
_TangentMapOS("TangentMapOS", 2D) = "white" {}
_SubsurfaceProfile("Subsurface Profile", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 1.0
_SubsurfaceRadiusMap("Subsurface Radius Map", 2D) = "white" {}
_Thickness("Thickness", Range(0.0, 1.0)) = 1.0
_ThicknessMap("Thickness Map", 2D) = "white" {}
_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Following options are for the GUI inspector and different from the input parameters above
// These option below will cause different compilation flag.
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_TransparentDepthWritePrepassEnable("Alpha Cutoff Enable", Float) = 1.0
_AlphaCutoffPrepass("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_AlphaCutoffOpacityThreshold("Alpha Cutoff", Range(0.0, 1.0)) = 0.99
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting (fixed at compile time)
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode("__blendmode", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
[Enum(UV0, 0, Planar, 1, TriPlanar, 2)] _UVBase("UV Set for base", Float) = 0
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[HideInInspector]_MaterialID("MaterialId", Int) = 0 // MaterialId.Subsurface
[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
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go futher in dev
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant
//-------------------------------------------------------------------------------------
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON
#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3
#pragma shader_feature _EMISSIVE_COLOR
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
#pragma shader_feature _SPECULAROCCLUSIONMAP
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _TANGENTMAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _SUBSURFACE_RADIUS_MAP
#pragma shader_feature _THICKNESSMAP
#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _VERTEX_WIND
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ?
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_EYE // Need to be define before including Material.hlsl
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "../../../Core/ShaderLibrary/Common.hlsl"
#include "../../../Core/ShaderLibrary/Wind.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#include "../../Material/Eye/EyeProperties.hlsl"
// All our shaders use same name for entry point
#pragma vertex Vert
#pragma fragment Frag
ENDHLSL
SubShader
{
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
Pass
{
Name "ForwardOnlyOpaqueSplitLighting"
Tags { "LightMode"="ForwardOnlyOpaqueSplitLighting" }
Blend One Zero
ZWrite [_ZWrite]
Cull [_CullMode]
Stencil
{
Ref 1
Comp Always
Pass Replace
}
HLSLPROGRAM
#define FORWARD_SPLIT_LIGHTING
#define SHADERPASS SHADERPASS_FORWARD
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/Forward.hlsl"
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "ShaderPass/EyeSharePass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardOnlyOpaqueDepthOnly"
Tags{ "LightMode" = "ForwardOnlyOpaqueDepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/EyeDepthPass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
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,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/EyeMetaPass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZClip Off
ZWrite On
ZTest LEqual
HLSLPROGRAM
#define SHADERPASS SHADERPASS_SHADOWS
#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/EyeDepthPass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/EyeDepthPass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.
HLSLPROGRAM
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/EyeVelocityPass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"
ENDHLSL
}
Pass
{
Name "Distortion" // Name is not used
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index
Blend One One
ZTest [_ZTestMode]
ZWrite off
Cull [_CullMode]
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DISTORTION
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/EyeDistortionPass.hlsl"
#include "EyeData.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.EyeGUI"
}

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

正在加载...
取消
保存