浏览代码

Merge pull request #398 from Unity-Technologies/Branch_DeferredDirShadow

Branch deferreddirshadow
/main
GitHub 7 年前
当前提交
02239cb4
共有 25 个文件被更改,包括 835 次插入47 次删除
  1. 480
      SampleScenes/HDTest/ShadowsTest.unity
  2. 41
      ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  3. 11
      ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  5. 13
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs.hlsl
  6. 5
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader
  7. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  8. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDShaderIDs.cs
  9. 42
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  10. 2
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  11. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  12. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  13. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  14. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  15. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  16. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl
  17. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  18. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader
  19. 2
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset
  20. 5
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs
  21. 159
      SampleScenes/HDTest/Material/HDRenderLoopMaterials/Grid_Red_Transparent_Planar.mat
  22. 10
      SampleScenes/HDTest/Material/HDRenderLoopMaterials/Grid_Red_Transparent_Planar.mat.meta
  23. 10
      SampleScenes/HDTest/ShadowsTest.meta
  24. 28
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/DeferredDirectionalShadow.compute
  25. 10
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/DeferredDirectionalShadow.compute.meta

480
SampleScenes/HDTest/ShadowsTest.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.12544414, g: 0.13212782, b: 0.11914396, a: 1}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 4590821631456672, guid: 63d293d8d9b22af4eb3a41f61a9d3538,
type: 2}
m_PrefabInternal: {fileID: 32170302}
--- !u!1 &38548578
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 38548579}
- component: {fileID: 38548582}
- component: {fileID: 38548581}
- component: {fileID: 38548580}
m_Layer: 0
m_Name: Camera_Transparent
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &38548579
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38548578}
m_LocalRotation: {x: -0.1807782, y: -0.018304696, z: 0.003408042, w: -0.98334765}
m_LocalPosition: {x: -0.28321838, y: 2.8972144, z: -7.6081085}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1938354575}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!81 &38548580
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38548578}
m_Enabled: 1
m_ExtensionPropertyValues: []
--- !u!124 &38548581
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38548578}
m_Enabled: 1
--- !u!20 &38548582
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38548578}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!1001 &43913312
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 4211168484685708, guid: e1e5df6b963abe54ea96453a0a5f4c5d,
type: 2}
m_PrefabInternal: {fileID: 240371583}
--- !u!1 &240603307
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 240603311}
- component: {fileID: 240603310}
- component: {fileID: 240603309}
- component: {fileID: 240603308}
m_Layer: 0
m_Name: Camera_FullScreen
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &240603308
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 240603307}
m_Enabled: 1
m_ExtensionPropertyValues: []
--- !u!124 &240603309
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 240603307}
m_Enabled: 1
--- !u!20 &240603310
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 240603307}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &240603311
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 240603307}
m_LocalRotation: {x: 0.04375193, y: -0.044928193, z: 0.001950043, w: 0.9980298}
m_LocalPosition: {x: 227.8387, y: 4.7424283, z: 66.025215}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 15
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &241568988
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 4183670430560096, guid: 0efe7337116b73545b3294ff35bb77fb,
type: 2}
m_PrefabInternal: {fileID: 280534489}
--- !u!1001 &283665924
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1938354575}
m_Modifications:
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalPosition.x
value: -2.12
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalPosition.y
value: 2.13
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalPosition.z
value: -0.04
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1848646394385768, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_Name
value: Block_1x1
objectReference: {fileID: 0}
- target: {fileID: 23152401306738044, guid: 04650b05fbf7d48489627d8b0f7fe442,
type: 2}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: f473ec9e1cd032545b8de43885028638, type: 2}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
m_IsPrefabParent: 0
--- !u!4 &283665925 stripped
Transform:
m_PrefabParentObject: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442,
type: 2}
m_PrefabInternal: {fileID: 283665924}
--- !u!1001 &283852906
Prefab:
m_ObjectHideFlags: 0

- 0.028
- 0.18
shadowCascadeBorders:
- 0.563
- 0.285
- 0
- 0
shadowAlgorithm: 3
shadowVariant: 0
- 0.333
- 0.322
- 0.272
- 0.356
shadowAlgorithm: 0
shadowVariant: 4
format: 24
data: 5839b43d000000000bd7233c02000000
format: 4
data: d044583b0000803f
data: 99bb163b0000803f
data: d044583b0000803f
- format: 24
data: 5839b43d000000000bd7233c02000000
- format: 16

m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!1001 &1642984832
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1938354575}
m_Modifications:
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalPosition.x
value: 0.17779541
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalPosition.y
value: -0.5473848
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalPosition.z
value: -0.42713928
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1848646394385768, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_Name
value: Block_2x2
objectReference: {fileID: 0}
- target: {fileID: 23152401306738044, guid: 04650b05fbf7d48489627d8b0f7fe442,
type: 2}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: f473ec9e1cd032545b8de43885028638, type: 2}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalScale.x
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalScale.y
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
propertyPath: m_LocalScale.z
value: 2
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 04650b05fbf7d48489627d8b0f7fe442, type: 2}
m_IsPrefabParent: 0
--- !u!4 &1642984833 stripped
Transform:
m_PrefabParentObject: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442,
type: 2}
m_PrefabInternal: {fileID: 1642984832}
--- !u!1001 &1679818134
Prefab:
m_ObjectHideFlags: 0

- {fileID: 1558117777}
- {fileID: 2095847159}
- {fileID: 1232280521}
- {fileID: 240603310}
- {fileID: 38548582}
--- !u!114 &1769631035
MonoBehaviour:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442,
type: 2}
m_PrefabInternal: {fileID: 1935664259}
--- !u!1 &1938354574
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1938354575}
m_Layer: 0
m_Name: Group_Transparent
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1938354575
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1938354574}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 174.57793, y: 1.5471382, z: 139.29814}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1642984833}
- {fileID: 283665925}
- {fileID: 2102352247}
- {fileID: 38548579}
m_Father: {fileID: 0}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1952157951 stripped
Transform:
m_PrefabParentObject: {fileID: 4681031789697754, guid: 7584a9289b26aca4d9026a4849d96358,

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 13
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2076719941
Prefab:

m_PrefabParentObject: {fileID: 4664348215551318, guid: 04650b05fbf7d48489627d8b0f7fe442,
type: 2}
m_PrefabInternal: {fileID: 2097384754}
--- !u!1 &2102352246
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 2102352247}
- component: {fileID: 2102352250}
- component: {fileID: 2102352249}
- component: {fileID: 2102352248}
m_Layer: 0
m_Name: Spotlight
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2102352247
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2102352246}
m_LocalRotation: {x: 0.33309358, y: 0.60142916, z: -0.3037428, w: 0.65959996}
m_LocalPosition: {x: -2.78, y: 3.93, z: -0.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1938354575}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 53.589, y: 84.716, z: -0.003}
--- !u!114 &2102352248
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2102352246}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c6c2871f720b2af4e9210febdac74517, type: 3}
m_Name:
m_EditorClassIdentifier:
shadowResolution: 512
shadowDimmer: 1
shadowFadeDistance: 10000
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05
- 0.2
- 0.3
shadowCascadeBorders:
- 0.2
- 0.2
- 0.2
- 0.2
shadowAlgorithm: 0
shadowVariant: 4
shadowPrecision: 0
shadowData:
format: 4
data: 0bd7a33b0000803f
shadowDatas:
- format: 4
data: 0bd7a33b0000803f
--- !u!114 &2102352249
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2102352246}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
m_innerSpotPercent: 0
lightDimmer: 1
fadeDistance: 10000
affectDiffuse: 1
affectSpecular: 1
archetype: 0
spotLightShape: 0
lightLength: 0
lightWidth: 0
maxSmoothness: 1
applyRangeAttenuation: 1
--- !u!108 &2102352250
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2102352246}
m_Enabled: 1
serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 200
m_Range: 20
m_SpotAngle: 61.7
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1001 &2106171676
Prefab:
m_ObjectHideFlags: 0

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


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 */
float border = borders[shadowSplitIndex];
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border );
float4 splitSphere = dirShadowSplitSpheres[shadowSplitIndex];
float3 cascadeDir = normalize( -splitSphere.xyz + dirShadowSplitSpheres[min(3,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 ) );
// get shadowmap texcoords
float3 posNDC;
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true );

UnpackShadowType( sd.shadowType, shadowType, shadowAlgorithm );
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 );
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]

payloadOffset++; \
float4 borders = asfloat( shadowContext.payloads[payloadOffset] ); \
payloadOffset++; \
\
uint orig_payloadOffset = payloadOffset; \
uint orig_payloadOffset = payloadOffset; \
/* get shadowmap texcoords */ \
\
/* Be careful of this code, we need it here before the if statement otherwise the compiler screws up optimizing dirShadowSplitSpheres VGPRs away */ \
float border = borders[shadowSplitIndex]; \
float alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border ); \
float4 splitSphere = dirShadowSplitSpheres[shadowSplitIndex]; \
float3 cascadeDir = normalize( -splitSphere.xyz + dirShadowSplitSpheres[min(kMaxShadowCascades-1,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 ) ); \
\
/* get shadowmap texcoords */ \
float3 posNDC; \
float3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true ); \
/* sample the texture */ \

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

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 Exp", cmd))
using (new HDPipeline.Utilities.ProfilingSample("Render Shadows", cmd))
{
foreach( var sm in m_Shadowmaps )
{

1
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


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

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


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

#define FULLSCREENDEBUGMODE_MIN_LIGHTING_FULL_SCREEN_DEBUG (1)
#define FULLSCREENDEBUGMODE_SSAO (2)
#define FULLSCREENDEBUGMODE_SSAOBEFORE_FILTERING (3)
#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)
#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)
#endif

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

29
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


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;

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_HTile.Create();
m_HTileRT = new RenderTargetIdentifier(m_HTile);
}
}
void Resize(Camera camera)

m_LightLoop.UpdateCullingParameters( ref cullingParams );
// emit scene view UI
#if UNITY_EDITOR
#endif
CullResults.Cull(ref cullingParams, renderContext,ref m_CullResults);

m_SsaoEffect.Render(ssaoSettingsToUse, this, hdCamera, renderContext, cmd, m_Asset.renderingSettings.useForwardRenderingOnly);
m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, m_CullResults, camera);
m_LightLoop.RenderShadows(renderContext, cmd, m_CullResults);
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);
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
m_LightLoop.BuildGPULightLists(camera, cmd, m_CameraDepthStencilBufferRT, GetStencilTexture());
}

// Output split lighting for materials asking for it (masked in the stencil buffer)
options.outputSplitLighting = true;
m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_DebugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, depthTexture, options);
m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_DebugDisplaySettings, 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_DebugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, depthTexture, m_DeferredShadowBuffer, options);
}
// Combines specular lighting and diffuse lighting with subsurface scattering.

Shader.SetGlobalVector(HDShaderIDs._DebugLightingSmoothness, debugSmoothness);
}
public void PushFullScreenDebugTexture(CommandBuffer cb, int textureID, Camera camera, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
public void PushFullScreenDebugTexture(CommandBuffer cb, RenderTargetIdentifier textureID, Camera camera, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
if(debugMode == m_DebugDisplaySettings.fullScreenDebugMode)
if (debugMode == m_DebugDisplaySettings.fullScreenDebugMode)
}
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)

4
ScriptableRenderPipeline/HDRenderPipeline/HDShaderIDs.cs


internal static readonly int _MainDepthTexture = Shader.PropertyToID("_MainDepthTexture");
internal static readonly int _DeferredShadowTexture = Shader.PropertyToID("_DeferredShadowTexture");
internal static readonly int _DeferredShadowTextureUAV = Shader.PropertyToID("_DeferredShadowTextureUAV");
internal static readonly int _DirectionalShadowIndex = Shader.PropertyToID("_DirectionalShadowIndex");
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");

42
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


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

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;

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

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

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++)
{

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

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

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;

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[] colorBuffers, RenderTargetIdentifier depthStencilBuffer, RenderTargetIdentifier depthTexture, RenderTargetIdentifier deferredShadowTexture,
LightingPassOptions options)
{
var bUseClusteredForDeferred = !usingFptl;

cmd.SetComputeVectorParam(deferredComputeShader, HDShaderIDs._DebugLightingSmoothness, debugLightingSmoothness);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, HDShaderIDs.g_vLightListGlobal, bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._DeferredShadowTexture, deferredShadowTexture);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, HDShaderIDs._MainDepthTexture, depthTexture);

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


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

2
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


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

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


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

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


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

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
// 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
#pragma shader_feature _ _MATID_SSS _MATID_ANISO _MATID_SPECULAR _MATID_CLEARCOAT

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


#pragma shader_feature _SPECULARCOLORMAP
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _ _BLENDMODE_LERP _BLENDMODE_ADD _BLENDMODE_SOFT_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
// 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
#pragma shader_feature _ _MATID_SSS _MATID_ANISO _MATID_SPECULAR _MATID_CLEARCOAT

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

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


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)
{
case BlendMode.Lerp:

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

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,

5
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class RenderPipelineResources : ScriptableObject
{

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");
// SceneSettings
// These shaders don't need to be reference by RenderPipelineResource as they are not use at runtime (only to draw in editor)

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)

159
SampleScenes/HDTest/Material/HDRenderLoopMaterials/Grid_Red_Transparent_Planar.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Grid_Red_Transparent_Planar
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _BLENDMODE_LERP _DEPTHOFFSETENABLE_OFF
_DISTORTIONDEPTHTEST_OFF _DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _DOUBLESIDEDENABLE_OFF
_ENABLEPERPIXELDISPLACEMENT_OFF _ENABLEWIND_OFF _MAPPING_PLANAR _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 2800000, guid: fef12d96364197f49b3aac63e72bf9d9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularOcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlbedoAffectEmissive: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _CoatCoverage: 1
- _CoatIOR: 0.5
- _CullMode: 2
- _DepthOffsetEnable: 0
- _DetailAlbedoScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _Drag: 1
- _DstBlend: 10
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _EnableSpecularOcclusion: 0
- _EnableWind: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HeightMax: 1
- _HeightMin: -1
- _HorizonFade: 1
- _InitialBend: 1
- _MaterialID: 1
- _Metallic: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 0
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SrcBlend: 5
- _StencilRef: 2
- _Stiffness: 1
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _SurfaceType: 1
- _TexWorldScale: 1
- _Thickness: 1
- _UVBase: 4
- _UVDetail: 0
- _ZTestMode: 8
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 1, g: 0.46274495, b: 0.46274495, a: 0.816}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 0, g: 0, b: 0, a: 0}

10
SampleScenes/HDTest/Material/HDRenderLoopMaterials/Grid_Red_Transparent_Planar.mat.meta


fileFormatVersion: 2
guid: f473ec9e1cd032545b8de43885028638
timeCreated: 1504540207
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

10
SampleScenes/HDTest/ShadowsTest.meta


fileFormatVersion: 2
guid: 37b64947bf0ad024fb931d24f17a52b7
folderAsset: yes
timeCreated: 1504864302
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

28
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/DeferredDirectionalShadow.compute


// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel DeferredDirectionalShadow
#include "../../../Core/ShaderLibrary/Common.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/Lighting.hlsl"
RWTexture2D<float4> _DeferredShadowTextureUAV;
float _DirectionalShadowIndex;
#define DEFERRED_SHADOW_TILE_SIZE 16
[numthreads(DEFERRED_SHADOW_TILE_SIZE, DEFERRED_SHADOW_TILE_SIZE, 1)]
void DeferredDirectionalShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId : SV_GroupID)
{
uint2 pixelCoord = groupId * DEFERRED_SHADOW_TILE_SIZE + groupThreadId;
uint2 tileCoord = groupId;
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw, tileCoord);
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.unPositionSS).x;
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
ShadowContext shadowContext = InitShadowContext();
float shadow = GetDirectionalShadowAttenuation(shadowContext, posInput.positionWS, float3(0.0, 0.0, 0.0), (uint)_DirectionalShadowIndex, float3(0.0, 0.0, 0.0));
_DeferredShadowTextureUAV[pixelCoord] = float4(shadow.xxx, 0.0);
}

10
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/DeferredDirectionalShadow.compute.meta


fileFormatVersion: 2
guid: fbde6fae193b2a94e9fd97c163c204f4
timeCreated: 1505129983
licenseType: Pro
ComputeShaderImporter:
externalObjects: {}
currentAPIMask: 8196
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存