浏览代码

Merge remote-tracking branch 'remotes/origin/master' into gpu-terrain

/main
Yao Xiao Ling 6 年前
当前提交
5eed6e3a
共有 107 个文件被更改,包括 3376 次插入580 次删除
  1. 3
      TestProjects/LWGraphicsTest/ProjectSettings/EditorBuildSettings.asset
  2. 2
      com.unity.render-pipelines.core/CHANGELOG.md
  3. 2
      com.unity.render-pipelines.core/package.json
  4. 6
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  5. 2
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugLightVolume.shader
  6. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRPass.template
  7. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDSubShaderUtilities.cs
  8. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitPassForward.template
  9. 5
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  10. 8
      com.unity.render-pipelines.high-definition/package.json
  11. 15
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  12. 56
      com.unity.render-pipelines.lightweight/LWRP/DefaultRendererSetup.cs
  13. 12
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs
  14. 7
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs
  15. 7
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs
  16. 4
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRExtraPasses.template
  17. 2
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template
  18. 4
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitExtraPasses.template
  19. 2
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitPass.template
  20. 2
      com.unity.render-pipelines.lightweight/LWRP/IAfterDepthPrePass.cs
  21. 2
      com.unity.render-pipelines.lightweight/LWRP/IAfterOpaquePass.cs
  22. 2
      com.unity.render-pipelines.lightweight/LWRP/IAfterOpaquePostProcess.cs
  23. 2
      com.unity.render-pipelines.lightweight/LWRP/IAfterRender.cs
  24. 2
      com.unity.render-pipelines.lightweight/LWRP/IAfterSkyboxPass.cs
  25. 2
      com.unity.render-pipelines.lightweight/LWRP/IAfterTransparentPass.cs
  26. 4
      com.unity.render-pipelines.lightweight/LWRP/IRendererSetup.cs
  27. 53
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
  28. 92
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs
  29. 4
      com.unity.render-pipelines.lightweight/LWRP/LightweightShadowUtils.cs
  30. 2
      com.unity.render-pipelines.lightweight/LWRP/MaterialHandles.cs
  31. 6
      com.unity.render-pipelines.lightweight/LWRP/Passes/BeginXRRenderingPass.cs
  32. 16
      com.unity.render-pipelines.lightweight/LWRP/Passes/CopyColorPass.cs
  33. 14
      com.unity.render-pipelines.lightweight/LWRP/Passes/CopyDepthPass.cs
  34. 13
      com.unity.render-pipelines.lightweight/LWRP/Passes/CreateLightweightRenderTexturesPass.cs
  35. 10
      com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs
  36. 23
      com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
  37. 25
      com.unity.render-pipelines.lightweight/LWRP/Passes/DrawSkyboxPass.cs
  38. 6
      com.unity.render-pipelines.lightweight/LWRP/Passes/EndXRRenderingPass.cs
  39. 8
      com.unity.render-pipelines.lightweight/LWRP/Passes/FinalBlitPass.cs
  40. 31
      com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs
  41. 11
      com.unity.render-pipelines.lightweight/LWRP/Passes/OpaquePostProcessPass.cs
  42. 48
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs
  43. 42
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderTransparentForwardPass.cs
  44. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/SceneViewDepthCopy.cs
  45. 18
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs
  46. 6
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs
  47. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/SetupForwardRenderingPass.cs
  48. 44
      com.unity.render-pipelines.lightweight/LWRP/Passes/SetupLightweightConstanstPass.cs
  49. 12
      com.unity.render-pipelines.lightweight/LWRP/Passes/TransparentPostProcessPass.cs
  50. 15
      com.unity.render-pipelines.lightweight/LWRP/RenderTargetHandle.cs
  51. 2
      com.unity.render-pipelines.lightweight/LWRP/RenderTargetHandles.cs
  52. 2
      com.unity.render-pipelines.lightweight/LWRP/SampleCount.cs
  53. 2
      com.unity.render-pipelines.lightweight/LWRP/SceneViewDrawMode.cs
  54. 214
      com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs
  55. 23
      com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightStandardUnlit.shader
  56. 8
      com.unity.render-pipelines.lightweight/package.json
  57. 154
      com.unity.shadergraph/CHANGELOG.md
  58. 8
      com.unity.shadergraph/Editor/Data/Graphs/ColorShaderProperty.cs
  59. 10
      com.unity.shadergraph/Editor/Data/Graphs/ShaderGraphRequirements.cs
  60. 9
      com.unity.shadergraph/Editor/Data/Graphs/VectorShaderProperty.cs
  61. 38
      com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs
  62. 12
      com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs
  63. 28
      com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl
  64. 2
      com.unity.shadergraph/package.json
  65. 2
      com.unity.testframework.graphics/CHANGELOG.md
  66. 2
      com.unity.testframework.graphics/package.json
  67. 4
      com.unity.testing.srp.core/package.json
  68. 12
      com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs
  69. 23
      com.unity.testing.srp.lightweight/Tests/Scenes/052_LWCallbacks/CameraCallbackTests.cs
  70. 6
      com.unity.testing.srp.lightweight/package.json
  71. 21
      TestProjects/LWGraphicsTest/Assets/Editor/LoadPackageSceneContext.cs
  72. 19
      com.unity.render-pipelines.high-definition/HDRP/ShaderGraphFunctions.hlsl
  73. 8
      com.unity.render-pipelines.high-definition/HDRP/ShaderGraphFunctions.hlsl.meta
  74. 16
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/LightweightPassMetaUnlit.hlsl
  75. 9
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/LightweightPassMetaUnlit.hlsl.meta
  76. 46
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl
  77. 9
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl.meta
  78. 18
      com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireCameraOpaqueTexture.cs
  79. 11
      com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireCameraOpaqueTexture.cs.meta
  80. 18
      com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireDepthTexture.cs
  81. 11
      com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireDepthTexture.cs.meta
  82. 51
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneColorNode.cs
  83. 11
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneColorNode.cs.meta
  84. 51
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneDepthNode.cs
  85. 11
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneDepthNode.cs.meta
  86. 527
      com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/OSXEditor/Metal/053_UnlitShader.png
  87. 88
      com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/OSXEditor/Metal/053_UnlitShader.png.meta
  88. 471
      com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/WindowsEditor/Direct3D11/053_UnlitShader.png
  89. 88
      com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/WindowsEditor/Direct3D11/053_UnlitShader.png.meta
  90. 8
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.meta
  91. 1001
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.unity
  92. 9
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.unity.meta
  93. 26
      .github/PULL_REQUEST_TEMPLATE.md
  94. 3
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/.gitignore
  95. 88
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red GI.mat
  96. 8
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red GI.mat.meta
  97. 88
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red no GI.mat
  98. 8
      com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red no GI.mat.meta

3
TestProjects/LWGraphicsTest/ProjectSettings/EditorBuildSettings.asset


- enabled: 0
path: Packages/com.unity.testing.srp.lightweight/Tests/Scenes/052_LWCallbacks.unity
guid: 58d22e8497ba91141b3ae7abd7b0bb41
- enabled: 1
path: Packages/com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.unity
guid: a28e1d48e6e3c0e42a4050ab4e770bf8
m_configObjects: {}

2
com.unity.render-pipelines.core/CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.4.0]
## [3.3.0]
## [3.2.0]

2
com.unity.render-pipelines.core/package.json


{
"name": "com.unity.render-pipelines.core",
"description": "Core library for Unity render pipelines.",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"unity": "2018.3",
"displayName": "Render Pipeline Core Library"
}

6
com.unity.render-pipelines.high-definition/CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.4.0-preview]
### Fixed
- Fixed an issue where sometimes the deferred shadow texture would not be valid, causing wrong rendering.
## [3.3.0-preview]
### Added

- Remove workaround for metal and vulkan in normal buffer encoding/decoding
- Fixed an issue with color picker not working in forward
- Fixed an issue where reseting HDLight do not reset all of its parameters
- Fixed shader compile warning in DebugLightVolumes.shader
### Changed
- Changed default reflection probe to be 256x256x6 and array size to be 64

2
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugLightVolume.shader


{
VaryingsDefault output;
float3 positionRWS = TransformObjectToWorld(att.positionOS * _Range + _Offset);
float3 positionRWS = TransformObjectToWorld(att.positionOS.xyz * _Range + _Offset);
output.positionCS = TransformWorldToHClip(positionRWS);
return output;
}

4
com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRPass.template


#include "CoreRP/ShaderLibrary/NormalSurfaceGradient.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
// define FragInputs structure
#include "HDRP/ShaderPass/FragInputs.hlsl"
#include "HDRP/ShaderPass/ShaderPass.cs.hlsl"

// End Defines
//-------------------------------------------------------------------------------------
#include "ShaderGraphLibrary/Functions.hlsl"
#include "HDRP/ShaderGraphFunctions.hlsl"
#ifdef DEBUG_DISPLAY
#include "HDRP/Debug/DebugDisplay.hlsl"
#endif

4
com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDSubShaderUtilities.cs


// graph requirements describe what the graph itself requires
var pixelRequirements = ShaderGraphRequirements.FromNodes(pixelNodes, ShaderStageCapability.Fragment, false); // TODO: is ShaderStageCapability.Fragment correct?
var vertexRequirements = ShaderGraphRequirements.FromNodes(vertexNodes, ShaderStageCapability.Vertex, false);
var graphRequirements = pixelRequirements.Union(vertexRequirements);
// Function Registry tracks functions to remove duplicates, it wraps a string builder that stores the combined function string
ShaderStringBuilder graphNodeFunctions = new ShaderStringBuilder();

foreach (var define in pass.ExtraDefines)
defines.AddShaderChunk(define);
}
if (graphRequirements.requiresDepthTexture)
defines.AddShaderChunk("#define REQUIRE_DEPTH_TEXTURE");
defines.AddGenerator(interpolatorDefines);
}

4
com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitPassForward.template


#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "CoreRP/ShaderLibrary/Wind.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
// define FragInputs structure
#include "HDRP/ShaderPass/FragInputs.hlsl"
#include "HDRP/ShaderPass/ShaderPass.cs.hlsl"

// End Defines
//-------------------------------------------------------------------------------------
#include "ShaderGraphLibrary/Functions.hlsl"
#include "HDRP/ShaderGraphFunctions.hlsl"
#ifdef DEBUG_DISPLAY
#include "HDRP/Debug/DebugDisplay.hlsl"
#endif

5
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


HDUtils.SetRenderTarget(cmd, hdCamera, m_ScreenSpaceShadowsBuffer, ClearFlag.Color, CoreUtils.clearColorAllBlack);
}
// In some cases when loading a project for the first time in the editor, the internal resource is destroyed.
// When used as render target, the C++ code will re-create the resource automatically. Since here it's used directly as an UAV, we need to check manually/
if (!m_ScreenSpaceShadowsBuffer.rt.IsCreated())
m_ScreenSpaceShadowsBuffer.rt.Create();
m_LightLoop.RenderScreenSpaceShadows(hdCamera, m_ScreenSpaceShadowsBuffer, GetDepthTexture(), cmd);
PushFullScreenDebugTexture(hdCamera, cmd, m_ScreenSpaceShadowsBuffer, FullScreenDebugMode.ScreenSpaceShadows);
}

8
com.unity.render-pipelines.high-definition/package.json


{
"name": "com.unity.render-pipelines.high-definition",
"description": "HD Render Pipeline for Unity.",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"com.unity.postprocessing": "2.0.10-preview",
"com.unity.render-pipelines.core": "3.3.0-preview",
"com.unity.shadergraph": "3.3.0-preview"
"com.unity.postprocessing": "2.0.11-preview",
"com.unity.render-pipelines.core": "3.4.0-preview",
"com.unity.shadergraph": "3.4.0-preview"
}
}

15
com.unity.render-pipelines.lightweight/CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.4.0-preview]
### Added
- When you have enabled Gizmos, they now appear correctly in the Game view.
- Added requiresDepthPrepass field to RenderingData struct to tell if the runtime platform requires a depth prepass to generate a camera depth texture.
- The _RenderingData_ struct now holds a reference to _CullResults_.
### Changed
- The _RenderingData_ struct is now read-only.
- _ScriptableRenderer_ always perform a Clear before calling _IRendererSetup::Setup_.
- _ScriptableRenderPass::Execute_ no longer takes _CullResults_ as input. Instead, use _RenderingData_ as input, since that references _CullResults_.
- _IRendererSetup::Setup_ no longer takes _ScriptableRenderContext_ and _CullResults_ as input.
### Fixed
- The Unlit shader now samples Global Illumination correctly.
- The Inspector window for the Unlit shader now displays correctly.
- Reduced GC pressure by removing several per-frame memory allocations.
## [3.3.0-preview]
### Added
- Add callbacks to LWRP that can be attached to a camera (IBeforeCameraRender, IAfterDepthPrePass, IAfterOpaquePass, IAfterOpaquePostProcess, IAfterSkyboxPass, IAfterTransparentPass, IAfterRender)

56
com.unity.render-pipelines.lightweight/LWRP/DefaultRendererSetup.cs


m_Initialized = true;
}
public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults, ref RenderingData renderingData)
public void Setup(ScriptableRenderer renderer, ref RenderingData renderingData)
renderer.Clear();
renderer.SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
renderer.SetupPerObjectLightIndices(ref renderingData.cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);
bool requiresCameraDepth = renderingData.cameraData.requiresDepthTexture;
bool requiresDepthPrepass = renderingData.shadowData.requiresScreenSpaceShadowResolve
|| renderingData.cameraData.isSceneViewCamera
|| (requiresCameraDepth && !ScriptableRenderer.CanCopyDepth(ref renderingData.cameraData));
bool requiresDepthPrepass = renderingData.shadowData.requiresScreenSpaceShadowResolve || renderingData.cameraData.isSceneViewCamera ||
(renderingData.cameraData.requiresDepthTexture && !CanCopyDepth(ref renderingData.cameraData));
// For now VR requires a depth prepass until we figure out how to properly resolve texture2DMS in stereo
requiresDepthPrepass |= renderingData.cameraData.isStereoEnabled;

renderer.EnqueuePass(m_ScreenSpaceShadowResolvePass);
}
bool requiresRenderToTexture =
ScriptableRenderer.RequiresIntermediateColorTexture(
ref renderingData.cameraData,
baseDescriptor);
bool requiresRenderToTexture = ScriptableRenderer.RequiresIntermediateColorTexture(ref renderingData.cameraData, baseDescriptor);
RenderTargetHandle colorHandle = RenderTargetHandle.CameraTarget;
RenderTargetHandle depthHandle = RenderTargetHandle.CameraTarget;

depthHandle = DepthAttachment;
}
}
bool dynamicBatching = renderingData.supportsDynamicBatching;
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration);
renderingData.cameraData.postProcessLayer.HasOpaqueOnlyEffects(renderer.postProcessRenderContext))
renderingData.cameraData.postProcessLayer.HasOpaqueOnlyEffects(renderer.postProcessingContext))
m_OpaquePostProcessPass.Setup(renderer.postProcessRenderContext, baseDescriptor, colorHandle);
m_OpaquePostProcessPass.Setup(renderer.postProcessingContext, baseDescriptor, colorHandle);
renderer.EnqueuePass(m_OpaquePostProcessPass);
foreach (var pass in camera.GetComponents<IAfterOpaquePostProcess>())

foreach (var pass in camera.GetComponents<IAfterSkyboxPass>())
renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
if (requiresCameraDepth && !requiresDepthPrepass)
if (renderingData.cameraData.requiresDepthTexture && !requiresDepthPrepass)
{
m_CopyDepthPass.Setup(depthHandle, DepthTexture);
renderer.EnqueuePass(m_CopyDepthPass);

renderer.EnqueuePass(m_CopyColorPass);
}
m_RenderTransparentForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ClearFlag.None, camera.backgroundColor, rendererConfiguration, dynamicBatching);
m_RenderTransparentForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, rendererConfiguration);
if (renderingData.cameraData.postProcessEnabled)
if (!renderingData.cameraData.isStereoEnabled && renderingData.cameraData.postProcessEnabled)
m_TransparentPostProcessPass.Setup(renderer.postProcessRenderContext, baseDescriptor, colorHandle, BuiltinRenderTextureType.CameraTarget);
m_TransparentPostProcessPass.Setup(renderer.postProcessingContext, baseDescriptor, colorHandle, BuiltinRenderTextureType.CameraTarget);
renderer.EnqueuePass(m_TransparentPostProcessPass);
}
else if (!renderingData.cameraData.isOffscreenRender && colorHandle != RenderTargetHandle.CameraTarget)

renderer.EnqueuePass(m_SceneViewDepthCopyPass);
}
#endif
}
bool CanCopyDepth(ref CameraData cameraData)
{
bool msaaEnabledForCamera = (int)cameraData.msaaSamples > 1;
bool supportsTextureCopy = SystemInfo.copyTextureSupport != CopyTextureSupport.None;
bool supportsDepthTarget = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth);
bool supportsDepthCopy = !msaaEnabledForCamera && (supportsDepthTarget || supportsTextureCopy);
// TODO: We don't have support to highp Texture2DMS currently and this breaks depth precision.
// currently disabling it until shader changes kick in.
//bool msaaDepthResolve = msaaEnabledForCamera && SystemInfo.supportsMultisampledTextures != 0;
bool msaaDepthResolve = false;
return supportsDepthCopy || msaaDepthResolve;
}
}
}

12
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs


if (alphaClipProp.floatValue == 1)
m_MaterialEditor.ShaderProperty(alphaCutoffProp, Styles.alphaClipThresholdText, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
EditorGUI.BeginChangeCheck();
bool receiveShadows = EditorGUILayout.Toggle(Styles.receiveShadowText, receiveShadowsProp.floatValue == 1.0f);
if (EditorGUI.EndChangeCheck())
receiveShadowsProp.floatValue = receiveShadows ? 1.0f : 0.0f;
if (receiveShadowsProp != null)
{
EditorGUI.BeginChangeCheck();
bool receiveShadows =
EditorGUILayout.Toggle(Styles.receiveShadowText, receiveShadowsProp.floatValue == 1.0f);
if (EditorGUI.EndChangeCheck())
receiveShadowsProp.floatValue = receiveShadows ? 1.0f : 0.0f;
}
EditorGUILayout.Space();
}

7
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs


var vertexRequirements = ShaderGraphRequirements.FromNodes(vertexNodes, ShaderStageCapability.Vertex, false);
var pixelRequirements = ShaderGraphRequirements.FromNodes(pixelNodes, ShaderStageCapability.Fragment);
var graphRequirements = pixelRequirements.Union(vertexRequirements);
var surfaceRequirements = ShaderGraphRequirements.FromNodes(pixelNodes, ShaderStageCapability.Fragment, false);
var modelRequiements = ShaderGraphRequirements.none;

if (masterNode.surfaceType == SurfaceType.Transparent && masterNode.alphaMode == AlphaMode.Premultiply)
defines.AppendLine("#define _ALPHAPREMULTIPLY_ON 1");
if (graphRequirements.requiresDepthTexture)
defines.AppendLine("#define REQUIRE_DEPTH_TEXTURE");
if (graphRequirements.requiresCameraOpaqueTexture)
defines.AppendLine("#define REQUIRE_OPAQUE_TEXTURE");
// ----------------------------------------------------- //
// START VERTEX DESCRIPTION //

7
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs


var vertexRequirements = ShaderGraphRequirements.FromNodes(vertexNodes, ShaderStageCapability.Vertex, false);
var pixelRequirements = ShaderGraphRequirements.FromNodes(pixelNodes, ShaderStageCapability.Fragment);
var graphRequirements = pixelRequirements.Union(vertexRequirements);
var surfaceRequirements = ShaderGraphRequirements.FromNodes(pixelNodes, ShaderStageCapability.Fragment, false);
var modelRequiements = ShaderGraphRequirements.none;

if (masterNode.surfaceType == SurfaceType.Transparent && masterNode.alphaMode == AlphaMode.Premultiply)
defines.AppendLine("#define _ALPHAPREMULTIPLY_ON 1");
if (graphRequirements.requiresDepthTexture)
defines.AppendLine("#define REQUIRE_DEPTH_TEXTURE");
if (graphRequirements.requiresCameraOpaqueTexture)
defines.AppendLine("#define REQUIRE_OPAQUE_TEXTURE");
// ----------------------------------------------------- //
// START VERTEX DESCRIPTION //

4
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRExtraPasses.template


${Defines}
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Lighting.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
#include "LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl"
#include "CoreRP/ShaderLibrary/Color.hlsl"
${Graph}

${Defines}
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Lighting.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
#include "LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl"
#include "CoreRP/ShaderLibrary/Color.hlsl"
${Graph}

2
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template


#include "LWRP/ShaderLibrary/Lighting.hlsl"
#include "CoreRP/ShaderLibrary/Color.hlsl"
#include "CoreRP/ShaderLibrary/UnityInstancing.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
#include "LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl"
${Graph}
struct GraphVertexOutput

4
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitExtraPasses.template


${Defines}
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Lighting.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
#include "LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl"
#include "CoreRP/ShaderLibrary/Color.hlsl"
${Graph}

${Defines}
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Lighting.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
#include "LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl"
#include "CoreRP/ShaderLibrary/Color.hlsl"
${Graph}

2
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitPass.template


#include "LWRP/ShaderLibrary/Lighting.hlsl"
#include "CoreRP/ShaderLibrary/Color.hlsl"
#include "LWRP/ShaderLibrary/InputSurfaceUnlit.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
#include "LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl"
${Graph}
struct GraphVertexOutput

2
com.unity.render-pipelines.lightweight/LWRP/IAfterDepthPrePass.cs


{
ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle depthAttachmentHandle);
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/IAfterOpaquePass.cs


RenderTargetHandle colorAttachmentHandle,
RenderTargetHandle depthAttachmentHandle);
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/IAfterOpaquePostProcess.cs


ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorHandle,
RenderTargetHandle depthHandle);
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/IAfterRender.cs


{
ScriptableRenderPass GetPassToEnqueue();
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/IAfterSkyboxPass.cs


{
ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorHandle, RenderTargetHandle depthHandle);
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/IAfterTransparentPass.cs


{
ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorHandle, RenderTargetHandle depthHandle);
}
}
}

4
com.unity.render-pipelines.lightweight/LWRP/IRendererSetup.cs


{
public interface IRendererSetup
{
void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData);
void Setup(ScriptableRenderer renderer, ref RenderingData renderingData);
}
}

53
com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs


using System;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Experimental.Rendering.LightweightPipeline;
#endif
using UnityEngine.Rendering;

{
public partial class LightweightPipeline : RenderPipeline
public sealed partial class LightweightPipeline : RenderPipeline
{
static class PerFrameBuffer
{

public LightweightPipelineAsset pipelineAsset { get; private set; }
private static IRendererSetup m_DefaultRendererSetup;
private static IRendererSetup defaultRendererSetup
{

}
}
CameraComparer m_CameraComparer = new CameraComparer();
const string k_RenderCameraTag = "Render Camera";
private PipelineSettings m_PipelineSettings;
PipelineSettings m_PipelineSettings;
public struct PipelineSettings
{

m_Renderer.Dispose();
}
public interface IBeforeCameraRender
{
void ExecuteBeforeCameraRender(ScriptableRenderContext context, Camera camera, PipelineSettings pipelineSettings, ScriptableRenderer renderer);

GraphicsSettings.lightsUseLinearIntensity = true;
SetupPerFrameShaderConstants();
// Sort cameras array by camera depth
Array.Sort(cameras, m_CameraComparer);
SortCameras(cameras);
foreach (Camera camera in cameras)
{
BeginCameraRendering(camera);

public static void RenderSingleCamera(ScriptableRenderContext context, PipelineSettings settings, Camera camera, ref CullResults cullResults, IRendererSetup setup, ScriptableRenderer renderer)
{
string renderCameraTag = camera.name;
CommandBuffer cmd = CommandBufferPool.Get(renderCameraTag);
using (new ProfilingSample(cmd, renderCameraTag))
CommandBuffer cmd = CommandBufferPool.Get(k_RenderCameraTag);
using (new ProfilingSample(cmd, k_RenderCameraTag))
{
CameraData cameraData;
InitializeCameraData(settings, camera, out cameraData);

ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
#endif
CullResults.Cull(ref cullingParameters, context, ref cullResults);
List<VisibleLight> visibleLights = cullResults.visibleLights;
InitializeRenderingData(settings, ref cameraData, visibleLights,
renderer.maxSupportedLocalLightsPerPass, renderer.maxSupportedVertexLights,
out renderingData);
InitializeRenderingData(settings, ref cameraData, ref cullResults,
renderer.maxSupportedLocalLightsPerPass, renderer.maxSupportedVertexLights, out renderingData);
setupToUse.Setup(renderer, ref context, ref cullResults, ref renderingData);
renderer.Execute(ref context, ref cullResults, ref renderingData);
renderer.Clear();
setupToUse.Setup(renderer, ref renderingData);
renderer.Execute(context, ref renderingData);
#if UNITY_EDITOR
Handles.DrawGizmos(camera);
#endif
}
}

Rect cameraRect = camera.rect;
cameraData.isDefaultViewport = (!(Math.Abs(cameraRect.x) > 0.0f || Math.Abs(cameraRect.y) > 0.0f ||
Math.Abs(cameraRect.width) < 1.0f || Math.Abs(cameraRect.height) < 1.0f));
Math.Abs(cameraRect.width) < 1.0f || Math.Abs(cameraRect.height) < 1.0f));
// If XR is enabled, use XR renderScale.
// If XR is enabled, use XR renderScale.
// Discard variations lesser than kRenderScaleThreshold.
// Scale is only enabled for gameview.
float usedRenderScale = XRGraphicsConfig.enabled ? settings.savedXRGraphicsConfig.renderScale : settings.renderScale;

cameraData.requiresDepthTexture |= cameraData.postProcessEnabled;
}
static void InitializeRenderingData(PipelineSettings settings, ref CameraData cameraData,
List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights,
static void InitializeRenderingData(PipelineSettings settings, ref CameraData cameraData, ref CullResults cullResults,
int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights,
List<VisibleLight> visibleLights = cullResults.visibleLights;
bool hasDirectionalShadowCastingLight = false;
bool hasLocalShadowCastingLight = false;

}
}
renderingData.cullResults = cullResults;
renderingData.cameraData = cameraData;
InitializeLightData(settings, visibleLights, maxSupportedLocalLightsPerPass, maxSupportedVertexLights, localLightIndices, out renderingData.lightData);
InitializeShadowData(settings, hasDirectionalShadowCastingLight, hasLocalShadowCastingLight, out renderingData.shadowData);

shadowData.localShadowAtlasWidth = shadowData.localShadowAtlasHeight = settings.localShadowAtlasResolution;
shadowData.supportsSoftShadows = settings.supportsSoftShadows;
shadowData.bufferBitCount = 16;
shadowData.renderedDirectionalShadowQuality = LightShadows.None;
shadowData.renderedLocalShadowQuality = LightShadows.None;
}
static void InitializeLightData(PipelineSettings settings, List<VisibleLight> visibleLights,

92
com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs


using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.XR;
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{

public struct RenderingData
{
public CullResults cullResults;
public CameraData cameraData;
public LightData lightData;
public ShadowData shadowData;

public int localShadowAtlasHeight;
public bool supportsSoftShadows;
public int bufferBitCount;
public LightShadows renderedDirectionalShadowQuality;
public LightShadows renderedLocalShadowQuality;
}
public class CameraComparer : IComparer<Camera>
{
public int Compare(Camera lhs, Camera rhs)
{
return (int)(lhs.depth - rhs.depth);
}
}
public static class LightweightKeywordStrings

public static readonly string DepthNoMsaa = "_DEPTH_NO_MSAA";
public static readonly string DepthMsaa2 = "_DEPTH_MSAA_2";
public static readonly string DepthMsaa4 = "_DEPTH_MSAA_4";
public static readonly string SoftParticles = "SOFTPARTICLES_ON";
public partial class LightweightPipeline
public sealed partial class LightweightPipeline
static Mesh s_FullscreenMesh = null;
public static Mesh fullscreenMesh
{
get
{
if (s_FullscreenMesh != null)
return s_FullscreenMesh;
float topV = 1.0f;
float bottomV = 0.0f;
Mesh mesh = new Mesh { name = "Fullscreen Quad" };
mesh.SetVertices(new List<Vector3>
{
new Vector3(-1.0f, -1.0f, 0.0f),
new Vector3(-1.0f, 1.0f, 0.0f),
new Vector3(1.0f, -1.0f, 0.0f),
new Vector3(1.0f, 1.0f, 0.0f)
});
mesh.SetUVs(0, new List<Vector2>
{
new Vector2(0.0f, bottomV),
new Vector2(0.0f, topV),
new Vector2(1.0f, bottomV),
new Vector2(1.0f, topV)
});
mesh.SetIndices(new[] { 0, 1, 2, 2, 1, 3 }, MeshTopology.Triangles, 0, false);
mesh.UploadMeshData(true);
return mesh;
}
}
}
public void SortCameras(Camera[] cameras)
{
Array.Sort(cameras, (lhs, rhs) => (int)(lhs.depth - rhs.depth));
}
static void SetPipelineCapabilities(LightweightPipelineAsset pipelineAsset)

if (pipelineAsset.keepSoftShadowVariants)
s_PipelineCapabilities |= PipelineCapabilities.SoftShadows;
}
}
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material,
MaterialPropertyBlock properties = null, int shaderPassId = 0)
{
commandBuffer.DrawMesh(fullscreenMesh, Matrix4x4.identity, material, 0, shaderPassId, properties);
}
public static void GetLightCookieMatrix(VisibleLight light, out Matrix4x4 cookieMatrix)

// Remaining light types don't support cookies
}
public static void CopyTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier dest, Material material)
{
// TODO: In order to issue a copyTexture we need to also check if source and dest have same size
//if (SystemInfo.copyTextureSupport != CopyTextureSupport.None)
// cmd.CopyTexture(source, dest);
//else
cmd.Blit(source, dest, material);
}
public static bool IsSupportedShadowType(LightType lightType)
{
return lightType == LightType.Directional || lightType == LightType.Spot;
}
public static bool IsSupportedCookieType(LightType lightType)
{
return lightType == LightType.Directional || lightType == LightType.Spot;

{
bool isSceneViewCamera = camera.cameraType == CameraType.SceneView;
return XRGraphicsConfig.enabled && !isSceneViewCamera && (camera.stereoTargetEye == StereoTargetEyeMask.Both);
}
public static void RenderPostProcess(CommandBuffer cmd, PostProcessRenderContext context, ref CameraData cameraData, RenderTextureFormat colorFormat, RenderTargetIdentifier source, RenderTargetIdentifier dest, bool opaqueOnly)
{
Camera camera = cameraData.camera;
context.Reset();
context.camera = camera;
context.source = source;
context.sourceFormat = colorFormat;
context.destination = dest;
context.command = cmd;
context.flip = !IsStereoEnabled(camera) && camera.targetTexture == null;
if (opaqueOnly)
cameraData.postProcessLayer.RenderOpaqueOnly(context);
else
cameraData.postProcessLayer.Render(context);
}
}
}

4
com.unity.render-pipelines.lightweight/LWRP/LightweightShadowUtils.cs


{
ShadowSplitData splitData;
bool success = cullResults.ComputeDirectionalShadowMatricesAndCullingPrimitives(shadowLightIndex,
cascadeIndex, shadowData.directionalLightCascadeCount, shadowData.directionalLightCascades, shadowResolution, shadowNearPlane, out viewMatrix, out projMatrix,
out splitData);
cascadeIndex, shadowData.directionalLightCascadeCount, shadowData.directionalLightCascades, shadowResolution, shadowNearPlane, out viewMatrix, out projMatrix,
out splitData);
cascadeSplitDistance = splitData.cullingSphere;
shadowSliceData.offsetX = (cascadeIndex % 2) * shadowResolution;

2
com.unity.render-pipelines.lightweight/LWRP/MaterialHandles.cs


ScrenSpaceShadow,
Count,
}
}
}

6
com.unity.render-pipelines.lightweight/LWRP/Passes/BeginXRRenderingPass.cs


{
public class BeginXRRenderingPass : ScriptableRenderPass
{
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
}
}

16
com.unity.render-pipelines.lightweight/LWRP/Passes/CopyColorPass.cs


{
public class CopyColorPass : ScriptableRenderPass
{
const string k_CopyColorTag = "Copy Color";
public CopyColorPass()
{
m_SampleOffsetShaderHandle = Shader.PropertyToID("_SampleOffset");

this.destination = destination;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
CommandBuffer cmd = CommandBufferPool.Get("Copy Color");
CommandBuffer cmd = CommandBufferPool.Get(k_CopyColorTag);
RenderTextureDescriptor opaqueDesc = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData, opaqueScaler);
RenderTextureDescriptor opaqueDesc = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData, opaqueScaler);
RenderTargetIdentifier colorRT = source.Identifier();
RenderTargetIdentifier opaqueColorRT = destination.Identifier();

context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
public override void FrameCleanup(CommandBuffer cmd)
{
if (destination != RenderTargetHandle.CameraTarget)

}
}
}
}

14
com.unity.render-pipelines.lightweight/LWRP/Passes/CopyDepthPass.cs


this.destination = destination;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
CommandBuffer cmd = CommandBufferPool.Get(k_DepthCopyTag);
RenderTargetIdentifier depthSurface = source.Identifier();

RenderTextureDescriptor descriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor descriptor = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);
if (renderingData.cameraData.msaaSamples > 1)
{
cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthNoMsaa);

cmd.EnableShaderKeyword(LightweightKeywordStrings.DepthNoMsaa);
cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthMsaa2);
cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthMsaa4);
LightweightPipeline.CopyTexture(cmd, depthSurface, copyDepthSurface, depthCopyMaterial);
ScriptableRenderer.CopyTexture(cmd, depthSurface, copyDepthSurface, depthCopyMaterial);
public override void FrameCleanup(CommandBuffer cmd)
{
if (destination != RenderTargetHandle.CameraTarget)

13
com.unity.render-pipelines.lightweight/LWRP/Passes/CreateLightweightRenderTexturesPass.cs


{
public class CreateLightweightRenderTexturesPass : ScriptableRenderPass
{
const string k_CreateRenderTexturesTag = "Create Render Textures";
const int k_DepthStencilBufferBits = 32;
private RenderTargetHandle colorAttachmentHandle { get; set; }
private RenderTargetHandle depthAttachmentHandle { get; set; }

descriptor = baseDescriptor;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
CommandBuffer cmd = CommandBufferPool.Get("");
CommandBuffer cmd = CommandBufferPool.Get(k_CreateRenderTexturesTag);
colorDescriptor.msaaSamples = (int) samples;
colorDescriptor.msaaSamples = (int)samples;
cmd.GetTemporaryRT(colorAttachmentHandle.id, colorDescriptor, FilterMode.Bilinear);
}

depthDescriptor.colorFormat = RenderTextureFormat.Depth;
depthDescriptor.depthBufferBits = k_DepthStencilBufferBits;
depthDescriptor.msaaSamples = (int) samples;
depthDescriptor.bindMS = (int) samples > 1;
depthDescriptor.msaaSamples = (int)samples;
depthDescriptor.bindMS = (int)samples > 1;
cmd.GetTemporaryRT(depthAttachmentHandle.id, depthDescriptor, FilterMode.Point);
}

10
com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs


};
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
CommandBuffer cmd = CommandBufferPool.Get(k_DepthPrepassTag);
using (new ProfilingSample(cmd, k_DepthPrepassTag))

{
Camera camera = renderingData.cameraData.camera;
context.StartMultiEye(camera);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, opaqueFilterSettings);
context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, opaqueFilterSettings);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, opaqueFilterSettings);
context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, opaqueFilterSettings);
public override void FrameCleanup(CommandBuffer cmd)
{
if (depthAttachmentHandle != RenderTargetHandle.CameraTarget)

}
}
}
}

23
com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs


public static int _ShadowOffset3;
public static int _ShadowmapSize;
}
const int k_MaxCascades = 4;
const int k_ShadowmapBufferBits = 16;
int m_ShadowCasterCascadesCount;

Vector4[] m_CascadeSplitDistances;
const string k_RenderDirectionalShadowmapTag = "Render Directional Shadowmap";
private RenderTargetHandle destination { get; set; }
public DirectionalShadowsPass()

{
this.destination = destination;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
RenderDirectionalCascadeShadowmap(ref context, ref cullResults, ref renderingData.lightData, ref renderingData.shadowData);
RenderDirectionalCascadeShadowmap(ref context, ref renderingData.cullResults, ref renderingData.lightData, ref renderingData.shadowData);
}
}

void RenderDirectionalCascadeShadowmap(ref ScriptableRenderContext context, ref CullResults cullResults, ref LightData lightData, ref ShadowData shadowData)
{
LightShadows shadowQuality = LightShadows.None;
int shadowLightIndex = lightData.mainLightIndex;
if (shadowLightIndex == -1)
return;

var settings = new DrawShadowsSettings(cullResults, shadowLightIndex);
m_DirectionalShadowmapTexture = RenderTexture.GetTemporary(shadowData.directionalShadowAtlasWidth,
shadowData.directionalShadowAtlasHeight, k_ShadowmapBufferBits, m_ShadowmapFormat);
shadowData.directionalShadowAtlasHeight, k_ShadowmapBufferBits, m_ShadowmapFormat);
m_DirectionalShadowmapTexture.filterMode = FilterMode.Bilinear;
m_DirectionalShadowmapTexture.wrapMode = TextureWrapMode.Clamp;
SetRenderTarget(cmd, m_DirectionalShadowmapTexture, RenderBufferLoadAction.DontCare,

}
if (success)
{
shadowQuality = (shadowData.supportsSoftShadows) ? light.shadows : LightShadows.Hard;
}
// TODO: We should have RenderingData as a readonly but currently we need this to pass shadow rendering to litpass
shadowData.renderedDirectionalShadowQuality = shadowQuality;
}
void SetupDirectionalShadowReceiverConstants(CommandBuffer cmd, ref ShadowData shadowData, VisibleLight shadowLight)

cmd.SetGlobalVector(DirectionalShadowConstantBuffer._ShadowOffset2, new Vector4(-invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f));
cmd.SetGlobalVector(DirectionalShadowConstantBuffer._ShadowOffset3, new Vector4(invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f));
cmd.SetGlobalVector(DirectionalShadowConstantBuffer._ShadowmapSize, new Vector4(invShadowAtlasWidth, invShadowAtlasHeight,
shadowData.directionalShadowAtlasWidth, shadowData.directionalShadowAtlasHeight));
shadowData.directionalShadowAtlasWidth, shadowData.directionalShadowAtlasHeight));
}
};
}

25
com.unity.render-pipelines.lightweight/LWRP/Passes/DrawSkyboxPass.cs


{
public class DrawSkyboxPass : ScriptableRenderPass
{
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
cmd.SetRenderTarget(colorAttachmentHandle.Identifier(), depthAttachmentHandle.Identifier());
if (renderingData.cameraData.isStereoEnabled && XRGraphicsConfig.eyeTextureDesc.dimension == TextureDimension.Tex2DArray)
{
cmd.SetRenderTarget(colorAttachmentHandle.Identifier(), depthAttachmentHandle.Identifier(), 0, CubemapFace.Unknown, -1);
}
else
{
cmd.SetRenderTarget(colorAttachmentHandle.Identifier(), depthAttachmentHandle.Identifier());
}
}
}

6
com.unity.render-pipelines.lightweight/LWRP/Passes/EndXRRenderingPass.cs


{
public class EndXRRenderingPass : ScriptableRenderPass
{
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
Camera camera = renderingData.cameraData.camera;
context.StopMultiEye(camera);

}
}

8
com.unity.render-pipelines.lightweight/LWRP/Passes/FinalBlitPass.cs


private RenderTargetHandle colorAttachmentHandle { get; set; }
private RenderTextureDescriptor descriptor { get; set; }
public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorAttachmentHandle)
{
this.colorAttachmentHandle = colorAttachmentHandle;

public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
Material material = renderingData.cameraData.isStereoEnabled ? null : renderer.GetMaterial(MaterialHandles.Blit);
RenderTargetIdentifier sourceRT = colorAttachmentHandle.Identifier();

cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);
cmd.SetViewport(renderingData.cameraData.camera.pixelRect);
LightweightPipeline.DrawFullScreen(cmd, material);
ScriptableRenderer.RenderFullscreenQuad(cmd, material);
}
else
{

31
com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs


public static int _LocalShadowOffset3;
public static int _LocalShadowmapSize;
}
const int k_ShadowmapBufferBits = 16;
RenderTexture m_LocalShadowmapTexture;
RenderTextureFormat m_LocalShadowmapFormat;

float[] m_LocalShadowStrength;
const string k_RenderLocalShadows = "Render Local Shadows";
private RenderTargetHandle destination { get; set; }
public LocalShadowsPass()

? RenderTextureFormat.Shadowmap
: RenderTextureFormat.Depth;
}
if (m_LocalShadowMatrices.Length != maxVisibleLocalLights)
{
m_LocalShadowMatrices = new Matrix4x4[maxVisibleLocalLights];

}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
RenderLocalShadowmapAtlas(ref context, ref cullResults, ref renderingData.lightData, ref renderingData.shadowData);
RenderLocalShadowmapAtlas(ref context, ref renderingData.cullResults, ref renderingData.lightData, ref renderingData.shadowData);
}
}

Matrix4x4 view, proj;
Bounds bounds;
int shadowSampling = 0;
CommandBuffer cmd = CommandBufferPool.Get(k_RenderLocalShadows);
using (new ProfilingSample(cmd, k_RenderLocalShadows))

int sliceResolution = LightweightShadowUtils.GetMaxTileResolutionInAtlas(atlasWidth, atlasHeight, shadowCastingLightsCount);
m_LocalShadowmapTexture = RenderTexture.GetTemporary(shadowData.localShadowAtlasWidth,
shadowData.localShadowAtlasHeight, k_ShadowmapBufferBits, m_LocalShadowmapFormat);
shadowData.localShadowAtlasHeight, k_ShadowmapBufferBits, m_LocalShadowmapFormat);
m_LocalShadowmapTexture.filterMode = FilterMode.Bilinear;
m_LocalShadowmapTexture.wrapMode = TextureWrapMode.Clamp;

Matrix4x4 shadowTransform;
bool success = LightweightShadowUtils.ExtractSpotLightMatrix(ref cullResults, ref shadowData,
shadowLightIndex, out shadowTransform, out view, out proj);
shadowLightIndex, out shadowTransform, out view, out proj);
if (success)
{

m_LocalLightSlices[i].shadowTransform = shadowTransform;
m_LocalShadowStrength[i] = light.shadowStrength;
shadowSampling = Math.Max(shadowSampling, (int)light.shadows);
if (shadowCastingLightsCount > 1)
LightweightShadowUtils.ApplySliceTransform(ref m_LocalLightSlices[i], atlasWidth, atlasHeight);

}
}
SetupLocalLightsShadowReceiverConstants(ref context, cmd, ref shadowData);
SetupLocalLightsShadowReceiverConstants(cmd, ref shadowData);
// TODO: We should have RenderingData as a readonly but currently we need this to pass shadow rendering to litpass
shadowData.renderedLocalShadowQuality = (shadowData.supportsSoftShadows) ? (LightShadows)shadowSampling : LightShadows.Hard;
void SetupLocalLightsShadowReceiverConstants(ref ScriptableRenderContext context, CommandBuffer cmd, ref ShadowData shadowData)
void SetupLocalLightsShadowReceiverConstants(CommandBuffer cmd, ref ShadowData shadowData)
{
for (int i = 0; i < m_LocalLightSlices.Length; ++i)
m_LocalShadowMatrices[i] = m_LocalLightSlices[i].shadowTransform;

cmd.SetGlobalVector(LocalShadowConstantBuffer._LocalShadowOffset2, new Vector4(-invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f));
cmd.SetGlobalVector(LocalShadowConstantBuffer._LocalShadowOffset3, new Vector4(invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f));
cmd.SetGlobalVector(LocalShadowConstantBuffer._LocalShadowmapSize, new Vector4(invShadowAtlasWidth, invShadowAtlasHeight,
shadowData.localShadowAtlasWidth, shadowData.localShadowAtlasHeight));
shadowData.localShadowAtlasWidth, shadowData.localShadowAtlasHeight));
}
}
}

11
com.unity.render-pipelines.lightweight/LWRP/Passes/OpaquePostProcessPass.cs


{
public class OpaquePostProcessPass : ScriptableRenderPass
{
const string k_OpaquePostProcessTag = "Render Opaque PostProcess Effects";
private PostProcessRenderContext postContext { get; set; }
public void Setup(
PostProcessRenderContext postProcessRenderContext,

this.colorAttachmentHandle = colorAttachmentHandle;
this.postContext = postProcessRenderContext;
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
CommandBuffer cmd = CommandBufferPool.Get("Render Opaque PostProcess Effects");
CommandBuffer cmd = CommandBufferPool.Get(k_OpaquePostProcessTag);
LightweightPipeline.RenderPostProcess(cmd, postContext, ref renderingData.cameraData, descriptor.colorFormat, source, colorAttachmentHandle.Identifier(), true);
renderer.RenderPostProcess(cmd, ref renderingData.cameraData, descriptor.colorFormat, source, colorAttachmentHandle.Identifier(), true);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}

48
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs


namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
public class RenderOpaqueForwardPass : LightweightForwardPass
public class RenderOpaqueForwardPass : ScriptableRenderPass
public FilterRenderersSettings opaqueFilterSettings { get; private set; }
FilterRenderersSettings m_OpaqueFilterSettings;
RenderTargetHandle colorAttachmentHandle { get; set; }
RenderTargetHandle depthAttachmentHandle { get; set; }
RenderTextureDescriptor descriptor { get; set; }
ClearFlag clearFlag { get; set; }
Color clearColor { get; set; }
RendererConfiguration rendererConfiguration;
opaqueFilterSettings = new FilterRenderersSettings(true)
RegisterShaderPassName("LightweightForward");
RegisterShaderPassName("SRPDefaultUnlit");
m_OpaqueFilterSettings = new FilterRenderersSettings(true)
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public void Setup(
RenderTextureDescriptor baseDescriptor,
RenderTargetHandle colorAttachmentHandle,
RenderTargetHandle depthAttachmentHandle,
ClearFlag clearFlag,
Color clearColor,
RendererConfiguration configuration)
{
this.colorAttachmentHandle = colorAttachmentHandle;
this.depthAttachmentHandle = depthAttachmentHandle;
this.clearColor = CoreUtils.ConvertSRGBToActiveColorSpace(clearColor);
this.clearFlag = clearFlag;
descriptor = baseDescriptor;
this.rendererConfiguration = configuration;
}
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
SetRenderTarget(cmd, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, clearFlag, CoreUtils.ConvertSRGBToActiveColorSpace(clearColor));
RenderBufferLoadAction loadOp = RenderBufferLoadAction.DontCare;
RenderBufferStoreAction storeOp = RenderBufferStoreAction.Store;
SetRenderTarget(cmd, colorAttachmentHandle.Identifier(), loadOp, storeOp,
depthAttachmentHandle.Identifier(), loadOp, storeOp, clearFlag, clearColor, descriptor.dimension);
// TODO: We need a proper way to handle multiple camera/ camera stack. Issue is: multiple cameras can share a same RT
// (e.g, split screen games). However devs have to be dilligent with it and know when to clear/preserve color.

cmd.Clear();
Camera camera = renderingData.cameraData.camera;
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonOpaque, rendererConfiguration, dynamicBatching);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, opaqueFilterSettings);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonOpaque, rendererConfiguration, renderingData.supportsDynamicBatching);
context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, m_OpaqueFilterSettings);
RenderObjectsWithError(renderer, ref context, ref cullResults, camera, opaqueFilterSettings, SortFlags.None);
renderer.RenderObjectsWithError(context, ref renderingData.cullResults, camera, m_OpaqueFilterSettings, SortFlags.None);
}
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);

42
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderTransparentForwardPass.cs


namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
public class RenderTransparentForwardPass : LightweightForwardPass
public class RenderTransparentForwardPass : ScriptableRenderPass
private FilterRenderersSettings transparentFilterSettings { get; set; }
FilterRenderersSettings m_TransparentFilterSettings;
RenderTargetHandle colorAttachmentHandle { get; set; }
RenderTargetHandle depthAttachmentHandle { get; set; }
RenderTextureDescriptor descriptor { get; set; }
RendererConfiguration rendererConfiguration;
transparentFilterSettings = new FilterRenderersSettings(true)
RegisterShaderPassName("LightweightForward");
RegisterShaderPassName("SRPDefaultUnlit");
m_TransparentFilterSettings = new FilterRenderersSettings(true)
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public void Setup(
RenderTextureDescriptor baseDescriptor,
RenderTargetHandle colorAttachmentHandle,
RenderTargetHandle depthAttachmentHandle,
RendererConfiguration configuration)
{
this.colorAttachmentHandle = colorAttachmentHandle;
this.depthAttachmentHandle = depthAttachmentHandle;
descriptor = baseDescriptor;
rendererConfiguration = configuration;
}
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
SetRenderTarget(cmd, RenderBufferLoadAction.Load, RenderBufferStoreAction.Store, clearFlag, CoreUtils.ConvertSRGBToActiveColorSpace(clearColor));
RenderBufferLoadAction loadOp = RenderBufferLoadAction.Load;
RenderBufferStoreAction storeOp = RenderBufferStoreAction.Store;
SetRenderTarget(cmd, colorAttachmentHandle.Identifier(), loadOp, storeOp,
depthAttachmentHandle.Identifier(), loadOp, storeOp, ClearFlag.None, Color.black, descriptor.dimension);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonTransparent, rendererConfiguration, dynamicBatching);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, transparentFilterSettings);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonTransparent, rendererConfiguration, renderingData.supportsDynamicBatching);
context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, m_TransparentFilterSettings);
RenderObjectsWithError(renderer, ref context, ref cullResults, camera, transparentFilterSettings, SortFlags.None);
renderer.RenderObjectsWithError(context, ref renderingData.cullResults, camera, m_TransparentFilterSettings, SortFlags.None);
}
context.ExecuteCommandBuffer(cmd);

4
com.unity.render-pipelines.lightweight/LWRP/Passes/SceneViewDepthCopy.cs


this.source = source;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
// Restore Render target for additional editor rendering.
// Note: Scene view camera always perform depth prepass

18
com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs


namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
const string k_CollectShadowsTag = "Collect Shadows";
RenderTextureFormat m_ColorFormat;
public ScreenSpaceShadowResolvePass()

descriptor = baseDescriptor;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
if (renderingData.shadowData.renderedDirectionalShadowQuality == LightShadows.None)
if (renderingData.lightData.mainLightIndex == -1)
CommandBuffer cmd = CommandBufferPool.Get("Collect Shadows");
CommandBuffer cmd = CommandBufferPool.Get(k_CollectShadowsTag);
SetShadowCollectPassKeywords(cmd, ref renderingData.shadowData);
VisibleLight shadowLight = renderingData.lightData.visibleLights[renderingData.lightData.mainLightIndex];
SetShadowCollectPassKeywords(cmd, ref shadowLight, ref renderingData.shadowData);
// Note: The source isn't actually 'used', but there's an engine peculiarity (bug) that
// doesn't like null sources when trying to determine a stereo-ized blit. So for proper

}
}
void SetShadowCollectPassKeywords(CommandBuffer cmd, ref ShadowData shadowData)
void SetShadowCollectPassKeywords(CommandBuffer cmd, ref VisibleLight shadowLight, ref ShadowData shadowData)
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.SoftShadows, shadowData.renderedDirectionalShadowQuality == LightShadows.Soft);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.SoftShadows, shadowData.supportsSoftShadows && shadowLight.light.shadows == LightShadows.Soft);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.CascadeShadows, shadowData.directionalLightCascadeCount > 1);
}
}

6
com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs


public virtual void FrameCleanup(CommandBuffer cmd)
{}
public abstract void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData);
public abstract void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData);
protected void RegisterShaderPassName(string passName)
{

4
com.unity.render-pipelines.lightweight/LWRP/Passes/SetupForwardRenderingPass.cs


{
public class SetupForwardRenderingPass : ScriptableRenderPass
{
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
// SetupCameraProperties does the following:
// Setup Camera RenderTarget and Viewport

44
com.unity.render-pipelines.lightweight/LWRP/Passes/SetupLightweightConstanstPass.cs


public static int _LightIndexBuffer;
}
const string k_SetupLightConstants = "Setup Light Constants";
MixedLightingSetup m_MixedLightingSetup;
Vector4 k_DefaultLightPosition = new Vector4(0.0f, 0.0f, 1.0f, 0.0f);

Vector4[] m_LightDistanceAttenuations;
Vector4[] m_LightSpotDirections;
Vector4[] m_LightSpotAttenuations;
private int maxVisibleLocalLights { get; set; }
private ComputeBuffer perObjectLightIndices { get; set; }

{
this.maxVisibleLocalLights = maxVisibleLocalLights;
this.perObjectLightIndices = perObjectLightIndices;
if (m_LightColors.Length != maxVisibleLocalLights)
{
m_LightPositions = new Vector4[maxVisibleLocalLights];

// if not using a compute buffer, engine will set indices in 2 vec4 constants
// unity_4LightIndices0 and unity_4LightIndices1
if (perObjectLightIndices != null)
cmd.SetGlobalBuffer("_LightIndexBuffer", perObjectLightIndices);
cmd.SetGlobalBuffer(LightConstantBuffer._LightIndexBuffer, perObjectLightIndices);
}
else
{

// TODO: We have to discuss cookie approach on LWRP.
// CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.MainLightCookieText, mainLightIndex != -1 && LightweightUtils.IsSupportedCookieType(visibleLights[mainLightIndex].lightType) && visibleLights[mainLightIndex].light.cookie != null);
LightShadows directionalShadowQuality = shadowData.renderedDirectionalShadowQuality;
LightShadows localShadowQuality = shadowData.renderedLocalShadowQuality;
List<VisibleLight> visibleLights = lightData.visibleLights;
// If shadows were resolved in screen space we don't sample shadowmap in lit shader. In that case we just set softDirectionalShadows to false.
bool softDirectionalShadows = shadowData.renderDirectionalShadows && !shadowData.requiresScreenSpaceShadowResolve &&
shadowData.supportsSoftShadows && lightData.mainLightIndex != -1 &&
visibleLights[lightData.mainLightIndex].light.shadows == LightShadows.Soft;
bool softLocalShadows = false;
if (shadowData.renderLocalShadows && shadowData.supportsSoftShadows)
{
List<int> visibleLocalLightIndices = lightData.visibleLocalLightIndices;
for (int i = 0; i < visibleLocalLightIndices.Count; ++i)
{
if (visibleLights[visibleLocalLightIndices[i]].light.shadows == LightShadows.Soft)
{
softLocalShadows = true;
break;
}
}
}
bool hasSoftShadows = (directionalShadowQuality == LightShadows.Soft || localShadowQuality == LightShadows.Soft) &&
shadowData.supportsSoftShadows;
bool hasSoftShadows = softDirectionalShadows || softLocalShadows;
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.DirectionalShadows, directionalShadowQuality != LightShadows.None);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.LocalShadows, localShadowQuality != LightShadows.None);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.DirectionalShadows, shadowData.renderDirectionalShadows);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.LocalShadows, shadowData.renderLocalShadows);
CoreUtils.SetKeyword(cmd, "SOFTPARTICLES_ON", cameraData.requiresSoftParticles);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.SoftParticles, cameraData.requiresSoftParticles);
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
CommandBuffer cmd = CommandBufferPool.Get("SetupShaderConstants");
CommandBuffer cmd = CommandBufferPool.Get(k_SetupLightConstants);
SetupShaderLightConstants(cmd, ref renderingData.lightData);
SetShaderKeywords(cmd, ref renderingData.cameraData, ref renderingData.lightData, ref renderingData.shadowData);
context.ExecuteCommandBuffer(cmd);

12
com.unity.render-pipelines.lightweight/LWRP/Passes/TransparentPostProcessPass.cs


{
public class TransparentPostProcessPass : ScriptableRenderPass
{
const string k_PostProcessingTag = "Render PostProcess Effects";
private PostProcessRenderContext postContext { get; set; }
private RenderTargetIdentifier destination { get; set; }
public void Setup(

RenderTargetIdentifier destination)
{
this.colorAttachmentHandle = colorAttachmentHandle;
this.postContext = postProcessRenderContext;
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
CommandBuffer cmd = CommandBufferPool.Get("Render PostProcess Effects");
LightweightPipeline.RenderPostProcess(cmd, postContext, ref renderingData.cameraData, descriptor.colorFormat, colorAttachmentHandle.Identifier(), destination, false);
CommandBuffer cmd = CommandBufferPool.Get(k_PostProcessingTag);
renderer.RenderPostProcess(cmd, ref renderingData.cameraData, descriptor.colorFormat, colorAttachmentHandle.Identifier(), destination, false);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}

15
com.unity.render-pipelines.lightweight/LWRP/RenderTargetHandle.cs


public struct RenderTargetHandle
{
public int id { private set; get; }
public static readonly RenderTargetHandle CameraTarget = new RenderTargetHandle {id = -1};
public void Init(string shaderProperty)

public RenderTargetIdentifier Identifier()
{
if (id == -1)

return new RenderTargetIdentifier(id);
}
public bool Equals(RenderTargetHandle other)
{
return id == other.id;

{
if (ReferenceEquals(null, obj)) return false;
return obj is RenderTargetHandle && Equals((RenderTargetHandle) obj);
return obj is RenderTargetHandle && Equals((RenderTargetHandle)obj);
}
public override int GetHashCode()

public static bool operator ==(RenderTargetHandle c1, RenderTargetHandle c2)
public static bool operator==(RenderTargetHandle c1, RenderTargetHandle c2)
public static bool operator !=(RenderTargetHandle c1, RenderTargetHandle c2)
public static bool operator!=(RenderTargetHandle c1, RenderTargetHandle c2)
}
}

2
com.unity.render-pipelines.lightweight/LWRP/RenderTargetHandles.cs


{
}*/
}
}

2
com.unity.render-pipelines.lightweight/LWRP/SampleCount.cs


Two = 2,
Four = 4,
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/SceneViewDrawMode.cs


cameraMode.drawMode == DrawCameraMode.ValidateMetalSpecular ||
cameraMode.drawMode == DrawCameraMode.ShadowMasks ||
cameraMode.drawMode == DrawCameraMode.LightOverlap
)
)
return false;
return true;

214
com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
public class ScriptableRenderer
public sealed class ScriptableRenderer
{
// Lights are culled per-object. In platforms that don't use StructuredBuffer
// the engine will set 4 light indices in the following constant unity_4LightIndices0

{
get
{
// TODO: Graphics Emulation are breaking StructuredBuffers disabling it for now until
// TODO: Graphics Emulation are breaking StructuredBuffers disabling it for now until
// we have a fix for it
return false;
// return SystemInfo.supportsComputeShaders &&

public int maxSupportedVertexLights { get { return k_MaxVertexLights; } }
public PostProcessRenderContext postProcessRenderContext { get; private set; }
public PostProcessRenderContext postProcessingContext { get; private set; }
static Mesh s_FullscreenMesh = null;
static Mesh fullscreenMesh
{
get
{
if (s_FullscreenMesh != null)
return s_FullscreenMesh;
float topV = 1.0f;
float bottomV = 0.0f;
Mesh mesh = new Mesh { name = "Fullscreen Quad" };
mesh.SetVertices(new List<Vector3>
{
new Vector3(-1.0f, -1.0f, 0.0f),
new Vector3(-1.0f, 1.0f, 0.0f),
new Vector3(1.0f, -1.0f, 0.0f),
new Vector3(1.0f, 1.0f, 0.0f)
});
mesh.SetUVs(0, new List<Vector2>
{
new Vector2(0.0f, bottomV),
new Vector2(0.0f, topV),
new Vector2(1.0f, bottomV),
new Vector2(1.0f, topV)
});
mesh.SetIndices(new[] { 0, 1, 2, 2, 1, 3 }, MeshTopology.Triangles, 0, false);
mesh.UploadMeshData(true);
return mesh;
}
}
List<ShaderPassName> m_LegacyShaderPassNames = new List<ShaderPassName>()
{
new ShaderPassName("Always"),
new ShaderPassName("ForwardBase"),
new ShaderPassName("PrepassBase"),
new ShaderPassName("Vertex"),
new ShaderPassName("VertexLMRGBM"),
new ShaderPassName("VertexLM"),
};
const string k_ReleaseResourcesTag = "Release Resources";
public ScriptableRenderer(LightweightPipelineAsset pipelineAsset)
{
m_Materials = new[]

CoreUtils.CreateEngineMaterial(pipelineAsset.screenSpaceShadowShader),
};
postProcessRenderContext = new PostProcessRenderContext();
postProcessingContext = new PostProcessRenderContext();
}
public void Dispose()

CoreUtils.Destroy(m_Materials[i]);
}
public static RenderTextureDescriptor CreateRTDesc(ref CameraData cameraData, float scaler = 1.0f)
{
Camera camera = cameraData.camera;
RenderTextureDescriptor desc;
float renderScale = cameraData.renderScale;
if (cameraData.isStereoEnabled)
{
return XRGraphicsConfig.eyeTextureDesc;
}
else
{
desc = new RenderTextureDescriptor(camera.pixelWidth, camera.pixelHeight);
}
desc.colorFormat = cameraData.isHdrEnabled ? RenderTextureFormat.DefaultHDR :
RenderTextureFormat.Default;
desc.enableRandomWrite = false;
desc.sRGB = true;
desc.width = (int)((float)desc.width * renderScale * scaler);
desc.height = (int)((float)desc.height * renderScale * scaler);
return desc;
}
public void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
public void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
m_ActiveRenderPassQueue[i].Execute(this, ref context, ref cullResults, ref renderingData);
m_ActiveRenderPassQueue[i].Execute(this, context, ref renderingData);
DisposePasses(ref context);
}

if (handleID >= m_Materials.Length)
{
Debug.LogError(string.Format("Material {0} is not registered.",
Enum.GetName(typeof(MaterialHandles), handleID)));
Enum.GetName(typeof(MaterialHandles), handleID)));
public void Clear()
{

m_ActiveRenderPassQueue.Add(pass);
}
public static bool RequiresIntermediateColorTexture(ref CameraData cameraData, RenderTextureDescriptor baseDescriptor)
{
if (cameraData.isOffscreenRender)
return false;
bool isScaledRender = !Mathf.Approximately(cameraData.renderScale, 1.0f);
bool isTargetTexture2DArray = baseDescriptor.dimension == TextureDimension.Tex2DArray;
return cameraData.isSceneViewCamera || isScaledRender || cameraData.isHdrEnabled ||
cameraData.postProcessEnabled || cameraData.requiresOpaqueTexture || isTargetTexture2DArray || !cameraData.isDefaultViewport;
}
public static bool CanCopyDepth(ref CameraData cameraData)
{
bool msaaEnabledForCamera = (int)cameraData.msaaSamples > 1;
bool supportsTextureCopy = SystemInfo.copyTextureSupport != CopyTextureSupport.None;
bool supportsDepthTarget = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth);
bool supportsDepthCopy = !msaaEnabledForCamera && (supportsDepthTarget || supportsTextureCopy);
// TODO: We don't have support to highp Texture2DMS currently and this breaks depth precision.
// currently disabling it until shader changes kick in.
//bool msaaDepthResolve = msaaEnabledForCamera && SystemInfo.supportsMultisampledTextures != 0;
bool msaaDepthResolve = false;
return supportsDepthCopy || msaaDepthResolve;
}
void DisposePasses(ref ScriptableRenderContext context)
{
CommandBuffer cmd = CommandBufferPool.Get("Release Resources");
for (int i = 0; i < m_ActiveRenderPassQueue.Count; ++i)
m_ActiveRenderPassQueue[i].FrameCleanup(cmd);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
public void SetupPerObjectLightIndices(ref CullResults cullResults, ref LightData lightData)
{
if (lightData.totalAdditionalLightsCount == 0)

}
}
public void RenderPostProcess(CommandBuffer cmd, ref CameraData cameraData, RenderTextureFormat colorFormat, RenderTargetIdentifier source, RenderTargetIdentifier dest, bool opaqueOnly)
{
Camera camera = cameraData.camera;
postProcessingContext.Reset();
postProcessingContext.camera = camera;
postProcessingContext.source = source;
postProcessingContext.sourceFormat = colorFormat;
postProcessingContext.destination = dest;
postProcessingContext.command = cmd;
postProcessingContext.flip = !cameraData.isStereoEnabled && camera.targetTexture == null;
if (opaqueOnly)
cameraData.postProcessLayer.RenderOpaqueOnly(postProcessingContext);
else
cameraData.postProcessLayer.Render(postProcessingContext);
}
[Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")]
public void RenderObjectsWithError(ScriptableRenderContext context, ref CullResults cullResults, Camera camera, FilterRenderersSettings filterSettings, SortFlags sortFlags)
{
Material errorMaterial = GetMaterial(MaterialHandles.Error);
if (errorMaterial != null)
{
DrawRendererSettings errorSettings = new DrawRendererSettings(camera, m_LegacyShaderPassNames[0]);
for (int i = 1; i < m_LegacyShaderPassNames.Count; ++i)
errorSettings.SetShaderPassName(i, m_LegacyShaderPassNames[i]);
errorSettings.sorting.flags = sortFlags;
errorSettings.rendererConfiguration = RendererConfiguration.None;
errorSettings.SetOverrideMaterial(errorMaterial, 0);
context.DrawRenderers(cullResults.visibleRenderers, ref errorSettings, filterSettings);
}
}
public static RenderTextureDescriptor CreateRenderTextureDescriptor(ref CameraData cameraData, float scaler = 1.0f)
{
Camera camera = cameraData.camera;
RenderTextureDescriptor desc;
float renderScale = cameraData.renderScale;
if (cameraData.isStereoEnabled)
{
return XRGraphicsConfig.eyeTextureDesc;
}
else
{
desc = new RenderTextureDescriptor(camera.pixelWidth, camera.pixelHeight);
}
desc.colorFormat = cameraData.isHdrEnabled ? RenderTextureFormat.DefaultHDR :
RenderTextureFormat.Default;
desc.enableRandomWrite = false;
desc.sRGB = true;
desc.width = (int)((float)desc.width * renderScale * scaler);
desc.height = (int)((float)desc.height * renderScale * scaler);
return desc;
}
public static bool RequiresIntermediateColorTexture(ref CameraData cameraData, RenderTextureDescriptor baseDescriptor)
{
if (cameraData.isOffscreenRender)
return false;
bool isScaledRender = !Mathf.Approximately(cameraData.renderScale, 1.0f);
bool isTargetTexture2DArray = baseDescriptor.dimension == TextureDimension.Tex2DArray;
return cameraData.isSceneViewCamera || isScaledRender || cameraData.isHdrEnabled ||
cameraData.postProcessEnabled || cameraData.requiresOpaqueTexture || isTargetTexture2DArray || !cameraData.isDefaultViewport;
}
public static ClearFlag GetCameraClearFlag(Camera camera)
{
ClearFlag clearFlag = ClearFlag.None;

}
return configuration;
}
public static void RenderFullscreenQuad(CommandBuffer cmd, Material material, MaterialPropertyBlock properties = null, int shaderPassId = 0)
{
cmd.DrawMesh(fullscreenMesh, Matrix4x4.identity, material, 0, shaderPassId, properties);
}
public static void CopyTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier dest, Material material)
{
// TODO: In order to issue a copyTexture we need to also check if source and dest have same size
//if (SystemInfo.copyTextureSupport != CopyTextureSupport.None)
// cmd.CopyTexture(source, dest);
//else
cmd.Blit(source, dest, material);
}
void DisposePasses(ref ScriptableRenderContext context)
{
CommandBuffer cmd = CommandBufferPool.Get(k_ReleaseResourcesTag);
for (int i = 0; i < m_ActiveRenderPassQueue.Count; ++i)
m_ActiveRenderPassQueue[i].FrameCleanup(cmd);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
}
}

23
com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightStandardUnlit.shader


#else
half3 normalWS = normalize(IN.normal);
#endif
color += SAMPLE_GI(IN.lightmapUV, IN.vertexSH, normalWS);
color *= SAMPLE_GI(IN.lightmapUV, IN.vertexSH, normalWS);
#endif
ApplyFog(color, IN.uv0AndFogCoord.z);

#include "LWRP/ShaderLibrary/InputSurfaceUnlit.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
ENDHLSL
}
// This pass it not used during regular rendering, only for lightmap baking.
Pass
{
Name "Meta"
Tags{"LightMode" = "Meta"}
Cull Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma vertex LightweightVertexMeta
#pragma fragment LightweightFragmentMetaUnlit
#include "LWRP/ShaderLibrary/InputSurfaceUnlit.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassMetaUnlit.hlsl"
ENDHLSL
}
}

8
com.unity.render-pipelines.lightweight/package.json


{
"name": "com.unity.render-pipelines.lightweight",
"description": "Lightweight Render Pipeline for Unity.",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"com.unity.postprocessing": "2.0.10-preview",
"com.unity.render-pipelines.core": "3.3.0-preview",
"com.unity.shadergraph": "3.3.0-preview"
"com.unity.postprocessing": "2.0.11-preview",
"com.unity.render-pipelines.core": "3.4.0-preview",
"com.unity.shadergraph": "3.4.0-preview"
}
}

154
com.unity.shadergraph/CHANGELOG.md


## [3.3.0]
## [3.2.0]
## [3.1.0]
### HD Render Pipeline support
![](.data/hd_render_pipeline.png)
Shader Graph now supports the High Definition Render Pipeline with both PBR and Unlit Master nodes. Shaders built with Shader Graph work with both the Lightweight and HD render pipelines.
### Vertex position
![](.data/vertex_position.png)
You can now modify vertex position via the Position slot on the PBR and Unlit Master nodes. By default, the input to this node is object space position. Custom inputs to this slot should specify the absolute local position of a given vertex. Certain nodes (such as Procedural Shapes) are not viable in the vertex shader. Such nodes are incompatible with this slot.
### Master node settings
![](.data/menu_settings.png)
The settings for master nodes now live in a small window that you can toggle on and off. Here, you can change various rendering settings for your shader.
### Property reference names and exposed state
![](.data/editable_property_references.gif)
You can now edit the Reference name for a property. To do so, select the property and type a new name next to Reference. If you want to reset to the default name, right-click Reference, and select Reset reference.
In the expanded property window, you can now also toggle if the property is exposed.
### Editable paths for graphs
![](.data/change_path.gif)
![](.data/use_path.gif)
You can now change the path of Shader Graphs and Sub Graphs. When you change the path of a Shader Graph, this modifies the location it has in the shader selection list. When you change the path of Sub Graph, it will have a different location in the node creation menu.
### Is Front Face node
![](.data/face_sign.png)
With this node, you can change graph output depending on the face sign of a given fragment. If the current fragment is part of a front face, the node returns True. For a back face, the node returns False.
Note: This functionality requires that you have enabled **two sided** on the Master node.
### Gradient nodes
![](.data/gradient_node.png)
This adds gradient functionality via two new nodes. The Sample Gradient node samples a gradient given a Time parameter. You can define this gradient on the Gradient slot control view. The Gradient Asset node defines a gradient that can be sampled by multiple Sample Gradient nodes using different Time parameters.
### Waveform nodes
![](.data/wave_form_nodes.png)
Math nodes now have a Waves category. The category has four different nodes: Triangle wave, Sawtooth wave, Square wave, and Noise Sine wave.
The Triangle, Sawtooth, and Square wave nodes output a waveform with a range of -1 to 1 over a period of 1.
The Noise Sine wave outputs a standard Sine wave with a range of -1 to 1 over a period of 2 * pi. For variance, random noise is added to the amplitude of the Sine wave, within a determined range.
## Normal Derive Nodes
![](.data/normal_derive_nodes.png)
There are two Normal Derive Nodes: `Normal From Height` and `Normal Reconstruct Z`.
`Normal From Height` uses Vector1 input to derive a normal map. `Normal Reconstruct Z` uses the X and Y components in Vector2 input to derive the proper Z value for a normal map.
### Sphere Mask Node
![](.data/sphereMask.png)
With this node, you can create a sphere mask. Indicate the starting coordinate and center point. The sphere mask uses these with the **Radius** and **Hardness** parameters. Sphere mask functionality works in both 2D and 3D spaces, and is based on the vector coordinates in the **Coords and Center** input.
### Texture3D and Texture2D Array
![](.data/texture_nodes.png)
This change expands Unity's support for Texture types via two new property types and four new nodes. These allow you to define and sample Texture 3D and Texture 2D Array type assets in Shader Graph.
# Changelog
All notable changes to this package are documented in this file.
### Texture 2D LOD node
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
![](.data/texture_2d_lod_node.png)
## [3.4.0-preview]
### Added
- Shader Graph now supports the High Definition Render Pipeline with both PBR and Unlit Master nodes. Shaders built with Shader Graph work with both the Lightweight and HD render pipelines.
- You can now modify vertex position via the Position slot on the PBR and Unlit Master nodes. By default, the input to this node is object space position. Custom inputs to this slot should specify the absolute local position of a given vertex. Certain nodes (such as Procedural Shapes) are not viable in the vertex shader. Such nodes are incompatible with this slot.
- You can now edit the Reference name for a property. To do so, select the property and type a new name next to Reference. If you want to reset to the default name, right-click Reference, and select Reset reference.
- In the expanded property window, you can now toggle whether the property is exposed.
- You can now change the path of Shader Graphs and Sub Graphs. When you change the path of a Shader Graph, this modifies the location it has in the shader selection list. When you change the path of Sub Graph, it will have a different location in the node creation menu.
- Added `Is Front Face` node. With this node, you can change graph output depending on the face sign of a given fragment. If the current fragment is part of a front face, the node returns true. For a back face, the node returns false. Note: This functionality requires that you have enabled **two sided** on the Master node.
- Gradient functionality is now available via two new nodes: Sample Gradient and Gradient Asset. The Sample Gradient node samples a gradient given a Time parameter. You can define this gradient on the Gradient slot control view. The Gradient Asset node defines a gradient that can be sampled by multiple Sample Gradient nodes using different Time parameters.
- Math nodes now have a Waves category. The category has four different nodes: Triangle wave, Sawtooth wave, Square wave, and Noise Sine wave. The Triangle, Sawtooth, and Square wave nodes output a waveform with a range of -1 to 1 over a period of 1. The Noise Sine wave outputs a standard Sine wave with a range of -1 to 1 over a period of 2 * pi. For variance, random noise is added to the amplitude of the Sine wave, within a determined range.
- Added `Sphere Mask` node for which you can indicate the starting coordinate and center point. The sphere mask uses these with the **Radius** and **Hardness** parameters. Sphere mask functionality works in both 2D and 3D spaces, and is based on the vector coordinates in the **Coords and Center** input.
- Added support for Texture 3D and Texture 2D Array via two new property types and four new nodes.
- A new node `Texture 2D LOD` has been added for LOD functionality on a Texture 2D Sample. Sample Texture 2D LOD uses the exact same input and output slots as Sample Texture 2D, but also includes an input for level of detail adjustments via a Vector1 slot.
- Added `Texel Size` node, which allows you to get the special texture properties of a Texture 2D Asset via the `{texturename}_TexelSize` variable. Based on input from the Texture 2D Asset, the node outputs the width and height of the texel size in Vector1 format.
- Added `Rotate About Axis` node. This allows you to rotate a 3D vector space around an axis. For the rotation, you can specify an amount of degrees or a radian value.
This adds a new node for LOD functionality on a Texture 2D Sample. Sample Texture 2D LOD uses the exact same input and output slots as Sample Texture 2D, but also includes an input for level of detail adjustments via a Vector1 slot.
### Texel Size Node
![](.data/texel_size_node.png)
With this node, you can get the special texture properties of a Texture 2D Asset via the `{texturename}_TexelSize` variable. Based on input from the Texture 2D Asset, the node outputs the width and height of the texel size in Vector1 format.
**Note:** Do not use the default input to reference your texture Asset. It makes your graph perform worse. Connect this node to a separate Texture 2D Asset node per image example.
### Show generated code
![](.data/show_generated_code.gif)
You can now see the generated code for any specific node. To do so, right-click the node, and select Show Generated Code. The code snippet will now open in the code editor that you have linked to Unity.
### Rotate About Axis node
![](.data/rotate_about_axis_node.png)
With the Rotate About Axis node, you can rotate a 3D vector space around an axis. For the rotation, you can specify an amount of degrees or a radian value.
### Bug fixes and minor changes
### Changed
- The settings for master nodes now live in a small window that you can toggle on and off. Here, you can change various rendering settings for your shader.
- There are two Normal Derive Nodes: `Normal From Height` and `Normal Reconstruct Z`.
`Normal From Height` uses Vector1 input to derive a normal map.
`Normal Reconstruct Z` uses the X and Y components in Vector2 input to derive the proper Z value for a normal map.
- The Texture type default input now accepts render textures.
- HD PBR subshader no longer duplicates surface description code into vertex shader.
- If the current render pipeline is not compatible, master nodes now display an error badge.
- The preview shader now only considers the current render pipeline. Because of this there is less code to compile, so the preview shader compiles faster.
- When you rename a shader graph or sub shader graph locally on your disk, the title of the Shader Graph window, black board, and preview also updates.
- Removed legacy matrices from Transfomation Matrix node.
- Texture 2D Array and Texture 3D nodes can no longer be used in the vertex shader.
- `Normal Create` node has been renamed to `Normal From Texture`.
- When you close the Shader Graph after you have modified a file, the prompt about saving your changes now shows the file name as well.
- `Blend` node now supports Overwrite mode.
- `Simple Noise` node no longer has a loop.
- The `Polygon` node now calculates radius based on apothem.
- `Normal Strength` node now calculates Z value more accurately.
### Fixed
- Vector 1 nodes now evaluate correctly. ([#334](https://github.com/Unity-Technologies/ShaderGraph/issues/334) and [#337](https://github.com/Unity-Technologies/ShaderGraph/issues/337))
- Properties can now be copied and pasted.
- Pasting a property node into another graph will now convert it to a concrete node. ([#300](https://github.com/Unity-Technologies/ShaderGraph/issues/300) and [#307](https://github.com/Unity-Technologies/ShaderGraph/pull/307))

- Sub graphs are now suffixed with (sub), so you can tell them apart from other nodes.
- Boolean and Texture type properties now function correctly in sub-graphs.
- The preview of a node does not obstruct the selection outliner anymore.
- The Texture type default input now accepts render textures.
- HD PBR subshader no longer duplicates surface description code into vertex shader.
- If the current render pipeline is not compatible, master nodes now display an error badge.
- The preview shader now only considers the current render pipeline. Because of this there is less code to compile, and therefore the preview shader will compile faster.
- When you rename a shader graph or sub shader graph locally on your disk, the title of the Shader Graph window, black board, and preview also updates.
- Removed legacy matrices from Transfomation Matrix node.
- Texture 2D Array and Texture 3D nodes can no longer be used in the vertex shader.
- `Blend` node now supports Overwrite mode.
- `Simple Noise` node no longer has a loop.
- The `Polygon` node now calculates radius based on apothem.
- `Normal Strength` node now calculates Z value more accurately.
- The preview of nodes now updates correctly.
- Your system locale can no longer cause incorrect commands due to full stops being converted to commas.

8
com.unity.shadergraph/Editor/Data/Graphs/ColorShaderProperty.cs


result.Append("(\"");
result.Append(displayName);
result.Append("\", Color) = (");
result.Append(value.r);
result.Append(NodeUtils.FloatToShaderValue(value.r));
result.Append(value.g);
result.Append(NodeUtils.FloatToShaderValue(value.g));
result.Append(value.b);
result.Append(NodeUtils.FloatToShaderValue(value.b));
result.Append(value.a);
result.Append(NodeUtils.FloatToShaderValue(value.a));
result.Append(")");
return result.ToString();
}

10
com.unity.shadergraph/Editor/Data/Graphs/ShaderGraphRequirements.cs


public bool requiresVertexColor;
public bool requiresFaceSign;
public List<UVChannel> requiresMeshUVs;
public bool requiresDepthTexture;
public bool requiresCameraOpaqueTexture;
public static ShaderGraphRequirements none
{

newReqs.requiresScreenPosition = other.requiresScreenPosition | requiresScreenPosition;
newReqs.requiresVertexColor = other.requiresVertexColor | requiresVertexColor;
newReqs.requiresFaceSign = other.requiresFaceSign | requiresFaceSign;
newReqs.requiresDepthTexture = other.requiresDepthTexture | requiresDepthTexture;
newReqs.requiresCameraOpaqueTexture = other.requiresCameraOpaqueTexture | requiresCameraOpaqueTexture;
newReqs.requiresMeshUVs = new List<UVChannel>();
if (requiresMeshUVs != null)

bool requiresScreenPosition = nodes.OfType<IMayRequireScreenPosition>().Any(x => x.RequiresScreenPosition());
bool requiresVertexColor = nodes.OfType<IMayRequireVertexColor>().Any(x => x.RequiresVertexColor());
bool requiresFaceSign = nodes.OfType<IMayRequireFaceSign>().Any(x => x.RequiresFaceSign());
bool requiresDepthTexture = nodes.OfType<IMayRequireDepthTexture>().Any(x => x.RequiresDepthTexture());
bool requiresCameraOpaqueTexture = nodes.OfType<IMayRequireCameraOpaqueTexture>().Any(x => x.RequiresCameraOpaqueTexture());
var meshUV = new List<UVChannel>();
for (int uvIndex = 0; uvIndex < ShaderGeneratorNames.UVCount; ++uvIndex)

requiresScreenPosition = requiresScreenPosition,
requiresVertexColor = requiresVertexColor,
requiresFaceSign = requiresFaceSign,
requiresMeshUVs = meshUV
requiresMeshUVs = meshUV,
requiresDepthTexture = requiresDepthTexture,
requiresCameraOpaqueTexture = requiresCameraOpaqueTexture
};
return reqs;

9
com.unity.shadergraph/Editor/Data/Graphs/VectorShaderProperty.cs


using System;
using System.Text;
using UnityEditor.Graphing;
using UnityEngine;
namespace UnityEditor.ShaderGraph

result.Append("(\"");
result.Append(displayName);
result.Append("\", Vector) = (");
result.Append(value.x);
result.Append(NodeUtils.FloatToShaderValue(value.x));
result.Append(value.y);
result.Append(NodeUtils.FloatToShaderValue(value.y));
result.Append(value.z);
result.Append(NodeUtils.FloatToShaderValue(value.z));
result.Append(value.w);
result.Append(NodeUtils.FloatToShaderValue(value.w));
result.Append(")");
return result.ToString();
}

38
com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs


{
var name = preferredCoordinateSpace.ToVariableName(InterpolatorType.Position);
var preferredSpacePosition = ConvertBetweenSpace("v.vertex", CoordinateSpace.Object, preferredCoordinateSpace, InputType.Position);
vertexShader.AppendLine("float3 {0} = {1};", name, preferredSpacePosition);
vertexShader.AppendLine("float3 {0} = {1}.xyz;", name, preferredSpacePosition);
if (graphModelRequirements.requiresPosition > 0)
{
vertexOutputStruct.AppendLine("float3 {0} : TEXCOORD{1};", name, interpolatorIndex);

}
return "error";
}
private static string DimensionToSwizzle(Dimension d)
{
switch (d)
{
case Dimension.One:
return "x";
case Dimension.Two:
return "xy";
case Dimension.Three:
return "xyz";
case Dimension.Four:
return "xyzw";
}
return "error";
}
public static void GenerateSpaceTranslations(
NeededCoordinateSpace neededSpaces,

Dimension dimension)
{
if ((neededSpaces & NeededCoordinateSpace.Object) > 0 && from != CoordinateSpace.Object)
pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
CoordinateSpace.Object.ToVariableName(type), ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Object, inputType, from));
pixelShader.AppendLine("float{0} {1} = {2}.{3};", DimensionToString(dimension),
CoordinateSpace.Object.ToVariableName(type), ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Object, inputType, from),
DimensionToSwizzle(dimension));
pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
CoordinateSpace.World.ToVariableName(type), ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.World, inputType, from));
pixelShader.AppendLine("float{0} {1} = {2}.{3};", DimensionToString(dimension),
CoordinateSpace.World.ToVariableName(type), ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.World, inputType, from),
DimensionToSwizzle(dimension));
pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
pixelShader.AppendLine("float{0} {1} = {2}.{3};", DimensionToString(dimension),
ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.View, inputType, from));
ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.View, inputType, from),
DimensionToSwizzle(dimension));
pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
pixelShader.AppendLine("float{0} {1} = {2}.{3};", DimensionToString(dimension),
ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Tangent, inputType, from));
ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Tangent, inputType, from),
DimensionToSwizzle(dimension));
}
public static string GetPreviewSubShader(AbstractMaterialNode node, ShaderGraphRequirements shaderGraphRequirements)

12
com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs


ColorSpace m_ColorSpace;
RenderPipelineAsset m_RenderPipelineAsset;
bool m_FrameAllAfterLayout;
GraphEditorView m_GraphEditorView;

m_GraphEditorView.saveRequested += UpdateAsset;
m_GraphEditorView.convertToSubgraphRequested += ToSubGraph;
m_GraphEditorView.showInProjectRequested += PingAsset;
m_GraphEditorView.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
this.GetRootVisualContainer().Add(graphEditorView);
}
}

{
if (graphObject != null)
{
if (graphObject.isDirty && EditorUtility.DisplayDialog("Shader Graph Has Been Modified", "Do you want to save the changes you made in the shader graph?\n\nYour changes will be lost if you don't save them.", "Save", "Don't Save"))
string nameOfFile = AssetDatabase.GUIDToAssetPath(selectedGuid);
if (graphObject.isDirty && EditorUtility.DisplayDialog("Shader Graph Has Been Modified", "Do you want to save the changes you made in the shader graph?\n" + nameOfFile + "\n\nYour changes will be lost if you don't save them.", "Save", "Don't Save"))
UpdateAsset();
Undo.ClearUndo(graphObject);
DestroyImmediate(graphObject);

persistenceKey = selectedGuid,
assetName = asset.name.Split('/').Last()
};
m_FrameAllAfterLayout = true;
graphEditorView.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
titleContent = new GUIContent(asset.name.Split('/').Last());

void OnGeometryChanged(GeometryChangedEvent evt)
{
graphEditorView.UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);
graphEditorView.graphView.FrameAll();
if (m_FrameAllAfterLayout)
graphEditorView.graphView.FrameAll();
m_FrameAllAfterLayout = false;
foreach (var node in m_GraphObject.graph.GetNodes<AbstractMaterialNode>())
node.Dirty(ModificationScope.Node);
}
}
}

28
com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl


// UNITY_SHADER_NO_UPGRADE
#ifndef UNITY_SHADER_GRAPH_INCLUDED
#define UNITY_SHADER_GRAPH_INCLUDED
#ifndef UNITY_GRAPHFUNCTIONS_INCLUDED
#define UNITY_GRAPHFUNCTIONS_INCLUDED
// ----------------------------------------------------------------------------
// Included in generated graph shaders
// ----------------------------------------------------------------------------
bool IsGammaSpace()
{

float2 alphas[8];
};
#endif // UNITY_SHADER_GRAPH_INCLUDED
#ifndef SHADERGRAPH_SAMPLE_SCENE_DEPTH
#define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_SampleSceneDepth(uv);
#endif
#ifndef SHADERGRAPH_SAMPLE_SCENE_COLOR
#define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_SampleSceneColor(uv);
#endif
float shadergraph_SampleSceneDepth(float2 uv)
{
return 1;
}
float3 shadergraph_SampleSceneColor(float2 uv)
{
return 0;
}
#endif // UNITY_GRAPHFUNCTIONS_INCLUDED

2
com.unity.shadergraph/package.json


{
"name": "com.unity.shadergraph",
"description": "Shader Graph",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"unity": "2018.3",
"displayName": "Shader Graph",
"dependencies": {

2
com.unity.testframework.graphics/CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.4.0]
## [3.3.0]
## [3.2.0]

2
com.unity.testframework.graphics/package.json


{
"name": "com.unity.testframework.graphics",
"displayName":"Graphics Tests Framework",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"unity": "2018.3",
"description": "Provides test framework helpers for writing tests for graphics code, such as image comparison assertions and automatic management of reference images.",
"keywords": ["qa", "test", "testing", "tests", "graphics"],

4
com.unity.testing.srp.core/package.json


{
"name": "com.unity.testing.srp.core",
"displayName":"Core Graphics Tests",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"com.unity.render-pipelines.core" : "3.3.0-preview"
"com.unity.render-pipelines.core" : "3.4.0-preview"
}
}

12
com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs


m_Initialized = true;
}
public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults, ref RenderingData renderingData)
public void Setup(ScriptableRenderer renderer, ref RenderingData renderingData)
renderer.Clear();
renderer.SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
renderer.SetupPerObjectLightIndices(ref renderingData.cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);
RenderTextureDescriptor shadowDescriptor = baseDescriptor;
shadowDescriptor.dimension = TextureDimension.Tex2D;

renderer.EnqueuePass(m_CreateLightweightRenderTexturesPass);
Camera camera = renderingData.cameraData.camera;
bool dynamicBatching = renderingData.supportsDynamicBatching;
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration);
renderer.EnqueuePass(m_RenderOpaqueForwardPass);
}
}

23
com.unity.testing.srp.lightweight/Tests/Scenes/052_LWCallbacks/CameraCallbackTests.cs


using UnityEngine;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
using UnityEngine.Rendering;

m_Target = target;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
RenderTextureDescriptor opaqueDesc = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor opaqueDesc = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);
var cmd = CommandBufferPool.Get("Capture Pass");
cmd.GetTemporaryRT(m_Target.id, opaqueDesc);

{
CapturePass m_CopyResult = new CapturePass();
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults,
ref RenderingData renderingData)
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
m_CopyResult.Execute(renderer, ref context, ref cullResults, ref renderingData);
m_CopyResult.Execute(renderer, context, ref renderingData);
Material material = renderer.GetMaterial(MaterialHandles.Blit);

cmd.SetViewport(new Rect(0, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
cmd.SetGlobalTexture("_BlitTex", afterDepth.Identifier());
LightweightPipeline.DrawFullScreen(cmd, material);
ScriptableRenderer.RenderFullscreenQuad(cmd, material);
LightweightPipeline.DrawFullScreen(cmd, material);
ScriptableRenderer.RenderFullscreenQuad(cmd, material);
LightweightPipeline.DrawFullScreen(cmd, material);
ScriptableRenderer.RenderFullscreenQuad(cmd, material);
LightweightPipeline.DrawFullScreen(cmd, material);
ScriptableRenderer.RenderFullscreenQuad(cmd, material);
LightweightPipeline.DrawFullScreen(cmd, material);
ScriptableRenderer.RenderFullscreenQuad(cmd, material);
//TODO: Upsidown UV trash, ignore this for now

6
com.unity.testing.srp.lightweight/package.json


{
"name": "com.unity.testing.srp.lightweight",
"displayName":"Lightweight Graphics Tests",
"version": "3.3.0-preview",
"version": "3.4.0-preview",
"com.unity.render-pipelines.lightweight" : "3.3.0-preview",
"com.unity.testframework.graphics" : "3.3.0-preview"
"com.unity.render-pipelines.lightweight" : "3.4.0-preview",
"com.unity.testframework.graphics" : "3.4.0-preview"
}
}

21
TestProjects/LWGraphicsTest/Assets/Editor/LoadPackageSceneContext.cs


using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
public class LoadPackageSceneContext : Editor
{
[MenuItem("Assets/Load Package Scene", false, -10)]
private static void LoadPackageScene()
{
var path = AssetDatabase.GetAssetPath(Selection.activeObject);
EditorSceneManager.OpenScene(path);
}
[MenuItem("Assets/Load Package Scene", true)]
private static bool ValidatePackageScene()
{
return Selection.activeObject is SceneAsset;
}
}

19
com.unity.render-pipelines.high-definition/HDRP/ShaderGraphFunctions.hlsl


#ifndef UNITY_GRAPHFUNCTIONS_HD_INCLUDED
#define UNITY_GRAPHFUNCTIONS_HD_INCLUDED
#define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_HDSampleSceneDepth(uv);
float shadergraph_HDSampleSceneDepth(float2 uv)
{
#if defined(REQUIRE_DEPTH_TEXTURE)
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv);
return Linear01Depth(rawDepth, _ZBufferParams);
#endif
return 0;
}
// Always include Shader Graph version
// Always include last to avoid double macros
#include "ShaderGraphLibrary/Functions.hlsl"
#endif // UNITY_GRAPHFUNCTIONS_HD_INCLUDED

8
com.unity.render-pipelines.high-definition/HDRP/ShaderGraphFunctions.hlsl.meta


fileFormatVersion: 2
guid: 609118ca59c7543f59f7b5967e96b463
timeCreated: 1472205826
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

16
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/LightweightPassMetaUnlit.hlsl


#ifndef LIGHTWEIGHT_PASS_META_SIMPLE_INCLUDED
#define LIGHTWEIGHT_PASS_META_SIMPLE_INCLUDED
#include "LightweightPassMetaCommon.hlsl"
half4 LightweightFragmentMetaUnlit(MetaVertexOuput i) : SV_Target
{
float2 uv = i.uv;
MetaInput o = (MetaInput)0;
o.Albedo = _Color.rgb * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv).rgb;
return MetaFragment(o);
}
#endif // LIGHTWEIGHT_PASS_META_SIMPLE_INCLUDED

9
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/LightweightPassMetaUnlit.hlsl.meta


fileFormatVersion: 2
guid: 138efaf7fb432134da44d5a4981a62ad
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

46
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl


#ifndef UNITY_GRAPHFUNCTIONS_LW_INCLUDED
#define UNITY_GRAPHFUNCTIONS_LW_INCLUDED
#define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_LWSampleSceneDepth(uv);
#define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_LWSampleSceneColor(uv);
#if defined(REQUIRE_DEPTH_TEXTURE)
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
TEXTURE2D_ARRAY(_CameraDepthTexture);
#else
TEXTURE2D(_CameraDepthTexture);
#endif
SAMPLER(sampler_CameraDepthTexture);
#endif // REQUIRE_DEPTH_TEXTURE
#if defined(REQUIRE_OPAQUE_TEXTURE)
TEXTURE2D(_CameraOpaqueTexture);
SAMPLER(sampler_CameraOpaqueTexture);
#endif // REQUIRE_OPAQUE_TEXTURE
float shadergraph_LWSampleSceneDepth(float2 uv)
{
#if defined(REQUIRE_DEPTH_TEXTURE)
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
float rawDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r;
#else
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv);
#endif
return Linear01Depth(rawDepth, _ZBufferParams);
#endif // REQUIRE_DEPTH_TEXTURE
return 0;
}
float3 shadergraph_LWSampleSceneColor(float2 uv)
{
#if defined(REQUIRE_OPAQUE_TEXTURE)
return SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv);
#endif
return 0;
}
// Always include Shader Graph version
// Always include last to avoid double macros
#include "ShaderGraphLibrary/Functions.hlsl"
#endif // UNITY_GRAPHFUNCTIONS_LW_INCLUDED

9
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl.meta


fileFormatVersion: 2
guid: 9adc879d74aec4400bbdce89ff664a05
timeCreated: 1488965025
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

18
com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireCameraOpaqueTexture.cs


using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
public interface IMayRequireCameraOpaqueTexture
{
bool RequiresCameraOpaqueTexture(ShaderStageCapability stageCapability = ShaderStageCapability.All);
}
public static class MayRequireCameraOpaqueTextureExtensions
{
public static bool RequiresCameraOpaqueTexture(this ISlot slot)
{
var mayRequireCameraOpaqueTexture = slot as IMayRequireCameraOpaqueTexture;
return mayRequireCameraOpaqueTexture != null && mayRequireCameraOpaqueTexture.RequiresCameraOpaqueTexture();
}
}
}

11
com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireCameraOpaqueTexture.cs.meta


fileFormatVersion: 2
guid: 93fdbd040dca943cbbd42c33416450a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

18
com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireDepthTexture.cs


using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
public interface IMayRequireDepthTexture
{
bool RequiresDepthTexture(ShaderStageCapability stageCapability = ShaderStageCapability.All);
}
public static class MayRequireDepthTextureExtensions
{
public static bool RequiresDepthTexture(this ISlot slot)
{
var mayRequireDepthTexture = slot as IMayRequireDepthTexture;
return mayRequireDepthTexture != null && mayRequireDepthTexture.RequiresDepthTexture();
}
}
}

11
com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireDepthTexture.cs.meta


fileFormatVersion: 2
guid: 6f00cea5e23a84b5bbe1ac581ebfc64e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

51
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneColorNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Input", "Scene", "Scene Color")]
public sealed class SceneColorNode : CodeFunctionNode, IMayRequireCameraOpaqueTexture
{
const string kScreenPositionSlotName = "UV";
const string kOutputSlotName = "Out";
public const int ScreenPositionSlotId = 0;
public const int OutputSlotId = 1;
public SceneColorNode()
{
name = "Scene Color";
UpdateNodeAfterDeserialization();
}
public override bool hasPreview { get { return false; } }
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Scene-Color-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_SceneColor", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_SceneColor(
[Slot(0, Binding.ScreenPosition)] Vector3 UV,
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out)
{
Out = Vector3.one;
return
@"
{
Out = SHADERGRAPH_SAMPLE_SCENE_COLOR(UV);
}
";
}
public bool RequiresCameraOpaqueTexture(ShaderStageCapability stageCapability)
{
return true;
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneColorNode.cs.meta


fileFormatVersion: 2
guid: c4ba33edde21e400685cf0fb5c8f2551
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

51
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneDepthNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Input", "Scene", "Scene Depth")]
public sealed class SceneDepthNode : CodeFunctionNode, IMayRequireDepthTexture
{
const string kScreenPositionSlotName = "UV";
const string kOutputSlotName = "Out";
public const int ScreenPositionSlotId = 0;
public const int OutputSlotId = 1;
public SceneDepthNode()
{
name = "Scene Depth";
UpdateNodeAfterDeserialization();
}
public override bool hasPreview { get { return false; } }
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Scene-Depth-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_SceneDepth", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_SceneDepth(
[Slot(0, Binding.ScreenPosition)] Vector3 UV,
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out)
{
Out = Vector3.one;
return
@"
{
Out = SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV);
}
";
}
public bool RequiresDepthTexture(ShaderStageCapability stageCapability)
{
return true;
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneDepthNode.cs.meta


fileFormatVersion: 2
guid: f8e0a75d065844105a06ca48151adb7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

527
com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/OSXEditor/Metal/053_UnlitShader.png

之前 之后
宽度: 640  |  高度: 360  |  大小: 163 KiB

88
com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/OSXEditor/Metal/053_UnlitShader.png.meta


fileFormatVersion: 2
guid: aa26d0308cd9631418e467acf2f89ab7
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

471
com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/WindowsEditor/Direct3D11/053_UnlitShader.png

之前 之后
宽度: 640  |  高度: 360  |  大小: 164 KiB

88
com.unity.testing.srp.lightweight/Tests/ReferenceImages/Linear/WindowsEditor/Direct3D11/053_UnlitShader.png.meta


fileFormatVersion: 2
guid: 69716be9cc82acf469f570a96784d55f
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.meta


fileFormatVersion: 2
guid: eabef01b56bce11469538142c0ccb63c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.unity
文件差异内容过多而无法显示
查看文件

9
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader.unity.meta


fileFormatVersion: 2
guid: a28e1d48e6e3c0e42a4050ab4e770bf8
labels:
- TestRunnerBake
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

26
.github/PULL_REQUEST_TEMPLATE.md


### Purpose of this PR
Why is this PR needed, what hard problem is it solving/fixing?
---
### Release Notes
Please add any useful notes about the feature/fix that might be helpful for others.
---
### Testing status
**Katana Tests**: First off we need to make sure the Katana SRP tests are green?
**Manual Tests**: What did you do?
**Automated Tests**: What did you setup?
Any test projects to go with this to help reviewers?
---
### Overall Product Risks
**Technical Risk**: None, Low, Medium, High?
**Halo Effect**: None, Low, Medium, High?
---
### Comments to reviewers
Notes for the reviewers you have assigned.

3
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/.gitignore


Lightmap-*_comp*
LightingData.*
ReflectionProbe-*

88
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red GI.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: unlit shader red GI
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: c7dece3af22324452a0f9fe4aeb9d462, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReceiveShadows: 1
- _SampleGI: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.75, g: 0.75, b: 0.75, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}

8
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red GI.mat.meta


fileFormatVersion: 2
guid: e72895f223ff50b47960163b47f8704f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

88
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red no GI.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: unlit shader red no GI
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_ShaderKeywords: _SAMPLE_GI
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: c7dece3af22324452a0f9fe4aeb9d462, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReceiveShadows: 1
- _SampleGI: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.7490196, g: 0.7490196, b: 0.7490196, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}

8
com.unity.testing.srp.lightweight/Tests/Scenes/053_UnlitShader/unlit shader red no GI.mat.meta


fileFormatVersion: 2
guid: 4324c9e03c85931409641c62a4f75f0b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

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

正在加载...
取消
保存