浏览代码

Merge remote-tracking branch 'origin/master' into batch_rendering

# Conflicts:
#	ProjectSettings/GraphicsSettings.asset
#	ProjectSettings/ProjectVersion.txt
/batch_rendering
Arnaud Carre 8 年前
当前提交
66610d8f
共有 372 个文件被更改,包括 2708 次插入1893 次删除
  1. 103
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 4
      Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
  3. 36
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  4. 6
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
  5. 19
      Assets/ScriptableRenderLoop/ShaderLibrary/API/D3D11.hlsl
  6. 4
      Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl
  7. 11
      Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl
  8. 177
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  9. 34
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  10. 380
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
  11. 11
      Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
  12. 28
      Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl
  13. 33
      Assets/ScriptableRenderLoop/common/ShaderBase.h
  14. 4
      Assets/ScriptableRenderLoop/common/SkyboxHelper.cs
  15. 137
      Assets/ScriptableRenderLoop/common/TextureCache.cs
  16. 2
      Assets/ScriptableRenderLoop/common/TextureSettings.cs
  17. 136
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  18. 8
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
  19. 2
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  20. 10
      Assets/ScriptableRenderLoop/fptl/LightingTemplate.hlsl
  21. 10
      Assets/ScriptableRenderLoop/fptl/ReflectionTemplate.hlsl
  22. 2
      Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs
  23. 89
      Assets/TestScenes/HDTest/GlobalIlluminationTest.unity
  24. 94
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity
  25. 914
      Assets/TestScenes/HDTest/LayeredLitTest.unity
  26. 25
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendColor.mat
  27. 28
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat
  28. 34
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
  29. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat.meta
  30. 30
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
  31. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat.meta
  32. 28
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
  33. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat.meta
  34. 25
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat
  35. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat.meta
  36. 45
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat
  37. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat.meta
  38. 36
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat
  39. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat.meta
  40. 29
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat
  41. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat.meta
  42. 27
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat
  43. 27
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV1.mat
  44. 37
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat
  45. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat.meta
  46. 38
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat
  47. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat.meta
  48. 31
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat
  49. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat.meta
  50. 28
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV0.mat
  51. 28
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV1.mat
  52. 39
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat
  53. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat.meta
  54. 44
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat
  55. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat.meta
  56. 34
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat
  57. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat.meta
  58. 30
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV0.mat
  59. 30
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV1.mat
  60. 51
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat
  61. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat.meta
  62. 9
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_UVChart_Layer2_Detail.mat
  63. 12
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_White_Detail.mat
  64. 10
      ProjectSettings/GraphicsSettings.asset
  65. 2
      ProjectSettings/ProjectVersion.txt
  66. 7
      README.md
  67. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta
  68. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta
  69. 13
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs
  70. 168
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
  71. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl
  72. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl
  73. 22
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
  74. 11
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  75. 23
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
  76. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl
  77. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl
  78. 29
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  79. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
  80. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
  81. 95
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
  82. 25
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
  83. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl
  84. 3
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs
  85. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky.meta
  86. 83
      Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
  87. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyRenderer.cs.meta
  88. 328
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyRenderer.cs
  89. 56
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
  90. 69
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
  91. 61
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
  92. 450
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  93. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit.meta
  94. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit.meta
  95. 27
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl
  96. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs
  97. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl
  98. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitSharePass.hlsl
  99. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitData.hlsl
  100. 16
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader

103
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


using System;
using System.Collections.Generic;
using UnityEngine.ScriptableRenderPipeline;
// Very basic scriptable rendering loop example:
// - Use with BasicRenderLoopShader.shader (the loop expects "BasicPass" pass type to exist)

// - This loop also does not setup lightmaps, light probes, reflection probes or light cookies
[ExecuteInEditMode]
public class BasicRenderLoop : RenderPipeline
public class BasicRenderLoop : RenderPipelineAsset
[UnityEditor.MenuItem("Renderloop/Create BasicRenderLoop")]
[UnityEditor.MenuItem("RenderPipeline/Create BasicRenderLoop")]
static void CreateBasicRenderLoop()
{
var instance = ScriptableObject.CreateInstance<BasicRenderLoop>();

private ShaderPassName shaderPassBasic;
public void OnEnable()
protected override IRenderPipeline InternalCreatePipeline()
Rebuild();
return new BasicRenderLoopInstance();
}
public override void Initialize()
public class BasicRenderLoopInstance : RenderPipeline
{
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
shaderPassBasic = new ShaderPassName("BasicPass");
base.Render(renderContext, cameras);
BasicRendering.Render(renderContext, cameras);
}
public static class BasicRendering
{
public override void Render(Camera[] cameras, RenderLoop loop)
public static void Render(ScriptableRenderContext context, IEnumerable<Camera> cameras)
if (!CullResults.GetCullingParameters (camera, out cullingParams))
if (!CullResults.GetCullingParameters(camera, out cullingParams))
CullResults cull = CullResults.Cull (ref cullingParams, loop);
CullResults cull = CullResults.Cull(ref cullingParams, context);
loop.SetupCameraProperties (camera);
context.SetupCameraProperties(camera);
loop.ExecuteCommandBuffer(cmd);
context.ExecuteCommandBuffer(cmd);
SetupLightShaderVariables (cull.visibleLights, loop);
SetupLightShaderVariables(cull.visibleLights, context);
var settings = new DrawRendererSettings (cull, camera, shaderPassBasic);
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("BasicPass"));
settings.inputFilter.SetQueuesOpaque ();
loop.DrawRenderers (ref settings);
settings.inputFilter.SetQueuesOpaque();
context.DrawRenderers(ref settings);
loop.DrawSkybox (camera);
context.DrawSkybox(camera);
settings.inputFilter.SetQueuesTransparent ();
loop.DrawRenderers (ref settings);
settings.inputFilter.SetQueuesTransparent();
context.DrawRenderers(ref settings);
loop.Submit ();
context.Submit();
static void SetupLightShaderVariables (VisibleLight[] lights, RenderLoop loop)
private static void SetupLightShaderVariables(VisibleLight[] lights, ScriptableRenderContext context)
{
// We only support up to 8 visible lights here. More complex approaches would
// be doing some sort of per-object light setups, but here we go for simplest possible

// to the viewer, so that "most important" lights in the scene are picked, and not the 8
// that happened to be first.
int lightCount = Mathf.Min (lights.Length, kMaxLights);
int lightCount = Mathf.Min(lights.Length, kMaxLights);
// Prepare light data
Vector4[] lightColors = new Vector4[kMaxLights];

if (light.lightType == LightType.Directional)
{
// light position for directional lights is: (-direction, 0)
var dir = light.localToWorld.GetColumn (2);
lightPositions[i] = new Vector4 (-dir.x, -dir.y, -dir.z, 0);
var dir = light.localToWorld.GetColumn(2);
lightPositions[i] = new Vector4(-dir.x, -dir.y, -dir.z, 0);
var pos = light.localToWorld.GetColumn (3);
lightPositions[i] = new Vector4 (pos.x, pos.y, pos.z, 1);
var pos = light.localToWorld.GetColumn(3);
lightPositions[i] = new Vector4(pos.x, pos.y, pos.z, 1);
}
// attenuation set in a way where distance attenuation can be computed:
// float lengthSq = dot(toLight, toLight);

// spot direction & attenuation
if (light.lightType == LightType.Spot)
{
var dir = light.localToWorld.GetColumn (2);
lightSpotDirections[i] = new Vector4 (-dir.x, -dir.y, -dir.z, 0);
var dir = light.localToWorld.GetColumn(2);
lightSpotDirections[i] = new Vector4(-dir.x, -dir.y, -dir.z, 0);
float cosTheta = Mathf.Cos (radAngle * 0.25f);
float cosPhi = Mathf.Cos (radAngle * 0.5f);
float cosTheta = Mathf.Cos(radAngle * 0.25f);
float cosPhi = Mathf.Cos(radAngle * 0.5f);
lightAtten[i] = new Vector4 (cosPhi, (cosDiff != 0.0f) ? 1.0f / cosDiff : 1.0f, quadAtten, rangeSq);
lightAtten[i] = new Vector4(cosPhi, (cosDiff != 0.0f) ? 1.0f / cosDiff : 1.0f, quadAtten, rangeSq);
lightSpotDirections[i] = new Vector4 (0, 0, 1, 0);
lightAtten[i] = new Vector4 (-1, 1, quadAtten, rangeSq);
lightSpotDirections[i] = new Vector4(0, 0, 1, 0);
lightAtten[i] = new Vector4(-1, 1, quadAtten, rangeSq);
}
}
GetShaderConstantsFromNormalizedSH (ref ambientSH, shConstants);
GetShaderConstantsFromNormalizedSH(ref ambientSH, shConstants);
cmd.SetGlobalVectorArray ("globalLightColor", lightColors);
cmd.SetGlobalVectorArray ("globalLightPos", lightPositions);
cmd.SetGlobalVectorArray ("globalLightSpotDir", lightSpotDirections);
cmd.SetGlobalVectorArray ("globalLightAtten", lightAtten);
cmd.SetGlobalVector ("globalLightCount", new Vector4 (lightCount, 0, 0, 0));
cmd.SetGlobalVectorArray ("globalSH", shConstants);
loop.ExecuteCommandBuffer (cmd);
cmd.Dispose ();
cmd.SetGlobalVectorArray("globalLightColor", lightColors);
cmd.SetGlobalVectorArray("globalLightPos", lightPositions);
cmd.SetGlobalVectorArray("globalLightSpotDir", lightSpotDirections);
cmd.SetGlobalVectorArray("globalLightAtten", lightAtten);
cmd.SetGlobalVector("globalLightCount", new Vector4(lightCount, 0, 0, 0));
cmd.SetGlobalVectorArray("globalSH", shConstants);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();
static void GetShaderConstantsFromNormalizedSH (ref SphericalHarmonicsL2 ambientProbe, Vector4[] outCoefficients)
private static void GetShaderConstantsFromNormalizedSH(ref SphericalHarmonicsL2 ambientProbe, Vector4[] outCoefficients)
{
for (int channelIdx = 0; channelIdx < 3; ++channelIdx)
{

4
Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs


[TestFixture]
public class CullResultsTest
{
void InspectCullResults(Camera camera, CullResults cullResults, RenderLoop renderLoop)
void InspectCullResults(Camera camera, CullResults cullResults, ScriptableRenderContext renderContext)
{
VisibleReflectionProbe[] probes = cullResults.visibleReflectionProbes;

public void TestReflectionProbes()
{
UnityEditor.SceneManagement.EditorSceneManager.OpenScene("Assets/Editor/Tests/TestScene.unity");
RenderLoopTestFixture.Run(InspectCullResults);
RenderLoopTestFixtureInstance.Run(InspectCullResults);
}
}

36
Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs


using System.Collections;
using System;
using UnityEngine.Experimental.ScriptableRenderLoop;
using UnityEngine.ScriptableRenderPipeline;
public class RenderLoopTestFixture : RenderPipeline
public class RenderLoopTestFixture : RenderPipelineAsset
public delegate void TestDelegate(Camera camera, CullResults cullResults, RenderLoop renderLoop);
protected override IRenderPipeline InternalCreatePipeline()
{
return new BasicRenderLoopInstance();
}
}
public class RenderLoopTestFixtureInstance : RenderPipeline
{
public delegate void TestDelegate(Camera camera, CullResults cullResults, ScriptableRenderContext renderContext);
public override void Render(Camera[] cameras, RenderLoop renderLoop)
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
base.Render(renderContext, cameras);
if (!camera.enabled)
continue;
CullResults cullResults = CullResults.Cull(ref cullingParams, renderLoop);
CullResults cullResults = CullResults.Cull(ref cullingParams, renderContext);
s_Callback(camera, cullResults, renderLoop);
s_Callback(camera, cullResults, renderContext);
renderLoop.Submit();
renderContext.Submit();
}
public static void Run(TestDelegate renderCallback)

var sceneCamera = Camera.main;
var camObject = sceneCamera.gameObject;
GraphicsSettings.SetRenderPipeline(m_Instance);
GraphicsSettings.renderPipeline = m_Instance;
s_Callback = renderCallback;
Transform t = camObject.transform;

SceneView.lastActiveSceneView.LookAtDirect(t.position + t.forward * camDist, t.rotation, size);
sceneCamera.Render();
GraphicsSettings.SetRenderPipeline(null);
GraphicsSettings.renderPipeline = null;
}
}

6
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


parameters.shadowDistance = Mathf.Min(m_Settings.maxShadowDistance, parameters.shadowDistance);
}
public void Render(RenderLoop loop, CullResults cullResults, out ShadowOutput packedShadows)
public void Render(ScriptableRenderContext loop, CullResults cullResults, out ShadowOutput packedShadows)
{
if (!m_Settings.enabled)
{

//---------------------------------------------------------------------------------------------------------------------------------------------------
// Render shadows
//---------------------------------------------------------------------------------------------------------------------------------------------------
void RenderPackedShadows(RenderLoop loop, CullResults cullResults, ref ShadowOutput packedShadows)
void RenderPackedShadows(ScriptableRenderContext loop, CullResults cullResults, ref ShadowOutput packedShadows)
{
var setRenderTargetCommandBuffer = new CommandBuffer();

}
//---------------------------------------------------------------------------------------------------------------------------------------------------
private void RenderShadowSplit(ref ShadowSliceData slice, Vector3 lightDirection, Matrix4x4 proj, Matrix4x4 view, ref RenderLoop loop, DrawShadowsSettings settings)
private void RenderShadowSplit(ref ShadowSliceData slice, Vector3 lightDirection, Matrix4x4 proj, Matrix4x4 view, ref ScriptableRenderContext loop, DrawShadowsSettings settings)
{
var commandBuffer = new CommandBuffer { name = "ShadowSetup" };

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


// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName;
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName;
#define TEXTURECUBE(textureName) TextureCube textureName;
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName;
#define TEXTURE3D(textureName) Texture3D textureName;
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName;
#define SAMPLERCUBE(samplerName) SamplerState samplerName;
#define SAMPLER3D(samplerName) SamplerState samplerName;
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName

#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, index, lod) textureName.Load(int4(unCoord2, index, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))

4
Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl


sum *= INV_TWO_PI; // Normalization
return twoSided ? abs(sum) : max(sum, 0.0);
sum = twoSided ? abs(sum) : max(sum, 0.0);
return isfinite(sum) ? sum : 0.0;
}
// For polygonal lights.

11
Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl


return INV_PI * D_GGXNoPI(NdotH, roughness);
}
float D_GGX_Inverse(float NdotH, float roughness)
{
roughness = max(roughness, UNITY_MIN_ROUGHNESS);
float a2 = roughness * roughness;
float f = (NdotH * a2 - NdotH) * NdotH + 1.0;
float g = (f * f) / a2;
return PI * g;
}
// Ref: http://jcgt.org/published/0003/02/03/paper.pdf
float V_SmithJointGGX(float NdotL, float NdotV, float roughness)
{

177
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


#define Clamp clamp
#endif // INTRINSIC_CLAMP
#ifndef INTRINSIC_MUL24
int Mul24(int a, int b)
{
return a * b;
}
uint Mul24(uint a, uint b)
{
return a * b;
}
#endif // INTRINSIC_MUL24
#ifndef INTRINSIC_MAD24
int Mad24(int a, int b, int c)
{
return a * b + c;
}
uint Mad24(uint a, uint b, uint c)
{
return a * b + c;
}
#endif // INTRINSIC_MAD24
#ifndef INTRINSIC_MED3
float Med3(float a, float b, float c)
{

float4 t = a; a = b; b = t;
}
#define CUBEMAPFACE_POSITIVE_X 0
#define CUBEMAPFACE_NEGATIVE_X 1
#define CUBEMAPFACE_POSITIVE_Y 2
#define CUBEMAPFACE_NEGATIVE_Y 3
#define CUBEMAPFACE_POSITIVE_Z 4
#define CUBEMAPFACE_NEGATIVE_Z 5
// TODO: implement this. Is the reference implementation of cubemapID provide by AMD the reverse of our ?
// TODO: implement this. Is the reference implementation of cubemapID provide by AMD the reverse of our ?
/*
float CubemapFaceID(float3 dir)
{

return faceID;
}
*/
#endif // INTRINSIC_CUBEMAP_FACE_ID
#define CUBEMAPFACE_POSITIVE_X 0
#define CUBEMAPFACE_NEGATIVE_X 1
#define CUBEMAPFACE_POSITIVE_Y 2
#define CUBEMAPFACE_NEGATIVE_Y 3
#define CUBEMAPFACE_POSITIVE_Z 4
#define CUBEMAPFACE_NEGATIVE_Z 5
void GetCubeFaceID(float3 dir, out int faceIndex)
{

}
}
#endif // INTRINSIC_CUBEMAP_FACE_ID
// ----------------------------------------------------------------------------
// Common math definition and fastmath function
// ----------------------------------------------------------------------------

#define INV_HALF_PI 0.636619772367
#define FLT_EPSILON 1.192092896e-07 // Smallest positive number, such that 1.0 + FLT_EPSILON != 1.0
#define FLT_MIN 1.175494351e-38 // Minimum representable positive floating-point number
#define FLT_MAX 3.402823466e+38 // Maximum representable floating-point number
#define MERGE_NAME(X, Y) X##Y

// 4 VGPR, 16 FR (12 FR, 1 QR), 2 scalar
// input [-infinity, infinity] and output [-PI/2, PI/2]
float FastATan(float x)
float FastATan(float x)
{
float t0 = FastATanPos(abs(x));
return (x < 0.0) ? -t0 : t0;

// World position reconstruction / transformation
// ----------------------------------------------------------------------------
struct Coordinate
// Z buffer to linear 0..1 depth (0 at near plane, 1 at far plane)
float Linear01DepthFromNear(float depth, float4 zBufferParam)
{
return 1.0 / (zBufferParam.x + zBufferParam.y / depth);
}
// Z buffer to linear 0..1 depth (0 at camera position, 1 at far plane)
float Linear01Depth(float depth, float4 zBufferParam)
// Normalize coordinates
float2 positionSS;
// Unormalize coordinates
uint2 unPositionSS;
return 1.0 / (zBufferParam.x * depth + zBufferParam.y);
}
// Z buffer to linear depth
float LinearEyeDepth(float depth, float4 zBufferParam)
{
return 1.0 / (zBufferParam.z * depth + zBufferParam.w);
}
struct PositionInputs
{
// Normalize screen position (offset by 0.5)
float2 positionSS;
// Unormalize screen position (offset by 0.5)
uint2 unPositionSS;
float depthRaw; // raw depth from depth buffer
float depthVS;
float4 positionCS;
float3 positionWS;
// else it is current unormalized screen coordinate like return by VPOS
Coordinate GetCoordinate(float2 unPositionSS, float2 invScreenSize)
// else it is current unormalized screen coordinate like return by SV_Position
PositionInputs GetPositionInput(float2 unPositionSS, float2 invScreenSize)
Coordinate coord;
coord.positionSS = unPositionSS;
PositionInputs posInput;
ZERO_INITIALIZE(PositionInputs, posInput);
posInput.positionSS = unPositionSS;
coord.positionSS.xy += float2(0.5, 0.5);
posInput.positionSS.xy += float2(0.5, 0.5);
coord.positionSS *= invScreenSize;
posInput.positionSS *= invScreenSize;
coord.unPositionSS = uint2(unPositionSS);
posInput.unPositionSS = uint2(unPositionSS);
return coord;
return posInput;
// screenPos is screen coordinate in [0..1] (return by Coordinate.positionSS)
// depth must be the depth from the raw depth buffer. This allow to handle all kind of depth automatically with the inverse view projection matrix.
// For information. In Unity Depth is always in range 0..1 (even on OpenGL) but can be reversed.
float3 UnprojectToWorld(float depth, float2 screenPos, float4x4 invViewProjectionMatrix)
// From forward
// depthRaw and depthVS come directly form .zw of SV_Position
void UpdatePositionInput(float depthRaw, float depthVS, float3 positionWS, inout PositionInputs posInput)
float4 positionCS = float4(screenPos.xy * 2.0 - 1.0, depth, 1.0);
float4 hpositionWS = mul(invViewProjectionMatrix, positionCS);
posInput.depthRaw = depthRaw;
posInput.depthVS = depthVS;
return hpositionWS.xyz / hpositionWS.w;
// TODO: We revert for DX but maybe it is not the case of OGL ? Test the define ?
posInput.positionCS = float4((posInput.positionSS - 0.5) * float2(2.0, -2.0), depthRaw, 1.0) * depthVS; // depthVS is SV_Position.w
posInput.positionWS = positionWS;
// Z buffer to linear 0..1 depth
float Linear01Depth(float depth, float4 zBufferParam)
// From deferred or compute shader
// depth must be the depth from the raw depth buffer. This allow to handle all kind of depth automatically with the inverse view projection matrix.
// For information. In Unity Depth is always in range 0..1 (even on OpenGL) but can be reversed.
void UpdatePositionInput(float depth, float4x4 invViewProjectionMatrix, float4x4 ViewProjectionMatrix, inout PositionInputs posInput)
return 1.0 / (zBufferParam.x * depth + zBufferParam.y);
posInput.depthRaw = depth;
// TODO: Do we need to flip Y axis here on OGL ?
posInput.positionCS = float4(posInput.positionSS.xy * 2.0 - 1.0, depth, 1.0);
float4 hpositionWS = mul(invViewProjectionMatrix, posInput.positionCS);
posInput.positionWS = hpositionWS.xyz / hpositionWS.w;
// The compiler should optimize this (less expensive than reconstruct depth VS from depth buffer)
posInput.depthVS = mul(ViewProjectionMatrix, float4(posInput.positionWS, 1.0)).w;
posInput.positionCS *= posInput.depthVS;
// Z buffer to linear depth
float LinearEyeDepth(float depth, float4 zBufferParam)
// depthOffsetVS is always in the direction of the view vector (V)
void ApplyDepthOffsetPositionInput(float V, float depthOffsetVS, inout PositionInputs posInput)
return 1.0 / (zBufferParam.z * depth + zBufferParam.w);
posInput.depthVS += depthOffsetVS;
// TODO: it is an approx, need a correct value where we use projection matrix to reproject the depth from VS
posInput.depthRaw = posInput.positionCS.z / posInput.depthVS;
// TODO: Do we need to flip Y axis here on OGL ?
posInput.positionCS = float4(posInput.positionSS.xy * 2.0 - 1.0, posInput.depthRaw, 1.0) * posInput.depthVS;
// Just add the offset along the view vector is sufficiant for world position
posInput.positionWS += V * depthOffsetVS;
}
//-----------------------------------------------------------------------------

// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping + decal
// In this case this may cause weird artifact.
// GetNdotV return a 'valid' data
float GetNdotV(float3 N, float3 V)
// NdotV should not be negative for visible pixels, but it can happen due to the
// perspective projection and the normal mapping + decals. In that case, the normal
// should be modified to become valid (i.e facing the camera) to avoid weird artifacts.
// Note: certain applications (e.g. SpeedTree) make use of two-sided lighting.
float GetShiftedNdotV(inout float3 N, float3 V, bool twoSided)
return abs(dot(N, V)); // This abs allow to limit artifact
}
float NdotV = dot(N, V);
float limit = 1e-4;
// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping + decal
// In this case normal should be modified to become valid (i.e facing camera) and not cause weird artifacts.
// but this operation adds few ALU and users may not want it. Alternative is to simply take the abs of NdotV (less correct but works too).
// Note: This code is not compatible with two sided lighting used in SpeedTree (TODO: investigate).
float GetShiftedNdotV(float3 N, float3 V)
{
// The amount we shift the normal toward the view vector is defined by the dot product.
float shiftAmount = dot(N, V);
N = shiftAmount < 0.0 ? N + V * (-shiftAmount + 1e-5f) : N;
N = normalize(N);
if (!twoSided && NdotV < limit)
{
// We do not renormalize the normal because { abs(length(N) - 1.0) < limit }.
N += (-NdotV + limit) * V;
NdotV = limit;
}
return saturate(dot(N, V)); // TODO: this saturate should not be necessary here
return NdotV;
#endif // UNITY_COMMON_INCLUDED

34
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


return dot(v, v) - v2.x * v2.y - v2.y * v2.z - v2.z * v2.x + v2.x * v2.y * v2.z;
}
// texelArea = 4.0 / (resolution * resolution).
// Ref: http://bpeers.com/blog/?itemid=1017
float ComputeCubemapTexelSolidAngle(float3 L, float texelArea)
{
// Stretch 'L' by (1/d) so that it points at a side of a [-1, 1]^2 cube.
float d = Max3(abs(L.x), abs(L.y), abs(L.z));
// Since 'L' is a unit vector, we can directly compute its
// new (inverse) length without dividing 'L' by 'd' first.
float invDist = d;
// dw = dA * cosTheta / (dist * dist), cosTheta = 1.0 / dist,
// where 'dA' is the area of the cube map texel.
return texelArea * invDist * invDist * invDist;
}
//-----------------------------------------------------------------------------
// Attenuation functions
//-----------------------------------------------------------------------------

// Get local frame
//-----------------------------------------------------------------------------
// generate an orthonormalBasis from 3d unit vector.
void GetLocalFrame(float3 N, out float3 tangentX, out float3 tangentY)
// Generates an orthonormal basis from two orthogonal unit vectors.
float3x3 GetLocalFrame(float3 localZ, float3 localX)
{
float3 localY = cross(localZ, localX);
return float3x3(localX, localY, localZ);
}
// Generates an orthonormal basis from a unit vector.
float3x3 GetLocalFrame(float3 localZ)
float3 upVector = abs(N.z) < 0.999 ? float3(0.0, 0.0, 1.0) : float3(1.0, 0.0, 0.0);
tangentX = normalize(cross(upVector, N));
tangentY = cross(N, tangentX);
float3 upVector = abs(localZ.z) < 0.999 ? float3(0.0, 0.0, 1.0) : float3(1.0, 0.0, 0.0);
float3 localX = normalize(cross(upVector, localZ));
return GetLocalFrame(localZ, localX);
}
// TODO: test

380
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


#include "BSDF.hlsl"
#include "Sampling.hlsl"
// TODO: We need to change this hard limit!
#ifndef UNITY_SPECCUBE_LOD_STEPS
#define UNITY_SPECCUBE_LOD_STEPS 6
#endif
// TODO: We need to change this hard limit!
#define UNITY_SPECCUBE_LOD_STEPS (6)
float perceptualRoughnessToMipmapLevel(float perceptualRoughness)
{

float mipmapLevelToPerceptualRoughness(float mipmapLevel)
{
return mipmapLevel / UNITY_SPECCUBE_LOD_STEPS;
return saturate(mipmapLevel / UNITY_SPECCUBE_LOD_STEPS);
}
//-----------------------------------------------------------------------------
// Coordinate system conversion
//-----------------------------------------------------------------------------
// Transforms the unit vector from the spherical to the Cartesian (right-handed, Z up) coordinate.
float3 SphericalToCartesian(float phi, float sinTheta, float cosTheta)
{
float sinPhi, cosPhi;
sincos(phi, sinPhi, cosPhi);
return float3(sinTheta * cosPhi, sinTheta * sinPhi, cosTheta);
}
// Converts Cartesian coordinates given in the right-handed coordinate system
// with Z pointing upwards (OpenGL style) to the coordinates in the left-handed
// coordinate system with Y pointing up and Z facing forward (DirectX style).
float3 TransformGLtoDX(float x, float y, float z)
{
return float3(x, z, y);
}
float3 TransformGLtoDX(float3 v)
{
return v.xzy;
}
// Performs conversion from equiareal map coordinates to Cartesian (DirectX cubemap) ones.
float3 ConvertEquiarealToCubemap(float u, float v)
{
// The equiareal mapping is defined as follows:
// phi = TWO_PI * (1.0 - u)
// cos(theta) = 1.0 - 2.0 * v
// sin(theta) = sqrt(1.0 - cos^2(theta)) = 2.0 * sqrt(v - v * v)
float phi = TWO_PI - TWO_PI * u;
float cosTheta = 1.0 - 2.0 * v;
float sinTheta = 2.0 * sqrt(v - v * v);
return TransformGLtoDX(SphericalToCartesian(phi, sinTheta, cosTheta));
}
// Ref: See "Moving Frostbite to PBR" Listing 22

// Importance sampling BSDF functions
// ----------------------------------------------------------------------------
void ImportanceSampleCosDir(float2 u,
float3 N,
float3 tangentX,
float3 tangentY,
out float3 L)
void ImportanceSampleCosDir(float2 u,
float3x3 localToWorld,
out float3 L)
float cosTheta = sqrt(max(0.0, 1.0 - u.x));
float cosTheta = sqrt(saturate(1.0 - u.x));
float phi = TWO_PI * u.y;
float phi = TWO_PI * u.y;
// Transform from spherical into cartesian
L = float3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);
// Local to world
L = tangentX * L.x + tangentY * L.y + N * L.z;
L = SphericalToCartesian(phi, sinTheta, cosTheta);
L = mul(L, localToWorld);
void ImportanceSampleGGXDir(float2 u,
float3 V,
float3 N,
float3 tangentX,
float3 tangentY,
float roughness,
out float3 H,
out float3 L)
void ImportanceSampleGGXDir(float2 u,
float3 V,
float3x3 localToWorld,
float roughness,
out float3 L,
out float NdotH,
out float VdotH,
bool VeqN = false)
float cosThetaH = sqrt((1.0 - u.x) / (1.0 + (roughness * roughness - 1.0) * u.x));
float sinThetaH = sqrt(max(0.0, 1.0 - cosThetaH * cosThetaH));
float phiH = TWO_PI * u.y;
float cosTheta = sqrt((1.0 - u.x) / (1.0 + (roughness * roughness - 1.0) * u.x));
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
float phi = TWO_PI * u.y;
// Transform from spherical into cartesian
H = float3(sinThetaH * cos(phiH), sinThetaH * sin(phiH), cosThetaH);
// Local to world
H = tangentX * H.x + tangentY * H.y + N * H.z;
float3 localH = SphericalToCartesian(phi, sinTheta, cosTheta);
// Convert sample from half angle to incident angle
L = 2.0 * dot(V, H) * H - V;
NdotH = cosTheta;
float3 localV;
if (VeqN)
{
// localV == localN
localV = float3(0.0, 0.0, 1.0);
VdotH = NdotH;
}
else
{
localV = mul(V, transpose(localToWorld));
VdotH = saturate(dot(localV, localH));
}
// Compute { L = reflect(-localV, localH) }
L = -localV + 2.0 * VdotH * localH;
L = mul(L, localToWorld);
}
// ref: http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf p26

// H = tangentX * H.x + tangentY * H.y + N * H.z;
// Convert sample from half angle to incident angle
L = 2.0 * dot(V, H) * H - V;
L = 2.0 * saturate(dot(V, H)) * H - V;
void ImportanceSampleLambert(
float2 u,
float3 N,
float3 tangentX,
float3 tangentY,
out float3 L,
out float NdotL,
out float weightOverPdf)
void ImportanceSampleLambert(float2 u,
float3x3 localToWorld,
out float3 L,
out float NdotL,
out float weightOverPdf)
ImportanceSampleCosDir(u, N, tangentX, tangentY, L);
ImportanceSampleCosDir(u, localToWorld, L);
NdotL = saturate(dot(N, L));
NdotL = saturate(dot(localToWorld[2], L));
// Importance sampling weight for each sample
// pdf = N.L / PI

}
// weightOverPdf return the weight (without the Fresnel term) over pdf. Fresnel term must be apply by the caller.
void ImportanceSampleGGX(
float2 u,
float3 V,
float3 N,
float3 tangentX,
float3 tangentY,
float roughness,
float NdotV,
out float3 L,
out float VdotH,
out float NdotL,
out float weightOverPdf)
void ImportanceSampleGGX(float2 u,
float3 V,
float3x3 localToWorld,
float roughness,
float NdotV,
out float3 L,
out float VdotH,
out float NdotL,
out float weightOverPdf)
ImportanceSampleGGXDir(u, V, N, tangentX, tangentY, roughness, H, L);
float NdotH;
ImportanceSampleGGXDir(u, V, localToWorld, roughness, L, NdotH, VdotH);
float NdotH = saturate(dot(N, H));
// Note: since L and V are symmetric around H, LdotH == VdotH
VdotH = saturate(dot(V, H));
NdotL = saturate(dot(N, L));
NdotL = saturate(dot(localToWorld[2], L));
// Importance sampling weight for each sample
// pdf = D(H) * (N.H) / (4 * (L.H))

// weightOverPdf = F(H) * G(V, L) * (L.H) / ((N.H) * (N.V))
// weightOverPdf = F(H) * 4 * (N.L) * V(V, L) * (L.H) / (N.H) with V(V, L) = G(V, L) / (4 * (N.L) * (N.V))
// Remind (L.H) == (V.H)
// F is apply outside the function
// F is apply outside the function
float TdotV = dot(tangentX, V);
float BdotV = dot(tangentY, V);
float TdotL = saturate(dot(tangentX, L));

// Ref: Listing 18 in "Moving Frostbite to PBR" + https://knarkowicz.wordpress.com/2014/12/27/analytical-dfg-term-for-ibl/
float4 IntegrateGGXAndDisneyFGD(float3 V, float3 N, float roughness, uint sampleCount)
{
float NdotV = saturate(dot(N, V));
float NdotV = GetShiftedNdotV(N, V, false); // This fix some rare artifact at edge.
float3 tangentX, tangentY;
GetLocalFrame(N, tangentX, tangentY);
float3x3 localToWorld = GetLocalFrame(N);
float2 u = Hammersley2d(i, sampleCount);
u = frac(u + randNum + 0.5);
float2 u = frac(randNum + Hammersley2d(i, sampleCount));
float VdotH;
float NdotL;

ImportanceSampleGGX(u, V, N, tangentX, tangentY, roughness, NdotV,
ImportanceSampleGGX(u, V, localToWorld, roughness, NdotV,
L, VdotH, NdotL, weightOverPdf);
if (NdotL > 0.0)

}
// for Disney we still use a Cosine importance sampling, true Disney importance sampling imply a look up table
ImportanceSampleLambert(u, N, tangentX, tangentY, L, NdotL, weightOverPdf);
ImportanceSampleLambert(u, localToWorld, L, NdotL, weightOverPdf);
if (NdotL > 0.0)
{

float3 V,
float3 N,
float roughness,
float mipmapcount,
float maxMipLevel,
uint sampleCount,
bool prefilter = true) // static bool
uint sampleCount, // Must be a Fibonacci number
bool prefilter)
float3 acc = float3(0.0, 0.0, 0.0);
float accWeight = 0;
float2 randNum = InitRandom(V.xy * 0.5 + 0.5);
float3x3 localToWorld = GetLocalFrame(N);
float3 tangentX, tangentY;
GetLocalFrame(N, tangentX, tangentY);
float3 lightInt = float3(0.0, 0.0, 0.0);
float cbsdfInt = 0.0;
float2 u = Hammersley2d(i, sampleCount);
u = frac(u + randNum + 0.5);
float2 u = Fibonacci2d(i, sampleCount);
float3 H;
// Bias samples towards the mirror direction to reduce variance.
// This will have a side effect of making the reflection sharper.
// Ref: Stochastic Screen-Space Reflections, p. 67.
const float bias = 0.2;
u.x = lerp(u.x, 0.0, bias);
ImportanceSampleGGXDir(u, V, N, tangentX, tangentY, roughness, H, L);
float NdotH, VdotH;
ImportanceSampleGGXDir(u, V, localToWorld, roughness, L, NdotH, VdotH, true);
float NdotL = saturate(dot(N,L));
float NdotL = saturate(dot(N, L));
mipLevel = 0.0;
mipLevel = 0;
float NdotH = saturate(dot(N, H));
// Note: since L and V are symmetric around H, LdotH == VdotH
float LdotH = saturate(dot(L, H));
// Use pre - filtered importance sampling (i.e use lower mipmap
// level for fetching sample with low probability in order
// to reduce the variance ).
// ( Reference : GPU Gem3: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html)
// Use lower MIP-map levels for fetching samples with low probabilities
// in order to reduce the variance.
// Ref: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html
// Since we pre - integrate the result for normal direction ,
// N == V and then NdotH == LdotH . This is why the BRDF pdf
// can be simplifed from :
// pdf = D * NdotH /(4* LdotH ) to pdf = D / 4;
// pdf = D * NdotH * jacobian, where jacobian = 1.0 / (4* LdotH).
//
// Since L and V are symmetric around H, LdotH == VdotH.
// Since we pre-integrate the result for the normal direction,
// N == V and then NdotH == LdotH. Therefore, the BRDF's pdf
// can be simplified:
// pdf = D * NdotH / (4 * LdotH) = D * 0.25;
float pdf = D_GGXNoPI(NdotH, roughness) * NdotH / (4.0 * LdotH); // TODO: Check if divide PI is required here
float omegaS = 1.0 / (sampleCount * pdf); // Solid angle associated to a sample
float invPdf = D_GGX_Inverse(NdotH, roughness) * 4.0;
// TODO: check the accuracy of the sample's solid angle fit for GGX.
float omegaS = rcp(sampleCount) * invPdf;
// float omegaP = FOUR_PI / (6.0f * cubemapWidth * cubemapWidth); // Solid angle associated to a pixel of the cubemap
// Clamp is not necessary as the hardware will do it.
// mipLevel = Clamp(0.5f * log2(omegaS * invOmegaP), 0, mipmapcount);
mipLevel = 0.5 * log2(omegaS * invOmegaP); // Clamp is not necessary as the hardware will do it.
// float omegaP = FOUR_PI / (6.0f * cubemapWidth * cubemapWidth);
mipLevel = 0.5 * log2(omegaS * invOmegaP);
// Bias the MIP map level to compensate for the importance sampling bias.
// This will blur the reflection.
// TODO: find a more accurate MIP bias function.
mipLevel = lerp(mipLevel, maxMipLevel, bias);
if (NdotL > 0.0f)
if (NdotL > 0.0)
// TODO: use a Gaussian-like filter to generate the MIP pyramid.
// See p63 equation (53) of moving Frostbite to PBR v2 for the extra NdotL here (both in weight and value)
acc += val * NdotL;
accWeight += NdotL;
// *********************************************************************************
// Our goal is to use Monte-Carlo integration with importance sampling to evaluate
// X(V) = Integral{Radiance(L) * CBSDF(L, N, V) dL} / Integral{CBSDF(L, N, V) dL}.
// CBSDF = F * D * G * NdotL / (4 * NdotL * NdotV) = F * D * G / (4 * NdotV).
// PDF = D * NdotH / (4 * LdotH).
// Weight = CBSDF / PDF = F * G * LdotH / (NdotV * NdotH).
// Since we perform filtering with the assumption that (V == N),
// (LdotH == NdotH) && (NdotV == 1) && (Weight == F * G).
// We use the approximation of Brian Karis from "Real Shading in Unreal Engine 4":
// Weight ≈ NdotL, which produces nearly identical results in practice.
// *********************************************************************************
lightInt += NdotL * val;
cbsdfInt += NdotL;
return float4(acc * (1.0 / accWeight), 1.0);
return float4(lightInt / cbsdfInt, 1.0);
}
// Searches the row 'j' containing 'n' elements of 'haystack' and
// returns the index of the first element greater or equal to 'needle'.
uint BinarySearchRow(uint j, float needle, TEXTURE2D(haystack), uint n)
{
uint i = n - 1;
float v = LOAD_TEXTURE2D(haystack, uint2(i, j)).r;
if (needle < v)
{
i = 0;
for (uint b = 1 << firstbithigh(n - 1); b != 0; b >>= 1)
{
uint p = i | b;
v = LOAD_TEXTURE2D(haystack, uint2(p, j)).r;
if (v <= needle) { i = p; } // Move to the right.
}
}
return i;
}
float4 IntegrateLD_MIS(TEXTURECUBE_ARGS(envMap, sampler_envMap),
TEXTURE2D(marginalRowDensities),
TEXTURE2D(conditionalDensities),
float3 V,
float3 N,
float roughness,
float invOmegaP,
uint width,
uint height,
uint sampleCount,
bool prefilter)
{
float3x3 localToWorld = GetLocalFrame(N);
float2 randNum = InitRandom(V.xy * 0.5 + 0.5);
float3 lightInt = float3(0.0, 0.0, 0.0);
float cbsdfInt = 0.0;
/*
// Dedicate 50% of samples to light sampling at 1.0 roughness.
// Only perform BSDF sampling when roughness is below 0.5.
const int lightSampleCount = lerp(0, sampleCount / 2, saturate(2.0 * roughness - 1.0));
const int bsdfSampleCount = sampleCount - lightSampleCount;
*/
// The value of the integral of intensity values of the environment map (as a 2D step function).
float envMapInt2dStep = LOAD_TEXTURE2D(marginalRowDensities, uint2(height, 0)).r;
// Since we are using equiareal mapping, we need to divide by the area of the sphere.
float envMapIntSphere = envMapInt2dStep * INV_FOUR_PI;
// Perform light importance sampling.
for (uint i = 0; i < sampleCount; i++)
{
float2 s = frac(randNum + Hammersley2d(i, sampleCount));
// Sample a row from the marginal distribution.
uint y = BinarySearchRow(0, s.x, marginalRowDensities, height - 1);
// Sample a column from the conditional distribution.
uint x = BinarySearchRow(y, s.y, conditionalDensities, width - 1);
// Compute the coordinates of the sample.
// Note: we take the sample in between two texels, and also apply the half-texel offset.
// We could compute fractional coordinates at the cost of 4 extra texel samples.
float u = saturate((float)x / width + 1.0 / width);
float v = saturate((float)y / height + 1.0 / height);
float3 L = ConvertEquiarealToCubemap(u, v);
float NdotL = saturate(dot(N, L));
if (NdotL > 0.0)
{
float3 val = SAMPLE_TEXTURECUBE_LOD(envMap, sampler_envMap, L, 0).rgb;
float pdf = (val.r + val.g + val.b) / envMapIntSphere;
if (pdf > 0.0)
{
// (N == V) && (acos(VdotL) == 2 * acos(NdotH)).
float NdotH = sqrt(NdotL * 0.5 + 0.5);
// *********************************************************************************
// Our goal is to use Monte-Carlo integration with importance sampling to evaluate
// X(V) = Integral{Radiance(L) * CBSDF(L, N, V) dL} / Integral{CBSDF(L, N, V) dL}.
// CBSDF = F * D * G * NdotL / (4 * NdotL * NdotV) = F * D * G / (4 * NdotV).
// Weight = CBSDF / PDF.
// We use two approximations of Brian Karis from "Real Shading in Unreal Engine 4":
// (F * G ≈ NdotL) && (NdotV == 1).
// Weight = D * NdotL / (4 * PDF).
// *********************************************************************************
float weight = D_GGX(NdotH, roughness) * NdotL / (4.0 * pdf);
lightInt += weight * val;
cbsdfInt += weight;
}
}
}
// Prevent NaNs arising from the division of 0 by 0.
cbsdfInt = max(cbsdfInt, FLT_MIN);
return float4(lightInt / cbsdfInt, 1.0);
}
#endif // UNITY_IMAGE_BASED_LIGHTING_INCLUDED

11
Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl


return normalize(n);
}
float3 UnpackNormalRGB(float4 packedNormal, float scale = 1.0)
{
float3 normal;
normal.xyz = packedNormal.rgb * 2.0 - 1.0;
normal.xy *= scale;
return normalize(normal);
}
float3 UnpackNormalAG(float4 packedNormal, float scale = 1.0)
{
float3 normal;

}
// Unpack normal as DXT5nm (1, y, 0, x) or BC5 (x, y, 0, 1)
float3 UnpackNormalmapRGorAG(float4 packedNormal)
float3 UnpackNormalmapRGorAG(float4 packedNormal, float scale = 1.0)
{
// This do the trick
packedNormal.x *= packedNormal.w;

normal.xy *= scale;
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
return normal;
}

28
Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl


// Sample generator
//-----------------------------------------------------------------------------
// Ref: http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
uint ReverseBits32(uint bits)
{
#if 0 // Shader model 5
return reversebits(bits);
#else
bits = (bits << 16) | (bits >> 16);
bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
bits = ((bits & 0x0f0f0f0f) << 4) | ((bits & 0xf0f0f0f0) >> 4);
bits = ((bits & 0x33333333) << 2) | ((bits & 0xcccccccc) >> 2);
bits = ((bits & 0x55555555) << 1) | ((bits & 0xaaaaaaaa) >> 1);
return bits;
#endif
}
float RadicalInverse_VdC(uint bits)
{
return float(ReverseBits32(bits)) * 2.3283064365386963e-10; // 0x100000000
}
float2 Hammersley2d(uint i, uint maxSampleCount)
{
return float2(float(i) / float(maxSampleCount), RadicalInverse_VdC(i));
}
#include "Fibonacci.hlsl"
#include "Hammersley.hlsl"
float Hash(uint s)
{

Ns = UniformSampleSphere(u1, u2);
// Transform from unit sphere to world space
// Transform from unit sphere to world space
P = radius * Ns + localToWorld[3].xyz;
// pdf is inverse of area

33
Assets/ScriptableRenderLoop/common/ShaderBase.h


#ifndef __SHADERBASE_H__
#define __SHADERBASE_H__
//#define CUBE_ARRAY_NOT_SUPPORTED
half2 DirectionToSphericalTexCoordinate(half3 dir)
{
// coordinate frame is (-Z,X) meaning negative Z is primary axis and X is secondary axis.
float recipPi = 1.0/3.1415926535897932384626433832795;
return half2( 1.0-0.5*recipPi*atan2(dir.x, -dir.z), asin(dir.y)*recipPi+0.5 );
}
#ifdef CUBE_ARRAY_NOT_SUPPORTED
#define UNITY_DECLARE_ABSTRACT_CUBE_ARRAY UNITY_DECLARE_TEX2DARRAY
#define UNITY_PASS_ABSTRACT_CUBE_ARRAY UNITY_PASS_TEX2DARRAY
#define UNITY_ARGS_ABSTRACT_CUBE_ARRAY UNITY_ARGS_TEX2DARRAY
#define UNITY_SAMPLE_ABSTRACT_CUBE_ARRAY_LOD(tex,coord,lod) UNITY_SAMPLE_TEX2DARRAY_LOD(tex, float3(DirectionToSphericalTexCoordinate((coord).xyz), (coord).w), lod)
#else
#define UNITY_DECLARE_ABSTRACT_CUBE_ARRAY UNITY_DECLARE_TEXCUBEARRAY
#define UNITY_PASS_ABSTRACT_CUBE_ARRAY UNITY_PASS_TEXCUBEARRAY
#define UNITY_ARGS_ABSTRACT_CUBE_ARRAY UNITY_ARGS_TEXCUBEARRAY
#define UNITY_SAMPLE_ABSTRACT_CUBE_ARRAY_LOD(tex,coord,lod) UNITY_SAMPLE_TEXCUBEARRAY_LOD(tex,coord,lod)
#endif
// can't use UNITY_REVERSED_Z since it's not enabled in compute shaders
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
#define REVERSE_ZBUF
#endif
#ifdef SHADER_API_PSSL
#ifndef Texture2DMS

float FetchDepth(Texture2D depthTexture, uint2 pixCoord)
{
float zdpth = depthTexture.Load(uint3(pixCoord.xy, 0)).x;
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
#ifdef REVERSE_ZBUF
zdpth = 1.0 - zdpth;
#endif
return zdpth;

{
float zdpth = depthTexture.Load(uint3(pixCoord.xy, 0), sampleIdx).x;
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
#ifdef REVERSE_ZBUF
zdpth = 1.0 - zdpth;
#endif
return zdpth;

4
Assets/ScriptableRenderLoop/common/SkyboxHelper.cs


using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering;
public class SkyboxHelper
{

get { return m_Mesh; }
}
public void Draw(RenderLoop loop, Camera camera)
public void Draw(ScriptableRenderContext loop, Camera camera)
{
if (camera.clearFlags != CameraClearFlags.Skybox)
{

137
Assets/ScriptableRenderLoop/common/TextureCache.cs


{
private CubemapArray m_Cache;
// alternative panorama path intended for mobile
// the member variables below are only in use when m_IsNoCubeArray is true.
private bool m_IsNoCubeArray = false;
private Texture2DArray m_CacheNoCubeArray;
private RenderTexture[] m_StagingRTs;
private int m_NumPanoMipLevels;
private Material m_CubeBlitMaterial;
private int m_CubeMipLevelPropName;
private int m_cubeSrcTexPropName;
// alternative panorama path intended for mobile
// the member variables below are only in use when m_IsNoCubeArray is true.
var mismatch = (m_Cache.width != texture.width) || (m_Cache.height != texture.height);
if (texture is Cubemap)
if(m_IsNoCubeArray)
TransferToPanoCache(sliceIndex, texture);
else
mismatch |= (m_Cache.format != (texture as Cubemap).format);
}
var mismatch = (m_Cache.width != texture.width) || (m_Cache.height != texture.height);
if (mismatch)
{
bool failed = false;
if (texture is Cubemap)
{
mismatch |= (m_Cache.format != (texture as Cubemap).format);
}
for (int f = 0; f < 6; f++)
if (mismatch)
if (!Graphics.ConvertTexture(texture, f, m_Cache, 6 * sliceIndex + f))
bool failed = false;
for (int f = 0; f < 6; f++)
{
if (!Graphics.ConvertTexture(texture, f, m_Cache, 6 * sliceIndex + f))
{
failed = true;
break;
}
}
if (failed)
failed = true;
break;
Debug.LogErrorFormat(texture, "Unable to convert texture \"{0}\" to match renderloop settings ({1}x{2} {3})",
texture.name, m_Cache.width, m_Cache.height, m_Cache.format);
if (failed)
else
Debug.LogErrorFormat(texture, "Unable to convert texture \"{0}\" to match renderloop settings ({1}x{2} {3})",
texture.name, m_Cache.width, m_Cache.height, m_Cache.format);
for (int f = 0; f < 6; f++)
Graphics.CopyTexture(texture, f, m_Cache, 6 * sliceIndex + f);
else
{
for (int f = 0; f < 6; f++)
Graphics.CopyTexture(texture, f, m_Cache, 6 * sliceIndex + f);
}
return m_Cache;
return m_IsNoCubeArray ? (Texture) m_CacheNoCubeArray : m_Cache;
var res = AllocTextureArray(6 * numCubeMaps);
m_NumMipLevels = GetNumMips(width, width);
var res = AllocTextureArray(numCubeMaps);
m_NumMipLevels = GetNumMips(width, width); // will calculate same way whether we have cube array or not
if(m_IsNoCubeArray)
{
if(!m_CubeBlitMaterial) m_CubeBlitMaterial = new Material(Shader.Find("Hidden/CubeToPano"));
int panoWidthTop = 4*width;
int panoHeightTop = 2*width;
// create panorama 2D array. Hardcoding the render target for now when m_IsNoCubeArray is true. No convenient way atm. to
// map from TextureFormat to RenderTextureFormat and don't want to deal with sRGB issues for now.
m_CacheNoCubeArray = new Texture2DArray(panoWidthTop, panoHeightTop, numCubeMaps, TextureFormat.RGBAHalf, isMipMapped)
{
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Repeat,
filterMode = FilterMode.Trilinear,
anisoLevel = 0
};
m_Cache = new CubemapArray(width, numCubeMaps, format, isMipMapped)
m_NumPanoMipLevels = isMipMapped ? GetNumMips(panoWidthTop, panoHeightTop) : 1;
m_StagingRTs = new RenderTexture[m_NumPanoMipLevels];
for(int m=0; m<m_NumPanoMipLevels; m++)
{
m_StagingRTs[m] = new RenderTexture(Mathf.Max(1,panoWidthTop>>m), Mathf.Max(1,panoHeightTop>>m), 0, RenderTextureFormat.ARGBHalf);
}
if(m_CubeBlitMaterial)
{
m_CubeMipLevelPropName = Shader.PropertyToID("_cubeMipLvl");
m_cubeSrcTexPropName = Shader.PropertyToID("_srcCubeTexture");
}
}
else
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Trilinear,
anisoLevel = 0 // It is important to set 0 here, else unity force anisotropy filtering
};
m_Cache = new CubemapArray(width, numCubeMaps, format, isMipMapped)
{
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Trilinear,
anisoLevel = 0 // It is important to set 0 here, else unity force anisotropy filtering
};
}
return res;
}

Texture.DestroyImmediate(m_Cache); // do I need this?
if(m_IsNoCubeArray)
{
Texture.DestroyImmediate(m_CacheNoCubeArray);
for(int m=0; m<m_NumPanoMipLevels; m++)
{
m_StagingRTs[m].Release();
}
m_StagingRTs=null;
if(m_CubeBlitMaterial) Material.DestroyImmediate(m_CubeBlitMaterial);
}
else Texture.DestroyImmediate(m_Cache);
}
private void TransferToPanoCache(int sliceIndex, Texture texture)
{
m_CubeBlitMaterial.SetTexture(m_cubeSrcTexPropName, texture);
for(int m=0; m<m_NumPanoMipLevels; m++)
{
m_CubeBlitMaterial.SetInt(m_CubeMipLevelPropName, Mathf.Min(m_NumMipLevels-1,m) );
Graphics.SetRenderTarget(m_StagingRTs[m]);
Graphics.Blit(null, m_CubeBlitMaterial, 0);
}
for(int m=0; m<m_NumPanoMipLevels; m++)
Graphics.CopyTexture(m_StagingRTs[m], 0, 0, m_CacheNoCubeArray, sliceIndex, m);
}
}

2
Assets/ScriptableRenderLoop/common/TextureSettings.cs


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[System.Serializable]
public class TextureSettings
public struct TextureSettings
{
public int spotCookieSize;
public int pointCookieSize;

136
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


using UnityEngine.Experimental.Rendering;
using System;
using System.Collections.Generic;
using UnityEngine.ScriptableRenderPipeline;
public class FptlLightingInstance : RenderPipeline
{
private readonly FptlLighting m_Owner;
public FptlLightingInstance(FptlLighting owner)
{
m_Owner = owner;
if (m_Owner != null)
m_Owner.Build();
}
public override void Dispose()
{
base.Dispose();
if (m_Owner != null)
m_Owner.Cleanup();
}
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{
base.Render(renderContext, cameras);
m_Owner.Render(renderContext, cameras);
}
}
public class FptlLighting : RenderPipeline
public class FptlLighting : RenderPipelineAsset
[UnityEditor.MenuItem("Renderloop/CreateRenderLoopFPTL")]
[UnityEditor.MenuItem("RenderPipeline/CreateRenderLoopFPTL")]
static void CreateRenderLoopFPTL()
{
var instance = ScriptableObject.CreateInstance<FptlLighting>();

protected override IRenderPipeline InternalCreatePipeline()
{
return new FptlLightingInstance(this);
}
[SerializeField]
ShadowSettings m_ShadowSettings = ShadowSettings.Default;

public bool enableBigTilePrepass = true;
public bool enableDrawLightBoundsDebug = false;
public bool enableDrawTileDebug = false;
public bool enableReflectionProbeDebug = false;
public bool enableComputeLightEvaluation = false;
const bool k_UseDepthBuffer = true;// // only has an impact when EnableClustered is true (requires a depth-prepass)
const bool k_UseAsyncCompute = true; // should not use on mobile

private Texture2D m_LightAttentuationTexture;
private int m_shadowBufferID;
private void OnValidate()
public void Cleanup()
Rebuild();
}
public override void Initialize()
{
Rebuild();
}
public override void Cleanup()
{
// RenderLoop.renderLoopDelegate -= ExecuteRenderLoop;
if (m_DeferredMaterial) DestroyImmediate(m_DeferredMaterial);
if (m_DeferredReflectionMaterial) DestroyImmediate(m_DeferredReflectionMaterial);
if (m_BlitMaterial) DestroyImmediate(m_BlitMaterial);

if (enableClustered)
{
s_GlobalLightListAtomic.Release();
if (s_GlobalLightListAtomic != null)
s_GlobalLightListAtomic.Release();
}
ClearComputeBuffers();

}
}
public override void Rebuild()
public void Build()
ClearComputeBuffers();
s_GBufferAlbedo = Shader.PropertyToID("_CameraGBufferTexture0");
s_GBufferSpecRough = Shader.PropertyToID("_CameraGBufferTexture1");
s_GBufferNormal = Shader.PropertyToID("_CameraGBufferTexture2");

m_shadowBufferID = Shader.PropertyToID("g_tShadowBuffer");
}
static void SetupGBuffer(int width, int height, CommandBuffer cmd)
{
var format10 = RenderTextureFormat.ARGB32;

cmd.GetTemporaryRT(s_GBufferZ, width, height, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(s_CameraDepthTexture, width, height, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(s_CameraTarget, width, height, 0, FilterMode.Point, formatHDR, RenderTextureReadWrite.Default, 1, true); // rtv/uav
var colorMRTs = new RenderTargetIdentifier[4] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission };
cmd.SetRenderTarget(colorMRTs, new RenderTargetIdentifier(s_GBufferZ));
cmd.ClearRenderTarget(true, true, new Color(0, 0, 0, 0));

static void RenderGBuffer(CullResults cull, Camera camera, RenderLoop loop)
static void RenderGBuffer(CullResults cull, Camera camera, ScriptableRenderContext loop)
{
// setup GBuffer for rendering
var cmd = new CommandBuffer { name = "Create G-Buffer" };

loop.DrawRenderers(ref settings);
}
void RenderForward(CullResults cull, Camera camera, RenderLoop loop, bool opaquesOnly)
void RenderForward(CullResults cull, Camera camera, ScriptableRenderContext loop, bool opaquesOnly)
{
var cmd = new CommandBuffer { name = opaquesOnly ? "Prep Opaques Only Forward Pass" : "Prep Forward Pass" };

loop.DrawRenderers(ref settings);
}
static void DepthOnlyForForwardOpaques(CullResults cull, Camera camera, RenderLoop loop)
static void DepthOnlyForForwardOpaques(CullResults cull, Camera camera, ScriptableRenderContext loop)
{
var cmd = new CommandBuffer { name = "Forward Opaques - Depth Only" };
cmd.SetRenderTarget(new RenderTargetIdentifier(s_GBufferZ));

return !disableFptl;
}
}
static void CopyDepthAfterGBuffer(RenderLoop loop)
static void CopyDepthAfterGBuffer(ScriptableRenderContext loop)
{
var cmd = new CommandBuffer { name = "Copy depth" };
cmd.CopyTexture(new RenderTargetIdentifier(s_GBufferZ), new RenderTargetIdentifier(s_CameraDepthTexture));

void DoTiledDeferredLighting(Camera camera, RenderLoop loop, int numLights, int numDirLights)
void DoTiledDeferredLighting(Camera camera, ScriptableRenderContext loop, int numLights, int numDirLights)
{
var bUseClusteredForDeferred = !usingFptl;
var cmd = new CommandBuffer();

if (enableDrawTileDebug)
m_DeferredMaterial.EnableKeyword("ENABLE_DEBUG");
else
m_DeferredMaterial.DisableKeyword("ENABLE_DEBUG");
if (enableDrawTileDebug) {
m_DeferredMaterial.EnableKeyword ("ENABLE_DEBUG");
} else {
m_DeferredMaterial.DisableKeyword ("ENABLE_DEBUG");
}
if (enableReflectionProbeDebug) {
m_DeferredReflectionMaterial.EnableKeyword ("ENABLE_DEBUG");
} else {
m_DeferredReflectionMaterial.DisableKeyword ("ENABLE_DEBUG");
}
cmd.SetGlobalBuffer("g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)

}
else
{
cmd.Blit(0, s_CameraTarget, m_DeferredMaterial, 0);
cmd.Blit(0, s_CameraTarget, m_DeferredReflectionMaterial, 0);
cmd.Blit(BuiltinRenderTextureType.CameraTarget, s_CameraTarget, m_DeferredMaterial, 0);
cmd.Blit(BuiltinRenderTextureType.CameraTarget, s_CameraTarget, m_DeferredReflectionMaterial, 0);
}

return numLightsOut + numProbesOut;
}
#if UNITY_EDITOR
public override void RenderSceneView(Camera camera, RenderLoop renderLoop)
{
base.RenderSceneView(camera, renderLoop);
renderLoop.PrepareForEditorRendering(camera, new RenderTargetIdentifier(s_CameraDepthTexture));
renderLoop.Submit();
}
#endif
public override void Render(Camera[] cameras, RenderLoop renderLoop)
public void Render(ScriptableRenderContext renderContext, IEnumerable<Camera> cameras)
{
foreach (var camera in cameras)
{

m_ShadowPass.UpdateCullingParameters(ref cullingParams);
var cullResults = CullResults.Cull(ref cullingParams, renderLoop);
ExecuteRenderLoop(camera, cullResults, renderLoop);
var cullResults = CullResults.Cull(ref cullingParams, renderContext);
ExecuteRenderLoop(camera, cullResults, renderContext);
renderLoop.Submit();
renderContext.Submit();
void FinalPass(RenderLoop loop)
void FinalPass(ScriptableRenderContext loop)
{
var cmd = new CommandBuffer { name = "FinalPass" };
cmd.Blit(s_CameraTarget, BuiltinRenderTextureType.CameraTarget, m_BlitMaterial, 0);

void ExecuteRenderLoop(Camera camera, CullResults cullResults, RenderLoop loop)
void ExecuteRenderLoop(Camera camera, CullResults cullResults, ScriptableRenderContext loop)
{
var w = camera.pixelWidth;
var h = camera.pixelHeight;

// debug views.
if (enableDrawLightBoundsDebug) DrawLightBoundsDebug(loop, cullResults.visibleLights.Length);
// bind depth surface for editor grid/gizmo/selection rendering
if (camera.cameraType == CameraType.SceneView)
{
var cmd = new CommandBuffer();
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, new RenderTargetIdentifier(s_CameraDepthTexture));
loop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
loop.Submit();
void DrawLightBoundsDebug(RenderLoop loop, int numLights)
void DrawLightBoundsDebug(ScriptableRenderContext loop, int numLights)
{
var cmd = new CommandBuffer { name = "DrawLightBoundsDebug" };
m_DebugLightBoundsMaterial.SetBuffer("g_data", s_ConvexBoundsBuffer);

m_CubeReflTexArray.NewFrame();
}
void RenderShadowMaps(CullResults cullResults, RenderLoop loop)
void RenderShadowMaps(CullResults cullResults, ScriptableRenderContext loop)
{
ShadowOutput shadows;
m_ShadowPass.Render(loop, cullResults, out shadows);

cmd.DispatchCompute(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, numTilesX, numTilesY, 1);
}
void BuildPerTileLightLists(Camera camera, RenderLoop loop, int numLights, Matrix4x4 projscr, Matrix4x4 invProjscr)
void BuildPerTileLightLists(Camera camera, ScriptableRenderContext loop, int numLights, Matrix4x4 projscr, Matrix4x4 invProjscr)
{
var w = camera.pixelWidth;
var h = camera.pixelHeight;

cmd.Dispose();
}
void PushGlobalParams(Camera camera, RenderLoop loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights)
void PushGlobalParams(Camera camera, ScriptableRenderContext loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights)
{
var cmd = new CommandBuffer { name = "Push Global Parameters" };

8
Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader


CGPROGRAM
#pragma target 5.0
#pragma target 4.5
#pragma multi_compile __ ENABLE_DEBUG
#include "UnityLightingCommon.cginc"

uint numReflectionsProcessed = 0;
float3 c = ExecuteReflectionList(numReflectionsProcessed, pixCoord, vP, data.normalWorld, Vworld, data.smoothness);
//c = OverlayHeatMap(numLightsProcessed, c);
#if ENABLE_DEBUG
c = OverlayHeatMap(pixCoord & 15, numReflectionsProcessed, c);
#endif
return float4(c,1.0);
}

2
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


CGPROGRAM
#pragma target 5.0
#pragma target 4.5
#pragma vertex vert
#pragma fragment frag

10
Assets/ScriptableRenderLoop/fptl/LightingTemplate.hlsl


//UNITY_DECLARE_TEX2D(_LightTextureB0);
sampler2D _LightTextureB0;
UNITY_DECLARE_TEX2DARRAY(_spotCookieTextures);
UNITY_DECLARE_TEXCUBEARRAY(_pointCookieTextures);
UNITY_DECLARE_ABSTRACT_CUBE_ARRAY(_pointCookieTextures);
#define SAMPLE_SHADOW( tex, coord ) tex.SampleCmpLevelZero( sampler##tex, (coord).xy, (coord).z )
#ifdef REVERSE_ZBUF
#define SAMPLE_SHADOW( tex, coord ) tex.SampleCmpLevelZero( sampler##tex, (coord).xy, (coord).z )
#else
#define SAMPLE_SHADOW( tex, coord ) tex.SampleCmpLevelZero( sampler##tex, (coord).xy, 1.0-(coord).z )
#endif
DECLARE_SHADOWMAP(g_tShadowBuffer);

[branch]if(bHasCookie)
{
float3 cookieCoord = -float3(dot(vL, lgtDat.lightAxisX.xyz), dot(vL, lgtDat.lightAxisY.xyz), dot(vL, lgtDat.lightAxisZ.xyz)); // negate to make vL a fromLight vector
cookieColor = UNITY_SAMPLE_TEXCUBEARRAY_LOD(_pointCookieTextures, float4(cookieCoord, lgtDat.sliceIndex), 0.0);
cookieColor = UNITY_SAMPLE_ABSTRACT_CUBE_ARRAY_LOD(_pointCookieTextures, float4(cookieCoord, lgtDat.sliceIndex), 0.0);
atten *= cookieColor.w;
}

10
Assets/ScriptableRenderLoop/fptl/ReflectionTemplate.hlsl


#include "UnityPBSLighting.cginc"
UNITY_DECLARE_TEXCUBEARRAY(_reflCubeTextures);
UNITY_DECLARE_ABSTRACT_CUBE_ARRAY(_reflCubeTextures);
UNITY_DECLARE_TEXCUBE(_reflRootCubeTexture);
//uniform int _reflRootSliceIndex;
uniform float _reflRootHdrDecodeMult;

half3 Unity_GlossyEnvironment (UNITY_ARGS_TEXCUBEARRAY(tex), int sliceIndex, half4 hdr, Unity_GlossyEnvironmentData glossIn);
half3 Unity_GlossyEnvironment (UNITY_ARGS_ABSTRACT_CUBE_ARRAY(tex), int sliceIndex, half4 hdr, Unity_GlossyEnvironmentData glossIn);
half3 distanceFromAABB(half3 p, half3 aabbMin, half3 aabbMax)
{

g.roughness = percRoughness;
g.reflUVW = sampleDir;
half3 env0 = Unity_GlossyEnvironment(UNITY_PASS_TEXCUBEARRAY(_reflCubeTextures), lgtDat.sliceIndex, float4(lgtDat.lightIntensity, lgtDat.decodeExp, 0.0, 0.0), g);
half3 env0 = Unity_GlossyEnvironment(UNITY_PASS_ABSTRACT_CUBE_ARRAY(_reflCubeTextures), lgtDat.sliceIndex, float4(lgtDat.lightIntensity, lgtDat.decodeExp, 0.0, 0.0), g);
UnityIndirect ind;

}
half3 Unity_GlossyEnvironment (UNITY_ARGS_TEXCUBEARRAY(tex), int sliceIndex, half4 hdr, Unity_GlossyEnvironmentData glossIn)
half3 Unity_GlossyEnvironment (UNITY_ARGS_ABSTRACT_CUBE_ARRAY(tex), int sliceIndex, half4 hdr, Unity_GlossyEnvironmentData glossIn)
{
#if UNITY_GLOSS_MATCHES_MARMOSET_TOOLBAG2 && (SHADER_TARGET >= 30)
// TODO: remove pow, store cubemap mips differently

half mip = perceptualRoughness * UNITY_SPECCUBE_LOD_STEPS;
half4 rgbm = UNITY_SAMPLE_TEXCUBEARRAY_LOD(tex, float4(glossIn.reflUVW.xyz, sliceIndex), mip);
half4 rgbm = UNITY_SAMPLE_ABSTRACT_CUBE_ARRAY_LOD(tex, float4(glossIn.reflUVW.xyz, sliceIndex), mip);
return DecodeHDR(rgbm, hdr);
}

2
Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs


{
public class ShaderGeneratorMenu
{
[UnityEditor.MenuItem("Renderloop/Generate Shader Includes")]
[UnityEditor.MenuItem("RenderPipeline/Generate Shader Includes")]
static void GenerateShaderIncludes()
{
CSharpToHLSL.GenerateAll();

89
Assets/TestScenes/HDTest/GlobalIlluminationTest.unity


--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3

m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1

m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.6238628, g: 0.56322443, b: 0.5425187, a: 1}
m_IndirectSpecularColor: {r: 0.5456157, g: 0.39781958, b: 0.24038762, a: 1}
serializedVersion: 7
m_GIWorkflowMode: 0
serializedVersion: 9
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1

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

m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_DirectLightInLightProbes: 1
m_StationaryBakeMode: 1
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2

minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &20738779

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 565152814}
m_Enabled: 1
serializedVersion: 7
serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 3

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

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1108908831}
m_Enabled: 1
serializedVersion: 7
serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 100

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

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1879932837}
m_LocalRotation: {x: 0.07759436, y: -0.72047704, z: 0.08170084, w: 0.6842638}
m_LocalPosition: {x: 7.3, y: 1.41, z: -4.72}
m_LocalRotation: {x: 0.120674305, y: -0, z: -0, w: 0.9926922}
m_LocalPosition: {x: -0.56, y: 2.81, z: -12.59}
m_LocalEulerAnglesHint: {x: 12.939001, y: -92.953, z: 0}
m_LocalEulerAnglesHint: {x: 13.862, y: 0, z: 0}
--- !u!114 &1879932843
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 92bb16b4ee20841929b24d6bd771738d, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderLoop: {fileID: 11400000, guid: 2400b74f5ce370c4481e5dc417d03703, type: 2}
--- !u!1 &1910068096
GameObject:
m_ObjectHideFlags: 0

- {x: -1, y: 1, z: -1}
- {x: -1, y: -1, z: 1}
- {x: -1, y: -1, z: -1}
--- !u!1 &1944423445
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1944423448}
- component: {fileID: 1944423447}
- component: {fileID: 1944423446}
m_Layer: 0
m_Name: SceneSettings
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1944423446
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1944423445}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59b6606ef2548734bb6d11b9d160bc7e, type: 3}
m_Name:
m_EditorClassIdentifier:
rotation: 0
exposure: 0
multiplier: 1
resolution: 256
updateMode: 1
updatePeriod: 0
skyHDRI: {fileID: 8900000, guid: 9b513842339ef704ca63ef696691bc34, type: 3}
--- !u!114 &1944423447
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1944423445}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc357c46587fc9d4cb8f311794d7d2f3, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SkyRendererTypeName: UnityEngine.Experimental.ScriptableRenderLoop.HDRISkyRenderer
--- !u!4 &1944423448
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1944423445}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

94
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


- component: {fileID: 605581071}
- component: {fileID: 605581070}
- component: {fileID: 605581072}
- component: {fileID: 605581073}
m_Layer: 0
m_Name: Sun (directional light)
m_TagString: Untagged

isDoubleSided: 0
areaLightLength: 0
areaLightWidth: 0
--- !u!114 &605581073
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 605581069}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 97f65a78ace4fbf4187144e9fe724009, type: 3}
m_Name:
m_EditorClassIdentifier:
worldRayleighColorRamp:
serializedVersion: 2
key0: {r: 0.3019608, g: 0.4, b: 0.6, a: 1}
key1: {r: 0.5019608, g: 0.6, b: 0.8, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
worldRayleighColorIntensity: 1
worldRayleighDensity: 10
worldRayleighExtinctionFactor: 1.1
worldRayleighIndirectScatter: 0.33
worldMieColorRamp:
serializedVersion: 2
key0: {r: 0.9490196, g: 0.7490196, b: 0.5019608, a: 1}
key1: {r: 1, g: 0.9019608, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
worldMieColorIntensity: 1
worldMieDensity: 15
worldMieExtinctionFactor: 0
worldMiePhaseAnisotropy: 0.9
worldNearScatterPush: 0
worldNormalDistance: 1000
heightRayleighColor: {r: 1, g: 1, b: 1, a: 1}
heightRayleighIntensity: 1
heightRayleighDensity: 10
heightMieDensity: 0
heightExtinctionFactor: 1.1
heightSeaLevel: 0
heightDistance: 50
heightPlaneShift: {x: 0, y: 0, z: 0}
heightNearScatterPush: 0
heightNormalDistance: 1000
atmosphericShaderOverride: {fileID: 0}
worldScaleExponent: 1
depthTexture: 0
debugMode: 0
--- !u!1 &609148480
GameObject:
m_ObjectHideFlags: 0

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

25
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendColor.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DiffuseLightingMap:
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}

- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale: 1
- _HeightScale0: 1
- _HeightScale1: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 1
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}

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


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DiffuseLightingMap:
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}

- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale: 1
- _HeightScale0: 1
- _HeightScale1: 1

- _Parallax: 0.02
- _Smoothness: 0.5
- _Smoothness0: 0.5
- _Smoothness1: 0.5
- _Smoothness1: 0.2
- _Smoothness3: 0.5
- _Smoothness3: 0.4
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}

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


m_Name: Layered_Layer0_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_0 _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

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

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 0, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask0: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask0: {r: 0, g: 0, b: 0, a: 0}
- _UVMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

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


fileFormatVersion: 2
guid: 91a8197de5f6d074c8dac4416c16cbb2
timeCreated: 1480934271
timeCreated: 1481879942
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'

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


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Offset: {x: 0, y: 0}
- _BaseColorMap1:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 1
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

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

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

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


fileFormatVersion: 2
guid: b8805bd8838bdf34996bedcee9ebbf10
timeCreated: 1480934285
timeCreated: 1481881655
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'

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


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Offset: {x: 0, y: 0}
- _BaseColorMap1:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

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


fileFormatVersion: 2
guid: ea0f1f2983d72874084abf3a8d75bf04
timeCreated: 1480933657
timeCreated: 1481819419
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'

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


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

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


fileFormatVersion: 2
guid: dde88fa6f8dc19a4eb2d828bf0f4d91c
timeCreated: 1480934261
timeCreated: 1481819429
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'

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


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Offset: {x: 0, y: 0}
- _BaseColorMap1:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _TexWorldScale2: 1
- _TexWorldScale3: 1
- _UVBase: 0
- _UVBase0: 2
- _UVBase1: 0
- _UVBase0: 3
- _UVBase1: 3
- _UVDetail0: 2
- _UVDetail1: 2
- _UVDetail0: 3
- _UVDetail1: 3
- _UVDetail2: 0
- _UVDetail3: 0
- _UVDetailsMappingMask0: 0

- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 0, g: 0, b: 1, a: 0}
- _UVDetailsMappingMask1: {r: 0, g: 0, b: 1, a: 0}
- _UVDetailsMappingMask0: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask1: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask0: {r: 0, g: 0, b: 1, a: 0}
- _UVMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask0: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask1: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

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


fileFormatVersion: 2
guid: 3e3a7e6d5f3b8164eb7c110dd465185d
timeCreated: 1480934266
timeCreated: 1481881392
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}'

36
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat


m_Name: Layered_Layer1_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV3
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_1 _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

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

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask1: {r: 0, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask1: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask1: {r: 0, g: 0, b: 0, a: 0}
- _UVMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat.meta


fileFormatVersion: 2
guid: fd9a6b078b486c8408e9c7ed638a47ec
timeCreated: 1480680901
timeCreated: 1481879952
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}'

29
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 1
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _TexWorldScale3: 1
- _UVBase: 0
- _UVBase0: 0
- _UVBase1: 4
- _UVBase1: 5
- _UVBase2: 0
- _UVBase3: 0
- _UVDetail: 0

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat.meta


fileFormatVersion: 2
guid: 74b98b46b0cf6f4408b920728d5945eb
timeCreated: 1480680915
timeCreated: 1481881644
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}'

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


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

27
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV1.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

37
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV3
_REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap1:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _TexWorldScale3: 1
- _UVBase: 0
- _UVBase0: 0
- _UVBase1: 2
- _UVBase1: 3
- _UVDetail1: 2
- _UVDetail1: 3
- _UVDetail2: 0
- _UVDetail3: 0
- _UVDetailsMappingMask0: 0

- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask1: {r: 0, g: 0, b: 1, a: 0}
- _UVDetailsMappingMask1: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask1: {r: 0, g: 0, b: 1, a: 0}
- _UVMappingMask1: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat.meta


fileFormatVersion: 2
guid: aa6171e055287cb4f9fea8ce6733e050
timeCreated: 1480680809
timeCreated: 1481881398
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}'

38
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat


m_Name: Layered_Layer2_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MAPPING_TRIPLANAR_2
_LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVBase: 0
- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 3
- _UVBase2: 4
- _UVBase3: 0
- _UVDetail: 0
- _UVDetail0: 0

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask2: {r: 0, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask2: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask2: {r: 0, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat.meta


fileFormatVersion: 2
guid: cd6fab12a4d34f841a5d2e59188f981c
timeCreated: 1480680992
timeCreated: 1481879997
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","b1bac0266a49a1040a9365f40c7b6ddd",""]}'

31
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 1
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVBase: 0
- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 4
- _UVBase2: 5
- _UVBase3: 0
- _UVDetail: 0
- _UVDetail0: 0

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat.meta


fileFormatVersion: 2
guid: 4e173a4bed5c8ba4b930247d61ca57ec
timeCreated: 1480681000
timeCreated: 1481881627
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","b1bac0266a49a1040a9365f40c7b6ddd",""]}'

28
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV0.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

28
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV1.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

39
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap2:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVBase: 0
- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 2
- _UVBase2: 3
- _UVDetail2: 2
- _UVDetail2: 3
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask2: {r: 0, g: 0, b: 1, a: 0}
- _UVDetailsMappingMask2: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask2: {r: 0, g: 0, b: 1, a: 0}
- _UVMappingMask2: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask3: {r: 1, g: 0, b: 0, a: 0}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat.meta


fileFormatVersion: 2
guid: ee3e0f05e742ad246855fc1151154c01
timeCreated: 1480680986
timeCreated: 1481881437
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","b1bac0266a49a1040a9365f40c7b6ddd",""]}'

44
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat


m_Name: Layered_Layer3_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MAPPING_TRIPLANAR_3
_LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 2800000, guid: 0e413f4460470044d93a7c42e4275b09, type: 3}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 2800000, guid: 0e413f4460470044d93a7c42e4275b09, type: 3}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap3:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 0
- _UVBase3: 3
- _UVBase3: 4
- _UVDetail: 0
- _UVDetail0: 0
- _UVDetail1: 0

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _BaseColor1: {r: 0.97058815, g: 0.51384073, b: 0.51384073, a: 1}
- _BaseColor2: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _BaseColor1: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 0.6602435, g: 0.63235295, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

- _UVDetailsMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask3: {r: 0, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask3: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask3: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask3: {r: 0, g: 0, b: 0, a: 0}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat.meta


fileFormatVersion: 2
guid: 32ddfc45781832a4f94eb0efa3b88571
timeCreated: 1480682190
timeCreated: 1481880057
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","6c40a6ba55a62fc4c92fdc1cdee2f85a"]}'

34
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap3:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 1
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 0
- _UVBase3: 4
- _UVBase3: 5
- _UVDetail: 0
- _UVDetail0: 0
- _UVDetail1: 0

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat.meta


fileFormatVersion: 2
guid: 0284c7765797bfe42b104f08550600a8
timeCreated: 1480935617
timeCreated: 1481881618
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","6c40a6ba55a62fc4c92fdc1cdee2f85a"]}'

30
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV0.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap3:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

30
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV1.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap3:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_UV3
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
disabledShaderPasses:
- DistortionVectors
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap3:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap0:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 21bed8c058c65f84e92fd4e28dd6ec51, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 21bed8c058c65f84e92fd4e28dd6ec51, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 21bed8c058c65f84e92fd4e28dd6ec51, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 21bed8c058c65f84e92fd4e28dd6ec51, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0
- _BlendSize2: 0
- _BlendSize3: 0
- _DepthOffsetEnable: 0
- _DetailAOScale0: 1
- _DetailAOScale1: 1
- _DetailAOScale2: 1

- _DetailSmoothnessScale2: 1
- _DetailSmoothnessScale3: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _HeightBias1: 0
- _HeightBias2: 0
- _HeightBias3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1
- _HeightOffset1: 0
- _HeightOffset2: 0
- _HeightOffset3: 0
- _HeightScale0: 1
- _HeightScale1: 1
- _HeightScale2: 1

- _UVBase0: 0
- _UVBase1: 0
- _UVBase2: 0
- _UVBase3: 2
- _UVBase3: 3
- _UVDetail3: 2
- _UVDetail3: 3
- _UVMappingPlanar0: 0
- _UVMappingPlanar1: 0
- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UseHeightBasedBlend1: 0
- _UseHeightBasedBlend2: 0
- _UseHeightBasedBlend3: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor0: {r: 1, g: 1, b: 1, a: 1}

- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask1: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask2: {r: 1, g: 0, b: 0, a: 0}
- _UVDetailsMappingMask3: {r: 0, g: 0, b: 1, a: 0}
- _UVDetailsMappingMask3: {r: 0, g: 0, b: 0, a: 1}
- _UVMappingMask3: {r: 0, g: 0, b: 1, a: 0}
- _UVMappingMask3: {r: 0, g: 0, b: 0, a: 1}

2
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat.meta


fileFormatVersion: 2
guid: b5dde76940778384c891440343094268
timeCreated: 1480681119
timeCreated: 1481881474
licenseType: Pro
NativeFormatImporter:
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","6c40a6ba55a62fc4c92fdc1cdee2f85a"]}'

9
Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_UVChart_Layer2_Detail.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
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}

- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DepthOffsetEnable: 0
- _DetailAOScale: 1
- _DetailAlbedoScale: 1
- _DetailHeightScale: 1

- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _TexWorldScale: 1
- _UVBase: 0
- _UVDetail: 0
- _UVMappingPlanar: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}

12
Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_White_Detail.mat


m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 866df234625deb44a8db971e2f2dca7c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:

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}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DepthOffsetEnable: 0
- _DetailAOScale: 1
- _DetailAlbedoScale: 1
- _DetailHeightScale: 1

- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0

- _TexWorldScale: 1
- _UVBase: 0
- _UVDetail: 0
- _UVMappingPlanar: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}

10
ProjectSettings/GraphicsSettings.asset


m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 11400000, guid: 6bec8f7a5722d5b47a3fd9a0c0b7bbf4,
m_CustomRenderPipeline: {fileID: 11400000, guid: e185fecca3c73cd47a09f1092663ef32,
type: 2}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}

m_FogStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDirSeparate: 1
m_LightmapKeepDynamicDirSeparate: 1
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_LightsUseLinearIntensity: 0
m_LightsUseCCT: 0
m_LightsUseLinearIntensity: 1
m_LightsUseCCT: 1

2
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 5.6.0b1
m_EditorVersion: 5.6.0b3

7
README.md


# Unity Scriptable Render Loop testbed
**NOTE**: this is a testbed for a Unity feature that has not shipped yet! The project will not work with any public
**NOTE**: this is a testbed for a Unity feature that has not shipped yet! The project does not work with any public
Unity version, and things in it might and will be broken.
"Scriptable Render Loops" is a potential future Unity feature, think "Command Buffers, take two". We plan to ship the feature, and a

There's a more detailed overview document here: [ScriptableRenderLoop google doc](https://docs.google.com/document/d/1e2jkr_-v5iaZRuHdnMrSv978LuJKYZhsIYnrDkNAuvQ/edit?usp=sharing)
Did we mention it's a very WIP, no promises, may or might not ship feature, anything and everything in it can change? It totally is.
## For Unity 5.6 beta users
* Unity 5.6 beta 1 and beta 2 should use an older revision of this project, [tagged unity-5.6.0b1](../../releases/tag/unity-5.6.0b1) (commit `acc230b` on 2016 Nov 23). "BasicRenderLoopScene" scene is the basic example, with the scriptable render loop defaulting to off; enable it by enabling the component on the camera. All the other scenes may or might not work. Use of Windows/DX11 is preferred.

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta


fileFormatVersion: 2
guid: 7dc18395c5211d44bbe417b8b8b2e81a
guid: 1c14e71d397fce047b1675fc26d0bb48
folderAsset: yes
timeCreated: 1474297943
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta


fileFormatVersion: 2
guid: 752ba4c5a264906428ff58cb5973e10a
guid: 96af336cb096f854ea18990a1c0a4e19
folderAsset: yes
timeCreated: 1474297943
licenseType: Pro

13
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs


// Changing a value in this enum Config here require to regenerate the hlsl include and recompile C# and shaders
public class ShaderConfig
{
public const int VelocityInGbuffer = (int)ShaderOptions.VelocityInGBuffer;
public const int PackgbufferInU16 = (int)ShaderOptions.PackGBufferInU16;
// const variable produce warning like this one: warning CS0162: Unreachable code detected
// If we want to avoid them we can add #pragma warning disable 162, however doing that make the debugger shift his line count when debugging which is really annoying
// so here we decalare two kind of variable, one const that can be use in enum init and one static so the compiler doesn't complain. It mean that the conditional code will stay
// but it is usually small, so we are fine with it (until someone at microsoft fix the debuggger).
public const int k_VelocityInGbuffer = (int)ShaderOptions.VelocityInGBuffer;
public static int s_VelocityInGbuffer = (int)ShaderOptions.VelocityInGBuffer;
public const int k_PackgbufferInU16 = (int)ShaderOptions.PackGBufferInU16;
public static int s_PackgbufferInU16 = (int)ShaderOptions.PackGBufferInU16;
//#define VELOCITY_IN_GBUFFER

168
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl


CBUFFER_START(UnityPerCamera)
// Time (t = time since current level load) values from Unity
float4 _Time; // (t/20, t, t*2, t*3)
float4 _SinTime; // sin(t/8), sin(t/4), sin(t/2), sin(t)
float4 _CosTime; // cos(t/8), cos(t/4), cos(t/2), cos(t)
float4 unity_DeltaTime; // dt, 1/dt, smoothdt, 1/smoothdt
// Time (t = time since current level load) values from Unity
float4 _Time; // (t/20, t, t*2, t*3)
float4 _SinTime; // sin(t/8), sin(t/4), sin(t/2), sin(t)
float4 _CosTime; // cos(t/8), cos(t/4), cos(t/2), cos(t)
float4 unity_DeltaTime; // dt, 1/dt, smoothdt, 1/smoothdt
#ifndef UNITY_SINGLE_PASS_STEREO
float3 _WorldSpaceCameraPos;
#if !defined(USING_STEREO_MATRICES)
float3 _WorldSpaceCameraPos;
// x = 1 or -1 (-1 if projection is flipped)
// y = near plane
// z = far plane
// w = 1/far plane
float4 _ProjectionParams;
// x = 1 or -1 (-1 if projection is flipped)
// y = near plane
// z = far plane
// w = 1/far plane
float4 _ProjectionParams;
// x = width
// y = height
// z = 1 + 1.0/width
// w = 1 + 1.0/height
float4 _ScreenParams;
// x = width
// y = height
// z = 1 + 1.0/width
// w = 1 + 1.0/height
float4 _ScreenParams;
// Values used to linearize the Z buffer (http://www.humus.name/temp/Linearize%20depth.txt)
// x = 1-far/near
// y = far/near
// z = x/far
// w = y/far
float4 _ZBufferParams;
// Values used to linearize the Z buffer (http://www.humus.name/temp/Linearize%20depth.txt)
// x = 1-far/near
// y = far/near
// z = x/far
// w = y/far
float4 _ZBufferParams;
// x = orthographic camera's width
// y = orthographic camera's height
// z = unused
// w = 1.0 if camera is ortho, 0.0 if perspective
float4 unity_OrthoParams;
// x = orthographic camera's width
// y = orthographic camera's height
// z = unused
// w = 1.0 if camera is ortho, 0.0 if perspective
float4 unity_OrthoParams;
float4 unity_CameraWorldClipPlanes[6];
// Projection matrices of the camera. Note that this might be different from projection matrix
// that is set right now, e.g. while rendering shadows the matrices below are still the projection
// of original camera.
float4x4 unity_CameraProjection;
float4x4 unity_CameraInvProjection;
float4 unity_CameraWorldClipPlanes[6];
#ifndef UNITY_SINGLE_PASS_STEREO
float4x4 unity_WorldToCamera;
float4x4 unity_CameraToWorld;
#if !defined(USING_STEREO_MATRICES)
// Projection matrices of the camera. Note that this might be different from projection matrix
// that is set right now, e.g. while rendering shadows the matrices below are still the projection
// of original camera.
float4x4 unity_CameraProjection;
float4x4 unity_CameraInvProjection;
float4x4 unity_WorldToCamera;
float4x4 unity_CameraToWorld;
#endif
CBUFFER_END

#ifndef UNITY_SINGLE_PASS_STEREO
float4x4 glstate_matrix_mvp;
#ifdef UNITY_USE_PREMULTIPLIED_MATRICES
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
// Use center position for stereo rendering
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
#ifdef UNITY_SINGLE_PASS_STEREO
CBUFFER_START(UnityPerEye)
float3 _WorldSpaceCameraPos;
float4x4 glstate_matrix_projection;
#if defined(USING_STEREO_MATRICES)
CBUFFER_START(UnityStereoGlobals)
float4x4 unity_StereoMatrixP[2];
float4x4 unity_StereoMatrixV[2];
float4x4 unity_StereoMatrixInvV[2];
float4x4 unity_StereoMatrixVP[2];
float4x4 unity_MatrixV;
float4x4 unity_MatrixVP;
float4x4 unity_StereoCameraProjection[2];
float4x4 unity_StereoCameraInvProjection[2];
float4x4 unity_StereoWorldToCamera[2];
float4x4 unity_StereoCameraToWorld[2];
float4x4 unity_WorldToCamera;
float4x4 unity_CameraToWorld;
float3 unity_StereoWorldSpaceCameraPos[2];
float4 unity_StereoScaleOffset[2];
CBUFFER_END
#ifdef UNITY_SUPPORT_MULTIVIEW
#define unity_StereoEyeIndex UNITY_VIEWID
UNITY_DECLARE_MULTIVIEW(2);
#else
CBUFFER_START(UnityStereoEyeIndex)
int unity_StereoEyeIndex;
CBUFFER_START(UnityPerDrawRare)
float4x4 glstate_matrix_transpose_modelview0;
#ifdef UNITY_SINGLE_PASS_STEREO
float4x4 glstate_matrix_mvp;
CBUFFER_START(UnityPerDrawRare)
float4x4 glstate_matrix_transpose_modelview0;
CBUFFER_END

#ifndef UNITY_SINGLE_PASS_STEREO
float4x4 glstate_matrix_projection;
float4x4 unity_MatrixV;
float4x4 unity_MatrixVP;
float4 glstate_lightmodel_ambient;
float4 unity_AmbientSky;
float4 unity_AmbientEquator;
float4 unity_AmbientGround;
float4 unity_IndirectSpecColor;
#if !defined(USING_STEREO_MATRICES)
float4x4 glstate_matrix_projection;
float4x4 unity_MatrixV;
float4x4 unity_MatrixInvV;
float4x4 unity_MatrixVP;
int unity_StereoEyeIndex;
float4 glstate_lightmodel_ambient;
float4 unity_AmbientSky;
float4 unity_AmbientEquator;
float4 unity_AmbientGround;
float4 unity_IndirectSpecColor;
float4 unity_ShadowColor;
CBUFFER_END

// TODO: Change code here so probe volume use only one transform instead of all this parameters!
TEXTURE3D(unity_ProbeVolumeSH);
SAMPLER3D(samplerunity_ProbeVolumeSH)
SAMPLER3D(samplerunity_ProbeVolumeSH);
CBUFFER_START(UnityProbeVolume)
// x = Disabled(0)/Enabled(1)

// ----------------------------------------------------------------------------
// TODO: move this to constant buffer by Pass
float4x4 _InvViewProjMatrix;
float4x4 _ViewProjMatrix; // Looks like using UNITY_MATRIX_VP in pixel shader doesn't work ??? need to setup my own...
return unity_MatrixV;
return UNITY_MATRIX_V;
}
float4x4 GetObjectToWorldMatrix()

// Transform to homogenous clip space
float4x4 GetWorldToHClipMatrix()
{
return unity_MatrixVP;
return UNITY_MATRIX_VP;
}
// Transform from clip space to homogenous world space

return unity_WorldTransformParams.w;
}
float4x4 GetObjectToWorldViewMatrix()
{
return glstate_matrix_modelview0;
}
float3 TransformWorldToView(float3 positionWS)
{
return mul(GetWorldToViewMatrix(), float4(positionWS, 1.0)).xyz;

float3 TransformWorldToObject(float3 positionWS)
{
return mul(GetWorldToObjectMatrix(), float4(positionWS, 1.0)).xyz;
}
float3 TransformObjectToView(float3 positionOS)
{
return mul(GetObjectToWorldViewMatrix(), float4(positionOS, 1.0)).xyz;
}
float3 TransformObjectToWorldDir(float3 dirOS)

2
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs. Please don't edit by hand.
//
#ifndef SHADERCONFIG_CS_HLSL

2
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPass.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs. Please don't edit by hand.
//
#ifndef SHADERPASS_CS_HLSL

22
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl


#error SHADERPASS_is_not_correctly_define
#endif
float4 Frag(PackedVaryings packedInput) : SV_Target
void Frag( PackedVaryings packedInput,
out float4 outColor : SV_Target
#ifdef _DEPTHOFFSET_ON
, out float outputDepth : SV_Depth
#endif
)
FragInput input = UnpackVaryings(packedInput);
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
return float4(0.0, 0.0, 0.0, 0.0);
outColor = float4(0.0, 0.0, 0.0, 0.0);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.rawDepth;
#endif
}

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


#include "Color.hlsl"
// TODO: This is the max value allowed for emissive (bad name - but keep for now to retrieve it) (It is 8^2.2 (gamma) and 8 is the limit of punctual light slider...), comme from UnityCg.cginc. Fix it!
// Ask Jesper if this can be change for HDRenderLoop
// Ask Jesper if this can be change for HDRenderPipeline
FragInput input = UnpackVaryings(packedInput);
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
// No position and depth in case of light transport
float3 V = float3(0, 0, 1); // No vector view in case of light transport
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);
LighTransportData lightTransportData = GetLightTransportData(surfaceData, builtinData, bsdfData);

23
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl


void Frag( PackedVaryings packedInput,
OUTPUT_GBUFFER(outGBuffer)
OUTPUT_GBUFFER_VELOCITY(outVelocityBuffer)
#ifdef _DEPTHOFFSET_ON
, float outputDepth : SV_Depth
#endif
FragInput input = UnpackVaryings(packedInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
float3 positionWS = input.positionWS;
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
Coordinate coord = GetCoordinate(input.unPositionSS.xy, _ScreenSize.zw);
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
ENCODE_INTO_GBUFFER(surfaceData, bakeDiffuseLighting, outGBuffer);
ENCODE_INTO_GBUFFER(surfaceData, bakeDiffuseLighting, outGBuffer);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.rawDepth;
#endif
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl


float4 Frag(PackedVaryings packedInput) : SV_Target
{
FragInput input = UnpackVaryings(packedInput);
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
float4 outBuffer;
EncodeVelocity(builtinData.velocity, outBuffer);

9
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl


float4 Frag(PackedVaryings packedInput) : SV_Target
{
FragInput input = UnpackVaryings(packedInput);
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);

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


#error SHADERPASS_is_not_correctly_define
#endif
float4 Frag(PackedVaryings packedInput) : SV_Target
void Frag( PackedVaryings packedInput,
out float4 outColor : SV_Target
#ifdef _DEPTHOFFSET_ON
, out float outputDepth : SV_Depth
#endif
)
FragInput input = UnpackVaryings(packedInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
float3 positionWS = input.positionWS;
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
Coordinate coord = GetCoordinate(input.unPositionSS.xy, _ScreenSize.zw);
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
LightLoop(V, positionWS, coord, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
return float4(diffuseLighting + specularLighting, builtinData.opacity);
outColor = float4(diffuseLighting + specularLighting, builtinData.opacity);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.rawDepth;
#endif
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl


float4 Frag(PackedVaryings packedInput) : SV_Target
{
FragInput input = UnpackVaryings(packedInput);
FragInputs input = UnpackVaryings(packedInput);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
// Not lit here (but emissive is allowed)

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


// Final compositing pass, just does gamma correction for now.
Shader "Hidden/HDRenderLoop/FinalPass"
Shader "Hidden/HDRenderPipeline/FinalPass"
{
Properties
{

#include "Common.hlsl"
#include "Color.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
TEXTURE2D(_MainTex);
SAMPLER2D(sampler_MainTex);

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


Shader "Hidden/HDRenderLoop/DebugViewTiles"
Shader "Hidden/HDRenderPipeline/DebugViewTiles"
{
SubShader
{

// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
// the deferred shader will require to use multicompile.
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Lighting.hlsl" // This include Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Lighting.hlsl" // This include Material.hlsl
uint _ViewTilesFlags;
float4x4 _InvViewProjMatrix;
uint _ViewTilesFlags;
float2 _MousePixelCoord;
}
float4 AlphaBlend(float4 c0, float4 c1) // c1 over c0
{
return float4(lerp(c0.rgb, c1.rgb, c1.a), c0.a + c1.a - c0.a * c1.a);
}
float4 OverlayHeatMap(uint2 pixCoord, uint numLights)

int2 coord = pixCoord - int2(1, 1);
float4 color = float4(pow(col.xyz, 2.2), 0.3*col.w);
float4 color = float4(PositivePow(col.xyz, 2.2), 0.3 * col.w);
if (numLights > 0)
{
if (SampleDebugFontNumber(coord, numLights)) // Shadow

float4 Frag(float4 positionCS : SV_POSITION) : SV_Target
{
Coordinate coord = GetCoordinate(positionCS.xy, _ScreenSize.zw);
#ifdef USE_CLUSTERED_LIGHTLIST
// Perform same calculation than in deferred.shader
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
float3 positionWS = UnprojectToWorld(depth, coord.positionSS, _InvViewProjMatrix);
float linearDepth = TransformWorldToView(positionWS).z; // View space linear depth
#else
float linearDepth = 0.0; // unused
#endif
// positionCS is SV_Position
PositionInputs posInput = GetPositionInput(positionCS.xy, _ScreenSize.zw);
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x;
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
int2 pixelCoord = posInput.unPositionSS.xy;
int2 tileCoord = (float2)pixelCoord / TILE_SIZE;
int2 mouseTileCoord = _MousePixelCoord / TILE_SIZE;
int2 offsetInTile = pixelCoord - tileCoord * TILE_SIZE;
int n = 0;
for (int category = 0; category < LIGHTCATEGORY_COUNT; category++)

{
uint start;
uint count;
GetCountAndStart(coord, category, linearDepth, start, count);
GetCountAndStart(posInput, category, start, count);
float4 result = float4(0.0, 0.0, 0.0, 0.0);
// Tile overlap counter
return OverlayHeatMap(int2(coord.unPositionSS.xy) & 15, n);
result = OverlayHeatMap(int2(posInput.unPositionSS.xy) & (TILE_SIZE - 1), n);
}
// Highlight selected tile
if (all(mouseTileCoord == tileCoord))
{
bool border = any(offsetInTile == 0 || offsetInTile == TILE_SIZE - 1);
float4 result2 = float4(1.0, 1.0, 1.0, border ? 1.0 : 0.5);
result = AlphaBlend(result, result2);
else
// Print light lists for selected tile at the bottom of the screen
int maxLights = 32;
if (tileCoord.y < LIGHTCATEGORY_COUNT && tileCoord.x < maxLights + 3)
return 0.0;
PositionInputs mousePosInput = GetPositionInput(_MousePixelCoord, _ScreenSize.zw);
float depthMouse = LOAD_TEXTURE2D(_CameraDepthTexture, mousePosInput.unPositionSS).x;
UpdatePositionInput(depthMouse, _InvViewProjMatrix, _ViewProjMatrix, mousePosInput);
int category = (LIGHTCATEGORY_COUNT - 1) - tileCoord.y;
int start;
int count;
GetCountAndStart(mousePosInput, category, start, count);
float4 result2 = float4(.1,.1,.1,.9);
int2 fontCoord = int2(pixelCoord.x, offsetInTile.y);
int lightListIndex = tileCoord.x - 2;
int n = -1;
if(tileCoord.x == 0)
{
n = count;
}
else if(lightListIndex >= 0 && lightListIndex < count)
{
n = FetchIndex(start, lightListIndex);
}
if (n >= 0)
{
if (SampleDebugFontNumber(offsetInTile, n))
result2 = float4(0.0, 0.0, 0.0, 1.0);
if (SampleDebugFontNumber(offsetInTile + 1, n))
result2 = float4(1.0, 1.0, 1.0, 1.0);
}
result = AlphaBlend(result, result2);
return result;
}
ENDHLSL

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


Shader "Hidden/HDRenderLoop/DebugViewMaterialGBuffer"
Shader "Hidden/HDRenderPipeline/DebugViewMaterialGBuffer"
{
SubShader
{

// CAUTION: In case deferred lighting need to support various lighting model statically, we will require to do multicompile with different define like UNITY_MATERIAL_LIT
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Debug/DebugViewMaterial.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Material/Material.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Material.hlsl"
SAMPLER2D(sampler_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
int _DebugViewMaterial;
struct Attributes

float4 Frag(Varyings input) : SV_Target
{
float4 unPositionSS = input.positionCS; // as input we have the vpos
Coordinate coord = GetCoordinate(unPositionSS.xy, _ScreenSize.zw);
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
// input.positionCS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x;
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
FETCH_GBUFFER(gbuffer, _GBufferTexture, coord.unPositionSS);
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS);
BSDFData bsdfData;
float3 bakeDiffuseLighting;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);

if (_DebugViewMaterial == DEBUGVIEWGBUFFER_DEPTH)
{
float linearDepth = frac(LinearEyeDepth(depth, _ZBufferParams) * 0.1);
float linearDepth = frac(posInput.depthVS * 0.1);
result = linearDepth.xxx;
}
else if (_DebugViewMaterial == DEBUGVIEWGBUFFER_BAKE_DIFFUSE_LIGHTING)

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Debug/DebugViewMaterial.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs. Please don't edit by hand.
//
#ifndef DEBUGVIEWMATERIAL_CS_HLSL

//
// UnityEngine.Experimental.ScriptableRenderLoop.Attributes.DebugViewGbuffer: static fields
//
#define DEBUGVIEWGBUFFER_DEPTH (9)
#define DEBUGVIEWGBUFFER_BAKE_DIFFUSE_LIGHTING (10)
#define DEBUGVIEWGBUFFER_DEPTH (10)
#define DEBUGVIEWGBUFFER_BAKE_DIFFUSE_LIGHTING (11)
#endif

3
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs


VertexNormalWS,
VertexColor,
VertexColorAlpha,
// caution if you add something here, it must start below
};
// Number must be contiguous

Depth = DebugViewVarying.VertexColor + 1,
Depth = DebugViewVarying.VertexColorAlpha + 1,
BakeDiffuseLighting,
}
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky.meta


fileFormatVersion: 2
guid: d7469c05ebee66f4886264af0ab8bf2a
guid: 066ab4d03bd03384f81c9d82b479f8dd
folderAsset: yes
timeCreated: 1479239906
licenseType: Pro

83
Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs


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

// Render Target Management.
public const ClearFlag kClearAll = ClearFlag.ClearDepth | ClearFlag.ClearColor;
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier buffer, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier buffer, ClearFlag clearFlag = ClearFlag.ClearNone, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
SetRenderTarget(renderLoop, colorBuffer, depthBuffer, ClearFlag.ClearNone, new Color(0.0f, 0.0f, 0.0f, 0.0f), miplevel, cubemapFace);
SetRenderTarget(renderContext, colorBuffer, depthBuffer, ClearFlag.ClearNone, new Color(0.0f, 0.0f, 0.0f, 0.0f), miplevel, cubemapFace);
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
SetRenderTarget(renderLoop, colorBuffer, depthBuffer, clearFlag, new Color(0.0f, 0.0f, 0.0f, 0.0f), miplevel, cubemapFace);
SetRenderTarget(renderContext, colorBuffer, depthBuffer, clearFlag, new Color(0.0f, 0.0f, 0.0f, 0.0f), miplevel, cubemapFace);
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
{
var cmd = new CommandBuffer();
cmd.name = "";

renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthBuffer)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthBuffer)
SetRenderTarget(renderLoop, colorBuffers, depthBuffer, ClearFlag.ClearNone, Color.black);
SetRenderTarget(renderContext, colorBuffers, depthBuffer, ClearFlag.ClearNone, Color.black);
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag = ClearFlag.ClearNone)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag = ClearFlag.ClearNone)
SetRenderTarget(renderLoop, colorBuffers, depthBuffer, clearFlag, Color.black);
SetRenderTarget(renderContext, colorBuffers, depthBuffer, clearFlag, Color.black);
public static void SetRenderTarget(RenderLoop renderLoop, RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, Color clearColor)
public static void SetRenderTarget(ScriptableRenderContext renderContext, RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, Color clearColor)
{
var cmd = new CommandBuffer();
cmd.name = "";

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

: IDisposable
{
bool disposed = false;
RenderLoop renderLoop;
ScriptableRenderContext renderContext;
public ProfilingSample(string _name, RenderLoop _renderloop)
public ProfilingSample(string _name, ScriptableRenderContext _renderloop)
renderLoop = _renderloop;
renderContext = _renderloop;
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}

CommandBuffer cmd = new CommandBuffer();
cmd.name = "";
cmd.EndSample(name);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}

public static Matrix4x4 GetViewProjectionMatrix(Camera camera)
public static Matrix4x4 GetViewProjectionMatrix(Matrix4x4 worldToViewMatrix, Matrix4x4 projectionMatrix)
var gpuProj = GL.GetGPUProjectionMatrix(projectionMatrix, false);
var gpuVP = gpuProj * worldToViewMatrix * Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)); // Need to scale -1.0 on Z to match what is being done in the camera.wolrdToCameraMatrix API.
return gpuVP;
}
public static HDRenderPipeline.HDCamera GetHDCamera(Camera camera)
{
HDRenderPipeline.HDCamera hdCamera = new HDRenderPipeline.HDCamera();
hdCamera.camera = camera;
hdCamera.screenSize = new Vector4(camera.pixelWidth, camera.pixelHeight, 1.0f / camera.pixelWidth, 1.0f / camera.pixelHeight);
// The actual projection matrix used in shaders is actually massaged a bit to work across all platforms
// (different Z value ranges etc.)
return gpuVP;
}
hdCamera.viewProjectionMatrix = gpuVP;
hdCamera.invViewProjectionMatrix = gpuVP.inverse;
public static Vector4 ComputeScreenSize(Camera camera)
return hdCamera;
}
public static void SetupMaterialHDCamera(HDRenderPipeline.HDCamera hdCamera, Material material)
return new Vector4(camera.pixelWidth, camera.pixelHeight, 1.0f / camera.pixelWidth, 1.0f / camera.pixelHeight);
material.SetVector("_ScreenSize", hdCamera.screenSize);
material.SetMatrix("_ViewProjMatrix", hdCamera.viewProjectionMatrix);
material.SetMatrix("_InvViewProjMatrix", hdCamera.invViewProjectionMatrix);
}
// TEMP: These functions should be implemented C++ side, for now do it in C#

m.EnableKeyword(keyword);
else
m.DisableKeyword(keyword);
}
public static HDRenderPipeline GetHDRenderPipeline()
{
HDRenderPipeline renderContext = UnityEngine.Rendering.GraphicsSettings.renderPipeline as HDRenderPipeline;
if (renderContext == null)
{
Debug.LogWarning("SkyParameters component can only be used with HDRenderPipeline custom RenderPipeline.");
return null;
}
return renderContext;
}
}
}

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyRenderer.cs.meta


fileFormatVersion: 2
guid: cf8a015aab8d3b643aa3ef3816f85447
timeCreated: 1479314393
guid: 0dc07ece20cf92244bb1f9c889f3cea5
timeCreated: 1481626426
licenseType: Pro
MonoImporter:
serializedVersion: 2

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


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[Serializable]
public enum SkyResolution
abstract public class SkyRenderer
SkyResolution128 = 128,
SkyResolution256 = 256,
SkyResolution512 = 512,
SkyResolution1024 = 1024,
// TODO: Anything above 1024 cause a crash in Unity...
//SkyResolution2048 = 2048,
//SkyResolution4096 = 4096
}
abstract public void Build();
abstract public void Cleanup();
abstract public void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters);
abstract public bool IsSkyValid(SkyParameters skyParameters);
[Serializable]
public class SkyParameters
{
public Texture skyHDRI;
public float rotation = 0.0f;
public float exposure = 0.0f;
public float multiplier = 1.0f;
public SkyResolution skyResolution = SkyResolution.SkyResolution256;
virtual public bool IsParameterValid(SkyParameters skyParameters) { return false; }
virtual public Type GetSkyParameterType() { return typeof(SkyParameters); }
public class SkyRenderer
abstract public class SkyRenderer<ParameterType> : SkyRenderer
where ParameterType : SkyParameters
RenderTexture m_SkyboxCubemapRT = null;
RenderTexture m_SkyboxGGXCubemapRT = null;
Material m_StandardSkyboxMaterial = null; // This is the Unity standard skybox material. Used to pass the correct cubemap to Enlighten.
Material m_SkyHDRIMaterial = null; // Renders a cubemap into a render texture (can be cube or 2D)
Material m_GGXConvolveMaterial = null; // Apply GGX convolution to cubemap
SkyParameters m_bakedSkyParameters = new SkyParameters(); // This is the SkyParam used when baking and convolving the sky.
MaterialPropertyBlock m_RenderSkyPropertyBlock = null;
GameObject[] m_CubemapFaceCamera = new GameObject[6];
Mesh[] m_CubemapFaceMesh = new Mesh[6];
Mesh BuildSkyMesh(Camera camera, bool forceUVBottom)
{
Vector4 vertData0 = new Vector4(-1.0f, -1.0f, 1.0f, 1.0f);
Vector4 vertData1 = new Vector4(1.0f, -1.0f, 1.0f, 1.0f);
Vector4 vertData2 = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
Vector4 vertData3 = new Vector4(-1.0f, 1.0f, 1.0f, 1.0f);
Vector3[] vertData = new Vector3[4];
vertData[0] = new Vector3(vertData0.x, vertData0.y, vertData0.z);
vertData[1] = new Vector3(vertData1.x, vertData1.y, vertData1.z);
vertData[2] = new Vector3(vertData2.x, vertData2.y, vertData2.z);
vertData[3] = new Vector3(vertData3.x, vertData3.y, vertData3.z);
// Get view vector based on the frustum, i.e (invert transform frustum get position etc...)
Vector3[] eyeVectorData = new Vector3[4];
Matrix4x4 transformMatrix = camera.cameraToWorldMatrix * camera.projectionMatrix.inverse;
Vector4 posWorldSpace0 = transformMatrix * vertData0;
Vector4 posWorldSpace1 = transformMatrix * vertData1;
Vector4 posWorldSpace2 = transformMatrix * vertData2;
Vector4 posWorldSpace3 = transformMatrix * vertData3;
Vector3 temp = camera.GetComponent<Transform>().position;
Vector4 cameraPosition = new Vector4(temp.x, temp.y, temp.z, 0.0f);
Vector4 direction0 = (posWorldSpace0 / posWorldSpace0.w - cameraPosition);
Vector4 direction1 = (posWorldSpace1 / posWorldSpace1.w - cameraPosition);
Vector4 direction2 = (posWorldSpace2 / posWorldSpace2.w - cameraPosition);
Vector4 direction3 = (posWorldSpace3 / posWorldSpace3.w - cameraPosition);
if (SystemInfo.graphicsUVStartsAtTop && !forceUVBottom)
{
eyeVectorData[3] = new Vector3(direction0.x, direction0.y, direction0.z).normalized;
eyeVectorData[2] = new Vector3(direction1.x, direction1.y, direction1.z).normalized;
eyeVectorData[1] = new Vector3(direction2.x, direction2.y, direction2.z).normalized;
eyeVectorData[0] = new Vector3(direction3.x, direction3.y, direction3.z).normalized;
}
else
{
eyeVectorData[0] = new Vector3(direction0.x, direction0.y, direction0.z).normalized;
eyeVectorData[1] = new Vector3(direction1.x, direction1.y, direction1.z).normalized;
eyeVectorData[2] = new Vector3(direction2.x, direction2.y, direction2.z).normalized;
eyeVectorData[3] = new Vector3(direction3.x, direction3.y, direction3.z).normalized;
}
// Write out the mesh
var triangles = new int[6] { 0, 1, 2, 2, 3, 0 };
return new Mesh
{
vertices = vertData,
normals = eyeVectorData,
triangles = triangles
};
}
void RebuildTextures(SkyParameters skyParameters)
{
if ((m_SkyboxCubemapRT != null) && (m_SkyboxCubemapRT.width != (int)skyParameters.skyResolution))
{
Utilities.Destroy(m_SkyboxCubemapRT);
Utilities.Destroy(m_SkyboxGGXCubemapRT);
}
if (m_SkyboxCubemapRT == null)
{
m_SkyboxCubemapRT = new RenderTexture((int)skyParameters.skyResolution, (int)skyParameters.skyResolution, 1, RenderTextureFormat.ARGBHalf);
m_SkyboxCubemapRT.dimension = TextureDimension.Cube;
m_SkyboxCubemapRT.useMipMap = true;
m_SkyboxCubemapRT.autoGenerateMips = true; // Generate regular mipmap for filtered importance sampling
m_SkyboxCubemapRT.filterMode = FilterMode.Trilinear;
m_SkyboxCubemapRT.Create();
m_SkyboxGGXCubemapRT = new RenderTexture((int)skyParameters.skyResolution, (int)skyParameters.skyResolution, 1, RenderTextureFormat.ARGBHalf);
m_SkyboxGGXCubemapRT.dimension = TextureDimension.Cube;
m_SkyboxGGXCubemapRT.useMipMap = true;
m_SkyboxGGXCubemapRT.autoGenerateMips = false;
m_SkyboxGGXCubemapRT.filterMode = FilterMode.Trilinear;
m_SkyboxGGXCubemapRT.Create();
}
}
// Sets the global MIP-mapped cubemap '_SkyTexture' in the shader.
// The texture being set is the sky (environment) map pre-convolved with GGX.
public void SetGlobalSkyTexture()
{
Shader.SetGlobalTexture("_SkyTexture", m_SkyboxGGXCubemapRT);
}
public void Resize(SkyParameters skyParameters)
{
// When loading RenderDoc, RenderTextures will go null
RebuildTextures(skyParameters);
}
public void Rebuild()
{
// TODO: We need to have an API to send our sky information to Enlighten. For now use a workaround through skybox/cubemap material...
m_StandardSkyboxMaterial = Utilities.CreateEngineMaterial("Skybox/Cubemap");
m_SkyHDRIMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/SkyHDRI");
m_GGXConvolveMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/GGXConvolve");
m_RenderSkyPropertyBlock = new MaterialPropertyBlock();
Matrix4x4 cubeProj = Matrix4x4.Perspective(90.0f, 1.0f, 0.1f, 1.0f);
Vector3[] lookAtList = {
new Vector3(1.0f, 0.0f, 0.0f),
new Vector3(-1.0f, 0.0f, 0.0f),
new Vector3(0.0f, 1.0f, 0.0f),
new Vector3(0.0f, -1.0f, 0.0f),
new Vector3(0.0f, 0.0f, 1.0f),
new Vector3(0.0f, 0.0f, -1.0f),
};
Vector3[] UpVectorList = {
new Vector3(0.0f, 1.0f, 0.0f),
new Vector3(0.0f, 1.0f, 0.0f),
new Vector3(0.0f, 0.0f, -1.0f),
new Vector3(0.0f, 0.0f, 1.0f),
new Vector3(0.0f, 1.0f, 0.0f),
new Vector3(0.0f, 1.0f, 0.0f),
};
for (int i = 0; i < 6; ++i)
{
m_CubemapFaceCamera[i] = new GameObject();
m_CubemapFaceCamera[i].hideFlags = HideFlags.HideAndDontSave;
Camera camera = m_CubemapFaceCamera[i].AddComponent<Camera>();
camera.projectionMatrix = cubeProj;
Transform transform = camera.GetComponent<Transform>();
transform.LookAt(lookAtList[i], UpVectorList[i]);
// When rendering into a texture the render will be flip (due to legacy unity openGL behavior), so we need to flip UV here...
m_CubemapFaceMesh[i] = BuildSkyMesh(camera, true);
}
}
public void Cleanup()
{
Utilities.Destroy(m_StandardSkyboxMaterial);
Utilities.Destroy(m_SkyHDRIMaterial);
Utilities.Destroy(m_GGXConvolveMaterial);
Utilities.Destroy(m_SkyboxCubemapRT);
Utilities.Destroy(m_SkyboxGGXCubemapRT);
for(int i = 0 ; i < 6 ; ++i)
{
Utilities.Destroy(m_CubemapFaceCamera[i]);
}
}
public bool IsSkyValid(SkyParameters parameters)
{
// Later we will also test shader for procedural skies.
return parameters.skyHDRI != null;
}
private void RenderSky(Camera camera, SkyParameters skyParameters, Mesh skyMesh, RenderLoop renderLoop)
override public bool IsParameterValid(SkyParameters skyParameters)
Shader.EnableKeyword("PERFORM_SKY_OCCLUSION_TEST");
m_RenderSkyPropertyBlock.SetTexture("_Cubemap", skyParameters.skyHDRI);
m_RenderSkyPropertyBlock.SetVector("_SkyParam", new Vector4(skyParameters.exposure, skyParameters.multiplier, skyParameters.rotation, 0.0f));
m_RenderSkyPropertyBlock.SetMatrix("_InvViewProjMatrix", Utilities.GetViewProjectionMatrix(camera).inverse);
var cmd = new CommandBuffer { name = "" };
cmd.DrawMesh(skyMesh, Matrix4x4.identity, m_SkyHDRIMaterial, 0, 0, m_RenderSkyPropertyBlock);
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
return GetParameters(skyParameters) != null;
private void RenderSkyToCubemap(SkyParameters skyParameters, RenderTexture target, RenderLoop renderLoop)
override public Type GetSkyParameterType()
Shader.DisableKeyword("PERFORM_SKY_OCCLUSION_TEST");
for (int i = 0; i < 6; ++i)
{
Utilities.SetRenderTarget(renderLoop, target, 0, (CubemapFace)i);
Camera faceCamera = m_CubemapFaceCamera[i].GetComponent<Camera>();
RenderSky(faceCamera, skyParameters, m_CubemapFaceMesh[i], renderLoop);
}
}
private void RenderCubemapGGXConvolution(Texture input, RenderTexture target, RenderLoop renderLoop)
{
using (new Utilities.ProfilingSample("Sky Pass: GGX Convolution", renderLoop))
{
int mipCount = 1 + (int)Mathf.Log(input.width, 2.0f);
if (mipCount < ((int)EnvConstants.SpecCubeLodStep + 1))
{
Debug.LogWarning("RenderCubemapGGXConvolution: Cubemap size is too small for GGX convolution, needs at least " + ((int)EnvConstants.SpecCubeLodStep + 1) + " mip levels");
return;
}
// Copy the first mip.
// TEMP code until CopyTexture is implemented for command buffer
// All parameters are neutral because exposure/multiplier have already been applied in the first copy.
SkyParameters skyParams = new SkyParameters();
skyParams.exposure = 0.0f;
skyParams.multiplier = 1.0f;
skyParams.rotation = 0.0f;
skyParams.skyHDRI = input;
RenderSkyToCubemap(skyParams, target, renderLoop);
// End temp
//
//for (int f = 0; f < 6; f++)
// Graphics.CopyTexture(input, f, 0, target, f, 0);
// Do the convolution on remaining mipmaps
float invOmegaP = (6.0f * input.width * input.width) / (4.0f * Mathf.PI); // Solid angle associated to a pixel of the cubemap;
m_GGXConvolveMaterial.SetTexture("_MainTex", input);
m_GGXConvolveMaterial.SetFloat("_MipMapCount", mipCount);
m_GGXConvolveMaterial.SetFloat("_InvOmegaP", invOmegaP);
for (int mip = 1; mip < ((int)EnvConstants.SpecCubeLodStep + 1); ++mip)
{
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
propertyBlock.SetFloat("_Level", mip);
for (int face = 0; face < 6; ++face)
{
Utilities.SetRenderTarget(renderLoop, target, mip, (CubemapFace)face);
var cmd = new CommandBuffer { name = "" };
cmd.DrawMesh(m_CubemapFaceMesh[face], Matrix4x4.identity, m_GGXConvolveMaterial, 0, 0, propertyBlock);
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}
}
return typeof(ParameterType);
public void RenderSky(Camera camera, SkyParameters skyParameters, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, RenderLoop renderLoop)
protected ParameterType GetParameters(SkyParameters parameters)
using (new Utilities.ProfilingSample("Sky Pass", renderLoop))
{
if (IsSkyValid(skyParameters))
{
// Trigger a rebuild of cubemap / convolution
// TODO: can we have some kind of hash value here ? +> use or override GetHashCode() + include a refresh rate value in parameters
// TODO: we could apply multiplier/exposure and rotation on the final result (i.e on the sky ibl and on lightprobe / lightmap, but can be tricky as Unity seems to merge sky information with
// other lighting into SH / lightmap.
if (skyParameters.skyResolution != m_bakedSkyParameters.skyResolution ||
skyParameters.exposure != m_bakedSkyParameters.exposure ||
skyParameters.rotation != m_bakedSkyParameters.rotation ||
skyParameters.multiplier != m_bakedSkyParameters.multiplier)
{
using (new Utilities.ProfilingSample("Sky Pass: Render Cubemap", renderLoop))
{
// Render sky into a cubemap - doesn't happen every frame, can be controlled
RenderSkyToCubemap(skyParameters, m_SkyboxCubemapRT, renderLoop);
// Convolve downsampled cubemap
RenderCubemapGGXConvolution(m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT, renderLoop);
// TODO: Properly send the cubemap to Enlighten. Currently workaround is to set the cubemap in a Skybox/cubemap material
m_StandardSkyboxMaterial.SetTexture("_Tex", m_SkyboxCubemapRT);
RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings
RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
RenderSettings.reflectionIntensity = 1.0f;
RenderSettings.customReflection = null;
DynamicGI.UpdateEnvironment();
}
// Cleanup all this...
m_bakedSkyParameters.skyResolution = skyParameters.skyResolution;
m_bakedSkyParameters.exposure = skyParameters.exposure;
m_bakedSkyParameters.rotation = skyParameters.rotation;
m_bakedSkyParameters.multiplier = skyParameters.multiplier;
}
// Render the sky itself
Utilities.SetRenderTarget(renderLoop, colorBuffer, depthBuffer);
RenderSky(camera, skyParameters, BuildSkyMesh(camera, false), renderLoop);
}
}
return parameters as ParameterType;
}
}
}

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


Shader "Hidden/HDRenderLoop/GGXConvolve"
Shader "Hidden/HDRenderPipeline/GGXConvolve"
{
SubShader
{

HLSLPROGRAM
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma multi_compile _ USE_MIS
#pragma vertex Vert
#pragma fragment Frag

#include "../SkyManager.cs.hlsl"
struct Attributes
{

TEXTURECUBE(_MainTex);
SAMPLERCUBE(sampler_MainTex);
#ifdef USE_MIS
TEXTURE2D(_MarginalRowDensities);
TEXTURE2D(_ConditionalDensities);
#endif
float _MipMapCount;
float _MaxLevel;
float _InvOmegaP;
half4 Frag(Varyings input) : SV_Target

// Remove view-dependency from GGX, effectively making the BSDF isotropic.
// We approximate the pre-integration with V == N
float4 val = IntegrateLD( TEXTURECUBE_PARAM(_MainTex, sampler_MainTex),
V,
N,
PerceptualRoughnessToRoughness(perceptualRoughness),
_MipMapCount,
_InvOmegaP,
64,
true);
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
#ifdef USE_MIS
float4 val = IntegrateLD_MIS(TEXTURECUBE_PARAM(_MainTex, sampler_MainTex),
_MarginalRowDensities, _ConditionalDensities,
V, N,
roughness,
_InvOmegaP,
LIGHTSAMPLINGPARAMETERS_TEXTURE_WIDTH,
LIGHTSAMPLINGPARAMETERS_TEXTURE_HEIGHT,
1024,
false);
#else
uint sampleCount = 0;
switch (_Level)
{
case 1: sampleCount = 21; break;
case 2: sampleCount = 34; break;
case 3: sampleCount = 55; break;
case 4: sampleCount = 89; break;
case 5: sampleCount = 89; break;
case 6: sampleCount = 89; break; // UNITY_SPECCUBE_LOD_STEPS
}
float4 val = IntegrateLD(TEXTURECUBE_PARAM(_MainTex, sampler_MainTex),
V, N,
roughness,
_MaxLevel,
_InvOmegaP,
sampleCount, // Must be a Fibonacci number
true);
#endif
return val;
}

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


uniform float _ShadowBias;
uniform float _ShadowBiasIndirect;
uniform float _ShadowBiasClouds;
uniform float2 _ShadowBiasSkyRayleighMie;
uniform float _OcclusionDepthThreshold;
uniform float4 _OcclusionTexture_TexelSize;

uniform float _HeightSeaLevel;
uniform float3 _HeightPlaneShift;
uniform float _HeightDistanceRcp;
uniform float4 _HeightRayleighColor;
uniform float _HeightExtinctionFactor;
uniform float _RayleighCoeffScale;
uniform float3 _RayleighSunTintIntensity;
uniform float _RayleighExtinctionFactor;
uniform float _MieCoeffScale;
uniform float3 _MieSunTintIntensity;
uniform float _HeightExtinctionFactor;
uniform float _RayleighExtinctionFactor;
uniform float4 _HeightRayleighColor;
SAMPLER2D(sampler_CameraDepthTexture)
SAMPLER2D(sampler_CameraDepthTexture);
#define SRL_BilinearSampler sampler_CameraDepthTexture // Used for all textures
TEXTURE2D(_CameraDepthTexture);

void VolundTransferScatter(float3 worldPos, out float4 coords1, out float4 coords2, out float4 coords3) {
const float3 scaledWorldPos = WorldScale(worldPos);
const float3 worldCamPos = WorldScale(_WorldSpaceCameraPos.xyz);
const float3 worldCamPos = WorldScale(_CameraPosWS.xyz);
const float c_MieScaleHeight = 1200.f;
const float worldRayleighDensity = 1.f;

const float worldVecLen = length(worldVec);
const float3 worldDir = worldVec / worldVecLen;
const float3 worldDirUnscaled = normalize(worldPos - _WorldSpaceCameraPos.xyz);
const float3 worldDirUnscaled = normalize(worldPos - _CameraPosWS.xyz);
const float viewSunCos = dot(worldDirUnscaled, _SunDirection);
const float rayleighPh = min(1.f, RayleighPhase(viewSunCos) * 12.f);

coords2.a = mieScatter;
}
void VolundTransferScatter(float3 scaledWorldPos, out float4 coords1) {
float4 c1, c2, c3;
VolundTransferScatter(scaledWorldPos, c1, c2, c3);
void VolundTransferScatter(float3 worldPos, out float4 coords1) {
float4 c1, c2, c3;
VolundTransferScatter(worldPos, c1, c2, c3);
#ifdef IS_RENDERING_SKY
coords1.rgb = c3.rgb;

}
float2 UVFromPos(float2 pos) {
return pos / _ScreenParams.xy;
#if defined(UNITY_PASS_FORWARDBASE)
return pos;
#else
return pos * _ScreenSize.zw;
#endif
}
float3 VolundApplyScatter(float4 coords1, float2 pos, float3 color) {

return color * coords1;
}
void VolundTransferScatterOcclusion(float3 scaledWorldPos, out float4 coords1, out float3 coords2) {
float4 c1, c2, c3;
VolundTransferScatter(scaledWorldPos, c1, c2, c3);
void VolundTransferScatterOcclusion(float3 worldPos, out float4 coords1, out float3 coords2) {
float4 c1, c2, c3;
VolundTransferScatter(worldPos, c1, c2, c3);
coords1.rgb = c1.rgb * _RayleighInScatterPct.x;
coords1.a = max(0.f, 1.f - c1.a * _RayleighExtinctionFactor - c3.a * _HeightExtinctionFactor);

float4 mfWeights = float4(fWeights.z * fWeights.y, fWeights.x * fWeights.y, fWeights.x * fWeights.w, fWeights.z * fWeights.w);
return dot(occ, mfWeights * maskDepth) / dot(mfWeights, maskDepth);
}
#endif //defined(ATMOSPHERICS_OCCLUSION_EDGE_FIXUP)
#else
return SAMPLE_TEXTURE2D(_OcclusionTexture, SRL_BilinearSampler, uv).r;
#endif
#else //defined(ATMOSPHERICS_OCCLUSION)
return 1.f;
#endif //defined(ATMOSPHERICS_OCCLUSION)

// Original vert/frag macros
#if defined(ATMOSPHERICS_OCCLUSION)
#define VOLUND_SCATTER_COORDS(idx1, idx2) float4 scatterCoords1 : TEXCOORD##idx1; float3 scatterCoords2 : TEXCOORD##idx2;
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz; o.scatterCoords2 = pos.xyz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyCloudScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#if defined(ATMOSPHERICS_PER_PIXEL)
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz; o.scatterCoords2 = pos.xyz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyCloudScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#else
#define VOLUND_TRANSFER_SCATTER(pos, o) VolundTransferScatterOcclusion(pos, o.scatterCoords1, o.scatterCoords2)
#define VOLUND_APPLY_SCATTER(i, color) color = VolundApplyScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) color = VolundApplyCloudScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#endif
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyScatter(i.scatterCoords1, i.pos.xy, color);
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyCloudScatter(i.scatterCoords1, color);
#if defined(ATMOSPHERICS_PER_PIXEL)
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyScatter(i.scatterCoords1, i.pos.xy, color);
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyCloudScatter(i.scatterCoords1, color);
#else
#define VOLUND_TRANSFER_SCATTER(pos, o) VolundTransferScatter(pos, o.scatterCoords1)
#define VOLUND_APPLY_SCATTER(i, color) color = VolundApplyScatter(i.scatterCoords1, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) color = VolundApplyCloudScatter(i.scatterCoords1, color)
#endif
#define SURFACE_SCATTER_COORDS float3 scaledWorldPos; float4 scatterCoords1; float3 scatterCoords2;
#define SURFACE_SCATTER_COORDS float3 worldPos; float4 scatterCoords1; float3 scatterCoords2;
#define SURFACE_SCATTER_APPLY(i, color) color += (i.scaledWorldPos + i.scatterCoords1.xyz + i.scatterCoords2.xyz) * 0.000001f
#define SURFACE_SCATTER_APPLY(i, color) color += (i.worldPos + i.scatterCoords1.xyz + i.scatterCoords2.xyz) * 0.000001f
#endif
#endif //FILE_ATMOSPHERICSCATTERING

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


Shader "Hidden/HDRenderLoop/SkyHDRI"
Shader "Hidden/HDRenderPipeline/Sky/SkyHDRI"
{
SubShader
{

#pragma vertex Vert
#pragma fragment Frag
#pragma multi_compile _ ATMOSPHERICS_DEBUG
#pragma multi_compile _ ATMOSPHERICS_OCCLUSION_FULLSKY
#pragma multi_compile _ PERFORM_SKY_OCCLUSION_TEST
#ifndef PERFORM_SKY_OCCLUSION_TEST
#define IS_RENDERING_SKY
#endif
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "AtmosphericScattering.hlsl"
float4x4 _InvViewProjMatrix;
float4 _SkyParam; // x exposure, y multiplier, z rotation
struct Attributes

float3 rotDirY = float3(sinPhi, 0, cosPhi);
dir = float3(dot(rotDirX, dir), dir.y, dot(rotDirY, dir));
/*
Coordinate coord = GetCoordinate(input.positionCS.xy, _ScreenSize.zw);
// If the sky box is too far away (depth set to 0), the resulting look is too foggy.
const float skyDepth = 0.01;
#ifdef PERFORM_SKY_OCCLUSION_TEST
// Determine whether the sky is occluded by the scene geometry.
// Do not perform blending with the environment map if the sky is occluded.
float rawDepth = max(skyDepth, LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).r);
float skyTexWeight = (rawDepth > skyDepth) ? 0.0 : 1.0;
#else
float rawDepth = skyDepth;
float skyTexWeight = 1.0;
#endif
float3 positionWS = UnprojectToWorld(rawDepth, coord.positionSS, _InvViewProjMatrix);
float4 c1, c2, c3;
VolundTransferScatter(positionWS, c1, c2, c3);
float4 coord1 = float4(c1.rgb + c3.rgb, max(0.f, 1.f - c1.a - c3.a));
float3 coord2 = c2.rgb;
float sunCos = dot(normalize(dir), _SunDirection);
float miePh = MiePhase(sunCos, _MiePhaseAnisotropy);
float2 occlusion = float2(1.0, 1.0); // TODO.
float extinction = coord1.a;
float3 scatter = coord1.rgb * occlusion.x + coord2 * miePh * occlusion.y;
#ifdef ATMOSPHERICS_DEBUG
switch (_AtmosphericsDebugMode)
{
case ATMOSPHERICS_DBG_RAYLEIGH: return c1;
case ATMOSPHERICS_DBG_MIE: return c2 * miePh;
case ATMOSPHERICS_DBG_HEIGHT: return c3;
case ATMOSPHERICS_DBG_SCATTERING: return float4(scatter, 0.0);
case ATMOSPHERICS_DBG_OCCLUSION: return float4(occlusion.xy, 0.0, 0.0);
case ATMOSPHERICS_DBG_OCCLUDEDSCATTERING: return float4(scatter, 0.0);
}
#endif
*/
// Apply extinction to the scene color when performing alpha-blending.
//return float4(skyColor * (skyTexWeight * extinction) + scatter, extinction);
}
ENDHLSL

450
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


using UnityEngine.Experimental.Rendering;
using System.Collections.Generic;
using System;
using UnityEngine.ScriptableRenderPipeline;
public class HDRenderPipelineInstance : RenderPipeline
{
private readonly HDRenderPipeline m_Owner;
public HDRenderPipelineInstance(HDRenderPipeline owner)
{
m_Owner = owner;
if (m_Owner != null)
m_Owner.Build();
}
public override void Dispose()
{
base.Dispose();
if (m_Owner != null)
m_Owner.Cleanup();
}
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{
base.Render(renderContext, cameras);
m_Owner.Render(renderContext, cameras);
}
}
// This HDRenderLoop assume linear lighting. Don't work with gamma.
public partial class HDRenderLoop : RenderPipeline
// This HDRenderPipeline assume linear lighting. Don't work with gamma.
public class HDRenderPipeline : RenderPipelineAsset
const string k_HDRenderLoopPath = "Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset";
const string k_HDRenderPipelinePath = "Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset";
[UnityEditor.MenuItem("Renderloop/CreateHDRenderLoop")]
static void CreateHDRenderLoop()
[UnityEditor.MenuItem("RenderPipeline/CreateHDRenderPipeline")]
static void CreateHDRenderPipeline()
var instance = ScriptableObject.CreateInstance<HDRenderLoop>();
UnityEditor.AssetDatabase.CreateAsset(instance, k_HDRenderLoopPath);
var instance = ScriptableObject.CreateInstance<HDRenderPipeline>();
UnityEditor.AssetDatabase.CreateAsset(instance, k_HDRenderPipelinePath);
[UnityEditor.MenuItem("HDRenderLoop/Add \"Additional Light Data\" (if not present)")]
[UnityEditor.MenuItem("HDRenderPipeline/Add \"Additional Light Data\" (if not present)")]
static void AddAdditionalLightData()
{
Light[] lights = FindObjectsOfType(typeof(Light)) as Light[];

}
#endif
SkyRenderer m_SkyRenderer = null;
[SerializeField]
SkyParameters m_SkyParameters = new SkyParameters();
protected override IRenderPipeline InternalCreatePipeline()
{
return new HDRenderPipelineInstance(this);
}
SkyManager m_SkyManager = new SkyManager();
public SkyManager skyManager
{
get { return m_SkyManager; }
}
public SkyParameters skyParameters
public void InstantiateSkyRenderer(Type skyRendererType)
get { return m_SkyParameters; }
m_SkyManager.InstantiateSkyRenderer(skyRendererType);
}
public class DebugParameters

public bool useForwardRenderingOnly = false; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepass = false;
public bool useDistortion = true;
public bool enableTonemap = true;
public float exposure = 0;

public TextureSettings textureSettings
{
get { return m_TextureSettings; }
set { m_TextureSettings = value; }
}
// Various set of material use in render loop

int m_VelocityBuffer;
int m_DistortionBuffer;
public bool m_Dirty = false;
RenderTargetIdentifier m_CameraColorBufferRT;
RenderTargetIdentifier m_CameraDepthBufferRT;
RenderTargetIdentifier m_VelocityBufferRT;

int m_WidthOnRecord;
int m_HeightOnRecord;
int m_currentWidth;
int m_currentHeight;
// This must be allocate outside of Rebuild() else the option in the class can't be set in the inspector (as it will in this case recreate the class with default value)
// Keep these settings safe to recover when leaving the render pipeline
bool previousLightsUseLinearIntensity;
bool previousLightsUseCCT;
// This must be allocate outside of Build() else the option in the class can't be set in the inspector (as it will in this case recreate the class with default value)
BaseLightLoop m_lightLoop = new TilePass.LightLoop();
public BaseLightLoop lightLoop

// TODO: Find a way to automatically create/iterate through deferred material
// TODO TO CHECK: SebL I move allocation from Rebuild() to here, but there was a comment "// Our object can be garbage collected, so need to be allocate here", it is still true ?
// TODO TO CHECK: SebL I move allocation from Build() to here, but there was a comment "// Our object can be garbage collected, so need to be allocate here", it is still true ?
public void OnValidate()
public struct HDCamera
// Calling direction Rebuild() here cause this warning:
// "SendMessage cannot be called during Awake, CheckConsistency, or OnValidate UnityEngine.Experimental.ScriptableRenderLoop.HDRenderLoop:OnValidate()"
// Workaround is to declare this dirty flag and call REbuild in Render()
m_Dirty = true;
public Camera camera;
public Vector4 screenSize;
public Matrix4x4 viewProjectionMatrix;
public Matrix4x4 invViewProjectionMatrix;
public override void Rebuild()
CommonSettings m_CommonSettings = null;
public CommonSettings commonSettings
// We call Cleanup() here because Rebuild() can be call by OnValidate(), i.e when inspector is touch
// Note that module don't need to do the same as the call here is propagated correctly
Cleanup();
set { m_CommonSettings = value; }
get { return m_CommonSettings; }
}
public void Build()
{
#if UNITY_EDITOR
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures
{
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
};
#endif
previousLightsUseLinearIntensity = UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity;
previousLightsUseCCT = UnityEngine.Rendering.GraphicsSettings.lightsUseCCT;
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = true;
UnityEngine.Rendering.GraphicsSettings.lightsUseCCT = true;
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture");

m_SkyRenderer = new SkyRenderer();
m_SkyRenderer.Rebuild();
m_SkyManager.Build();
m_FinalPassMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/FinalPass");
m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/DebugViewMaterialGBuffer");
m_FinalPassMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/FinalPass");
m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");
m_ShadowPass = new ShadowRenderPass(m_ShadowSettings);

m_gbufferManager.SetBufferDescription(gbufferIndex, "_GBufferTexture" + gbufferIndex, RTFormat[gbufferIndex], RTReadWrite[gbufferIndex]);
}
#pragma warning disable 162 // warning CS0162: Unreachable code detected
if (ShaderConfig.VelocityInGbuffer == 1)
if (ShaderConfig.s_VelocityInGbuffer == 1)
{
// If velocity is in GBuffer then it is in the last RT. Assign a different name to it.
m_gbufferManager.SetBufferDescription(m_gbufferManager.gbufferCount, "_VelocityTexture", Builtin.RenderLoop.GetVelocityBufferFormat(), Builtin.RenderLoop.GetVelocityBufferReadWrite());

#pragma warning restore 162
m_LitRenderLoop.Rebuild();
m_lightLoop.Rebuild(m_TextureSettings);
m_Dirty = false;
}
public override void Initialize()
{
#if UNITY_EDITOR
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures
{
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
};
#endif
Rebuild();
m_LitRenderLoop.Build();
m_lightLoop.Build(m_TextureSettings);
public override void Cleanup()
public void Cleanup()
m_LitRenderLoop.Cleanup();
m_LitRenderLoop.Cleanup();
if (m_SkyRenderer != null)
{
m_SkyRenderer.Cleanup();
}
m_SkyManager.Cleanup();
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = previousLightsUseLinearIntensity;
UnityEngine.Rendering.GraphicsSettings.lightsUseCCT = previousLightsUseCCT;
void InitAndClearBuffer(Camera camera, RenderLoop renderLoop)
void InitAndClearBuffer(Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("InitAndClearBuffer", renderLoop))
using (new Utilities.ProfilingSample("InitAndClearBuffer", renderContext))
using (new Utilities.ProfilingSample("InitGBuffers and clear Depth/Stencil", renderLoop))
using (new Utilities.ProfilingSample("InitGBuffers and clear Depth/Stencil", renderContext))
{
var cmd = new CommandBuffer();
cmd.name = "";

// Also we manage ourself the HDR format, here allocating fp16 directly.
// With scriptable render loop we can allocate temporary RT in a command buffer, they will not be release with ExecuteCommandBuffer
// These temporary surface are release automatically at the end of the scriptable renderloop if not release explicitly
// These temporary surface are release automatically at the end of the scriptable render pipeline if not release explicitly
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT, ClearFlag.ClearDepth);
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT, ClearFlag.ClearDepth);
using (new Utilities.ProfilingSample("Clear HDR target", renderLoop))
using (new Utilities.ProfilingSample("Clear HDR target", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT, ClearFlag.ClearColor, Color.black);
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT, ClearFlag.ClearColor, Color.black);
using (new Utilities.ProfilingSample("Clear GBuffer", renderLoop))
using (new Utilities.ProfilingSample("Clear GBuffer", renderContext))
Utilities.SetRenderTarget(renderLoop, m_gbufferManager.GetGBuffers(), m_CameraDepthBufferRT, ClearFlag.ClearColor, Color.black);
Utilities.SetRenderTarget(renderContext, m_gbufferManager.GetGBuffers(), m_CameraDepthBufferRT, ClearFlag.ClearColor, Color.black);
}
// END TEMP

void RenderOpaqueRenderList(CullResults cull, Camera camera, RenderLoop renderLoop, string passName, RendererConfiguration rendererConfiguration = 0)
void RenderOpaqueRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, string passName, RendererConfiguration rendererConfiguration = 0)
{
if (!debugParameters.displayOpaqueObjects)
return;

sorting = { flags = SortFlags.CommonOpaque }
};
settings.inputFilter.SetQueuesOpaque();
renderLoop.DrawRenderers(ref settings);
renderContext.DrawRenderers(ref settings);
void RenderTransparentRenderList(CullResults cull, Camera camera, RenderLoop renderLoop, string passName, RendererConfiguration rendererConfiguration = 0)
void RenderTransparentRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, string passName, RendererConfiguration rendererConfiguration = 0)
{
if (!debugParameters.displayTransparentObjects)
return;

sorting = { flags = SortFlags.CommonTransparent }
};
settings.inputFilter.SetQueuesTransparent();
renderLoop.DrawRenderers(ref settings);
renderContext.DrawRenderers(ref settings);
void RenderDepthPrepass(CullResults cull, Camera camera, RenderLoop renderLoop)
void RenderDepthPrepass(CullResults cull, Camera camera, ScriptableRenderContext renderContext)
{
// If we are forward only we will do a depth prepass
// TODO: Depth prepass should be enabled based on light loop settings. LightLoop define if they need a depth prepass + forward only...

using (new Utilities.ProfilingSample("Depth Prepass", renderLoop))
using (new Utilities.ProfilingSample("Depth Prepass", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderLoop, "DepthOnly");
Utilities.SetRenderTarget(renderContext, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderContext, "DepthOnly");
void RenderGBuffer(CullResults cull, Camera camera, RenderLoop renderLoop)
void RenderGBuffer(CullResults cull, Camera camera, ScriptableRenderContext renderContext)
{
if (debugParameters.useForwardRenderingOnly)
{

using (new Utilities.ProfilingSample("GBuffer Pass", renderLoop))
using (new Utilities.ProfilingSample("GBuffer Pass", renderContext))
Utilities.SetRenderTarget(renderLoop, m_gbufferManager.GetGBuffers(), m_CameraDepthBufferRT);
Utilities.SetRenderTarget(renderContext, m_gbufferManager.GetGBuffers(), m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderLoop, "GBuffer", Utilities.kRendererConfigurationBakedLighting);
RenderOpaqueRenderList(cull, camera, renderContext, "GBuffer", Utilities.kRendererConfigurationBakedLighting);
void RenderForwardOpaqueDepth(CullResults cull, Camera camera, RenderLoop renderLoop)
void RenderForwardOnlyDepthPrepass(CullResults cull, Camera camera, ScriptableRenderContext renderContext)
// If we have render a depth prepass, no need for this pass
if (debugParameters.useDepthPrepass)
// If we are forward only we don't need to render ForwardOpaqueDepth object
// But in case we request a prepass we render it
if (debugParameters.useForwardRenderingOnly && !debugParameters.useDepthPrepass)
using (new Utilities.ProfilingSample("Forward opaque depth", renderLoop))
using (new Utilities.ProfilingSample("Forward opaque depth", renderContext))
// TODO: Use the render queue index to only send the forward opaque!
// or use the new MAterial.SetPassEnable ?
Utilities.SetRenderTarget(renderLoop, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderLoop, "DepthOnly");
Utilities.SetRenderTarget(renderContext, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderContext, "ForwardOnlyDepthOnly");
void RenderDebugViewMaterial(CullResults cull, Camera camera, RenderLoop renderLoop)
void RenderDebugViewMaterial(CullResults cull, HDCamera hdCamera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("DebugView Material Mode Pass", renderLoop))
using (new Utilities.ProfilingSample("DebugView Material Mode Pass", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT, Utilities.kClearAll, Color.black);
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT, Utilities.kClearAll, Color.black);
RenderOpaqueRenderList(cull, camera, renderLoop, "DebugViewMaterial");
RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, "DebugViewMaterial");
Vector4 screenSize = Utilities.ComputeScreenSize(camera);
m_DebugViewMaterialGBuffer.SetVector("_ScreenSize", screenSize);
Utilities.SetupMaterialHDCamera(hdCamera, m_DebugViewMaterialGBuffer);
m_DebugViewMaterialGBuffer.SetFloat("_DebugViewMaterial", (float)debugParameters.debugViewMaterial);
// m_gbufferManager.BindBuffers(m_DebugViewMaterialGBuffer);

renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
RenderTransparentRenderList(cull, camera, renderLoop, "DebugViewMaterial");
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, "DebugViewMaterial");
}
// Last blit

renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
void RenderDeferredLighting(Camera camera, RenderLoop renderLoop)
void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext)
{
if (debugParameters.useForwardRenderingOnly)
{

// Bind material data
m_LitRenderLoop.Bind();
m_lightLoop.RenderDeferredLighting(camera, renderLoop, m_CameraColorBuffer);
m_lightLoop.RenderDeferredLighting(hdCamera, renderContext, m_CameraColorBuffer);
}
void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext)
{
m_SkyManager.UpdateEnvironment(hdCamera, m_lightLoop.GetCurrentSunLight(), renderContext);
void RenderSky(Camera camera, RenderLoop renderLoop)
void RenderSky(HDCamera hdCamera, ScriptableRenderContext renderContext)
m_SkyRenderer.RenderSky(camera, m_SkyParameters, m_CameraColorBufferRT, m_CameraDepthBufferRT, renderLoop);
m_SkyManager.RenderSky(hdCamera, m_lightLoop.GetCurrentSunLight(), m_CameraColorBufferRT, m_CameraDepthBufferRT, renderContext);
void RenderForward(CullResults cullResults, Camera camera, RenderLoop renderLoop, bool renderOpaque)
void RenderForward(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, bool renderOpaque)
{
// TODO: Currently we can't render opaque object forward when deferred is enabled
// miss option

using (new Utilities.ProfilingSample("Forward Pass", renderLoop))
using (new Utilities.ProfilingSample("Forward Pass", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT);
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT);
m_lightLoop.RenderForward(camera, renderLoop, renderOpaque);
m_lightLoop.RenderForward(camera, renderContext, renderOpaque);
RenderOpaqueRenderList(cullResults, camera, renderLoop, "Forward");
RenderOpaqueRenderList(cullResults, camera, renderContext, "Forward");
RenderTransparentRenderList(cullResults, camera, renderLoop, "Forward", Utilities.kRendererConfigurationBakedLighting);
RenderTransparentRenderList(cullResults, camera, renderContext, "Forward", Utilities.kRendererConfigurationBakedLighting);
void RenderForwardUnlit(CullResults cullResults, Camera camera, RenderLoop renderLoop)
// Render material that are forward opaque only (like eye)
// TODO: Think about hair that could be render both as opaque and transparent...
void RenderForwardOnly(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Forward Unlit Pass", renderLoop))
using (new Utilities.ProfilingSample("Forward Only Pass", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cullResults, camera, renderLoop, "ForwardUnlit");
RenderTransparentRenderList(cullResults, camera, renderLoop, "ForwardUnlit");
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT);
m_lightLoop.RenderForward(camera, renderContext, true);
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardOnly");
void RenderVelocity(CullResults cullResults, Camera camera, RenderLoop renderLoop)
void RenderForwardUnlit(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
{
using (new Utilities.ProfilingSample("Forward Unlit Pass", renderContext))
{
// Bind material data
m_LitRenderLoop.Bind();
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardUnlit");
RenderTransparentRenderList(cullResults, camera, renderContext, "ForwardUnlit");
}
}
void RenderVelocity(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Velocity Pass", renderLoop))
using (new Utilities.ProfilingSample("Velocity Pass", renderContext))
// warning CS0162: Unreachable code detected // warning CS0429: Unreachable expression code detected
#pragma warning disable 162, 429
if ((ShaderConfig.VelocityInGbuffer == 0) || debugParameters.useForwardRenderingOnly)
if ((ShaderConfig.s_VelocityInGbuffer == 0) || debugParameters.useForwardRenderingOnly)
return ;
int w = camera.pixelWidth;

cmd.GetTemporaryRT(m_VelocityBuffer, w, h, 0, FilterMode.Point, Builtin.RenderLoop.GetVelocityBufferFormat(), Builtin.RenderLoop.GetVelocityBufferReadWrite());
cmd.SetRenderTarget(m_VelocityBufferRT, m_CameraDepthBufferRT);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
RenderOpaqueRenderList(cullResults, camera, renderLoop, "MotionVectors");
#pragma warning restore 162, 429
RenderOpaqueRenderList(cullResults, camera, renderContext, "MotionVectors");
void RenderDistortion(CullResults cullResults, Camera camera, RenderLoop renderLoop)
void RenderDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Distortion Pass", renderLoop))
if (!debugParameters.useDistortion)
return ;
using (new Utilities.ProfilingSample("Distortion Pass", renderContext))
{
int w = camera.pixelWidth;
int h = camera.pixelHeight;

cmd.SetRenderTarget(m_DistortionBufferRT, m_CameraDepthBufferRT);
renderLoop.ExecuteCommandBuffer(cmd);
cmd.ClearRenderTarget(false, true, Color.black); // TODO: can we avoid this clear for performance ?
renderContext.ExecuteCommandBuffer(cmd);
RenderTransparentRenderList(cullResults, camera, renderLoop, "DistortionVectors");
RenderTransparentRenderList(cullResults, camera, renderContext, "DistortionVectors");
#if UNITY_EDITOR
public override void RenderSceneView(Camera camera, RenderLoop renderLoop)
{
base.RenderSceneView(camera, renderLoop);
renderLoop.PrepareForEditorRendering(camera, m_CameraDepthBufferRT);
renderLoop.Submit();
}
#endif
void FinalPass(RenderLoop renderLoop)
void FinalPass(ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Final Pass", renderLoop))
using (new Utilities.ProfilingSample("Final Pass", renderContext))
{
// Those could be tweakable for the neutral tonemapper, but in the case of the LookDev we don't need that
const float blackIn = 0.02f;

// Resolve our HDR texture to CameraTarget.
cmd.Blit(m_CameraColorBufferRT, BuiltinRenderTextureType.CameraTarget, m_FinalPassMaterial, 0);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}

void PrepareLightsForGPU(CullResults cullResults, Camera camera, ref ShadowOutput shadowOutput)
void PrepareLightsForGPU(ShadowSettings shadowSettings, CullResults cullResults, Camera camera, ref ShadowOutput shadowOutput)
m_lightLoop.PrepareLightsForGPU(cullResults, camera, ref shadowOutput);
m_lightLoop.PrepareLightsForGPU(shadowSettings, cullResults, camera, ref shadowOutput);
}
void Resize(Camera camera)

// TODO: This is the wrong way to handle resize/allocation. We can have several different camera here, mean that the loop on camera will allocate and deallocate
// the below buffer which is bad. Best is to have a set of buffer for each camera that is persistent and reallocate resource if need
// For now consider we have only one camera that go to this code, the main one.
m_SkyRenderer.Resize(m_SkyParameters); // TODO: Also a bad naming, here we just want to realloc texture if skyparameters change (usefull for lookdev)
m_SkyManager.Resize(); // TODO: Also a bad naming, here we just want to realloc texture if skyparameters change (usefull for lookdev)
if (camera.pixelWidth != m_WidthOnRecord || camera.pixelHeight != m_HeightOnRecord || m_lightLoop.NeedResize())
if (camera.pixelWidth != m_currentWidth || camera.pixelHeight != m_currentHeight || m_lightLoop.NeedResize())
if (m_WidthOnRecord > 0 && m_HeightOnRecord > 0)
if (m_currentWidth > 0 && m_currentHeight > 0)
{
m_lightLoop.ReleaseResolutionDependentBuffers();
}

// update recorded window resolution
m_WidthOnRecord = camera.pixelWidth;
m_HeightOnRecord = camera.pixelHeight;
m_currentWidth = camera.pixelWidth;
m_currentHeight = camera.pixelHeight;
public void PushGlobalParams(Camera camera, RenderLoop renderLoop)
public void PushGlobalParams(HDCamera hdCamera, ScriptableRenderContext renderContext)
if (m_SkyRenderer.IsSkyValid(m_SkyParameters))
if (m_SkyManager.IsSkyValid())
m_SkyRenderer.SetGlobalSkyTexture();
m_SkyManager.SetGlobalSkyTexture();
Shader.SetGlobalInt("_EnvLightSkyEnabled", 1);
}
else

m_lightLoop.PushGlobalParams(camera, renderLoop);
var cmd = new CommandBuffer { name = "Push Global Parameters" };
cmd.SetGlobalVector("_ScreenSize", hdCamera.screenSize);
cmd.SetGlobalMatrix("_ViewProjMatrix", hdCamera.viewProjectionMatrix);
cmd.SetGlobalMatrix("_InvViewProjMatrix", hdCamera.invViewProjectionMatrix);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
m_lightLoop.PushGlobalParams(hdCamera.camera, renderContext);
public override void Render(Camera[] cameras, RenderLoop renderLoop)
void UpdateCommonSettings()
if (m_Dirty)
if(m_CommonSettings == null)
Rebuild();
m_ShadowSettings.maxShadowDistance = ShadowSettings.Default.maxShadowDistance;
m_ShadowSettings.directionalLightCascadeCount = ShadowSettings.Default.directionalLightCascadeCount;
m_ShadowSettings.directionalLightCascades = ShadowSettings.Default.directionalLightCascades;
else
{
m_ShadowSettings.directionalLightCascadeCount = m_CommonSettings.shadowCascadeCount;
m_ShadowSettings.directionalLightCascades = new Vector3(m_CommonSettings.shadowCascadeSplit0, m_CommonSettings.shadowCascadeSplit1, m_CommonSettings.shadowCascadeSplit2);
m_ShadowSettings.maxShadowDistance = m_CommonSettings.shadowMaxDistance;
}
}
public void Render(ScriptableRenderContext renderContext, IEnumerable<Camera> cameras)
{
m_LitRenderLoop.RenderInit(renderLoop);
m_LitRenderLoop.RenderInit(renderContext);
UpdateCommonSettings();
// Set Frame constant buffer
// TODO...

m_ShadowPass.UpdateCullingParameters(ref cullingParams);
var cullResults = CullResults.Cull(ref cullingParams, renderLoop);
var cullResults = CullResults.Cull(ref cullingParams, renderContext);
renderLoop.SetupCameraProperties(camera);
renderContext.SetupCameraProperties(camera);
InitAndClearBuffer(camera, renderLoop);
HDCamera hdCamera = Utilities.GetHDCamera(camera);
RenderDepthPrepass(cullResults, camera, renderLoop);
InitAndClearBuffer(camera, renderContext);
RenderGBuffer(cullResults, camera, renderLoop);
RenderDepthPrepass(cullResults, camera, renderContext);
// Forward opaque with deferred tile require that we fill the depth buffer
// Forward opaque with deferred/cluster tile require that we fill the depth buffer
// TODO: ask Morten why this pass is not before GBuffer ? Will make more sense and avoid
// to do gbuffer pass on unseen mesh.
// TODO: how do we select only the object that must be render forward ?
// this is all object with gbuffer pass disabled ?
//RenderForwardOpaqueDepth(cullResults, camera, renderLoop);
RenderForwardOnlyDepthPrepass(cullResults, camera, renderContext);
RenderGBuffer(cullResults, camera, renderContext);
RenderDebugViewMaterial(cullResults, camera, renderLoop);
RenderDebugViewMaterial(cullResults, hdCamera, renderContext);
using (new Utilities.ProfilingSample("Shadow Pass", renderLoop))
using (new Utilities.ProfilingSample("Shadow Pass", renderContext))
m_ShadowPass.Render(renderLoop, cullResults, out shadows);
}
renderLoop.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
m_ShadowPass.Render(renderContext, cullResults, out shadows);
}
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
using (new Utilities.ProfilingSample("Build Light list", renderLoop))
using (new Utilities.ProfilingSample("Build Light list", renderContext))
m_lightLoop.PrepareLightsForGPU(cullResults, camera, ref shadows);
m_lightLoop.BuildGPULightLists(camera, renderLoop, m_CameraDepthBufferRT);
m_lightLoop.PrepareLightsForGPU(m_ShadowSettings, cullResults, camera, ref shadows);
m_lightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthBufferRT);
PushGlobalParams(camera, renderLoop);
}
RenderDeferredLighting(camera, renderLoop);
PushGlobalParams(hdCamera, renderContext);
}
UpdateSkyEnvironment(hdCamera, renderContext);
// TODO: enable this for tile forward opaque
// RenderForward(cullResults, camera, renderLoop, true);
RenderDeferredLighting(hdCamera, renderContext);
RenderSky(camera, renderLoop);
RenderForward(cullResults, camera, renderContext, true);
RenderForwardOnly(cullResults, camera, renderContext);
RenderForward(cullResults, camera, renderLoop, false);
RenderSky(hdCamera, renderContext);
RenderForwardUnlit(cullResults, camera, renderLoop);
RenderForward(cullResults, camera, renderContext, false);
RenderVelocity(cullResults, camera, renderLoop); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
RenderForwardUnlit(cullResults, camera, renderContext);
RenderVelocity(cullResults, camera, renderContext); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
// RenderDistortion(cullResults, camera, renderLoop);
RenderDistortion(cullResults, camera, renderContext);
FinalPass(renderLoop);
FinalPass(renderContext);
renderLoop.Submit();
}
// bind depth surface for editor grid/gizmo/selection rendering
if (camera.cameraType == CameraType.SceneView)
{
var cmd = new CommandBuffer();
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, m_CameraDepthBufferRT);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
renderContext.Submit();
}
// Post effects
}
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit.meta


fileFormatVersion: 2
guid: d43c06a2afd9f2f4ab88a7a94c43e1a6
guid: e173dfe6cd75d954b95306237244f6de
folderAsset: yes
timeCreated: 1476653183
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit.meta


fileFormatVersion: 2
guid: 24406b9cf8c7f2543b7d20ead11e37d5
guid: d6cadd3aaf3ad6641b86e85a0929b245
folderAsset: yes
timeCreated: 1476653183
licenseType: Pro

27
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl


//-------------------------------------------------------------------------------------
// FragInput
// FragInputs
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Debug/DebugViewMaterial.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl"
struct FragInput
struct FragInputs
float4 unPositionSS; // This is the position return by VPOS (That is name positionCS in PackedVarying), only xy is use
// Contain value return by SV_POSITION (That is name positionCS in PackedVarying).
// xy: unormalized screen position (offset by 0.5), z: device depth, w: depth in view space
// Note: SV_POSITION is the result of the clip space position provide to the vertex shaders that is transform by the viewport
float4 unPositionSS; // In case depth offset is use, positionWS.w is equal to depth offset
float3 positionWS;
float2 texCoord0;
float2 texCoord1;

float4 vertexColor;
// For velocity
// Note: Z component is not use
float4 positionCS; // This is the clip spae position. Warning, do not confuse with the value of positionCS in PackedVarying which is VPOS and store in unPositionSS
// CAUTION: Only use with velocity currently, null else
// Note: Z component is not use currently
// This is the clip space position. Warning, do not confuse with the value of positionCS in PackedVarying which is SV_POSITION and store in unPositionSS
float4 positionCS;
// end velocity specific
void GetVaryingsDataDebug(uint paramId, FragInput input, inout float3 result, inout bool needLinearToSRGB)
void ApplyDepthOffsetAttribute(float depthOffsetVS, inout FragInputs fragInput)
{
fragInput.positionCS.w += depthOffsetVS;
fragInput.previousPositionCS.w += depthOffsetVS;
}
void GetVaryingsDataDebug(uint paramId, FragInputs input, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{

7
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs


public Vector2 distortion;
[SurfaceDataAttributes("Distortion Blur")]
public float distortionBlur; // Define the color buffer mipmap level to use
// Depth
[SurfaceDataAttributes("Depth Offset")]
public float depthOffset; // define the depth in unity unit to add in Z forward direction
};
//-----------------------------------------------------------------------------

public static RenderTextureFormat GetDistortionBufferFormat()
{
return RenderTextureFormat.ARGBHalf; // This format need to be blendable and include distortionBlur
// TODO: // This format need to be additive blendable and include distortionBlur, blend mode different for alpha value
return RenderTextureFormat.ARGBHalf;
}
public static RenderTextureReadWrite GetDistortionBufferReadWrite()

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Material/Builtin/BuiltinData.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs. Please don't edit by hand.
//
#ifndef BUILTINDATA_CS_HLSL

#define DEBUGVIEW_BUILTIN_BUILTINDATA_VELOCITY (104)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION (105)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION_BLUR (106)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET (107)
//
// UnityEngine.Experimental.ScriptableRenderLoop.Builtin.LighTransportData: static fields

float2 velocity;
float2 distortion;
float distortionBlur;
float depthOffset;
};
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Builtin.LighTransportData

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitSharePass.hlsl


return output;
}
FragInput UnpackVaryings(PackedVaryings input)
FragInputs UnpackVaryings(PackedVaryings input)
FragInput output;
ZERO_INITIALIZE(FragInput, output);
FragInputs output;
ZERO_INITIALIZE(FragInputs, output);
output.unPositionSS = input.positionCS;
output.texCoord0.xy = input.interpolators[0].xy;

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitData.hlsl


// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
void GetSurfaceAndBuiltinData(FragInput input, out SurfaceData surfaceData, out BuiltinData builtinData)
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
surfaceData.color = SAMPLE_TEXTURE2D(_ColorMap, sampler_ColorMap, input.texCoord0).rgb * _Color.rgb;
float alpha = SAMPLE_TEXTURE2D(_ColorMap, sampler_ColorMap, input.texCoord0).a * _Color.a;

builtinData.distortion = float2(0.0, 0.0);
builtinData.distortionBlur = 0.0;
builtinData.depthOffset = 0.0;
}

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


Shader "HDRenderLoop/Unlit"
Shader "HDRenderPipeline/Unlit"
{
Properties
{

//-------------------------------------------------------------------------------------
#include "common.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Material/Attributes.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPass.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration

return output;
}
FragInput UnpackVaryings(PackedVaryings input)
FragInputs UnpackVaryings(PackedVaryings input)
FragInput output;
ZERO_INITIALIZE(FragInput, output);
FragInputs output;
ZERO_INITIALIZE(FragInputs, output);
output.unPositionSS = input.positionCS;
output.texCoord0 = input.interpolators[0].xy;

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

正在加载...
取消
保存