浏览代码

Merge pull request #71 from Unity-Technologies/Renaming-HDRenderLoop

Renaming hdrenderloop to hd renderPipeline
/main
GitHub 8 年前
当前提交
23f2ee44
共有 154 个文件被更改,包括 1691 次插入377 次删除
  1. 8
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 2
      Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
  3. 12
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  4. 10
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  5. 2
      Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs
  6. 10
      ProjectSettings/GraphicsSettings.asset
  7. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl
  8. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
  9. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
  10. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
  11. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl
  12. 26
      Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/CommonSettings.cs
  13. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl
  14. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  15. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/UpgradeStandardShaderMaterials.cs
  16. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderLoopMenuItems.cs
  17. 46
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderLoopInspector.cs
  18. 220
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.cs
  19. 52
      Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
  20. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
  21. 22
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  22. 120
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute
  23. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
  24. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Lighting.hlsl
  25. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs
  26. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
  27. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl
  28. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl
  29. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
  30. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl
  31. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  32. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  33. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
  34. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardToHDLitMaterialUpgrader.cs
  35. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardSpecularToHDLitMaterialUpgrader.cs
  36. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  37. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs
  38. 18
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyParameters.cs
  39. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl
  40. 42
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs
  41. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
  42. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
  43. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  44. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
  45. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
  46. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline.meta
  47. 24
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  48. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta
  49. 110
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.hlsl
  50. 1001
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  51. 151
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Material.hlsl
  52. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl.meta
  53. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl.meta
  54. 9
      Assets/ScriptableRenderLoop/HDRenderLoop.meta
  55. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.asset
  56. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.asset.meta
  57. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.cs.meta
  58. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow
  59. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Debug.meta
  60. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta
  61. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta
  62. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess.meta
  63. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs
  64. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl.meta
  65. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.meta
  66. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass.meta
  67. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl.meta
  68. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow.meta
  69. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl
  70. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess
  71. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Debug
  72. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Editor.meta
  73. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Sky.meta
  74. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs.meta
  75. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings.meta
  76. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings
  77. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl.meta
  78. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl.meta
  79. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl.meta
  80. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl.meta
  81. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs
  82. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl
  83. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.meta
  84. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl.meta
  85. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  86. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl.meta
  87. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl
  88. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl.meta
  89. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl
  90. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
  91. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl
  92. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl.meta
  93. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
  94. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl

8
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


public class BasicRenderLoop : RenderPipelineAsset
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/Create BasicRenderLoop")]
[UnityEditor.MenuItem("RenderPipeline/Create BasicRenderLoop")]
static void CreateBasicRenderLoop()
{
var instance = ScriptableObject.CreateInstance<BasicRenderLoop>();

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

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


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

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


public class RenderLoopTestFixtureInstance : RenderPipeline
{
public delegate void TestDelegate(Camera camera, CullResults cullResults, ScriptableRenderContext renderLoop);
public delegate void TestDelegate(Camera camera, CullResults cullResults, ScriptableRenderContext renderContext);
public override void Render(ScriptableRenderContext renderLoop, Camera[] cameras)
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
base.Render(renderLoop, cameras);
base.Render(renderContext, cameras);
foreach (var camera in cameras)
{

bool gotCullingParams = CullResults.GetCullingParameters(camera, out cullingParams);
Assert.IsTrue(gotCullingParams);
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)

10
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


public class FptlLighting : RenderPipelineAsset
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/CreateRenderLoopFPTL")]
[UnityEditor.MenuItem("RenderPipeline/CreateRenderLoopFPTL")]
static void CreateRenderLoopFPTL()
{
var instance = ScriptableObject.CreateInstance<FptlLighting>();

return numLightsOut + numProbesOut;
}
public void Render(ScriptableRenderContext renderLoop, IEnumerable<Camera> cameras)
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(ScriptableRenderContext loop)

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

10
ProjectSettings/GraphicsSettings.asset


--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 10
serializedVersion: 11
m_Deferred:
m_Mode: 0
m_Shader: {fileID: 0}

m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 11400000, guid: 2400b74f5ce370c4481e5dc417d03703,
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: 1
m_LightsUseCCT: 1

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

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

8
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
//-------------------------------------------------------------------------------------
// variable declaration

10
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"
DECLARE_GBUFFER_TEXTURE(_GBufferTexture);

2
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

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


void OnEnable()
{
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop();
if (renderLoop == null)
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
if (renderLoop.commonSettings == null)
renderLoop.commonSettings = this;
else if (renderLoop.commonSettings != this)
if (renderPipeline.commonSettings == null)
renderPipeline.commonSettings = this;
else if (renderPipeline.commonSettings != this)
Debug.LogWarning("Only one CommonSettings can be setup at a time.");
OnSkyRendererChanged();

{
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop();
if (renderLoop == null)
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
if (renderLoop.commonSettings == this)
renderLoop.commonSettings = null;
if (renderPipeline.commonSettings == this)
renderPipeline.commonSettings = null;
}
void OnValidate()

void OnSkyRendererChanged()
{
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop();
if (renderLoop == null)
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
renderLoop.InstantiateSkyRenderer(skyRendererType);
renderPipeline.InstantiateSkyRenderer(skyRendererType);
Type skyParamType = renderLoop.skyManager.GetSkyParameterType();
Type skyParamType = renderPipeline.skyManager.GetSkyParameterType();
// Disable all incompatible sky parameters and enable the compatible one
bool found = false;

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

2
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
#define EMISSIVE_RGBM_SCALE 97.0
float4 Frag(PackedVaryings packedInput) : SV_Target

10
Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/UpgradeStandardShaderMaterials.cs


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

return upgraders;
}
[MenuItem("HDRenderLoop/Upgrade Materials - Project")]
[MenuItem("HDRenderPipeline/Upgrade Materials - Project")]
[MenuItem("HDRenderLoop/Upgrade Materials - Selection")]
[MenuItem("HDRenderPipeline/Upgrade Materials - Selection")]
[MenuItem("HDRenderLoop/Modify Light Intensity for Upgrade - Scene Only")]
[MenuItem("HDRenderPipeline/Modify Light Intensity for Upgrade - Scene Only")]
static void UpgradeLights()
{
Light[] lights = Light.GetLights(LightType.Directional, 0);

}
}
}
}
}

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderLoopMenuItems.cs


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public class HDRenderLoopMenuItems
public class HDRenderPipelineMenuItems
[UnityEditor.MenuItem("HDRenderLoop/Create Scene Settings")]
[UnityEditor.MenuItem("HDRenderPipeline/Create Scene Settings")]
static void CreateSceneSettings()
{
CommonSettings[] settings = Object.FindObjectsOfType(typeof(CommonSettings)) as CommonSettings[];

46
Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderLoopInspector.cs


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[CustomEditor(typeof(HDRenderLoop))]
public class HDRenderLoopInspector : Editor
[CustomEditor(typeof(HDRenderPipeline))]
public class HDRenderPipelineInspector : Editor
{
private class Styles
{

}
}
private void DebugParametersUI(HDRenderLoop renderLoop)
private void DebugParametersUI(HDRenderPipeline renderContext)
var debugParameters = renderLoop.debugParameters;
var debugParameters = renderContext.debugParameters;
EditorGUILayout.LabelField(styles.debugParameters);
EditorGUI.indentLevel++;

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
EditorUtility.SetDirty(renderContext); // Repaint
private void ShadowParametersUI(HDRenderLoop renderLoop)
private void ShadowParametersUI(HDRenderPipeline renderContext)
var shadowParameters = renderLoop.shadowSettings;
var shadowParameters = renderContext.shadowSettings;
EditorGUILayout.LabelField(styles.shadowSettings);
EditorGUI.indentLevel++;

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
EditorUtility.SetDirty(renderContext); // Repaint
private void TextureParametersUI(HDRenderLoop renderLoop)
private void TextureParametersUI(HDRenderPipeline renderContext)
var textureParameters = renderLoop.textureSettings;
var textureParameters = renderContext.textureSettings;
EditorGUILayout.LabelField(styles.textureSettings);
EditorGUI.indentLevel++;

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

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
EditorUtility.SetDirty(renderContext); // Repaint
renderLoop.DestroyCreatedInstances();
renderContext.DestroyCreatedInstances();
}
EditorGUI.BeginChangeCheck();

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
EditorUtility.SetDirty(renderContext); // Repaint
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
EditorGUI.indentLevel--;

public override void OnInspectorGUI()
{
var renderLoop = target as HDRenderLoop;
var renderContext = target as HDRenderPipeline;
if (!renderLoop)
if (!renderContext)
DebugParametersUI(renderLoop);
ShadowParametersUI(renderLoop);
TextureParametersUI(renderLoop);
TilePassUI(renderLoop);
DebugParametersUI(renderContext);
ShadowParametersUI(renderContext);
TextureParametersUI(renderContext);
TilePassUI(renderContext);
}
}
}

220
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.cs


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public class HDRenderLoopInstance : RenderPipeline
public class HDRenderPipelineInstance : RenderPipeline
private readonly HDRenderLoop m_Owner;
private readonly HDRenderPipeline m_Owner;
public HDRenderLoopInstance(HDRenderLoop owner)
public HDRenderPipelineInstance(HDRenderPipeline owner)
{
m_Owner = owner;

}
[ExecuteInEditMode]
// This HDRenderLoop assume linear lighting. Don't work with gamma.
public class HDRenderLoop : RenderPipelineAsset
// 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[];

protected override IRenderPipeline InternalCreatePipeline()
{
return new HDRenderLoopInstance(this);
return new HDRenderPipelineInstance(this);
}
SkyManager m_SkyManager = new SkyManager();

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

UnityEngine.Rendering.GraphicsSettings.lightsUseCCT = previousLightsUseCCT;
}
void InitAndClearBuffer(Camera camera, ScriptableRenderContext 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
int w = camera.pixelWidth;
int h = camera.pixelHeight;

{
m_gbufferManager.InitGBuffers(w, h, cmd);
}
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, ScriptableRenderContext 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, ScriptableRenderContext 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, ScriptableRenderContext 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, ScriptableRenderContext 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 RenderForwardOnlyDepthPrepass(CullResults cull, Camera camera, ScriptableRenderContext renderLoop)
void RenderForwardOnlyDepthPrepass(CullResults cull, Camera camera, ScriptableRenderContext renderContext)
{
// If we are forward only we don't need to render ForwardOpaqueDepth object
// But in case we request a prepass we render it

using (new Utilities.ProfilingSample("Forward opaque depth", renderLoop))
using (new Utilities.ProfilingSample("Forward opaque depth", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderLoop, "ForwardOnlyDepthOnly");
Utilities.SetRenderTarget(renderContext, m_CameraDepthBufferRT);
RenderOpaqueRenderList(cull, camera, renderContext, "ForwardOnlyDepthOnly");
void RenderDebugViewMaterial(CullResults cull, HDCamera hdCamera, ScriptableRenderContext 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, hdCamera.camera, renderLoop, "DebugViewMaterial");
RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, "DebugViewMaterial");
}
// Render GBuffer opaque

// TODO: Bind depth textures
var cmd = new CommandBuffer { name = "GBuffer Debug Pass" };
cmd.Blit(null, m_CameraColorBufferRT, m_DebugViewMaterialGBuffer, 0);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
RenderTransparentRenderList(cull, hdCamera.camera, renderLoop, "DebugViewMaterial");
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, "DebugViewMaterial");
}
// Last blit

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

// Bind material data
m_LitRenderLoop.Bind();
m_lightLoop.RenderDeferredLighting(hdCamera, renderLoop, m_CameraColorBuffer);
m_lightLoop.RenderDeferredLighting(hdCamera, renderContext, m_CameraColorBuffer);
void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderLoop)
void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext)
m_SkyManager.UpdateEnvironment(hdCamera, m_lightLoop.GetCurrentSunLight(), renderLoop);
m_SkyManager.UpdateEnvironment(hdCamera, m_lightLoop.GetCurrentSunLight(), renderContext);
void RenderSky(HDCamera hdCamera, ScriptableRenderContext renderLoop)
void RenderSky(HDCamera hdCamera, ScriptableRenderContext renderContext)
m_SkyManager.RenderSky(hdCamera, m_lightLoop.GetCurrentSunLight(), m_CameraColorBufferRT, m_CameraDepthBufferRT, renderLoop);
m_SkyManager.RenderSky(hdCamera, m_lightLoop.GetCurrentSunLight(), m_CameraColorBufferRT, m_CameraDepthBufferRT, renderContext);
void RenderForward(CullResults cullResults, Camera camera, ScriptableRenderContext 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 RenderForwardOnly(CullResults cullResults, Camera camera, ScriptableRenderContext renderLoop)
void RenderForwardOnly(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Forward Only Pass", renderLoop))
using (new Utilities.ProfilingSample("Forward Only Pass", renderContext))
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT);
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT);
m_lightLoop.RenderForward(camera, renderLoop, true);
RenderOpaqueRenderList(cullResults, camera, renderLoop, "ForwardOnly");
m_lightLoop.RenderForward(camera, renderContext, true);
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardOnly");
void RenderForwardUnlit(CullResults cullResults, Camera camera, ScriptableRenderContext renderLoop)
void RenderForwardUnlit(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Forward Unlit Pass", renderLoop))
using (new Utilities.ProfilingSample("Forward Unlit 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);
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardUnlit");
RenderTransparentRenderList(cullResults, camera, renderContext, "ForwardUnlit");
void RenderVelocity(CullResults cullResults, Camera camera, ScriptableRenderContext renderLoop)
void RenderVelocity(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Velocity Pass", renderLoop))
using (new Utilities.ProfilingSample("Velocity Pass", renderContext))
{
// If opaque velocity have been render during GBuffer no need to render it here
if ((ShaderConfig.s_VelocityInGbuffer == 0) || debugParameters.useForwardRenderingOnly)

var cmd = new CommandBuffer { name = "" };
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");
RenderOpaqueRenderList(cullResults, camera, renderContext, "MotionVectors");
void RenderDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderLoop)
void RenderDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Distortion Pass", renderLoop))
using (new Utilities.ProfilingSample("Distortion Pass", renderContext))
{
int w = camera.pixelWidth;
int h = camera.pixelHeight;

cmd.SetRenderTarget(m_DistortionBufferRT, m_CameraDepthBufferRT);
cmd.ClearRenderTarget(false, true, Color.black); // TODO: can we avoid this clear for performance ?
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
RenderTransparentRenderList(cullResults, camera, renderLoop, "DistortionVectors");
RenderTransparentRenderList(cullResults, camera, renderContext, "DistortionVectors");
void FinalPass(ScriptableRenderContext 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();
}
}

}
}
public void PushGlobalParams(HDCamera hdCamera, ScriptableRenderContext renderLoop)
public void PushGlobalParams(HDCamera hdCamera, ScriptableRenderContext renderContext)
{
if (m_SkyManager.IsSkyValid())
{

cmd.SetGlobalMatrix("_ViewProjMatrix", hdCamera.viewProjectionMatrix);
cmd.SetGlobalMatrix("_InvViewProjMatrix", hdCamera.invViewProjectionMatrix);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
m_lightLoop.PushGlobalParams(hdCamera.camera, renderLoop);
m_lightLoop.PushGlobalParams(hdCamera.camera, renderContext);
}
void UpdateCommonSettings()

}
}
public void Render(ScriptableRenderContext renderLoop, IEnumerable<Camera> cameras)
public void Render(ScriptableRenderContext renderContext, IEnumerable<Camera> cameras)
m_LitRenderLoop.RenderInit(renderLoop);
m_LitRenderLoop.RenderInit(renderContext);
}
// Do anything we need to do upon a new frame.

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);
InitAndClearBuffer(camera, renderContext);
RenderDepthPrepass(cullResults, camera, renderLoop);
RenderDepthPrepass(cullResults, camera, renderContext);
RenderForwardOnlyDepthPrepass(cullResults, camera, renderLoop);
RenderGBuffer(cullResults, camera, renderLoop);
RenderForwardOnlyDepthPrepass(cullResults, camera, renderContext);
RenderGBuffer(cullResults, camera, renderContext);
RenderDebugViewMaterial(cullResults, hdCamera, 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);
m_ShadowPass.Render(renderContext, cullResults, out shadows);
renderLoop.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
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.BuildGPULightLists(camera, renderLoop, m_CameraDepthBufferRT);
m_lightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthBufferRT);
PushGlobalParams(hdCamera, renderLoop);
PushGlobalParams(hdCamera, renderContext);
UpdateSkyEnvironment(hdCamera, renderLoop);
UpdateSkyEnvironment(hdCamera, renderContext);
RenderDeferredLighting(hdCamera, renderLoop);
RenderDeferredLighting(hdCamera, renderContext);
RenderForward(cullResults, camera, renderLoop, true);
RenderForwardOnly(cullResults, camera, renderLoop);
RenderForward(cullResults, camera, renderContext, true);
RenderForwardOnly(cullResults, camera, renderContext);
RenderSky(hdCamera, renderLoop);
RenderSky(hdCamera, renderContext);
RenderForward(cullResults, camera, renderLoop, false);
RenderForward(cullResults, camera, renderContext, false);
RenderForwardUnlit(cullResults, camera, renderLoop);
RenderForwardUnlit(cullResults, camera, renderContext);
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 ?
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);
}
// bind depth surface for editor grid/gizmo/selection rendering

cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, m_CameraDepthBufferRT);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
renderLoop.Submit();
renderContext.Submit();
}
// Post effects

52
Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs


// Render Target Management.
public const ClearFlag kClearAll = ClearFlag.ClearDepth | ClearFlag.ClearColor;
public static void SetRenderTarget(ScriptableRenderContext renderLoop, RenderTargetIdentifier buffer, ClearFlag clearFlag = ClearFlag.ClearNone, 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(ScriptableRenderContext 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(ScriptableRenderContext 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(ScriptableRenderContext 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(ScriptableRenderContext 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(ScriptableRenderContext 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(ScriptableRenderContext 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;
ScriptableRenderContext renderLoop;
ScriptableRenderContext renderContext;
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();
}

return gpuVP;
}
public static HDRenderLoop.HDCamera GetHDCamera(Camera camera)
public static HDRenderPipeline.HDCamera GetHDCamera(Camera camera)
HDRenderLoop.HDCamera hdCamera = new HDRenderLoop.HDCamera();
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);

return hdCamera;
}
public static void SetupMaterialHDCamera(HDRenderLoop.HDCamera hdCamera, Material material)
public static void SetupMaterialHDCamera(HDRenderPipeline.HDCamera hdCamera, Material material)
{
material.SetVector("_ScreenSize", hdCamera.screenSize);
material.SetMatrix("_ViewProjMatrix", hdCamera.viewProjectionMatrix);

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

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


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

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


s_LightList = null;
m_DeferredDirectMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/Deferred");
m_DeferredDirectMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_DeferredIndirectMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/Deferred");
m_DeferredIndirectMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_DeferredAllMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/Deferred");
m_DeferredAllMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_DebugViewTilesMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/DebugViewTiles");
m_DebugViewTilesMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewTiles");
m_SingleDeferredMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/Deferred");
m_SingleDeferredMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Deferred");
m_SingleDeferredMaterial.EnableKeyword("LIGHTLOOP_SINGLE_PASS");
m_DefaultTexture2DArray = new Texture2DArray(1, 1, 1, TextureFormat.ARGB32, false);

}
#endif
public override void RenderDeferredLighting(HDRenderLoop.HDCamera hdCamera, ScriptableRenderContext renderLoop, RenderTargetIdentifier cameraColorBufferRT)
public override void RenderDeferredLighting(HDRenderPipeline.HDCamera hdCamera, ScriptableRenderContext renderContext, RenderTargetIdentifier cameraColorBufferRT)
{
var bUseClusteredForDeferred = !usingFptl;

}
#endif
using (new Utilities.ProfilingSample(disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderLoop))
using (new Utilities.ProfilingSample(disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderContext))
{
var cmd = new CommandBuffer();

// Pass global parameters to compute shader
// TODO: get rid of this by making global parameters visible to compute shaders
BindGlobalParams(cmd, shadeOpaqueShader, kernel, camera, renderLoop);
BindGlobalParams(cmd, shadeOpaqueShader, kernel, camera, renderContext);
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_CameraDepthTexture", Shader.PropertyToID("_CameraDepthTexture"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture0", Shader.PropertyToID("_GBufferTexture0"));

SetGlobalPropertyRedirect(null, 0, null);
//}
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
public override void RenderForward(Camera camera, ScriptableRenderContext renderLoop, bool renderOpaque)
public override void RenderForward(Camera camera, ScriptableRenderContext renderContext, bool renderOpaque)
{
// Note: if we use render opaque with deferred tiling we need to render a opque depth pass for these opaque objects
bool useFptl = renderOpaque && usingFptl;

cmd.SetGlobalBuffer("g_vLightListGlobal", useFptl ? s_LightList : s_PerVoxelLightLists);
}
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}

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


#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST=1
#pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST=1
#define LIGHTLOOP_TILE_PASS 1
#define LIGHTLOOP_TILE_DIRECT 1
#define LIGHTLOOP_TILE_INDIRECT 1
#define LIGHTLOOP_TILE_ALL 1
#define USE_FPTL_LIGHTLIST 1
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "Common.hlsl"
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
// 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
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
DECLARE_GBUFFER_TEXTURE(_GBufferTexture);
TEXTURE2D(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
RWTexture2D<float4> uavOutput;
[numthreads(TILE_SIZE, TILE_SIZE, 1)]
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID)
{
// input.positionCS is SV_Position
uint2 pixelCoord = dispatchThreadId;
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw);
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x;
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS);
BSDFData bsdfData;
float3 bakeDiffuseLighting;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
float3 diffuseLighting;
float3 specularLighting;
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
uavOutput[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0);
}
#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST=1
#pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST=1
#define LIGHTLOOP_TILE_PASS 1
#define LIGHTLOOP_TILE_DIRECT 1
#define LIGHTLOOP_TILE_INDIRECT 1
#define LIGHTLOOP_TILE_ALL 1
#define USE_FPTL_LIGHTLIST 1
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "Common.hlsl"
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
// the deferred shader will require to use multicompile.
#define UNITY_MATERIAL_LIT // Need to be define before including 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
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
DECLARE_GBUFFER_TEXTURE(_GBufferTexture);
TEXTURE2D(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
RWTexture2D<float4> uavOutput;
[numthreads(TILE_SIZE, TILE_SIZE, 1)]
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID)
{
// input.positionCS is SV_Position
uint2 pixelCoord = dispatchThreadId;
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw);
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x;
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS);
BSDFData bsdfData;
float3 bakeDiffuseLighting;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
float3 diffuseLighting;
float3 specularLighting;
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
uavOutput[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0);
}

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


Shader "Hidden/HDRenderLoop/Deferred"
Shader "Hidden/HDRenderPipeline/Deferred"
{
Properties
{

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

12
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Lighting.hlsl


#define HAS_LIGHTLOOP // Allow to not define LightLoop related function in Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/LightDefinition.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/LightUtilities.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightUtilities.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shadow/Shadow.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Material/Material.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow/Shadow.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Material.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl"
#endif

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


public virtual void PushGlobalParams(Camera camera, ScriptableRenderContext loop) {}
public virtual void RenderDeferredLighting(HDRenderLoop.HDCamera hdCamera, ScriptableRenderContext renderLoop, RenderTargetIdentifier cameraColorBufferRT) {}
public virtual void RenderDeferredLighting(HDRenderPipeline.HDCamera hdCamera, ScriptableRenderContext renderContext, RenderTargetIdentifier cameraColorBufferRT) {}
public virtual void RenderForward(Camera camera, ScriptableRenderContext renderLoop, bool renderOpaque) {}
public virtual void RenderForward(Camera camera, ScriptableRenderContext renderContext, bool renderOpaque) {}
public Light GetCurrentSunLight() { return m_CurrentSunLight; }
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl


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

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


// This structure gather all possible varying/interpolator for this shader.
//-------------------------------------------------------------------------------------
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Debug/DebugViewMaterial.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl"
struct FragInputs
{

2
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

10
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

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl


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

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


Shader "HDRenderLoop/LayeredLit"
Shader "HDRenderPipeline/LayeredLit"
{
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

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


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

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


Shader "Hidden/HDRenderLoop/PreIntegratedFGD"
Shader "Hidden/HDRenderPipeline/PreIntegratedFGD"
{
SubShader {
Pass {

#include "Common.hlsl"
#include "ImageBasedLighting.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
struct Attributes

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardToHDLitMaterialUpgrader.cs


using System;
using System;
using NUnit.Framework;
using UnityEngine;

{
public StandardToHDLitMaterialUpgrader()
{
RenameShader("Standard", "HDRenderLoop/LitLegacySupport");
RenameShader("Standard", "HDRenderPipeline/LitLegacySupport");
RenameTexture("_MainTex", "_BaseColorMap");
RenameColor("_Color", "_BaseColor");

[Test]
public void UpgradeMaterial()
{
var newShader = Shader.Find("HDRenderLoop/LitLegacySupport");
var newShader = Shader.Find("HDRenderPipeline/LitLegacySupport");
var mat = new Material(Shader.Find("Standard"));
var albedo = new Texture2D(1, 1);
var normals = new Texture2D(1, 1);

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardSpecularToHDLitMaterialUpgrader.cs


using System;
using System;
using NUnit.Framework;
using UnityEngine;

{
public StandardSpecularToHDLitMaterialUpgrader()
{
RenameShader("Standard (Specular setup)", "HDRenderLoop/LitLegacySupport");
RenameShader("Standard (Specular setup)", "HDRenderPipeline/LitLegacySupport");
RenameTexture("_MainTex", "_BaseColorMap");
RenameColor("_Color", "_BaseColor");

[Test]
public void UpgradeMaterial()
{
var newShader = Shader.Find("HDRenderLoop/LitLegacySupport");
var newShader = Shader.Find("HDRenderPipeline/LitLegacySupport");
var mat = new Material(Shader.Find("Standard (Specular setup)"));
var albedo = new Texture2D(1, 1);
var normals = new Texture2D(1, 1);

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


Shader "HDRenderLoop/Lit"
Shader "HDRenderPipeline/Lit"
{
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

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


public void Build()
{
m_InitPreFGD = CreateEngineMaterial("Hidden/HDRenderLoop/PreIntegratedFGD");
m_InitPreFGD = CreateEngineMaterial("Hidden/HDRenderPipeline/PreIntegratedFGD");
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGBHalf);
m_LtcGGXMatrix = LoadLUT(TextureFormat.RGBAHalf, s_LtcGGXMatrixData);

isInit = false;
}
public void RenderInit(Rendering.ScriptableRenderContext renderLoop)
public void RenderInit(Rendering.ScriptableRenderContext renderContext)
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
isInit = true;

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


protected void OnEnable()
{
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop();
if (renderLoop == null)
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
{
return;
}

.GetFields(BindingFlags.Public | BindingFlags.Instance)
.ToArray();
if (renderLoop.skyManager.skyParameters == null || renderLoop.skyManager.skyParameters.GetType() != this.GetType()) // We allow override of parameters only if the type is different. It means that we changed the Sky Renderer and might need a new set of parameters.
renderLoop.skyManager.skyParameters = this;
else if (renderLoop.skyManager.skyParameters != this && renderLoop.skyManager.skyParameters.GetType() == this.GetType())
if (renderPipeline.skyManager.skyParameters == null || renderPipeline.skyManager.skyParameters.GetType() != this.GetType()) // We allow override of parameters only if the type is different. It means that we changed the Sky Renderer and might need a new set of parameters.
renderPipeline.skyManager.skyParameters = this;
else if (renderPipeline.skyManager.skyParameters != this && renderPipeline.skyManager.skyParameters.GetType() == this.GetType())
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop();
if (renderLoop == null)
HDRenderPipeline renderPipeline = Utilities.GetHDRenderPipeline();
if (renderPipeline == null)
if (renderLoop.skyManager.skyParameters == this)
renderLoop.skyManager.skyParameters = null;
if (renderPipeline.skyManager.skyParameters == this)
renderPipeline.skyManager.skyParameters = null;
}
public int GetHash()

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl


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

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


public Vector3 cameraPosWS;
public Vector4 screenSize;
public Mesh skyMesh;
public ScriptableRenderContext renderLoop;
public ScriptableRenderContext renderContext;
public Light sunLight;
public RenderTargetIdentifier colorBuffer;
public RenderTargetIdentifier depthBuffer;

bool m_UpdateRequired = true;
float m_CurrentUpdateTime = 0.0f;
const bool m_useMIS = false;
bool m_useMIS = false;
SkyParameters m_SkyParameters = null;

// 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_GGXConvolveMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/GGXConvolve");
m_GGXConvolveMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/GGXConvolve");
m_BuildProbabilityTablesCS = Resources.Load<ComputeShader>("BuildProbabilityTables");
m_ConditionalDensitiesKernel = m_BuildProbabilityTablesCS.FindKernel("ComputeConditionalDensities");

{
for (int i = 0; i < 6; ++i)
{
Utilities.SetRenderTarget(builtinParams.renderLoop, target, ClearFlag.ClearNone, 0, (CubemapFace)i);
Utilities.SetRenderTarget(builtinParams.renderContext, target, ClearFlag.ClearNone, 0, (CubemapFace)i);
builtinParams.invViewProjMatrix = m_faceCameraInvViewProjectionMatrix[i];
builtinParams.viewProjMatrix = m_faceCameraViewProjectionMatrix[i];

}
}
private void BuildProbabilityTables(ScriptableRenderContext renderLoop)
private void BuildProbabilityTables(ScriptableRenderContext renderContext)
{
// Bind the input cubemap.
m_BuildProbabilityTablesCS.SetTexture(m_ConditionalDensitiesKernel, "envMap", m_SkyboxCubemapRT);

var cmd = new CommandBuffer() { name = "" };
cmd.DispatchCompute(m_BuildProbabilityTablesCS, m_ConditionalDensitiesKernel, (int)LightSamplingParameters.TextureHeight, 1, 1);
cmd.DispatchCompute(m_BuildProbabilityTablesCS, m_MarginalRowDensitiesKernel, 1, 1, 1);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
private void RenderCubemapGGXConvolution(ScriptableRenderContext renderLoop, BuiltinSkyParameters builtinParams, SkyParameters skyParams, Texture input, RenderTexture target)
private void RenderCubemapGGXConvolution(ScriptableRenderContext renderContext, BuiltinSkyParameters builtinParams, SkyParameters skyParams, Texture input, RenderTexture target)
using (new Utilities.ProfilingSample("Sky Pass: GGX Convolution", renderLoop))
using (new Utilities.ProfilingSample("Sky Pass: GGX Convolution", renderContext))
{
int mipCount = 1 + (int)Mathf.Log(input.width, 2.0f);
if (mipCount < ((int)EnvConstants.SpecCubeLodStep + 1))

if (m_useMIS)
{
BuildProbabilityTables(renderLoop);
BuildProbabilityTables(renderContext);
}
// Copy the first mip.

for (int face = 0; face < 6; ++face)
{
Utilities.SetRenderTarget(renderLoop, target, ClearFlag.ClearNone, mip, (CubemapFace)face);
Utilities.SetRenderTarget(renderContext, target, ClearFlag.ClearNone, mip, (CubemapFace)face);
renderLoop.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}

m_UpdateRequired = true;
}
public void UpdateEnvironment(HDRenderLoop.HDCamera camera, Light sunLight, ScriptableRenderContext renderLoop)
public void UpdateEnvironment(HDRenderPipeline.HDCamera camera, Light sunLight, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Sky Environment Pass", renderLoop))
using (new Utilities.ProfilingSample("Sky Environment Pass", renderContext))
m_BuiltinParameters.renderLoop = renderLoop;
m_BuiltinParameters.renderContext = renderContext;
m_BuiltinParameters.sunLight = sunLight;
// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed direclty but the renderloop is not (so we need to wait for the sky texture to be rendered first)

// Render sky into a cubemap - doesn't happen every frame, can be controlled
RenderSkyToCubemap(m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT);
// Convolve downsampled cubemap
RenderCubemapGGXConvolution(renderLoop, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
m_NeedLowLevelUpdateEnvironment = true;
m_UpdateRequired = false;

// DynamicGI.UpdateEnvironment();
// // Clear temp cubemap and redo GGX from black
// Utilities.SetRenderTarget(renderLoop, m_SkyboxCubemapRT, ClearFlag.ClearColor);
// RenderCubemapGGXConvolution(renderLoop, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// Utilities.SetRenderTarget(renderContext, m_SkyboxCubemapRT, ClearFlag.ClearColor);
// RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// m_SkyParametersHash = 0;
//}

}
public void RenderSky(HDRenderLoop.HDCamera camera, Light sunLight, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ScriptableRenderContext renderLoop)
public void RenderSky(HDRenderPipeline.HDCamera camera, Light sunLight, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ScriptableRenderContext renderContext)
using (new Utilities.ProfilingSample("Sky Pass", renderLoop))
using (new Utilities.ProfilingSample("Sky Pass", renderContext))
m_BuiltinParameters.renderLoop = renderLoop;
m_BuiltinParameters.renderContext = renderContext;
m_BuiltinParameters.sunLight = sunLight;
m_BuiltinParameters.invViewProjMatrix = camera.invViewProjectionMatrix;
m_BuiltinParameters.viewProjMatrix = camera.viewProjectionMatrix;

m_BuiltinParameters.colorBuffer = colorBuffer;
m_BuiltinParameters.depthBuffer = depthBuffer;
Utilities.SetRenderTarget(renderLoop, colorBuffer, depthBuffer);
Utilities.SetRenderTarget(renderContext, colorBuffer, depthBuffer);
m_Renderer.RenderSky(m_BuiltinParameters, skyParameters);
}
}

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


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

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


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

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


override public void Build()
{
m_ProceduralSkyMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/Sky/SkyProcedural");
m_ProceduralSkyMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Sky/SkyProcedural");
}
override public void Cleanup()

cmd.SetGlobalTexture("_CameraDepthTexture", builtinParams.depthBuffer);
}
cmd.DrawMesh(builtinParams.skyMesh, Matrix4x4.identity, m_ProceduralSkyMaterial);
builtinParams.renderLoop.ExecuteCommandBuffer(cmd);
builtinParams.renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}

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


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

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


override public void Build()
{
m_SkyHDRIMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/Sky/SkyHDRI");
m_SkyHDRIMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/Sky/SkyHDRI");
}
override public void Cleanup()

var cmd = new CommandBuffer { name = "" };
cmd.DrawMesh(builtinParams.skyMesh, Matrix4x4.identity, m_SkyHDRIMaterial);
builtinParams.renderLoop.ExecuteCommandBuffer(cmd);
builtinParams.renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline.meta


fileFormatVersion: 2
guid: 4c38eac64d0e8344d85c9f309419d619
folderAsset: yes
timeCreated: 1483548930
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

24
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name: HDRenderPipeline
m_EditorClassIdentifier: Assembly-CSharp:UnityEngine.Experimental.ScriptableRenderLoop:HDRenderPipeline
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
maxShadowDistance: 1000
directionalLightCascadeCount: 4
directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
m_TextureSettings:
spotCookieSize: 128
pointCookieSize: 512
reflectionCubemapSize: 128

8
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta


fileFormatVersion: 2
guid: e185fecca3c73cd47a09f1092663ef32
timeCreated: 1483549297
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

110
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.hlsl


#ifndef UNITY_BUILTIN_DATA_INCLUDED
#define UNITY_BUILTIN_DATA_INCLUDED
//-----------------------------------------------------------------------------
// BuiltinData
// This structure include common data that should be present in all material
// and are independent from the BSDF parametrization.
// Note: These parameters can be store in GBuffer if the writer wants
//-----------------------------------------------------------------------------
#include "BuiltinData.cs.hlsl"
//-----------------------------------------------------------------------------
// common Encode/Decode functions
//-----------------------------------------------------------------------------
// Guideline for velocity buffer.
// We support various architecture for HDRenderPipeline
// - Forward only rendering
// - Hybrid forward/deferred opaque
// - Regular deferred
// The velocity buffer is potentially fill in several pass.
// - In gbuffer pass with extra RT
// - In forward opaque pass (Can happen even when deferred) with MRT
// - In dedicated velocity pass
// Also the velocity buffer is only fill in case of dynamic or deformable objects, static case can use camera reprojection to retrieve motion vector (<= TODO: this may be false with TAA due to jitter matrix)
// or just previous and current transform
// So here we decide the following rules:
// - A deferred material can't override the velocity buffer format of builtinData, must use appropriate function
// - If velocity buffer is enable in deferred material it is the last one
// - Velocity buffer can be optionally enabled (either in forward or deferred)
// - Velocity data can't be pack with other properties
// - Same velocity buffer is use for all scenario, so if deferred define a velocity buffer, the same is reuse for forward case.
// For these reasons we chose to avoid to pack velocity buffer with anything else in case of PackgbufferInFP16 (and also in case the format change)
// Encode/Decode velocity/distortion in a buffer (either forward of deferred)
// Design note: We assume that velocity/distortion fit into a single buffer (i.e not spread on several buffer)
void EncodeVelocity(float2 velocity, out float4 outBuffer)
{
// RT - 16:16 float
outBuffer = float4(velocity.xy, 0.0, 0.0);
}
void DecodeVelocity(float4 inBuffer, out float2 velocity)
{
velocity = inBuffer.xy;
}
void EncodeDistortion(float2 distortion, float distortionBlur, out float4 outBuffer)
{
// RT - 16:16:16:16 float
// distortionBlur in alpha for a different blend mode
outBuffer = float4(distortion, 0.0, distortionBlur);
}
void DecodeDistortion(float4 inBuffer, out float2 distortion, out float2 distortionBlur)
{
distortion = inBuffer.xy;
distortionBlur = inBuffer.a;
}
void GetBuiltinDataDebug(uint paramId, BuiltinData builtinData, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{
case DEBUGVIEW_BUILTIN_BUILTINDATA_OPACITY:
result = builtinData.opacity.xxx;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_BAKE_DIFFUSE_LIGHTING:
// TODO: require a remap
result = builtinData.bakeDiffuseLighting;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_COLOR:
// emissiveColor is premultiply by emissive intensity
result = (builtinData.emissiveColor / builtinData.emissiveIntensity); needLinearToSRGB = true;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_INTENSITY:
result = builtinData.emissiveIntensity.xxx;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_VELOCITY:
result = float3(builtinData.velocity, 0.0);
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION:
result = float3(builtinData.distortion, 0.0);
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION_BLUR:
result = builtinData.distortionBlur.xxx;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET:
result = builtinData.depthOffset.xxx * 10.0; // * 10 assuming 1 unity unity is 1m
break;
}
}
void GetLighTransportDataDebug(uint paramId, LighTransportData lightTransportData, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{
case DEBUGVIEW_BUILTIN_LIGHTRANSPORTDATA_DIFFUSE_COLOR:
result = lightTransportData.diffuseColor; needLinearToSRGB = true;
break;
case DEBUGVIEW_BUILTIN_LIGHTRANSPORTDATA_EMISSIVE_COLOR:
// TODO: Need a tonemap ?
result = lightTransportData.emissiveColor;
break;
}
}
#endif // UNITY_BUILTIN_DATA_INCLUDED

1001
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
文件差异内容过多而无法显示
查看文件

151
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Material.hlsl


#ifndef UNITY_MATERIAL_INCLUDED
#define UNITY_MATERIAL_INCLUDED
#include "Color.hlsl"
#include "Packing.hlsl"
#include "BSDF.hlsl"
#include "Debug.hlsl"
#include "GeometricTools.hlsl"
#include "CommonMaterial.hlsl"
#include "EntityLighting.hlsl"
#include "ImageBasedLighting.hlsl"
//-----------------------------------------------------------------------------
// BuiltinData
//-----------------------------------------------------------------------------
#include "Builtin/BuiltinData.hlsl"
//-----------------------------------------------------------------------------
// Material definition
//-----------------------------------------------------------------------------
// Here we include all the different lighting model supported by the renderloop based on define done in .shader
// Only one deferred layout is allowed for a HDRenderPipeline, this will be detect by the redefinition of GBUFFERMATERIAL_COUNT
// If GBUFFERMATERIAL_COUNT is define two time, the shaders will not compile
#ifdef UNITY_MATERIAL_LIT
#include "Lit/Lit.hlsl"
#elif defined(UNITY_MATERIAL_UNLIT)
#include "Unlit/Unlit.hlsl"
#endif
//-----------------------------------------------------------------------------
// Define for GBuffer management
//-----------------------------------------------------------------------------
#ifdef GBUFFERMATERIAL_COUNT
#if GBUFFERMATERIAL_COUNT == 2
#define OUTPUT_GBUFFER(NAME) \
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1
#define DECLARE_GBUFFER_TEXTURE(NAME) \
TEXTURE2D(MERGE_NAME(NAME, 0)); \
TEXTURE2D(MERGE_NAME(NAME, 1));
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target2
#endif
#elif GBUFFERMATERIAL_COUNT == 3
#define OUTPUT_GBUFFER(NAME) \
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \
out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2
#define DECLARE_GBUFFER_TEXTURE(NAME) \
TEXTURE2D(MERGE_NAME(NAME, 0)); \
TEXTURE2D(MERGE_NAME(NAME, 1)); \
TEXTURE2D(MERGE_NAME(NAME, 2));
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); \
GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target3
#endif
#elif GBUFFERMATERIAL_COUNT == 4
#define OUTPUT_GBUFFER(NAME) \
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \
out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \
out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3
#define DECLARE_GBUFFER_TEXTURE(NAME) \
TEXTURE2D(MERGE_NAME(NAME, 0)); \
TEXTURE2D(MERGE_NAME(NAME, 1)); \
TEXTURE2D(MERGE_NAME(NAME, 2)); \
TEXTURE2D(MERGE_NAME(NAME, 3));
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); \
GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2); \
GBufferType3 MERGE_NAME(NAME, 3) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 3), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target4
#endif
#elif GBUFFERMATERIAL_COUNT == 5
#define OUTPUT_GBUFFER(NAME) \
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \
out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \
out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3, \
out GBufferType4 MERGE_NAME(NAME, 4) : SV_Target4
#define DECLARE_GBUFFER_TEXTURE(NAME) \
TEXTURE2D(MERGE_NAME(NAME, 0)); \
TEXTURE2D(MERGE_NAME(NAME, 1)); \
TEXTURE2D(MERGE_NAME(NAME, 2)); \
TEXTURE2D(MERGE_NAME(NAME, 3)); \
TEXTURE2D(MERGE_NAME(NAME, 4));
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); \
GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2); \
GBufferType3 MERGE_NAME(NAME, 3) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 3), unCoord2); \
GBufferType4 MERGE_NAME(NAME, 4) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 4), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target5
#endif
#endif
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define ENCODE_VELOCITY_INTO_GBUFFER(VELOCITY, NAME) EncodeVelocity(VELOCITY, NAME)
#else
#define OUTPUT_GBUFFER_VELOCITY(NAME)
#define ENCODE_VELOCITY_INTO_GBUFFER(VELOCITY, NAME)
#endif
#endif // #ifdef GBUFFERMATERIAL_COUNT
#endif // UNITY_MATERIAL_INCLUDED

9
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl.meta


fileFormatVersion: 2
guid: 2c2d7b256f4650943b60cc4ef1c7aeaa
timeCreated: 1483548875
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl.meta


fileFormatVersion: 2
guid: 839dd86bae5fa4d46bf4facd02608862
timeCreated: 1483546512
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderLoop.meta


fileFormatVersion: 2
guid: efe43be6d4923e441a2d4b20b3783b7f
folderAsset: yes
timeCreated: 1474540060
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset → /Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.asset

/Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.asset.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderLoop.cs.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Shadow → /Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow

/Assets/ScriptableRenderLoop/HDRenderLoop/Debug.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Debug.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Lighting.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Material.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/PostProcess.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Shadow.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/PostProcess → /Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess

/Assets/ScriptableRenderLoop/HDRenderLoop/Debug → /Assets/ScriptableRenderLoop/HDRenderPipeline/Debug

/Assets/ScriptableRenderLoop/HDRenderLoop/Editor.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Editor.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Sky.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Sky.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Utilities.cs.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/SceneSettings.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/SceneSettings → /Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDebugViewMaterial.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassForward.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassGBuffer.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassForwardUnlit.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPass.cs → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPass.cs.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPass.cs.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDepthOnly.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassLightTransport.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassLightTransport.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassVelocity.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassVelocity.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDebugViewMaterial.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassForwardUnlit.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDistortion.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDistortion.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDepthOnly.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassForward.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl

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

正在加载...
取消
保存