浏览代码

Merge branch 'master' into volume-improvements

/namespace
GitHub 7 年前
当前提交
10e23187
共有 100 个文件被更改,包括 1375 次插入997 次删除
  1. 110
      LICENSE
  2. 2
      SampleScenes/Common/Shaders/CubemapColorMap.shader
  3. 68
      ScriptableRenderPipeline/Core/Editor/ShaderGenerator/CSharpToHLSL.cs
  4. 2
      ScriptableRenderPipeline/Core/Resources/BlitCubeTextureFace.shader
  5. 8
      ScriptableRenderPipeline/Core/Resources/EncodeBC6H.compute
  6. 4
      ScriptableRenderPipeline/Core/Resources/GPUCopy.compute
  7. 4
      ScriptableRenderPipeline/Core/Resources/GPUCopy.compute.meta
  8. 4
      ScriptableRenderPipeline/Core/Resources/GPUCopyAsset.cs
  9. 125
      ScriptableRenderPipeline/Core/ShaderLibrary/API/D3D11.hlsl
  10. 125
      ScriptableRenderPipeline/Core/ShaderLibrary/API/Metal.hlsl
  11. 125
      ScriptableRenderPipeline/Core/ShaderLibrary/API/PSSL.hlsl
  12. 125
      ScriptableRenderPipeline/Core/ShaderLibrary/API/Vulkan.hlsl
  13. 125
      ScriptableRenderPipeline/Core/ShaderLibrary/API/XBoxOne.hlsl
  14. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/ImageBasedLighting.hlsl
  15. 3
      ScriptableRenderPipeline/Core/ShaderLibrary/Macros.hlsl
  16. 4
      ScriptableRenderPipeline/Core/ShaderLibrary/Wind.hlsl
  17. 2
      ScriptableRenderPipeline/Core/package.json
  18. 2
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayLatlong.shader
  19. 2
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader
  20. 9
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDAssetFactory.cs
  21. 6
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/BaseLitUI.cs
  22. 5
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.Styles.cs
  23. 11
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.cs
  24. 263
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  25. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
  26. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDStringConstants.cs
  27. 30
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightEvaluation.hlsl
  28. 11
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoopDef.hlsl
  29. 8
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/ShadowContext.hlsl
  30. 1
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/builddispatchindirect.compute
  31. 1
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/materialflags.compute
  32. 2
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/Lighting.hlsl
  33. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl
  34. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/GGXConvolution/BuildProbabilityTables.compute
  35. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/GGXConvolution/GGXConvolve.shader
  36. 12
      ScriptableRenderPipeline/HDRenderPipeline/Material/GGXConvolution/RuntimeFilterIBL.cs
  37. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  38. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  39. 16
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  40. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  41. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataMeshModification.hlsl
  42. 46
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  43. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  44. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl
  45. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.hlsl
  46. 224
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs
  47. 9
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScatteringSettings.cs
  48. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/UnlitProperties.hlsl
  49. 55
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DepthDownsample.compute
  50. 14
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset
  51. 4
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset.meta
  52. 10
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs
  53. 52
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl
  54. 11
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl
  55. 24
      ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl
  56. 2
      ScriptableRenderPipeline/HDRenderPipeline/Sky/BlitCubemap.shader
  57. 2
      ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
  58. 8
      ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  59. 5
      ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyVariables.hlsl
  60. 4
      ScriptableRenderPipeline/HDRenderPipeline/package.json
  61. 68
      ScriptableRenderPipeline/LightweightPipeline/Data/LightweightPipelineAsset.cs
  62. 4
      ScriptableRenderPipeline/LightweightPipeline/package.json
  63. 2
      ScriptableRenderPipeline/master-package.json
  64. 74
      Tests/GraphicsTests/Framework/Editor/TestFramework.cs
  65. 23
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_GraphicTests_Asset.asset
  66. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMapping.hlsl
  67. 4
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CopyStencilBuffer.shader
  68. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.shader
  69. 20
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute
  70. 97
      ScriptableRenderPipeline/Core/LICENSE
  71. 7
      ScriptableRenderPipeline/Core/LICENSE.meta
  72. 8
      ScriptableRenderPipeline/Core/ShaderLibrary/Sampling.meta
  73. 97
      ScriptableRenderPipeline/HDRenderPipeline/LICENSE
  74. 7
      ScriptableRenderPipeline/HDRenderPipeline/LICENSE.meta
  75. 9
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CopyStencilBuffer.shader.meta
  76. 97
      ScriptableRenderPipeline/LightweightPipeline/LICENSE
  77. 7
      ScriptableRenderPipeline/LightweightPipeline/LICENSE.meta
  78. 82
      ScriptableRenderPipeline/Core/ShaderLibrary/Filtering.hlsl
  79. 8
      ScriptableRenderPipeline/Core/ShaderLibrary/Filtering.hlsl.meta
  80. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CopyStencilBuffer.shader.meta
  81. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Sampling.hlsl.meta
  82. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Fibonacci.hlsl.meta
  83. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Hammersley.hlsl.meta
  84. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Fibonacci.hlsl
  85. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Hammersley.hlsl
  86. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl.meta
  87. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl.meta
  88. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMapping.hlsl.meta
  89. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMapping.hlsl
  90. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl
  91. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl
  92. 0
      /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Sampling.hlsl
  93. 0
      /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute.meta
  94. 0
      /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.shader.meta
  95. 0
      /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/CombineLighting.shader.meta
  96. 0
      /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/CombineLighting.shader
  97. 0
      /ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CopyStencilBuffer.shader
  98. 0
      /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.shader
  99. 0
      /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute

110
LICENSE


MIT License
Unity Companion License (“License”)
Software Copyright © 2017 Unity Technologies ApS
Copyright (c) 2016 Unity Technologies
Unity Technologies ApS (“Unity”) grants to you a worldwide, non-exclusive,
no-charge, and royalty-free copyright license to reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense, and distribute the
software that is made available under this License (“Software”), subject to the
following terms and conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
1. Unity Companion Use Only. Exercise of the license granted herein is limited
to exercise for the creation, use, and/or distribution of applications,
software, or other content pursuant to a valid Unity content authoring and
rendering engine software license (“Engine License”). That means while use of
the Software is not limited to use in the software licensed under the Engine
License, the Software may not be used for any purpose other than the creation,
use, and/or distribution of Engine License-dependent applications, software, or
other content. No other exercise of the license granted herein is permitted,
and in no event may the Software be used for competitive analysis or to develop
a competing product or service.
2. No Modification of Engine License. Neither this License nor any exercise of
the license granted herein modifies the Engine License in any way.
3. Ownership & Grant Back to You.
3.1 You own your content. In this License, “derivative works” means derivatives
of the Software itself--works derived only from the Software by you under this
License (for example, modifying the code of the Software itself to improve its
efficacy); “derivative works” of the Software do not include, for example,
games, apps, or content that you create using the Software. You keep all right,
title, and interest to your own content.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
3.2 Unity owns its content. While you keep all right, title, and interest to
your own content per the above, as between Unity and you, Unity will own all
right, title, and interest to all intellectual property rights (including
patent, trademark, and copyright) in the Software and derivative works of the
Software, and you hereby assign and agree to assign all such rights in those
derivative works to Unity.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3.3 You have a license to those derivative works. Subject to this License,
Unity grants to you the same worldwide, non-exclusive, no-charge, and
royalty-free copyright license to derivative works of the Software you create
as is granted to you for the Software under this License.
4. Trademarks. You are not granted any right or license under this License to
use any trademarks, service marks, trade names, products names, or branding of
Unity or its affiliates (“Trademarks”). Descriptive uses of Trademarks are
permitted; see, for example, Unity’s Branding Usage Guidelines at
https://unity3d.com/public-relations/brand.
5. Notices & Third-Party Rights. This License, including the copyright notice
associated with the Software, must be provided in all substantial portions of
the Software and derivative works thereof (or, if that is impracticable, in any
other location where such notices are customarily placed). Further, if the
Software is accompanied by a Unity “third-party notices” or similar file, you
acknowledge and agree that software identified in that file is governed by
those separate license terms.
6. DISCLAIMER, LIMITATION OF LIABILITY. THE SOFTWARE AND ANY DERIVATIVE WORKS
THEREOF IS PROVIDED ON AN "AS IS" BASIS, AND IS PROVIDED WITHOUT WARRANTY OF
ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR NONINFRINGEMENT. IN
NO EVENT SHALL ANY COPYRIGHT HOLDER OR AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES
(WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL,
INCLUDING PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR
PROFITS, AND BUSINESS INTERRUPTION), OR OTHER LIABILITY WHATSOEVER, WHETHER IN
AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM OR OUT OF, OR IN
CONNECTION WITH, THE SOFTWARE OR ANY DERIVATIVE WORKS THEREOF OR THE USE OF OR
OTHER DEALINGS IN SAME, EVEN WHERE ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7. USE IS ACCEPTANCE and License Versions. Your receipt and use of the Software
constitutes your acceptance of this License and its terms and conditions.
Software released by Unity under this License may be modified or updated and
the License with it; upon any such modification or update, you will comply with
the terms of the updated License for any use of any of the Software under the
updated License.
8. Use in Compliance with Law and Termination. Your exercise of the license
granted herein will at all times be in compliance with applicable law and will
not infringe any proprietary rights (including intellectual property rights);
this License will terminate immediately on any breach by you of this License.
9. Severability. If any provision of this License is held to be unenforceable
or invalid, that provision will be enforced to the maximum extent possible and
the other provisions will remain in full force and effect.
10. Governing Law and Venue. This License is governed by and construed in
accordance with the laws of Denmark, except for its conflict of laws rules; the
United Nations Convention on Contracts for the International Sale of Goods will
not apply. If you reside (or your principal place of business is) within the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the state and federal courts located in San
Francisco County, California concerning any dispute arising out of this License
(“Dispute”). If you reside (or your principal place of business is) outside the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the courts located in Copenhagen, Denmark
concerning any Dispute.

2
SampleScenes/Common/Shaders/CubemapColorMap.shader


Shader "Hidden/CubemapColorMap" {
Shader "Hidden/CubemapColorMap" {
Properties {
_ColorMap("Color", Cube) = "white" {}
_MipIndex("Mip Index", Int) = 0

68
ScriptableRenderPipeline/Core/Editor/ShaderGenerator/CSharpToHLSL.cs


using System;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.NRefactory.Ast;

s_TypeName = new Dictionary<string, ShaderTypeGenerator>();
// Iterate over assemblyList, discover all applicable types with fully qualified names
var assemblyList = AssemblyEnumerator.EnumerateReferencedAssemblies(Assembly.GetCallingAssembly());
var assemblyList = AppDomain.CurrentDomain.GetAssemblies().ToList();
foreach (var assembly in assemblyList)
{

return null;
}
}
}
// Helper class to recursively enumerate assemblies referenced by the calling assembly, including unloaded ones
static class AssemblyEnumerator
{
public static List<Assembly> EnumerateReferencedAssemblies(Assembly assembly)
{
Dictionary<string, Assembly> referenced = assembly.GetReferencedAssembliesRecursive();
referenced[GetName(assembly.FullName)] = assembly;
return referenced.Values.ToList();
}
public static Dictionary<string, Assembly> GetReferencedAssembliesRecursive(this Assembly assembly)
{
s_Assemblies = new Dictionary<string, Assembly>();
InternalGetDependentAssembliesRecursive(assembly);
// Skip assemblies from GAC (@TODO: any reason we'd want to include them?)
var keysToRemove = s_Assemblies.Values.Where(
o => o.GlobalAssemblyCache == true).ToList();
foreach (var k in keysToRemove)
{
s_Assemblies.Remove(GetName(k.FullName));
}
return s_Assemblies;
}
private static void InternalGetDependentAssembliesRecursive(Assembly assembly)
{
// Load assemblies with newest versions first.
var referencedAssemblies = assembly.GetReferencedAssemblies()
.OrderByDescending(o => o.Version);
foreach (var r in referencedAssemblies)
{
if (string.IsNullOrEmpty(assembly.FullName))
{
continue;
}
if (s_Assemblies.ContainsKey(GetName(r.FullName)))
continue;
try
{
// Ensure that the assembly is loaded
var a = Assembly.Load(r.FullName);
s_Assemblies[GetName(a.FullName)] = a;
InternalGetDependentAssembliesRecursive(a);
}
catch
{
// Missing dll, ignore.
}
}
}
static string GetName(string name)
{
return name.Split(',')[0];
}
static Dictionary<string, Assembly> s_Assemblies;
}
}

2
ScriptableRenderPipeline/Core/Resources/BlitCubeTextureFace.shader


#pragma target 3.0
TEXTURECUBE(_InputTex);
SAMPLERCUBE(sampler_InputTex);
SAMPLER(sampler_InputTex);
float _FaceIndex;
float _LoD;

8
ScriptableRenderPipeline/Core/Resources/EncodeBC6H.compute


#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/Sampling.hlsl"
#include "ShaderLibrary/Sampling/Sampling.hlsl"
SamplerState s_point_clamp;
SAMPLER(s_point_clamp);
static const uint2 kOffsets[] =
{

{
nvc = CubemapTexelToNVC(topLeftSourceID + kOffsets[i], size);
dir = CubemapTexelToDirection(nvc, faceId);
texels[i] = _Source.SampleLevel(s_point_clamp, dir, _MipIndex).rgb;
texels[i] = SAMPLE_TEXTURECUBE_LOD(_Source, s_point_clamp, dir, _MipIndex).rgb;
}
uint4 block = uint4(0, 0, 0, 0);

4
ScriptableRenderPipeline/Core/Resources/GPUCopy.compute


RWTexture2D<float1> _Result1;
Texture2D<float4> _Source4;
TEXTURE2D(_Source4);
#pragma kernel KSampleCopy4_1_x

_Result1[dispatchThreadId] = _Source4.SampleLevel(sampler_LinearClamp, float2(dispatchThreadId) * _Size.zw, 0.0).x;
_Result1[dispatchThreadId] = SAMPLE_TEXTURE2D_LOD(_Source4, sampler_LinearClamp, float2(dispatchThreadId) * _Size.zw, 0.0).x;
}

4
ScriptableRenderPipeline/Core/Resources/GPUCopy.compute.meta


fileFormatVersion: 2
guid: a68d8aaeb0956234d94e389f196381ee
timeCreated: 1507123133
licenseType: Pro
guid: a4d45eda75e8e474dbe24a31f741f3b4
ComputeShaderImporter:
externalObjects: {}
currentAPIMask: 4

4
ScriptableRenderPipeline/Core/Resources/GPUCopyAsset.cs


using System;
using System;
using System.Collections.Generic;
using System.Text;

k_KernelSize.ToString(), k_KernelSize.ToString()));
cck.AppendLine(string.Format(@"void {0}(uint2 dispatchThreadId : SV_DispatchThreadID)", kernelName));
cck.AppendLine("{");
cck.AppendLine(string.Format(" _Result{0}[dispatchThreadId] = _Source{1}.SampleLevel(sampler_LinearClamp, float2(dispatchThreadId) * _Size.zw, 0.0).{2};",
cck.AppendLine(string.Format(" _Result{0}[dispatchThreadId] = SAMPLE_TEXTURE2D_LOD(_Source{1}, sampler_LinearClamp, float2(dispatchThreadId) * _Size.zw, 0.0).{2};",
o.targetChannel.ToString(), o.sourceChannel.ToString(), o.subscript));
cck.AppendLine("}");
cck.AppendLine();

125
ScriptableRenderPipeline/Core/ShaderLibrary/API/D3D11.hlsl


// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_SHADOW(textureName) TEXTURECUBE_ARRAY(textureName)
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define RW_TEXTURE3D(type, textureName) RWTexture3D<type> textureName
#define SAMPLER(samplerName) SamplerState samplerName
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURE3D_ARGS(textureName, samplerName) TEXTURE3D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)

125
ScriptableRenderPipeline/Core/ShaderLibrary/API/Metal.hlsl


// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_SHADOW(textureName) TEXTURECUBE_ARRAY(textureName)
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define RW_TEXTURE3D(type, textureName) RWTexture3D<type> textureName
#define SAMPLER(samplerName) SamplerState samplerName
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURE3D_ARGS(textureName, samplerName) TEXTURE3D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)

125
ScriptableRenderPipeline/Core/ShaderLibrary/API/PSSL.hlsl


// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define RW_TEXTURE2D(type, textureName) RW_Texture2D<type> textureName
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_SHADOW(textureName) TEXTURECUBE_ARRAY(textureName)
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName
#define RW_TEXTURE2D(type, textureName) RW_Texture2D<type> textureName
#define RW_TEXTURE3D(type, textureName) RW_Texture3D<type> textureName
#define SAMPLER(samplerName) SamplerState samplerName
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURE3D_ARGS(textureName, samplerName) TEXTURE3D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)

125
ScriptableRenderPipeline/Core/ShaderLibrary/API/Vulkan.hlsl


// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_SHADOW(textureName) TEXTURECUBE_ARRAY(textureName)
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define RW_TEXTURE3D(type, textureName) RWTexture3D<type> textureName
#define SAMPLER(samplerName) SamplerState samplerName
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURE3D_ARGS(textureName, samplerName) TEXTURE3D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)

125
ScriptableRenderPipeline/Core/ShaderLibrary/API/XBoxOne.hlsl


// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_SHADOW(textureName) TEXTURECUBE_ARRAY(textureName)
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
#define RW_TEXTURE3D(type, textureName) RWTexture3D<type> textureName
#define SAMPLER(samplerName) SamplerState samplerName
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER(samplerName)
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER(samplerName)
#define TEXTURE3D_ARGS(textureName, samplerName) TEXTURE3D(textureName), SAMPLER(samplerName)
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) TEXTURE2D(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER_CMP(samplerName)
#define TEXTURECUBE_ARRAY_SHADOW_ARGS(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER_CMP(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define TEXTURE3D_HALF TEXTURE3D
#define TEXTURE3D_FLOAT TEXTURE3D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)

2
ScriptableRenderPipeline/Core/ShaderLibrary/ImageBasedLighting.hlsl


#include "CommonLighting.hlsl"
#include "CommonMaterial.hlsl"
#include "BSDF.hlsl"
#include "Sampling.hlsl"
#include "Sampling/Sampling.hlsl"
#ifndef UNITY_SPECCUBE_LOD_STEPS
#define UNITY_SPECCUBE_LOD_STEPS 6

3
ScriptableRenderPipeline/Core/ShaderLibrary/Macros.hlsl


// Some platform don't support cubemap array so we fallback on 2D latlong
#ifdef UNITY_NO_CUBEMAP_ARRAY
#define TEXTURECUBE_ARRAY_ABSTRACT TEXTURE2D_ARRAY
#define SAMPLERCUBE_ABSTRACT SAMPLER2D
#define SAMPLERCUBE_ABSTRACT SAMPLERCUBE
#define TEXTURECUBE_ARRAY_ARGS_ABSTRACT TEXTURECUBE_ARRAY_ARGS
#define TEXTURECUBE_ARRAY_PARAM_ABSTRACT TEXTURECUBE_ARRAY_PARAM
#define SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(textureName, samplerName, coord3, index, lod) SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod)

#define FLT_EPS 5.960464478e-8 // 2^-24, machine epsilon: 1 + EPS = 1 (half of the ULP for 1)
#define FLT_MIN 1.175494351e-38 // Minimum representable positive floating-point number
#define FLT_MAX 3.402823466e+38 // Maximum representable floating-point number
#define FLT_NAN asfloat(0xFFFFFFFF)
#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats
#define HALF_MAX 65504.0
#define UINT_MAX 0xFFFFFFFFu

4
ScriptableRenderPipeline/Core/ShaderLibrary/Wind.hlsl


// Globals
TEXTURE2D(WIND_SETTINGS_TexNoise);
SAMPLER2D(sampler_WIND_SETTINGS_TexNoise);
SAMPLER(sampler_WIND_SETTINGS_TexNoise);
SAMPLER2D(sampler_WIND_SETTINGS_TexGust);
SAMPLER(sampler_WIND_SETTINGS_TexGust);
float4 WIND_SETTINGS_WorldDirectionAndSpeed;
float WIND_SETTINGS_FlexNoiseScale;

2
ScriptableRenderPipeline/Core/package.json


{
"name": "com.unity.render-pipelines.core",
"description": "Core library for Unity render pipelines.",
"version": "0.1.20",
"version": "0.1.21",
"unity": "2018.1",
"dependencies": {
"com.unity.postprocessing": "0.1.7"

2
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayLatlong.shader


#include "ShaderLibrary/ImageBasedLighting.hlsl"
TEXTURECUBE(_InputCubemap);
SAMPLERCUBE(sampler_InputCubemap);
SAMPLER(sampler_InputCubemap);
float _Mipmap;
struct Attributes

2
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader


#include "../ShaderVariables.hlsl"
TEXTURE2D(_DebugFullScreenTexture);
SAMPLER2D(sampler_DebugFullScreenTexture);
SAMPLER(sampler_DebugFullScreenTexture);
float _FullScreenDebugMode;
struct Attributes

9
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDAssetFactory.cs


newAsset.debugFullScreenShader = Load<Shader>(HDRenderPipelinePath + "Debug/DebugFullScreen.Shader");
newAsset.deferredShader = Load<Shader>(HDRenderPipelinePath + "Lighting/Deferred.Shader");
newAsset.subsurfaceScatteringCS = Load<ComputeShader>(HDRenderPipelinePath + "Material/Lit/Resources/SubsurfaceScattering.compute");
newAsset.gaussianPyramidCS = Load<ComputeShader>(PostProcessingPath + "Shaders/Builtins/GaussianDownsample.compute");
newAsset.depthPyramidCS = Load<ComputeShader>(HDRenderPipelinePath + "RenderPipelineResources/DepthDownsample.compute");
newAsset.copyChannelCS = Load<ComputeShader>(CorePath + "Resources/GPUCopy.compute");

newAsset.deferredDirectionalShadowComputeShader = Load<ComputeShader>(HDRenderPipelinePath + "Lighting/DeferredDirectionalShadow.compute");
// SceneSettings
// SubsurfaceScattering
newAsset.subsurfaceScatteringCS = Load<ComputeShader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/SubsurfaceScattering.compute");
newAsset.subsurfaceScattering = Load<Shader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/SubsurfaceScattering.shader");
newAsset.combineLighting = Load<Shader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/CombineLighting.shader");
// General
newAsset.copyStencilBuffer = Load<Shader>(HDRenderPipelinePath + "RenderPipelineResources/copyStencilBuffer.shader");
// Sky
newAsset.blitCubemap = Load<Shader>(HDRenderPipelinePath + "Sky/BlitCubemap.shader");

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


static public void SetupBaseLitMaterialPass(Material material)
{
SetupBaseUnlitMaterialPass(material);
bool windEnabled = material.GetFloat(kWindEnabled) > 0.0f;
bool enableVertexDisplacement = (DisplacementMode)material.GetFloat(kDisplacementMode) == DisplacementMode.Vertex;
material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, windEnabled || enableVertexDisplacement);
}
}
} // namespace UnityEditor

5
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.Styles.cs


public readonly GUIContent profileMinMaxThickness = new GUIContent("Min-Max Thickness (mm)", "Shows the values of the thickness remap below (in millimeters).");
public readonly GUIContent profileThicknessRemap = new GUIContent("Thickness Remap (mm)", "Remaps the thickness parameter from [0, 1] to the desired range (in millimeters).");
public readonly GUIContent profileWorldScale = new GUIContent("World Scale", "Size of the world unit in meters.");
// Old SSS Model >>>
public readonly GUIContent profileFresnel0 = new GUIContent("Specular", "Fraction of light reflected at the normal angle of incidence. Typical skin value is 0.028");
// Jimenez SSS Model
// <<< Old SSS Model
// End Jimenez SSS Model
public readonly GUIStyle centeredMiniBoldLabel = new GUIStyle(GUI.skin.label);
public Styles()

11
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.cs


internal SerializedProperty transmissionMode;
internal SerializedProperty thicknessRemap;
internal SerializedProperty worldScale;
internal SerializedProperty fresnel0;
// Old SSS Model >>>
internal SerializedProperty scatterDistance1;

transmissionMode = rp.Find(x => x.transmissionMode),
thicknessRemap = rp.Find(x => x.thicknessRemap),
worldScale = rp.Find(x => x.worldScale),
fresnel0 = rp.Find(x => x.fresnel0),
scatterDistance1 = rp.Find(x => x.scatterDistance1),
scatterDistance2 = rp.Find(x => x.scatterDistance2),

serializedObject.Update();
using (var scope = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.PropertyField(m_UseDisneySSS, s_Styles.useDisneySSS);
if (scope.changed && m_HDPipeline != null)
m_HDPipeline.CreateSssMaterials();
}
EditorGUILayout.PropertyField(m_UseDisneySSS, s_Styles.useDisneySSS);
EditorGUILayout.Space();

EditorGUILayout.MinMaxSlider(s_Styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0f, 50f);
profile.thicknessRemap.vector2Value = thicknessRemap;
EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale);
EditorGUILayout.Slider(profile.fresnel0, 0.0f, 0.1f, s_Styles.profileFresnel0);
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel);

263
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


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

RenderTargetIdentifier[] m_RTIDs = new RenderTargetIdentifier[k_MaxDbuffer];
public void InitDBuffers(int width, int height, CommandBuffer cmd)
{
{
dbufferCount = Decal.GetMaterialDBufferCount();
RenderTextureFormat[] rtFormat;
RenderTextureReadWrite[] rtReadWrite;

// Renderer Bake configuration can vary depends on if shadow mask is enabled or no
RendererConfiguration m_currentRendererConfigurationBakedLighting = HDUtils.k_RendererConfigurationBakedLighting;
Material m_CopyStencilForSplitLighting;
// Various set of material use in render loop
ComputeShader m_SubsurfaceScatteringCS { get { return m_Asset.renderPipelineResources.subsurfaceScatteringCS; } }
int m_SubsurfaceScatteringKernel;
Material m_CombineLightingPass;
// Old SSS Model >>>
Material m_SssVerticalFilterPass;
Material m_SssHorizontalFilterAndCombinePass;
// <<< Old SSS Model
ComputeShader m_GaussianPyramidCS { get { return m_Asset.renderPipelineResources.gaussianPyramidCS; } }
int m_GaussianPyramidKernel;
ComputeShader m_DepthPyramidCS { get { return m_Asset.renderPipelineResources.depthPyramidCS; } }

// Various buffer
readonly int m_CameraColorBuffer;
readonly int m_CameraSssDiffuseLightingBuffer;
// Old SSS Model >>>
readonly int m_CameraFilteringBuffer;
// <<< Old SSS Model
readonly int m_ShadowMaskBuffer;
readonly int m_VelocityBuffer;
readonly int m_DistortionBuffer;

// 'm_CameraColorBuffer' does not contain diffuse lighting of SSS materials until the SSS pass. It is stored within 'm_CameraSssDiffuseLightingBuffer'.
readonly RenderTargetIdentifier m_CameraColorBufferRT;
readonly RenderTargetIdentifier m_CameraSssDiffuseLightingBufferRT;
// Old SSS Model >>>
readonly RenderTargetIdentifier m_CameraFilteringBufferRT;
// <<< Old SSS Model
readonly RenderTargetIdentifier m_VelocityBufferRT;
readonly RenderTargetIdentifier m_DistortionBufferRT;
readonly RenderTargetIdentifier m_GaussianPyramidColorBufferRT;

RenderTexture m_CameraDepthStencilBuffer;
RenderTexture m_CameraDepthBufferCopy;
RenderTexture m_CameraStencilBufferCopy;
RenderTexture m_HTile; // If the hardware does not expose it, we compute our own, optimized to only contain the SSS bit
RenderTargetIdentifier m_HTileRT;
static CustomSampler[] m_samplers = new CustomSampler[(int)CustomSamplerId.Max];

m_CameraColorBufferRT = new RenderTargetIdentifier(m_CameraColorBuffer);
m_CameraSssDiffuseLightingBuffer = HDShaderIDs._CameraSssDiffuseLightingBuffer;
m_CameraSssDiffuseLightingBufferRT = new RenderTargetIdentifier(m_CameraSssDiffuseLightingBuffer);
m_CameraFilteringBuffer = HDShaderIDs._CameraFilteringBuffer;
m_CameraFilteringBufferRT = new RenderTargetIdentifier(m_CameraFilteringBuffer);
CreateSssMaterials();
m_SSSBufferManager.Build(asset.renderPipelineResources, asset.sssSettings);
m_CopyStencilForSplitLighting = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/CopyStencilBuffer");
m_CopyStencilForSplitLighting.SetInt(HDShaderIDs._StencilRef, (int)StencilLightingUsage.SplitLighting);
m_CopyStencilForNoLighting = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/CopyStencilBuffer");
// General material
m_CopyStencilForNoLighting = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.copyStencilBuffer);
m_CameraMotionVectorsMaterial = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/CameraMotionVectors");
m_CameraMotionVectorsMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.cameraMotionVectors);
InitializeDebugMaterials();

m_ErrorMaterial = CoreUtils.CreateEngineMaterial("Hidden/InternalErrorShader");
}
public void CreateSssMaterials()
{
m_SubsurfaceScatteringKernel = m_SubsurfaceScatteringCS.FindKernel("SubsurfaceScattering");
CoreUtils.Destroy(m_CombineLightingPass);
m_CombineLightingPass = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineLighting");
// Old SSS Model >>>
CoreUtils.Destroy(m_SssVerticalFilterPass);
m_SssVerticalFilterPass = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/SubsurfaceScattering");
m_SssVerticalFilterPass.DisableKeyword("SSS_FILTER_HORIZONTAL_AND_COMBINE");
m_SssVerticalFilterPass.SetFloat(HDShaderIDs._DstBlend, (float)BlendMode.Zero);
CoreUtils.Destroy(m_SssHorizontalFilterAndCombinePass);
m_SssHorizontalFilterAndCombinePass = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/SubsurfaceScattering");
m_SssHorizontalFilterAndCombinePass.EnableKeyword("SSS_FILTER_HORIZONTAL_AND_COMBINE");
m_SssHorizontalFilterAndCombinePass.SetFloat(HDShaderIDs._DstBlend, (float)BlendMode.One);
// <<< Old SSS Model
}
void InitializeRenderStateBlocks()
{
m_DepthStateOpaque = new RenderStateBlock

m_MaterialList.ForEach(material => material.Cleanup());
CoreUtils.Destroy(m_CopyStencilForNoLighting);
CoreUtils.Destroy(m_CameraMotionVectorsMaterial);
CoreUtils.Destroy(m_DebugViewMaterialGBuffer);
CoreUtils.Destroy(m_DebugViewMaterialGBufferShadowMask);
CoreUtils.Destroy(m_DebugDisplayLatlong);

m_SSSBufferManager.Cleanup();
m_SkyManager.Cleanup();
#if UNITY_EDITOR

m_CameraStencilBufferCopy.Create();
m_CameraStencilBufferCopyRT = new RenderTargetIdentifier(m_CameraStencilBufferCopy);
}
if (NeedHTileCopy())
{
if (m_HTile!= null)
m_HTile.Release();
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
m_HTile = new RenderTexture((camera.pixelWidth + 7) / 8, (camera.pixelHeight + 7) / 8, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_HTile.filterMode = FilterMode.Point;
m_HTile.enableRandomWrite = true;
m_HTile.Create();
m_HTileRT = new RenderTargetIdentifier(m_HTile);
}
}
void Resize(Camera camera)

bool resolutionChanged = camera.pixelWidth != m_CurrentWidth || camera.pixelHeight != m_CurrentHeight;
if (resolutionChanged || m_CameraDepthStencilBuffer == null)
{
m_SSSBufferManager.Resize(camera);
}
if (resolutionChanged || m_LightLoop.NeedResize())
{

cmd.SetGlobalInt(HDShaderIDs._EnvLightSkyEnabled, 0);
}
// Broadcast SSS parameters to all shaders.
cmd.SetGlobalInt(HDShaderIDs._EnableSSSAndTransmission, m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._UseDisneySSS, sssParameters.useDisneySSS ? 1 : 0);
unsafe
{
// Warning: Unity is not able to losslessly transfer integers larger than 2^24 to the shader system.
// Therefore, we bitcast uint to float in C#, and bitcast back to uint in the shader.
uint texturingModeFlags = sssParameters.texturingModeFlags;
uint transmissionFlags = sssParameters.transmissionFlags;
cmd.SetGlobalFloat(HDShaderIDs._TexturingModeFlags, *(float*)&texturingModeFlags);
cmd.SetGlobalFloat(HDShaderIDs._TransmissionFlags, *(float*)&transmissionFlags);
}
cmd.SetGlobalVectorArray(HDShaderIDs._ThicknessRemaps, sssParameters.thicknessRemaps);
cmd.SetGlobalVectorArray(HDShaderIDs._ShapeParams, sssParameters.shapeParams);
cmd.SetGlobalVectorArray(HDShaderIDs._HalfRcpVariancesAndWeights, sssParameters.halfRcpVariancesAndWeights);
cmd.SetGlobalVectorArray(HDShaderIDs._TransmissionTints, sssParameters.transmissionTints);
cmd.SetGlobalVectorArray(HDShaderIDs._WorldScales, sssParameters.worldScales);
m_SSSBufferManager.PushGlobalParams(cmd, sssParameters, m_CurrentDebugDisplaySettings);
}
}

// TODO: test/implement for other platforms.
return SystemInfo.graphicsDeviceType != GraphicsDeviceType.PlayStation4;
return SystemInfo.graphicsDeviceType != GraphicsDeviceType.PlayStation4 &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.XboxOne &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.XboxOneD3D12;
}
bool NeedStencilBufferCopy()

return m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission || m_LightLoop.GetFeatureVariantsEnabled();
}
bool NeedHTileCopy()
{
// Currently, Unity does not offer a way to access the GCN HTile even on PS4 and Xbox One.
// Therefore, it's computed in a pixel shader, and optimized to only contain the SSS bit.
return m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission && sssSettings.useDisneySSS;
}
bool NeedTemporarySubsurfaceBuffer()
{
// Typed UAV loads from FORMAT_R16G16B16A16_FLOAT is an optional feature of Direct3D 11.
// Most modern GPUs support it. We can avoid performing a costly copy in this case.
// TODO: test/implement for other platforms.
return m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission && (!sssSettings.useDisneySSS || (
SystemInfo.graphicsDeviceType != GraphicsDeviceType.PlayStation4 &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.XboxOne &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.XboxOneD3D12));
return m_LightLoop.GetFeatureVariantsEnabled();
}
RenderTargetIdentifier GetDepthTexture()

RenderTargetIdentifier GetHTile()
{
// Currently, Unity does not offer a way to access the GCN HTile.
return m_HTileRT;
}
void CopyDepthBufferIfNeeded(CommandBuffer cmd)
{
using (new ProfilingSample(cmd, NeedDepthBufferCopy() ? "Copy DepthBuffer" : "Set DepthBuffer", GetSampler(CustomSamplerId.CopySetDepthBuffer)))

cmd.CopyTexture(m_CameraDepthStencilBufferRT, m_CameraDepthBufferCopyRT);
}
}
cmd.SetGlobalTexture(HDShaderIDs._MainDepthTexture, GetDepthTexture());
}
}

// In both forward and deferred, everything opaque should have been rendered at this point so we can safely copy the depth buffer for later processing.
CopyDepthBufferIfNeeded(cmd);
// Depth texture is now ready, bind it.
cmd.SetGlobalTexture(HDShaderIDs._MainDepthTexture, GetDepthTexture());
RenderPyramidDepth(camera, cmd, renderContext, FullScreenDebugMode.DepthPyramid);
if (m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled())

{
CoreUtils.SetRenderTarget(cmd, m_CameraStencilBufferCopyRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
cmd.SetRandomWriteTarget(1, GetHTile());
// In the material classification shader we will simply test is we are no lighting
// Use ShaderPassID 1 => "Pass 1 - Write 1 if value different from stencilRef to output"
CoreUtils.DrawFullScreen(cmd, m_CopyStencilForNoLighting, m_CameraStencilBufferCopyRT, m_CameraDepthStencilBufferRT, null, 1);

RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
// SSS pass here handle both SSS material from deferred and forward
SubsurfaceScatteringPass(hdCamera, cmd, sssSettings);
m_SSSBufferManager.SubsurfaceScatteringPass(hdCamera, cmd, sssSettings, m_CurrentDebugDisplaySettings,
m_CameraColorBufferRT, m_CameraSssDiffuseLightingBufferRT, m_CameraDepthStencilBufferRT, GetDepthTexture());
RenderSky(hdCamera, cmd);

// Render transparent depth prepass after opaque one
using (new ProfilingSample(cmd, "Transparent Depth Prepass", GetSampler(CustomSamplerId.TransparentDepthPrepass)))
{
{
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_TransparentDepthPrePassNames);
}
}

using (new ProfilingSample(cmd, "DBuffer", GetSampler(CustomSamplerId.DBuffer)))
{
// We need to copy depth buffer texture if we want to bind it at this stage
CopyDepthBufferIfNeeded(cmd);
// Depth texture is now ready, bind it.
cmd.SetGlobalTexture(HDShaderIDs._MainDepthTexture, GetDepthTexture());
cmd.SetGlobalTexture(HDShaderIDs._MainDepthTexture, GetDepthTexture());
DecalSystem.instance.Render(renderContext, cameraPos, cmd);
}
}

m_LightLoop.RenderDeferredLighting(hdCamera, cmd, m_CurrentDebugDisplaySettings, m_MRTCache2, m_CameraDepthStencilBufferRT, depthTexture, options);
}
// Combines specular lighting and diffuse lighting with subsurface scattering.
void SubsurfaceScatteringPass(HDCamera hdCamera, CommandBuffer cmd, SubsurfaceScatteringSettings sssParameters)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission)
return;
using (new ProfilingSample(cmd, "Subsurface Scattering", GetSampler(CustomSamplerId.SubsurfaceScattering)))
{
if (sssSettings.useDisneySSS)
{
using (new ProfilingSample(cmd, "HTile for SSS", GetSampler(CustomSamplerId.HTileForSSS)))
{
CoreUtils.SetRenderTarget(cmd, m_HTileRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
cmd.SetRandomWriteTarget(1, GetHTile());
// Generate HTile for the split lighting stencil usage. Don't write into stencil texture (shaderPassId = 2)
// Use ShaderPassID 1 => "Pass 2 - Export HTILE for stencilRef to output"
CoreUtils.DrawFullScreen(cmd, m_CopyStencilForSplitLighting, m_CameraStencilBufferCopyRT, m_CameraDepthStencilBufferRT, null, 2);
cmd.ClearRandomWriteTargets();
}
// TODO: Remove this once fix, see comment inside the function
hdCamera.SetupComputeShader(m_SubsurfaceScatteringCS, cmd);
unsafe
{
// Warning: Unity is not able to losslessly transfer integers larger than 2^24 to the shader system.
// Therefore, we bitcast uint to float in C#, and bitcast back to uint in the shader.
uint texturingModeFlags = sssParameters.texturingModeFlags;
cmd.SetComputeFloatParam(m_SubsurfaceScatteringCS, HDShaderIDs._TexturingModeFlags, *(float*)&texturingModeFlags);
}
cmd.SetComputeVectorArrayParam(m_SubsurfaceScatteringCS, HDShaderIDs._WorldScales, sssParameters.worldScales);
cmd.SetComputeVectorArrayParam(m_SubsurfaceScatteringCS, HDShaderIDs._FilterKernels, sssParameters.filterKernels);
cmd.SetComputeVectorArrayParam(m_SubsurfaceScatteringCS, HDShaderIDs._ShapeParams, sssParameters.shapeParams);
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._DepthTexture, GetDepthTexture());
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._HTile, GetHTile());
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._IrradianceSource, m_CameraSssDiffuseLightingBufferRT);
for (int i = 0; i < m_SSSBufferManager.sssBufferCount; ++i)
{
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._SSSBufferTexture[i], m_SSSBufferManager.GetSSSBuffers(i));
}
if (NeedTemporarySubsurfaceBuffer())
{
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._CameraFilteringBuffer, m_CameraFilteringBufferRT);
// Perform the SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
// We dispatch 4x swizzled 16x16 groups per a 32x32 macrotile.
cmd.DispatchCompute(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, 4, ((int)hdCamera.screenSize.x + 31) / 32, ((int)hdCamera.screenSize.y + 31) / 32);
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, m_CameraFilteringBufferRT); // Cannot set a RT on a material
// Additively blend diffuse and specular lighting into 'm_CameraColorBufferRT'.
CoreUtils.DrawFullScreen(cmd, m_CombineLightingPass, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT);
}
else
{
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._CameraColorTexture, m_CameraColorBufferRT);
// Perform the SSS filtering pass which performs an in-place update of 'm_CameraColorBufferRT'.
// We dispatch 4x swizzled 16x16 groups per a 32x32 macrotile.
cmd.DispatchCompute(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, 4, ((int)hdCamera.screenSize.x + 31) / 32, ((int)hdCamera.screenSize.y + 31) / 32);
}
}
else
{
for (int i = 0; i < m_SSSBufferManager.sssBufferCount; ++i)
{
cmd.SetGlobalTexture(HDShaderIDs._SSSBufferTexture[i], m_SSSBufferManager.GetSSSBuffers(i));
}
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, m_CameraSssDiffuseLightingBufferRT); // Cannot set a RT on a material
m_SssVerticalFilterPass.SetVectorArray(HDShaderIDs._FilterKernelsBasic, sssParameters.filterKernelsBasic);
m_SssVerticalFilterPass.SetVectorArray(HDShaderIDs._HalfRcpWeightedVariances, sssParameters.halfRcpWeightedVariances);
// Perform the vertical SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
CoreUtils.DrawFullScreen(cmd, m_SssVerticalFilterPass, m_CameraFilteringBufferRT, m_CameraDepthStencilBufferRT);
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, m_CameraFilteringBufferRT); // Cannot set a RT on a material
m_SssHorizontalFilterAndCombinePass.SetVectorArray(HDShaderIDs._FilterKernelsBasic, sssParameters.filterKernelsBasic);
m_SssHorizontalFilterAndCombinePass.SetVectorArray(HDShaderIDs._HalfRcpWeightedVariances, sssParameters.halfRcpWeightedVariances);
// Perform the horizontal SSS filtering pass, and combine diffuse and specular lighting into 'm_CameraColorBufferRT'.
CoreUtils.DrawFullScreen(cmd, m_SssHorizontalFilterAndCombinePass, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT);
}
}
}
void UpdateSkyEnvironment(HDCamera hdCamera, CommandBuffer cmd)
{
m_SkyManager.UpdateEnvironment(hdCamera,m_LightLoop.GetCurrentSunLight(), cmd);

var mipSize = size;
for (int i = 0; i < lodCount; i++)
{
int srcMipSize = mipSize;
mipSize >>= 1;
cmd.ReleaseTemporaryRT(HDShaderIDs._DepthPyramidMips[i + 1]);

cmd.SetComputeVectorParam(m_DepthPyramidCS, "_Size", new Vector4(mipSize, mipSize, 1f / mipSize, 1f / mipSize));
cmd.SetComputeVectorParam(m_DepthPyramidCS, "_SrcSize", new Vector4(srcMipSize, srcMipSize, 1f / srcMipSize, 1f / srcMipSize));
cmd.DispatchCompute(m_DepthPyramidCS, m_DepthPyramidKernel, mipSize / 8, mipSize / 8, 1);
cmd.CopyTexture(HDShaderIDs._DepthPyramidMips[i + 1], 0, 0, m_DepthPyramidBufferRT, 0, i + 1);
}

}
}
void InitAndClearBuffer(HDCamera camera, bool enableBakeShadowMask, CommandBuffer cmd)
void InitAndClearBuffer(HDCamera hdCamera, bool enableBakeShadowMask, CommandBuffer cmd)
{
using (new ProfilingSample(cmd, "InitAndClearBuffer", GetSampler(CustomSamplerId.InitAndClearBuffer)))
{

// Also we manage ourself the HDR format, here allocating fp16 directly.
// With scriptable render loop we can allocate temporary RT in a command buffer, they will not be release with ExecuteCommandBuffer
// These temporary surface are release automatically at the end of the scriptable render pipeline if not release explicitly
int w = camera.camera.pixelWidth;
int h = camera.camera.pixelHeight;
int w = hdCamera.camera.pixelWidth;
int h = hdCamera.camera.pixelHeight;
if (NeedTemporarySubsurfaceBuffer())
{
cmd.GetTemporaryRT(m_CameraFilteringBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
}
// Color and depth pyramids
int s = CalculatePyramidSize(w, h);

cmd.GetTemporaryRT(m_DepthPyramidBuffer, m_DepthPyramidBufferDesc, FilterMode.Trilinear);
// End
if (!camera.useForwardOnly)
if (!hdCamera.useForwardOnly)
m_SSSBufferManager.InitGBuffers(w, h, m_GbufferManager, cmd);
m_SSSBufferManager.InitSSSBuffersFromGBuffer(w, h, m_GbufferManager, cmd);
m_SSSBufferManager.InitGBuffers(w, h, cmd);
m_SSSBufferManager.InitSSSBuffers(w, h, cmd);
}
m_DbufferManager.InitDBuffers(w, h, cmd);

CoreUtils.SetRenderTarget(cmd, m_CameraSssDiffuseLightingBufferRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
}
// Old SSS Model >>>
if (NeedTemporarySubsurfaceBuffer())
{
// Clear the SSS filtering target
using (new ProfilingSample(cmd, "Clear SSS filtering target", GetSampler(CustomSamplerId.ClearSSSFilteringTarget)))
{
CoreUtils.SetRenderTarget(cmd, m_CameraFilteringBuffer, ClearFlag.Color, CoreUtils.clearColorAllBlack);
}
}
// <<< Old SSS Model
Color clearColor = camera.camera.backgroundColor.linear; // Need it in linear because we clear a linear fp16 texture.
Color clearColor = hdCamera.camera.backgroundColor.linear; // Need it in linear because we clear a linear fp16 texture.
if (!camera.useForwardOnly)
if (!hdCamera.useForwardOnly)
{
using (new ProfilingSample(cmd, "Clear GBuffer", GetSampler(CustomSamplerId.ClearGBuffer)))
{

4
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset


m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRenderPipelineAsset
m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 42086e81f4f0c724f96f7f09cc995354,
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
globalRenderingSettings:
useForwardRenderingOnly: 0

reflectionCubemapSize: 128
reflectionCacheCompressed: 0
sssSettings: {fileID: 11400000, guid: c4d57f106d34d0046a33b3e66da29a72, type: 2}
tileSettings:
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1

7
ScriptableRenderPipeline/HDRenderPipeline/HDStringConstants.cs


public static readonly int _ThicknessRemaps = Shader.PropertyToID("_ThicknessRemaps");
public static readonly int _ShapeParams = Shader.PropertyToID("_ShapeParams");
public static readonly int _HalfRcpVariancesAndWeights = Shader.PropertyToID("_HalfRcpVariancesAndWeights");
public static readonly int _TransmissionTints = Shader.PropertyToID("_TransmissionTints");
public static readonly int _TransmissionTintsAndFresnel0 = Shader.PropertyToID("_TransmissionTintsAndFresnel0");
public static readonly int specularLightingUAV = Shader.PropertyToID("specularLightingUAV");
public static readonly int diffuseLightingUAV = Shader.PropertyToID("diffuseLightingUAV");

public static readonly int _DstBlend = Shader.PropertyToID("_DstBlend");
public static readonly int _HTile = Shader.PropertyToID("_HTile");
public static readonly int _SSSHTile = Shader.PropertyToID("_SSSHTile");
public static readonly int _StencilTexture = Shader.PropertyToID("_StencilTexture");
public static readonly int _ViewMatrix = Shader.PropertyToID("_ViewMatrix");

public static readonly int[] _DBufferTexture =
{
Shader.PropertyToID("_DBufferTexture0"),
Shader.PropertyToID("_DBufferTexture0"),
public static readonly int[] _SSSBufferTexture =
public static readonly int[] _SSSBufferTexture =
{
Shader.PropertyToID("_SSSBufferTexture0"),
Shader.PropertyToID("_SSSBufferTexture1"),

30
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightEvaluation.hlsl


//-----------------------------------------------------------------------------
float3 EvaluateCookie_Directional(LightLoopContext lightLoopContext, DirectionalLightData lightData,
float3 lighToSample)
float3 positionWS)
// Compute the CS position (in [-1, 1]^2) by projecting 'positionWS' onto the near plane.
// Translate and rotate 'positionWS' into the light space.
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3 positionLS = mul(lighToSample, transpose(lightToWorld));
float2 positionCS = positionLS.xy;
float3 lightToSample = positionWS - lightData.positionWS;
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3 positionLS = mul(lightToSample, transpose(lightToWorld));
// Perform orthographic projection.
float2 positionCS = positionLS.xy;
// Remap the texture coordinates from [-1, 1]^2 to [0, 1]^2.
float2 positionNDC = positionCS * 0.5 + 0.5;

[branch] if (lightData.cookieIndex >= 0)
{
float3 lightToSample = positionWS - lightData.positionWS;
float3 cookie = EvaluateCookie_Directional(lightLoopContext, lightData, lightToSample);
float3 cookie = EvaluateCookie_Directional(lightLoopContext, lightData, positionWS);
color *= cookie;
}

//-----------------------------------------------------------------------------
float4 EvaluateCookie_Punctual(LightLoopContext lightLoopContext, LightData lightData,
float3 lighToSample)
float3 positionWS)
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3 positionLS = mul(lighToSample, transpose(lightToWorld));
float3 lightToSample = positionWS - lightData.positionWS;
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3 positionLS = mul(lightToSample, transpose(lightToWorld));
float4 cookie;

}
else
{
// Compute the NDC position (in [-1, 1]^2) by projecting 'positionWS' onto the plane at 1m distance.
// Box projector lights require no perspective division.
// Perform orthographic or perspective projection.
float perspectiveZ = (lightType != GPULIGHTTYPE_PROJECTOR_BOX) ? positionLS.z : 1.0;
float2 positionCS = positionLS.xy / perspectiveZ;
bool isInBounds = Max3(abs(positionCS.x), abs(positionCS.y), 1.0 - positionLS.z) <= 1.0;

// Projector lights always have cookies, so we can perform clipping inside the if().
[branch] if (lightData.cookieIndex >= 0)
{
float3 lightToSample = positionWS - lightData.positionWS;
float4 cookie = EvaluateCookie_Punctual(lightLoopContext, lightData, lightToSample);
float4 cookie = EvaluateCookie_Punctual(lightLoopContext, lightData, positionWS);
color *= cookie.rgb;
attenuation *= cookie.a;

11
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoopDef.hlsl


// Used by directional and spot lights
TEXTURE2D_ARRAY(_CookieTextures);
SAMPLER2D(sampler_CookieTextures);
SAMPLERCUBE_ABSTRACT(sampler_CookieCubeTextures);
SAMPLERCUBE_ABSTRACT(sampler_EnvTextures);
TEXTURE2D(_DeferredShadowTexture);

// Used by directional and spot lights.
float3 SampleCookie2D(LightLoopContext lightLoopContext, float2 coord, int index)
{
return SAMPLE_TEXTURE2D_ARRAY_LOD(_CookieTextures, sampler_CookieTextures, coord, index, 0).rgb;
// TODO: add MIP maps to combat aliasing?
return SAMPLE_TEXTURE2D_ARRAY_LOD(_CookieTextures, s_linear_clamp_sampler, coord, index, 0).rgb;
return SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(_CookieCubeTextures, sampler_CookieCubeTextures, coord, index, 0).rgb;
// TODO: add MIP maps to combat aliasing?
return SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(_CookieCubeTextures, s_linear_clamp_sampler, coord, index, 0).rgb;
}
//-----------------------------------------------------------------------------

// This code will be inlined as lightLoopContext is hardcoded in the light loop
if (lightLoopContext.sampleReflection == SINGLE_PASS_CONTEXT_SAMPLE_REFLECTION_PROBES)
{
return SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(_EnvTextures, sampler_EnvTextures, texCoord, index, lod);
return SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(_EnvTextures, s_trilinear_clamp_sampler, texCoord, index, lod);
}
else // SINGLE_PASS_SAMPLE_SKY
{

8
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/ShadowContext.hlsl


#include "ShaderLibrary/Shadow/Shadow.hlsl"
TEXTURE2D_ARRAY(_ShadowmapExp_VSM_0);
SAMPLER2D(sampler_ShadowmapExp_VSM_0);
SAMPLER(sampler_ShadowmapExp_VSM_0);
SAMPLER2D(sampler_ShadowmapExp_VSM_1);
SAMPLER(sampler_ShadowmapExp_VSM_1);
SAMPLER2D(sampler_ShadowmapExp_VSM_2);
SAMPLER(sampler_ShadowmapExp_VSM_2);
SAMPLER2D_SHADOW(sampler_ShadowmapExp_PCF);
SAMPLER_CMP(sampler_ShadowmapExp_PCF);
StructuredBuffer<ShadowData> _ShadowDatasExp;
StructuredBuffer<int4> _ShadowPayloads;

1
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/builddispatchindirect.compute


#include "ShaderLibrary/Common.hlsl"
#include "LightLoop.cs.hlsl"
#include "../../ShaderVariables.hlsl"
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "../../Material/Material.hlsl" // This includes Material.hlsl

1
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/materialflags.compute


#include "ShaderBase.hlsl"
#include "LightLoop.cs.hlsl"
#include "../../ShaderVariables.hlsl"
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "../../Material/Material.hlsl" // This includes Material.hlsl
#include "../../Lighting/LightDefinition.cs.hlsl"

2
ScriptableRenderPipeline/HDRenderPipeline/Lighting/Lighting.hlsl


#include "ShaderLibrary/CommonLighting.hlsl"
#include "ShaderLibrary/CommonShadow.hlsl"
#include "ShaderLibrary/Sampling.hlsl"
#include "ShaderLibrary/Sampling/Sampling.hlsl"
#include "ShaderLibrary/AreaLighting.hlsl"
#include "ShaderLibrary/ImageBasedLighting.hlsl"

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl


TEXTURE2D(_BaseColorMap);
SAMPLER2D(sampler_BaseColorMap);
SAMPLER(sampler_BaseColorMap);
SAMPLER2D(sampler_NormalMap);
SAMPLER(sampler_NormalMap);
float _DecalBlend;

6
ScriptableRenderPipeline/HDRenderPipeline/Material/GGXConvolution/BuildProbabilityTables.compute


#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/ImageBasedLighting.hlsl"
#include "../../ShaderVariables.hlsl"
/* --- Input --- */

TEXTURECUBE(envMap); // Input cubemap
SAMPLERCUBE(sampler_envMap);
/* --- Output --- */

float3 L1 = ConvertEquiarealToCubemap(u1, v);
float3 L2 = ConvertEquiarealToCubemap(u2, v);
float3 c1 = SAMPLE_TEXTURECUBE_LOD(envMap, sampler_envMap, L1, 0).rgb;
float3 c2 = SAMPLE_TEXTURECUBE_LOD(envMap, sampler_envMap, L2, 0).rgb;
float3 c1 = SAMPLE_TEXTURECUBE_LOD(envMap, s_linear_clamp_sampler, L1, 0).rgb;
float3 c2 = SAMPLE_TEXTURECUBE_LOD(envMap, s_linear_clamp_sampler, L2, 0).rgb;
// Compute the integral of the step function (row values).
// TODO: process 4 texels per thread, and manually unroll.

8
ScriptableRenderPipeline/HDRenderPipeline/Material/GGXConvolution/GGXConvolve.shader


#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/ImageBasedLighting.hlsl"
#include "GGXConvolution.cs.hlsl"
#include "../../ShaderVariables.hlsl"
SAMPLERCUBE(sampler_MainTex);
TEXTURE2D_FLOAT(_GgxIblSamples);
TEXTURE2D(_GgxIblSamples);
#ifdef USE_MIS
TEXTURE2D(_MarginalRowDensities);

uint sampleCount = GetIBLRuntimeFilterSampleCount(_Level);
#ifdef USE_MIS
float4 val = IntegrateLD_MIS(TEXTURECUBE_PARAM(_MainTex, sampler_MainTex),
float4 val = IntegrateLD_MIS(TEXTURECUBE_PARAM(_MainTex, s_trilinear_clamp_sampler),
_MarginalRowDensities, _ConditionalDensities,
V, N,
roughness,

1024,
false);
#else
float4 val = IntegrateLD(TEXTURECUBE_PARAM(_MainTex, sampler_MainTex),
float4 val = IntegrateLD(TEXTURECUBE_PARAM(_MainTex, s_trilinear_clamp_sampler),
_GgxIblSamples,
V, N,
roughness,

12
ScriptableRenderPipeline/HDRenderPipeline/Material/GGXConvolution/RuntimeFilterIBL.cs


Matrix4x4[] m_faceWorldToViewMatrixMatrices = new Matrix4x4[6];
RenderPipelineResources m_RenderPipelinesResources;
RenderPipelineResources m_RenderPipelineResources;
public bool supportMis
{

public IBLFilterGGX(RenderPipelineResources renderPipelinesResources)
public IBLFilterGGX(RenderPipelineResources renderPipelineResources)
m_RenderPipelinesResources = renderPipelinesResources;
m_RenderPipelineResources = renderPipelineResources;
}
public bool IsInitialized()

{
if (!m_ComputeGgxIblSampleDataCS)
{
m_ComputeGgxIblSampleDataCS = m_RenderPipelinesResources.computeGgxIblSampleData;
m_ComputeGgxIblSampleDataCS = m_RenderPipelineResources.computeGgxIblSampleData;
m_BuildProbabilityTablesCS = m_RenderPipelinesResources.buildProbabilityTables;
m_BuildProbabilityTablesCS = m_RenderPipelineResources.buildProbabilityTables;
m_ConditionalDensitiesKernel = m_BuildProbabilityTablesCS.FindKernel("ComputeConditionalDensities");
m_MarginalRowDensitiesKernel = m_BuildProbabilityTablesCS.FindKernel("ComputeMarginalRowDensities");
}

m_GgxConvolveMaterial = CoreUtils.CreateEngineMaterial(m_RenderPipelinesResources.GGXConvolve);
m_GgxConvolveMaterial = CoreUtils.CreateEngineMaterial(m_RenderPipelineResources.GGXConvolve);
}
if (!m_GgxIblSampleData)

1
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs


public static int s_GBufferLitStandardSpecularColorId = 1;
public static float s_DefaultSpecularValue = 0.04f;
public static float s_SkinSpecularValue = 0.028f;
}
[GenerateHLSL(PackingRules.Exact)]

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


#define GBUFFER_LIT_STANDARD_REGULAR_ID (0)
#define GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID (1)
#define DEFAULT_SPECULAR_VALUE (0.04)
#define SKIN_SPECULAR_VALUE (0.028)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+RefractionMode: static fields

16
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


// #define LIT_DIFFUSE_LAMBERT_BRDF
#define LIT_USE_GGX_ENERGY_COMPENSATION
// Sampler use by area light, gaussian pyramid, ambient occlusion etc...
SamplerState s_linear_clamp_sampler;
SamplerState s_trilinear_clamp_sampler;
// Rough refraction texture
// Color pyramid (width, height, lodcount, Unused)
TEXTURE2D(_GaussianPyramidColorTexture);

if (_UseDisneySSS != 0)
{
bsdfData.transmittance = ComputeTransmittanceDisney(_ShapeParams[subsurfaceProfile].rgb,
_TransmissionTints[subsurfaceProfile].rgb,
_TransmissionTintsAndFresnel0[subsurfaceProfile].rgb,
bsdfData.thickness, bsdfData.subsurfaceRadius);
}
else

_HalfRcpVariancesAndWeights[subsurfaceProfile][1].rgb,
_HalfRcpVariancesAndWeights[subsurfaceProfile][1].a,
_TransmissionTints[subsurfaceProfile].rgb,
_TransmissionTintsAndFresnel0[subsurfaceProfile].rgb,
bsdfData.thickness, bsdfData.subsurfaceRadius);
}
}

else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
bsdfData.diffuseColor = surfaceData.baseColor;
bsdfData.fresnel0 = SKIN_SPECULAR_VALUE; // TODO: take from the SSS profile
bsdfData.fresnel0 = _TransmissionTintsAndFresnel0[surfaceData.subsurfaceProfile].a;
uint transmissionMode = BitFieldExtract(asuint(_TransmissionFlags), 2u, 2u * surfaceData.subsurfaceProfile);
FillMaterialIdSssData(surfaceData.subsurfaceProfile,

radius = sssData.subsurfaceRadius;
thickness = inGBuffer2.g;
dielectricF0 = SKIN_SPECULAR_VALUE; // TODO: take from the SSS profile
dielectricF0 = _TransmissionTintsAndFresnel0[subsurfaceProfile].a;
}
FillMaterialIdSssData(subsurfaceProfile, radius, thickness, transmissionMode, bsdfData);

{
// Note: this is a ad-hoc tweak.
// TODO: we need a better hack.
float iblPerceptualRoughness = bsdfData.perceptualRoughness * saturate(1.2 - bsdfData.anisotropy);
float iblPerceptualRoughness = bsdfData.perceptualRoughness * saturate(1.2 - abs(bsdfData.anisotropy));
float iblRoughness = PerceptualRoughnessToRoughness(iblPerceptualRoughness);
preLightData.iblDirWS = GetSpecularDominantDir(N, iblR, iblRoughness, NdotV);
preLightData.iblMipLevel = PerceptualRoughnessToMipmapLevel(iblPerceptualRoughness);

#ifndef _SURFACE_TYPE_TRANSPARENT
#define USE_DEFERRED_DIRECTIONAL_SHADOWS // Deferred shadows are always enabled for opaque objects
#endif
#include "../../Lighting/LightEvaluation.hlsl"
//-----------------------------------------------------------------------------
// Lighting structure for light accumulation

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


//-------------------------------------------------------------------------------------
// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
#include "ShaderLibrary/SampleUVMapping.hlsl"
#include "ShaderLibrary/Sampling/SampleUVMapping.hlsl"
#include "../MaterialUtilities.hlsl"
#include "../Decal/DecalUtilities.hlsl"

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


return ComputePerVertexDisplacement(layerTexCoord, vertexColor, lod) * normalWS;
}
void ApplyVertexModification(AttributesMesh input, float3 normalWS, inout float3 positionWS)
void ApplyVertexModification(AttributesMesh input, float3 normalWS, inout float3 positionWS, float4 time)
{
#if defined(_VERTEX_DISPLACEMENT)

#ifdef _VERTEX_WIND
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
ApplyWindDisplacement(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, input.color.a, _Time);
ApplyWindDisplacement(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, input.color.a, time);
#endif
}

46
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl


// ===========================================================================
TEXTURE2D(_DistortionVectorMap);
SAMPLER2D(sampler_DistortionVectorMap);
SAMPLER(sampler_DistortionVectorMap);
SAMPLER2D(sampler_EmissiveColorMap);
SAMPLER(sampler_EmissiveColorMap);
SAMPLER2D(sampler_DiffuseLightingMap);
SAMPLER(sampler_DiffuseLightingMap);
SAMPLER2D(sampler_BaseColorMap);
SAMPLER(sampler_BaseColorMap);
SAMPLER2D(sampler_MaskMap);
SAMPLER(sampler_MaskMap);
SAMPLER2D(sampler_BentNormalMap);
SAMPLER(sampler_BentNormalMap);
SAMPLER2D(sampler_NormalMap);
SAMPLER(sampler_NormalMap);
SAMPLER2D(sampler_NormalMapOS);
SAMPLER(sampler_NormalMapOS);
SAMPLER2D(sampler_DetailMap);
SAMPLER(sampler_DetailMap);
SAMPLER2D(sampler_HeightMap);
SAMPLER(sampler_HeightMap);
SAMPLER2D(sampler_TangentMap);
SAMPLER(sampler_TangentMap);
SAMPLER2D(sampler_TangentMapOS);
SAMPLER(sampler_TangentMapOS);
SAMPLER2D(sampler_AnisotropyMap);
SAMPLER(sampler_AnisotropyMap);
SAMPLER2D(sampler_SubsurfaceRadiusMap);
SAMPLER(sampler_SubsurfaceRadiusMap);
SAMPLER2D(sampler_ThicknessMap);
SAMPLER(sampler_ThicknessMap);
SAMPLER2D(sampler_SpecularColorMap);
SAMPLER(sampler_SpecularColorMap);
SAMPLER2D(sampler_TransmittanceColorMap);
SAMPLER(sampler_TransmittanceColorMap);
#else

// mean we must declare all sampler
#define PROP_DECL_TEX2D(name)\
TEXTURE2D(MERGE_NAME(name, 0)); \
SAMPLER2D(MERGE_NAME(MERGE_NAME(sampler, name), 0)); \
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 0)); \
SAMPLER2D(MERGE_NAME(MERGE_NAME(sampler, name), 1)); \
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 1)); \
SAMPLER2D(MERGE_NAME(MERGE_NAME(sampler, name), 2)); \
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 2)); \
SAMPLER2D(MERGE_NAME(MERGE_NAME(sampler, name), 3))
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 3))
PROP_DECL_TEX2D(_BaseColorMap);

PROP_DECL_TEX2D(_ThicknessMap);
TEXTURE2D(_LayerMaskMap);
SAMPLER2D(sampler_LayerMaskMap);
SAMPLER(sampler_LayerMaskMap);
SAMPLER2D(sampler_LayerInfluenceMaskMap);
SAMPLER(sampler_LayerInfluenceMaskMap);
#endif

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


// conflict with the normal in the semantic. This need to be fix! Also no per pixel displacement is possible either.
// Attributes
#define REQUIRE_TANGENT_TO_WORLD 0 /* defined(_PIXEL_DISPLACEMENT) */
#define REQUIRE_NORMAL 0 /* defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD || defined(_VERTEX_WIND) || defined(_VERTEX_DISPLACEMENT) */
#define REQUIRE_TANGENT_TO_WORLD defined(_PIXEL_DISPLACEMENT)
#define REQUIRE_NORMAL defined(TESSELLATION_ON) || REQUIRE_TANGENT_TO_WORLD || defined(_VERTEX_WIND) || defined(_VERTEX_DISPLACEMENT)
#define REQUIRE_VERTEX_COLOR ((defined(_VERTEX_DISPLACEMENT) || defined(_TESSELLATION_DISPLACEMENT)) && defined(LAYERED_LIT_SHADER) && (defined(_LAYER_MASK_VERTEX_COLOR_MUL) || defined(_LAYER_MASK_VERTEX_COLOR_ADD))) || defined(_VERTEX_WIND)
// This first set of define allow to say which attributes will be use by the mesh in the vertex and domain shader (for tesselation)

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl


#include "Builtin/BuiltinData.hlsl"
#if defined(LIGHTLOOP_SINGLE_PASS) || defined(LIGHTLOOP_TILE_PASS)
#include "../Lighting/LightEvaluation.hlsl" // Depends on LightLoopDef and BuiltinData, shared by different materials and light loops
#endif
//-----------------------------------------------------------------------------
// Material definition
//-----------------------------------------------------------------------------

2
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.hlsl


// Use float4 to avoid any packing issue between compute and pixel shaders
float4 _ThicknessRemaps[SSS_N_PROFILES]; // R: start, G = end - start, BA unused
float4 _ShapeParams[SSS_N_PROFILES]; // RGB = S = 1 / D, A = filter radius
float4 _TransmissionTints[SSS_N_PROFILES]; // RGB = 1/4 * color, A = unused
float4 _TransmissionTintsAndFresnel0[SSS_N_PROFILES]; // RGB = 1/4 * color, A = fresnel0
float4 _WorldScales[SSS_N_PROFILES]; // X = meters per world unit; Y = world units per meter
CBUFFER_END

224
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs


RenderTargetIdentifier[] m_ColorMRTs;
RenderTargetIdentifier[] m_RTIDs = new RenderTargetIdentifier[k_MaxSSSBuffer];
// Disney SSS Model
ComputeShader m_SubsurfaceScatteringCS;
int m_SubsurfaceScatteringKernel;
Material m_CombineLightingPass;
RenderTexture m_HTile;
RenderTargetIdentifier m_HTileRT;
// End Disney SSS Model
// Jimenez SSS Model
Material m_SssVerticalFilterPass;
Material m_SssHorizontalFilterAndCombinePass;
// End Jimenez SSS Model
// Jimenez need an extra buffer and Disney need one for some platform
readonly int m_CameraFilteringBuffer;
readonly RenderTargetIdentifier m_CameraFilteringBufferRT;
// This is use to be able to read stencil value in compute shader
Material m_CopyStencilForSplitLighting;
SubsurfaceScatteringSettings m_sssSettings;
// Use with Jimenez
m_CameraFilteringBuffer = HDShaderIDs._CameraFilteringBuffer;
m_CameraFilteringBufferRT = new RenderTargetIdentifier(m_CameraFilteringBuffer);
public void InitGBuffers(int width, int height, GBufferManager gbufferManager, CommandBuffer cmd)
public void InitSSSBuffersFromGBuffer(int width, int height, GBufferManager gbufferManager, CommandBuffer cmd)
{
m_RTIDs[0] = gbufferManager.GetGBuffers()[0];
}

public void InitGBuffers(int width, int height, CommandBuffer cmd)
public void InitSSSBuffers(int width, int height, CommandBuffer cmd)
cmd.GetTemporaryRT(m_SSSBuffer0, width, height, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
cmd.GetTemporaryRT(m_SSSBuffer0, width, height, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
}
public RenderTargetIdentifier GetSSSBuffers(int index)

}
public void Build(RenderPipelineResources renderPipelineResources, SubsurfaceScatteringSettings sssSettings)
{
m_sssSettings = sssSettings;
// Disney SSS (compute + combine)
m_SubsurfaceScatteringCS = renderPipelineResources.subsurfaceScatteringCS;
m_SubsurfaceScatteringKernel = m_SubsurfaceScatteringCS.FindKernel("SubsurfaceScattering");
m_CombineLightingPass = CoreUtils.CreateEngineMaterial(renderPipelineResources.combineLighting);
// Jimenez SSS Model (shader)
m_SssVerticalFilterPass = CoreUtils.CreateEngineMaterial(renderPipelineResources.subsurfaceScattering);
m_SssVerticalFilterPass.DisableKeyword("SSS_FILTER_HORIZONTAL_AND_COMBINE");
m_SssVerticalFilterPass.SetFloat(HDShaderIDs._DstBlend, (float)BlendMode.Zero);
m_SssHorizontalFilterAndCombinePass = CoreUtils.CreateEngineMaterial(renderPipelineResources.subsurfaceScattering);
m_SssHorizontalFilterAndCombinePass.EnableKeyword("SSS_FILTER_HORIZONTAL_AND_COMBINE");
m_SssHorizontalFilterAndCombinePass.SetFloat(HDShaderIDs._DstBlend, (float)BlendMode.One);
m_CopyStencilForSplitLighting = CoreUtils.CreateEngineMaterial(renderPipelineResources.copyStencilBuffer);
m_CopyStencilForSplitLighting.SetInt(HDShaderIDs._StencilRef, (int)StencilLightingUsage.SplitLighting);
}
public void Cleanup()
{
CoreUtils.Destroy(m_CombineLightingPass);
CoreUtils.Destroy(m_SssVerticalFilterPass);
CoreUtils.Destroy(m_SssHorizontalFilterAndCombinePass);
CoreUtils.Destroy(m_CopyStencilForSplitLighting);
}
public void Resize(Camera camera)
{
// We must use a RenderTexture and not GetTemporaryRT() as currently Unity only aloow to bind a RenderTexture for a UAV in a pixel shader
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
m_HTile = new RenderTexture((camera.pixelWidth + 7) / 8, (camera.pixelHeight + 7) / 8, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_HTile.filterMode = FilterMode.Point;
m_HTile.enableRandomWrite = true;
m_HTile.Create();
m_HTileRT = new RenderTargetIdentifier(m_HTile);
}
public void PushGlobalParams(CommandBuffer cmd, SubsurfaceScatteringSettings sssParameters, DebugDisplaySettings debugDisplaySettings)
{
// Broadcast SSS parameters to all shaders.
cmd.SetGlobalInt(HDShaderIDs._EnableSSSAndTransmission, debugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._UseDisneySSS, sssParameters.useDisneySSS ? 1 : 0);
unsafe
{
// Warning: Unity is not able to losslessly transfer integers larger than 2^24 to the shader system.
// Therefore, we bitcast uint to float in C#, and bitcast back to uint in the shader.
uint texturingModeFlags = sssParameters.texturingModeFlags;
uint transmissionFlags = sssParameters.transmissionFlags;
cmd.SetGlobalFloat(HDShaderIDs._TexturingModeFlags, *(float*)&texturingModeFlags);
cmd.SetGlobalFloat(HDShaderIDs._TransmissionFlags, *(float*)&transmissionFlags);
}
cmd.SetGlobalVectorArray(HDShaderIDs._ThicknessRemaps, sssParameters.thicknessRemaps);
cmd.SetGlobalVectorArray(HDShaderIDs._ShapeParams, sssParameters.shapeParams);
cmd.SetGlobalVectorArray(HDShaderIDs._HalfRcpVariancesAndWeights, sssParameters.halfRcpVariancesAndWeights);
cmd.SetGlobalVectorArray(HDShaderIDs._TransmissionTintsAndFresnel0, sssParameters.transmissionTintsAndFresnel0);
cmd.SetGlobalVectorArray(HDShaderIDs._WorldScales, sssParameters.worldScales);
}
bool NeedTemporarySubsurfaceBuffer()
{
// Caution: need to be in sync with SubsurfaceScattering.cs USE_INTERMEDIATE_BUFFER (Can't make a keyword as it is a compute shader)
// Typed UAV loads from FORMAT_R16G16B16A16_FLOAT is an optional feature of Direct3D 11.
// Most modern GPUs support it. We can avoid performing a costly copy in this case.
// TODO: test/implement for other platforms.
return SystemInfo.graphicsDeviceType != GraphicsDeviceType.PlayStation4 &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.XboxOne &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.XboxOneD3D12;
}
// Combines specular lighting and diffuse lighting with subsurface scattering.
public void SubsurfaceScatteringPass(HDCamera hdCamera, CommandBuffer cmd, SubsurfaceScatteringSettings sssParameters, DebugDisplaySettings debugDisplaySettings,
RenderTargetIdentifier colorBufferRT, RenderTargetIdentifier diffuseBufferRT, RenderTargetIdentifier depthStencilBufferRT, RenderTargetIdentifier depthTextureRT)
{
if (m_sssSettings == null || !debugDisplaySettings.renderingDebugSettings.enableSSSAndTransmission)
return;
using (new ProfilingSample(cmd, "Subsurface Scattering", HDRenderPipeline.GetSampler(CustomSamplerId.SubsurfaceScattering)))
{
int w = hdCamera.camera.pixelWidth;
int h = hdCamera.camera.pixelHeight;
// For Jimenez we always need an extra buffer, for Disney it depends on platform
if (!m_sssSettings.useDisneySSS ||
(m_sssSettings.useDisneySSS && NeedTemporarySubsurfaceBuffer()))
{
// Caution: must be same format as m_CameraSssDiffuseLightingBuffer
cmd.ReleaseTemporaryRT(m_CameraFilteringBuffer);
cmd.GetTemporaryRT(m_CameraFilteringBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
// Clear the SSS filtering target
using (new ProfilingSample(cmd, "Clear SSS filtering target", HDRenderPipeline.GetSampler(CustomSamplerId.ClearSSSFilteringTarget)))
{
CoreUtils.SetRenderTarget(cmd, m_CameraFilteringBufferRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
}
}
if (m_sssSettings.useDisneySSS)
{
using (new ProfilingSample(cmd, "HTile for SSS", HDRenderPipeline.GetSampler(CustomSamplerId.HTileForSSS)))
{
// Currently, Unity does not offer a way to access the GCN HTile even on PS4 and Xbox One.
// Therefore, it's computed in a pixel shader, and optimized to only contain the SSS bit.
CoreUtils.SetRenderTarget(cmd, m_HTileRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
cmd.SetRandomWriteTarget(1, m_HTile);
// Generate HTile for the split lighting stencil usage. Don't write into stencil texture (shaderPassId = 2)
// Use ShaderPassID 1 => "Pass 2 - Export HTILE for stencilRef to output"
CoreUtils.SetRenderTarget(cmd, depthStencilBufferRT); // No need for color buffer here
CoreUtils.DrawFullScreen(cmd, m_CopyStencilForSplitLighting, null, 2);
cmd.ClearRandomWriteTargets();
}
// TODO: Remove this once fix, see comment inside the function
hdCamera.SetupComputeShader(m_SubsurfaceScatteringCS, cmd);
unsafe
{
// Warning: Unity is not able to losslessly transfer integers larger than 2^24 to the shader system.
// Therefore, we bitcast uint to float in C#, and bitcast back to uint in the shader.
uint texturingModeFlags = sssParameters.texturingModeFlags;
cmd.SetComputeFloatParam(m_SubsurfaceScatteringCS, HDShaderIDs._TexturingModeFlags, *(float*)&texturingModeFlags);
}
cmd.SetComputeVectorArrayParam(m_SubsurfaceScatteringCS, HDShaderIDs._WorldScales, sssParameters.worldScales);
cmd.SetComputeVectorArrayParam(m_SubsurfaceScatteringCS, HDShaderIDs._FilterKernels, sssParameters.filterKernels);
cmd.SetComputeVectorArrayParam(m_SubsurfaceScatteringCS, HDShaderIDs._ShapeParams, sssParameters.shapeParams);
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._DepthTexture, depthTextureRT);
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._SSSHTile, m_HTileRT);
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._IrradianceSource, diffuseBufferRT);
for (int i = 0; i < sssBufferCount; ++i)
{
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._SSSBufferTexture[i], GetSSSBuffers(i));
}
if (NeedTemporarySubsurfaceBuffer())
{
// Caution: must be same format as m_CameraSssDiffuseLightingBuffer
cmd.ReleaseTemporaryRT(m_CameraFilteringBuffer);
cmd.GetTemporaryRT(m_CameraFilteringBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
// Clear the SSS filtering target
using (new ProfilingSample(cmd, "Clear SSS filtering target", HDRenderPipeline.GetSampler(CustomSamplerId.ClearSSSFilteringTarget)))
{
CoreUtils.SetRenderTarget(cmd, m_CameraFilteringBufferRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
}
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._CameraFilteringBuffer, m_CameraFilteringBufferRT);
// Perform the SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
// We dispatch 4x swizzled 16x16 groups per a 32x32 macro tile.
cmd.DispatchCompute(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, 4, ((int)hdCamera.screenSize.x + 31) / 32, ((int)hdCamera.screenSize.y + 31) / 32);
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, m_CameraFilteringBufferRT); // Cannot set a RT on a material
// Additively blend diffuse and specular lighting into 'm_CameraColorBufferRT'.
CoreUtils.DrawFullScreen(cmd, m_CombineLightingPass, colorBufferRT, depthStencilBufferRT);
}
else
{
cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._CameraColorTexture, colorBufferRT);
// Perform the SSS filtering pass which performs an in-place update of 'colorBuffer'.
// We dispatch 4x swizzled 16x16 groups per a 32x32 macro tile.
cmd.DispatchCompute(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, 4, ((int)hdCamera.screenSize.x + 31) / 32, ((int)hdCamera.screenSize.y + 31) / 32);
}
}
else
{
for (int i = 0; i < sssBufferCount; ++i)
{
cmd.SetGlobalTexture(HDShaderIDs._SSSBufferTexture[i], GetSSSBuffers(i));
}
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, diffuseBufferRT); // Cannot set a RT on a material
m_SssVerticalFilterPass.SetVectorArray(HDShaderIDs._FilterKernelsBasic, sssParameters.filterKernelsBasic);
m_SssVerticalFilterPass.SetVectorArray(HDShaderIDs._HalfRcpWeightedVariances, sssParameters.halfRcpWeightedVariances);
// Perform the vertical SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
CoreUtils.DrawFullScreen(cmd, m_SssVerticalFilterPass, m_CameraFilteringBufferRT, depthStencilBufferRT);
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, m_CameraFilteringBufferRT); // Cannot set a RT on a material
m_SssHorizontalFilterAndCombinePass.SetVectorArray(HDShaderIDs._FilterKernelsBasic, sssParameters.filterKernelsBasic);
m_SssHorizontalFilterAndCombinePass.SetVectorArray(HDShaderIDs._HalfRcpWeightedVariances, sssParameters.halfRcpWeightedVariances);
// Perform the horizontal SSS filtering pass, and combine diffuse and specular lighting into 'm_CameraColorBufferRT'.
CoreUtils.DrawFullScreen(cmd, m_SssHorizontalFilterAndCombinePass, colorBufferRT, depthStencilBufferRT);
}
}
}
}
}

9
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScatteringSettings.cs


public TransmissionMode transmissionMode;
public Vector2 thicknessRemap; // X = min, Y = max (in millimeters)
public float worldScale; // Size of the world unit in meters
public float fresnel0; // Fresnel0, 0.028 for skin
// Old SSS Model >>>
[ColorUsage(false, true)]

transmissionMode = TransmissionMode.None;
thicknessRemap = new Vector2(0f, 5f);
worldScale = 1f;
fresnel0 = 0.028f; // TYpical value for skin specular reflectance
// Old SSS Model >>>
scatterDistance1 = new Color(0.3f, 0.3f, 0.3f, 0f);

thicknessRemap.y = Mathf.Max(thicknessRemap.y, 0f);
thicknessRemap.x = Mathf.Clamp(thicknessRemap.x, 0f, thicknessRemap.y);
worldScale = Mathf.Max(worldScale, 0.001f);
fresnel0 = Mathf.Clamp(fresnel0, 0.0f, 0.1f);
// Old SSS Model >>>
scatterDistance1 = new Color

[NonSerialized] public Vector4[] thicknessRemaps; // Remap: 0 = start, 1 = end - start
[NonSerialized] public Vector4[] worldScales; // X = meters per world unit; Y = world units per meter
[NonSerialized] public Vector4[] shapeParams; // RGB = S = 1 / D, A = filter radius
[NonSerialized] public Vector4[] transmissionTints; // RGB = color, A = unused
[NonSerialized] public Vector4[] transmissionTintsAndFresnel0; // RGB = color, A = fresnel0
[NonSerialized] public Vector4[] filterKernels; // XY = near field, ZW = far field; 0 = radius, 1 = reciprocal of the PDF
// Old SSS Model >>>

ValidateArray(ref thicknessRemaps, SssConstants.SSS_N_PROFILES);
ValidateArray(ref worldScales, SssConstants.SSS_N_PROFILES);
ValidateArray(ref shapeParams, SssConstants.SSS_N_PROFILES);
ValidateArray(ref transmissionTints, SssConstants.SSS_N_PROFILES);
ValidateArray(ref transmissionTintsAndFresnel0, SssConstants.SSS_N_PROFILES);
ValidateArray(ref filterKernels, SssConstants.SSS_N_PROFILES * SssConstants.SSS_N_SAMPLES_NEAR_FIELD);
// Old SSS Model >>>

worldScales[i] = new Vector4(profiles[p].worldScale, 1.0f / profiles[p].worldScale, 0f, 0f);
shapeParams[i] = profiles[p].shapeParam;
shapeParams[i].w = profiles[p].maxRadius;
transmissionTints[i] = profiles[p].transmissionTint * 0.25f; // Premultiplied
transmissionTintsAndFresnel0[i] = new Vector4(profiles[p].transmissionTint.r * 0.25f, profiles[p].transmissionTint.g * 0.25f, profiles[p].transmissionTint.b * 0.25f, profiles[p].fresnel0); // Premultiplied
for (int j = 0, n = SssConstants.SSS_N_SAMPLES_NEAR_FIELD; j < n; j++)
{

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/UnlitProperties.hlsl


float4 _UnlitColor;
TEXTURE2D(_UnlitColorMap);
SAMPLER2D(sampler_UnlitColorMap);
SAMPLER(sampler_UnlitColorMap);
SAMPLER2D(sampler_DistortionVectorMap);
SAMPLER(sampler_DistortionVectorMap);
SAMPLER2D(sampler_EmissiveColorMap);
SAMPLER(sampler_EmissiveColorMap);
float4 _EmissiveColorMap_ST;
float _EmissiveIntensity;

55
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DepthDownsample.compute


#include "ShaderLibrary/Common.hlsl"
Texture2D<float> _Source;
RWTexture2D<float> _Result;
SamplerState sampler_LinearClamp;
CBUFFER_START(cb)
float4 _Size;
CBUFFER_END
#pragma kernel KMain
[numthreads(8, 8, 1)]
void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
{
// Upper-left pixel coordinate of quad that this thread will read
int2 threadUL = dispatchThreadId;
// Downsample the block
float2 offset = float2(threadUL);
float p00 = _Source.SampleLevel(sampler_LinearClamp, (offset ) * _Size.zw, 0.0).x;
float p10 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(1.0, 0.0)) * _Size.zw, 0.0).x;
float p01 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(0.0, 1.0)) * _Size.zw, 0.0).x;
float p11 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(1.0, 1.0)) * _Size.zw, 0.0).x;
float depth = min(min(min(p00, p01), p10), p11);
// Write to the final target
_Result[dispatchThreadId] = depth;
#include "ShaderLibrary/Common.hlsl"
Texture2D<float> _Source;
RWTexture2D<float> _Result;
SamplerState sampler_PointClamp; //TODO: could we use min-sampler instead of using ALU?
CBUFFER_START(cb)
float4 _SrcSize;
CBUFFER_END
#pragma kernel KMain
[numthreads(8, 8, 1)]
void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
{
// Upper-left pixel coordinate of quad that this thread will read
int2 threadUL = dispatchThreadId;
// Downsample the block
float2 offset = float2(threadUL) * 2.0f + 1.0f;
float4 depths = _Source.GatherRed(sampler_PointClamp, offset * _SrcSize.zw, 0.0);
float minDepth = min(min(depths.x, depths.y), min(depths.z, depths.w));
// Write to the final target
_Result[dispatchThreadId] = minDepth;
}

14
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset


debugFullScreenShader: {fileID: 4800000, guid: e874aca2df8300a488258738c31f85cf,
type: 3}
deferredShader: {fileID: 4800000, guid: 00dd221e34a6ab349a1196b0f2fab693, type: 3}
screenSpaceAmbientOcclusionShader: {fileID: 4800000, guid: cf0db7f5267ad944dbf4326b7102c9ca,
type: 3}
subsurfaceScatteringCS: {fileID: 7200000, guid: b06a7993621def248addd55d0fe931b1,
type: 3}
volumetricLightingCS: {fileID: 7200000, guid: 799166e2ee6a4b041bba9e74f6942097,
type: 3}
copyChannelCS: {fileID: 7200000, guid: a68d8aaeb0956234d94e389f196381ee, type: 3}
copyChannelCS: {fileID: 7200000, guid: a4d45eda75e8e474dbe24a31f741f3b4, type: 3}
applyDistortionCS: {fileID: 7200000, guid: 2fa6c0e3fe6dc3145a4156f21913fe5c, type: 3}
clearDispatchIndirectShader: {fileID: 7200000, guid: fc1f553acb80a6446a32d33e403d0656,
type: 3}

type: 3}
deferredDirectionalShadowComputeShader: {fileID: 7200000, guid: fbde6fae193b2a94e9fd97c163c204f4,
type: 3}
subsurfaceScatteringCS: {fileID: 7200000, guid: b06a7993621def248addd55d0fe931b1,
type: 3}
subsurfaceScattering: {fileID: 4800000, guid: 867b36db983aa0548889a66f8d685ff6,
type: 3}
combineLighting: {fileID: 4800000, guid: 2e37131331fbdca449b1a2bc47a639ca, type: 3}
copyStencilBuffer: {fileID: 4800000, guid: 3d1574f1cdfa0ce4995f9bc79ed7f8ec, type: 3}
blitCubemap: {fileID: 4800000, guid: d05913e251bed7a4992c921c62e1b647, type: 3}
buildProbabilityTables: {fileID: 7200000, guid: b9f26cf340afe9145a699753531b2a4c,
type: 3}

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


fileFormatVersion: 2
guid: 42086e81f4f0c724f96f7f09cc995354
timeCreated: 1507194928
licenseType: Pro
guid: 3ce144cff5783da45aa5d4fdc2da14b7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

10
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs


// Lighting resources
public Shader deferredShader;
public Shader combineLightingPass;
public ComputeShader subsurfaceScatteringCS;
public ComputeShader gaussianPyramidCS;
public ComputeShader depthPyramidCS;
public ComputeShader copyChannelCS;

public ComputeShader deferredComputeShader;
public ComputeShader deferredDirectionalShadowComputeShader;
// SceneSettings
// Subsurface scattering
public ComputeShader subsurfaceScatteringCS; // Disney SSS
public Shader subsurfaceScattering; // Jimenez SSS
public Shader combineLighting;
// General
public Shader copyStencilBuffer;
// Sky
public Shader blitCubemap;

52
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl


// Available semantic start from TEXCOORD4
struct AttributesPass
{
float3 previousPositionOS : NORMAL; // Contain previous transform position (in case of skinning for example)
// TODO: Caution - For now the tesselation doesn't displace along the normal with Velocity shader as the previous previous position
// conflict with the normal in the semantic. This need to be fix!
float3 previousPositionOS : TEXCOORD4; // Contain previous transform position (in case of skinning for example)
};
struct VaryingsPassToPS

#define VARYINGS_NEED_PASS
#include "VertMesh.hlsl"
// Transforms normal from object to world space
float3 TransformPreviousObjectToWorldNormal(float3 normalOS)
{
#ifdef UNITY_ASSUME_UNIFORM_SCALING
return normalize(mul((float3x3)unity_MatrixPreviousM, normalOS));
#else
// Normal need to be multiply by inverse transpose
// mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)}
return normalize(mul(normalOS, (float3x3)unity_MatrixPreviousMI));
#endif
}
void VelocityPositionZBias(VaryingsToPS input)
{
#if defined(UNITY_REVERSED_Z)
input.vmesh.positionCS.z -= unity_MotionVectorsParams.z * input.vmesh.positionCS.w;
#else
input.vmesh.positionCS.z += unity_MotionVectorsParams.z * input.vmesh.positionCS.w;
#endif
}
PackedVaryingsType Vert(AttributesMesh inputMesh,
AttributesPass inputPass)
{

#if !defined(TESSELLATION_ON)
VelocityPositionZBias(varyingsType);
#endif
varyingsType.vpass.positionCS = mul(_NonJitteredViewProjMatrix, mul(unity_ObjectToWorld, float4(inputMesh.positionOS, 1.0)));
varyingsType.vpass.previousPositionCS = mul(_PrevViewProjMatrix, mul(unity_MatrixPreviousM, unity_MotionVectorsParams.x ? float4(inputPass.previousPositionOS, 1.0) : float4(inputMesh.positionOS, 1.0)));
varyingsType.vpass.positionCS = mul(_NonJitteredViewProjMatrix, float4(varyingsType.vmesh.positionWS, 1.0));
//Need to apply any vertex animation to the previous worldspace position, if we want it to show up in the velocity buffer
float3 previousPositionWS = mul(unity_MatrixPreviousM, unity_MotionVectorsParams.x ? float4(inputPass.previousPositionOS, 1.0) : float4(inputMesh.positionOS, 1.0)).xyz;
#ifdef ATTRIBUTES_NEED_NORMAL
float3 normalWS = TransformPreviousObjectToWorldNormal(inputMesh.normalOS);
#else
float3 normalWS = float3(0.0, 0.0, 0.0);
#endif
#if defined(HAVE_VERTEX_MODIFICATION)
ApplyVertexModification(inputMesh, normalWS, previousPositionWS, _LastTime);
#endif
//Need this since we are using the current position from VertMesh()
previousPositionWS = GetCameraRelativePositionWS(previousPositionWS);
varyingsType.vpass.previousPositionCS = mul(_PrevViewProjMatrix, float4(previousPositionWS, 1.0));
return PackVaryingsType(varyingsType);
}

VaryingsToPS output;
output.vmesh = VertMeshTesselation(input.vmesh);
VelocityPositionZBias(output);
output.vpass.positionCS = input.vpass.positionCS;
output.vpass.previousPositionCS = input.vpass.previousPositionCS;

11
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl


// TODO: deal with camera center rendering and instancing (This is the reason why we always perform two steps transform to clip space + instancing matrix)
// This code is disabled for velocity pass for now because at the moment we cannot have Normals with the velocity pass (this attributes holds last frame data)
// TODO: Remove the velocity pass test when velocity is properly handled.
#if defined(HAVE_VERTEX_MODIFICATION) && (SHADERPASS != SHADERPASS_VELOCITY)
ApplyVertexModification(input, normalWS, positionWS);
#if defined(HAVE_VERTEX_MODIFICATION)
ApplyVertexModification(input, normalWS, positionWS, _Time);
#endif
positionWS = GetCameraRelativePositionWS(positionWS);

// TODO: TEMP: Velocity has a flow as it doens't have normal. This need to be fix. In the mean time, generate fix normal so compiler doesn't complain - When fix, think to also enable ATTRIBUTES_NEED_NORMAL in LitVelocityPass.hlsl
#if (SHADERPASS == SHADERPASS_VELOCITY)
output.normalWS = float3(0.0, 0.0, 1.0);
#else
#endif
#if defined(VARYINGS_NEED_TANGENT_TO_WORLD) || defined(VARYINGS_DS_NEED_TANGENT)
output.tangentWS = tangentWS;
#endif

24
ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl


CBUFFER_START(UnityPerCamera)
// Time (t = time since current level load) values from Unity
float4 _Time; // (t/20, t, t*2, t*3)
float4 _LastTime; // Last frame time (t/20, t, t*2, t*3)
float4 _SinTime; // sin(t/8), sin(t/4), sin(t/2), sin(t)
float4 _CosTime; // cos(t/8), cos(t/4), cos(t/2), cos(t)
float4 unity_DeltaTime; // dt, 1/dt, smoothdt, 1/smoothdt

// ----------------------------------------------------------------------------
TEXTURE2D_FLOAT(_MainDepthTexture);
SAMPLER2D(sampler_MainDepthTexture);
// These are the samplers available in the HDRenderPipeline.
// Avoid declaring extra samplers as they are 4x SGPR each on GCN.
SAMPLER(s_linear_clamp_sampler);
SAMPLER(s_trilinear_clamp_sampler);
// ----------------------------------------------------------------------------
TEXTURE2D(_MainDepthTexture);
SAMPLER(sampler_MainDepthTexture);
SAMPLER2D(samplerunity_Lightmap);
SAMPLER(samplerunity_Lightmap);
SAMPLER2D(samplerunity_DynamicLightmap);
SAMPLER(samplerunity_DynamicLightmap);
TEXTURE2D(unity_DynamicDirectionality);

// TODO: Change code here so probe volume use only one transform instead of all this parameters!
TEXTURE3D_FLOAT(unity_ProbeVolumeSH);
SAMPLER3D(samplerunity_ProbeVolumeSH);
TEXTURE3D(unity_ProbeVolumeSH);
SAMPLER(samplerunity_ProbeVolumeSH);
float4x4 unity_MatrixPreviousMI;
//X : Use last frame positions (right now skinned meshes are the only objects that use this
//Y : Force No Motion
//Z : Z bias value
float4 unity_MotionVectorsParams;
CBUFFER_END

2
ScriptableRenderPipeline/HDRenderPipeline/Sky/BlitCubemap.shader


#include "ShaderLibrary/Common.hlsl"
TEXTURECUBE(_MainTex);
SAMPLERCUBE(sampler_MainTex);
SAMPLER(sampler_MainTex);
float _faceIndex;
struct appdata_t {

2
ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader


#include "ShaderLibrary/CommonLighting.hlsl"
TEXTURECUBE(_Cubemap);
SAMPLERCUBE(sampler_Cubemap);
SAMPLER(sampler_Cubemap);
float4 _SkyParam; // x exposure, y multiplier, z rotation
float4x4 _PixelCoordToViewDirWS; // Actually just 3x3, but Unity can only set 4x4

8
ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


RebuildSkyMatrices(nearPlane, farPlane);
}
public void Build(RenderPipelineResources renderPipelinesResources, IBLFilterGGX iblFilterGGX)
public void Build(RenderPipelineResources renderPipelineResources, IBLFilterGGX iblFilterGGX)
m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(renderPipelinesResources.skyboxCubemap);
m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.skyboxCubemap);
m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(renderPipelinesResources.blitCubemap);
m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.blitCubemap);
m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(renderPipelinesResources.opaqueAtmosphericScattering);
m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.opaqueAtmosphericScattering);
m_CurrentUpdateTime = 0.0f;
}

5
ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyVariables.hlsl


#define UNITY_SKY_VARIABLES_INCLUDED
TEXTURECUBE(_SkyTexture);
SAMPLERCUBE(sampler_SkyTexture); // NOTE: Sampler could be share here with _EnvTextures. Don't know if the shader compiler will complain...
CBUFFER_START(SkyParameters)
float _SkyTextureMipCount;

{
return SAMPLE_TEXTURECUBE(_SkyTexture, sampler_SkyTexture, texCoord);
return SAMPLE_TEXTURECUBE(_SkyTexture, s_trilinear_clamp_sampler, texCoord);
return SAMPLE_TEXTURECUBE_LOD(_SkyTexture, sampler_SkyTexture, texCoord, lod);
return SAMPLE_TEXTURECUBE_LOD(_SkyTexture, s_trilinear_clamp_sampler, texCoord, lod);
}
#endif

4
ScriptableRenderPipeline/HDRenderPipeline/package.json


{
"name": "com.unity.render-pipelines.high-definition",
"description": "HD Render Pipeline for Unity.",
"version": "0.1.20",
"version": "0.1.21",
"com.unity.render-pipelines.core": "0.1.20"
"com.unity.render-pipelines.core": "0.1.21"
}
}

68
ScriptableRenderPipeline/LightweightPipeline/Data/LightweightPipelineAsset.cs


using UnityEditor;
using UnityEditor.ProjectWindowCallback;
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
public enum ShadowCascades

public class LightweightPipelineAsset : RenderPipelineAsset
{
public static readonly string[] m_SearchPaths = {"Assets", "Packages/com.unity.render-pipelines"};
public static readonly string[] m_SearchPaths = {"Assets", "Packages/com.unity.render-pipelines.lightweight"};
// Default values set when a new LightweightPipeline asset is created
[SerializeField] private int m_MaxPixelLights = 4;

[SerializeField] private Material m_DefaultParticleMaterial;
[SerializeField] private Material m_DefaultTerrainMaterial;
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
var instance = CreateInstance<LightweightPipelineAsset>();
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateLightweightPipelineAsset>(),
"LightweightAsset.asset", null, null);
}
string[] guids = UnityEditor.AssetDatabase.FindAssets("LightweightPipelineResource t:scriptableobject", m_SearchPaths);
LightweightPipelineResource resourceAsset = null;
foreach (string guid in guids)
class CreateLightweightPipelineAsset : EndNameEditAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
resourceAsset = UnityEditor.AssetDatabase.LoadAssetAtPath<LightweightPipelineResource>(path);
if (resourceAsset != null)
break;
}
var instance = CreateInstance<LightweightPipelineAsset>();
// There's currently an issue that prevents FindAssets from find resources withing the package folder.
if (resourceAsset == null)
{
string path = "Packages/com.unity.render-pipelines.lightweight/Data/LightweightPipelineResource.asset";
resourceAsset = UnityEditor.AssetDatabase.LoadAssetAtPath<LightweightPipelineResource>(path);
}
string[] guids = AssetDatabase.FindAssets("LightweightPipelineResource t:scriptableobject", m_SearchPaths);
LightweightPipelineResource resourceAsset = null;
foreach (string guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
resourceAsset = AssetDatabase.LoadAssetAtPath<LightweightPipelineResource>(path);
if (resourceAsset != null)
break;
}
if (resourceAsset != null)
{
instance.m_DefaultMaterial = resourceAsset.DefaultMaterial;
instance.m_DefaultParticleMaterial = resourceAsset.DefaultParticleMaterial;
instance.m_DefaultTerrainMaterial = resourceAsset.DefaultTerrainMaterial;
}
// There's currently an issue that prevents FindAssets from find resources withing the package folder.
if (resourceAsset == null)
{
string path = "Packages/com.unity.render-pipelines.lightweight/Data/LightweightPipelineResource.asset";
resourceAsset = AssetDatabase.LoadAssetAtPath<LightweightPipelineResource>(path);
}
instance.m_DefaultShader = Shader.Find(LightweightShaderUtils.GetShaderPath(ShaderPathID.STANDARD_PBS));
instance.m_BlitShader = Shader.Find(LightweightShaderUtils.GetShaderPath(ShaderPathID.HIDDEN_BLIT));
instance.m_CopyDepthShader = Shader.Find(LightweightShaderUtils.GetShaderPath(ShaderPathID.HIDDEN_DEPTH_COPY));
if (resourceAsset != null)
{
instance.m_DefaultMaterial = resourceAsset.DefaultMaterial;
instance.m_DefaultParticleMaterial = resourceAsset.DefaultParticleMaterial;
instance.m_DefaultTerrainMaterial = resourceAsset.DefaultTerrainMaterial;
}
string assetPath = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Lightweight Asset", "LightweightAsset", "asset",
"Please enter a file name to save the asset to");
instance.m_DefaultShader = Shader.Find(LightweightShaderUtils.GetShaderPath(ShaderPathID.STANDARD_PBS));
instance.m_BlitShader = Shader.Find(LightweightShaderUtils.GetShaderPath(ShaderPathID.HIDDEN_BLIT));
instance.m_CopyDepthShader = Shader.Find(LightweightShaderUtils.GetShaderPath(ShaderPathID.HIDDEN_DEPTH_COPY));
if (assetPath.Length > 0)
UnityEditor.AssetDatabase.CreateAsset(instance, assetPath);
AssetDatabase.CreateAsset(instance, pathName);
}
}
#endif

4
ScriptableRenderPipeline/LightweightPipeline/package.json


{
"name": "com.unity.render-pipelines.lightweight",
"description": "Lightweight Render Pipeline for Unity.",
"version": "0.1.20",
"version": "0.1.21",
"com.unity.render-pipelines.core": "0.1.20"
"com.unity.render-pipelines.core": "0.1.21"
}
}

2
ScriptableRenderPipeline/master-package.json


{
"version": "0.1.20",
"version": "0.1.21",
"unity": "2018.1",
"dependencies": {
"com.unity.postprocessing": "0.1.7"

74
Tests/GraphicsTests/Framework/Editor/TestFramework.cs


"RenderPipeline"
};
private static readonly string[] s_PipelinePath =
{
"LightweightPipeline",
"HDRenderPipeline",
};
// info that gets generated for use
// in a dod way
public struct TestInfo

// collect the scenes that we can use
public static class CollectScenes
{
public static IEnumerable scenes
public static IEnumerable HDScenes
var absoluteScenesPath = s_Path.Aggregate(s_RootPath, Path.Combine);
return GetScenesForPipeline("HDRenderPipeline");
}
}
foreach (var pipelinePath in s_PipelinePath)
{
public static IEnumerable LWScenes
{
get
{
return GetScenesForPipeline("LightweightPipeline");
}
}
var filesPath = Path.Combine(absoluteScenesPath, pipelinePath);
public static IEnumerable GetScenesForPipeline(string _pipelinePath)
{
var absoluteScenesPath = s_Path.Aggregate(s_RootPath, Path.Combine);
// find all the scenes
var allPaths = System.IO.Directory.GetFiles(filesPath, "*.unity", System.IO.SearchOption.AllDirectories);
var filesPath = Path.Combine(absoluteScenesPath, _pipelinePath);
// construct all the needed test infos
foreach (var path in allPaths)
{
var p = new FileInfo(path);
var split = s_Path.Aggregate("", Path.Combine);
split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar);
var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries);
// find all the scenes
var allPaths = System.IO.Directory.GetFiles(filesPath, "*.unity", System.IO.SearchOption.AllDirectories);
yield return new TestInfo
{
name = p.Name,
relativePath = splitPaths.Last(),
threshold = 0.02f,
frameWait = 100
};
}
}
// construct all the needed test infos
foreach (var path in allPaths)
{
var p = new FileInfo(path);
var split = s_Path.Aggregate("", Path.Combine);
split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar);
var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries);
yield return new TestInfo
{
name = p.Name,
relativePath = splitPaths.Last(),
threshold = 0.02f,
frameWait = 100
};
}
}
}

}
[UnityTest]
public IEnumerator TestScene([ValueSource(typeof(CollectScenes), "scenes")]TestInfo testInfo)
public IEnumerator HDRP_TestScene([ValueSource(typeof(CollectScenes), "HDScenes")]TestInfo testInfo)
{
return TestScene(testInfo);
}
[UnityTest]
public IEnumerator LWRP_TestScene([ValueSource(typeof(CollectScenes), "LWScenes")]TestInfo testInfo)
{
return TestScene(testInfo);
}
public IEnumerator TestScene(TestInfo testInfo)
{
var prjRelativeGraphsPath = s_Path.Aggregate(s_RootPath, Path.Combine);
var filePath = Path.Combine(prjRelativeGraphsPath, testInfo.relativePath);

23
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_GraphicTests_Asset.asset


m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRP_GraphicTests_Asset
m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 42086e81f4f0c724f96f7f09cc995354,
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
renderingSettings:
globalRenderingSettings:
sssSettings: {fileID: 11400000, guid: 873499ce7a6f749408981f512a9683f7, type: 2}
tileSettings:
globalTextureSettings:
spotCookieSize: 128
pointCookieSize: 512
reflectionCubemapSize: 128
reflectionCacheCompressed: 0
sssSettings: {fileID: 0}
lightLoopSettings:
enableClustered: 1
enableFptlForOpaqueWhenClustered: 1
enableFptlForForwardOpaque: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableAsyncCompute: 0
textureSettings:
spotCookieSize: 128
pointCookieSize: 512
reflectionCubemapSize: 128
m_DefaultDiffuseMaterial: {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17,
type: 2}
m_DefaultShader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}

2
ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMapping.hlsl


// This structure abstract uv mapping inside one struct.
// It represent a mapping of any uv (with its associated tangent space for derivative if SurfaceGradient mode) - UVSet0 to 4, planar, triplanar
#include "NormalSurfaceGradient.hlsl"
#include "../NormalSurfaceGradient.hlsl"
#define UV_MAPPING_UVSET 0
#define UV_MAPPING_PLANAR 1

4
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CopyStencilBuffer.shader


#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/Packing.hlsl"
#include "../../../ShaderVariables.hlsl"
#include "../../../Lighting/LightDefinition.cs.hlsl"
#include "../ShaderVariables.hlsl"
#include "../Lighting/LightDefinition.cs.hlsl"
int _StencilRef;
RW_TEXTURE2D(float, _HTile); // DXGI_FORMAT_R8_UINT is not supported by Unity

6
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.shader


#pragma multi_compile _ SSS_FILTER_HORIZONTAL_AND_COMBINE
// Do not modify these.
#include "../../../ShaderPass/ShaderPass.cs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
#define SHADERPASS SHADERPASS_SUBSURFACE_SCATTERING
//-------------------------------------------------------------------------------------

#include "ShaderLibrary/Common.hlsl"
#include "../../../ShaderVariables.hlsl"
#include "../../SubsurfaceScattering/SubsurfaceScattering.hlsl"
#include "../../ShaderVariables.hlsl"
#include "SubsurfaceScattering.hlsl"
//-------------------------------------------------------------------------------------
// Inputs & outputs

20
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute


#define SSS_DEBUG_NORMAL_VS 0
// Do not modify these.
#include "../../../ShaderPass/ShaderPass.cs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
#define SHADERPASS SHADERPASS_SUBSURFACE_SCATTERING
#define GROUP_SIZE_1D 16
#define GROUP_SIZE_2D (GROUP_SIZE_1D * GROUP_SIZE_1D)

#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/Packing.hlsl"
#include "ShaderLibrary\Fibonacci.hlsl"
#include "ShaderLibrary/Sampling/Fibonacci.hlsl"
#include "../../../ShaderVariables.hlsl"
#include "../../../Lighting/LightDefinition.cs.hlsl"
#include "../../SubsurfaceScattering/SubsurfaceScattering.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/LightDefinition.cs.hlsl"
#include "SubsurfaceScattering.hlsl"
//--------------------------------------------------------------------------------------------------
// Inputs & outputs

TEXTURE2D(_DepthTexture); // Z-buffer
TEXTURE2D(_HTile); // DXGI_FORMAT_R8_UINT is not supported by Unity
TEXTURE2D(_SSSHTile); // DXGI_FORMAT_R8_UINT is not supported by Unity
TEXTURE2D(_IrradianceSource); // Includes transmitted light
#ifdef USE_INTERMEDIATE_BUFFER

float stencilRef = STENCILLIGHTINGUSAGE_SPLIT_LIGHTING;
// Check whether the thread group needs to perform any work.
float s00 = LOAD_TEXTURE2D(_HTile, 2 * groupId + uint2(0, 0)).r;
float s10 = LOAD_TEXTURE2D(_HTile, 2 * groupId + uint2(1, 0)).r;
float s01 = LOAD_TEXTURE2D(_HTile, 2 * groupId + uint2(0, 1)).r;
float s11 = LOAD_TEXTURE2D(_HTile, 2 * groupId + uint2(1, 1)).r;
float s00 = LOAD_TEXTURE2D(_SSSHTile, 2 * groupId + uint2(0, 0)).r;
float s10 = LOAD_TEXTURE2D(_SSSHTile, 2 * groupId + uint2(1, 0)).r;
float s01 = LOAD_TEXTURE2D(_SSSHTile, 2 * groupId + uint2(0, 1)).r;
float s11 = LOAD_TEXTURE2D(_SSSHTile, 2 * groupId + uint2(1, 1)).r;
// Perform the stencil test (reject at the tile rate).
processGroup = (stencilRef == s00 || stencilRef == s10 || stencilRef == s01 || stencilRef == s11);

97
ScriptableRenderPipeline/Core/LICENSE


Unity Companion License (“License”)
Software Copyright © 2017 Unity Technologies ApS
Unity Technologies ApS (“Unity”) grants to you a worldwide, non-exclusive,
no-charge, and royalty-free copyright license to reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense, and distribute the
software that is made available under this License (“Software”), subject to the
following terms and conditions:
1. Unity Companion Use Only. Exercise of the license granted herein is limited
to exercise for the creation, use, and/or distribution of applications,
software, or other content pursuant to a valid Unity content authoring and
rendering engine software license (“Engine License”). That means while use of
the Software is not limited to use in the software licensed under the Engine
License, the Software may not be used for any purpose other than the creation,
use, and/or distribution of Engine License-dependent applications, software, or
other content. No other exercise of the license granted herein is permitted,
and in no event may the Software be used for competitive analysis or to develop
a competing product or service.
2. No Modification of Engine License. Neither this License nor any exercise of
the license granted herein modifies the Engine License in any way.
3. Ownership & Grant Back to You.
3.1 You own your content. In this License, “derivative works” means derivatives
of the Software itself--works derived only from the Software by you under this
License (for example, modifying the code of the Software itself to improve its
efficacy); “derivative works” of the Software do not include, for example,
games, apps, or content that you create using the Software. You keep all right,
title, and interest to your own content.
3.2 Unity owns its content. While you keep all right, title, and interest to
your own content per the above, as between Unity and you, Unity will own all
right, title, and interest to all intellectual property rights (including
patent, trademark, and copyright) in the Software and derivative works of the
Software, and you hereby assign and agree to assign all such rights in those
derivative works to Unity.
3.3 You have a license to those derivative works. Subject to this License,
Unity grants to you the same worldwide, non-exclusive, no-charge, and
royalty-free copyright license to derivative works of the Software you create
as is granted to you for the Software under this License.
4. Trademarks. You are not granted any right or license under this License to
use any trademarks, service marks, trade names, products names, or branding of
Unity or its affiliates (“Trademarks”). Descriptive uses of Trademarks are
permitted; see, for example, Unity’s Branding Usage Guidelines at
https://unity3d.com/public-relations/brand.
5. Notices & Third-Party Rights. This License, including the copyright notice
associated with the Software, must be provided in all substantial portions of
the Software and derivative works thereof (or, if that is impracticable, in any
other location where such notices are customarily placed). Further, if the
Software is accompanied by a Unity “third-party notices” or similar file, you
acknowledge and agree that software identified in that file is governed by
those separate license terms.
6. DISCLAIMER, LIMITATION OF LIABILITY. THE SOFTWARE AND ANY DERIVATIVE WORKS
THEREOF IS PROVIDED ON AN "AS IS" BASIS, AND IS PROVIDED WITHOUT WARRANTY OF
ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR NONINFRINGEMENT. IN
NO EVENT SHALL ANY COPYRIGHT HOLDER OR AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES
(WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL,
INCLUDING PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR
PROFITS, AND BUSINESS INTERRUPTION), OR OTHER LIABILITY WHATSOEVER, WHETHER IN
AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM OR OUT OF, OR IN
CONNECTION WITH, THE SOFTWARE OR ANY DERIVATIVE WORKS THEREOF OR THE USE OF OR
OTHER DEALINGS IN SAME, EVEN WHERE ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7. USE IS ACCEPTANCE and License Versions. Your receipt and use of the Software
constitutes your acceptance of this License and its terms and conditions.
Software released by Unity under this License may be modified or updated and
the License with it; upon any such modification or update, you will comply with
the terms of the updated License for any use of any of the Software under the
updated License.
8. Use in Compliance with Law and Termination. Your exercise of the license
granted herein will at all times be in compliance with applicable law and will
not infringe any proprietary rights (including intellectual property rights);
this License will terminate immediately on any breach by you of this License.
9. Severability. If any provision of this License is held to be unenforceable
or invalid, that provision will be enforced to the maximum extent possible and
the other provisions will remain in full force and effect.
10. Governing Law and Venue. This License is governed by and construed in
accordance with the laws of Denmark, except for its conflict of laws rules; the
United Nations Convention on Contracts for the International Sale of Goods will
not apply. If you reside (or your principal place of business is) within the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the state and federal courts located in San
Francisco County, California concerning any dispute arising out of this License
(“Dispute”). If you reside (or your principal place of business is) outside the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the courts located in Copenhagen, Denmark
concerning any Dispute.

7
ScriptableRenderPipeline/Core/LICENSE.meta


fileFormatVersion: 2
guid: ef45a081b89729f48887261245188e37
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
ScriptableRenderPipeline/Core/ShaderLibrary/Sampling.meta


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

97
ScriptableRenderPipeline/HDRenderPipeline/LICENSE


Unity Companion License (“License”)
Software Copyright © 2017 Unity Technologies ApS
Unity Technologies ApS (“Unity”) grants to you a worldwide, non-exclusive,
no-charge, and royalty-free copyright license to reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense, and distribute the
software that is made available under this License (“Software”), subject to the
following terms and conditions:
1. Unity Companion Use Only. Exercise of the license granted herein is limited
to exercise for the creation, use, and/or distribution of applications,
software, or other content pursuant to a valid Unity content authoring and
rendering engine software license (“Engine License”). That means while use of
the Software is not limited to use in the software licensed under the Engine
License, the Software may not be used for any purpose other than the creation,
use, and/or distribution of Engine License-dependent applications, software, or
other content. No other exercise of the license granted herein is permitted,
and in no event may the Software be used for competitive analysis or to develop
a competing product or service.
2. No Modification of Engine License. Neither this License nor any exercise of
the license granted herein modifies the Engine License in any way.
3. Ownership & Grant Back to You.
3.1 You own your content. In this License, “derivative works” means derivatives
of the Software itself--works derived only from the Software by you under this
License (for example, modifying the code of the Software itself to improve its
efficacy); “derivative works” of the Software do not include, for example,
games, apps, or content that you create using the Software. You keep all right,
title, and interest to your own content.
3.2 Unity owns its content. While you keep all right, title, and interest to
your own content per the above, as between Unity and you, Unity will own all
right, title, and interest to all intellectual property rights (including
patent, trademark, and copyright) in the Software and derivative works of the
Software, and you hereby assign and agree to assign all such rights in those
derivative works to Unity.
3.3 You have a license to those derivative works. Subject to this License,
Unity grants to you the same worldwide, non-exclusive, no-charge, and
royalty-free copyright license to derivative works of the Software you create
as is granted to you for the Software under this License.
4. Trademarks. You are not granted any right or license under this License to
use any trademarks, service marks, trade names, products names, or branding of
Unity or its affiliates (“Trademarks”). Descriptive uses of Trademarks are
permitted; see, for example, Unity’s Branding Usage Guidelines at
https://unity3d.com/public-relations/brand.
5. Notices & Third-Party Rights. This License, including the copyright notice
associated with the Software, must be provided in all substantial portions of
the Software and derivative works thereof (or, if that is impracticable, in any
other location where such notices are customarily placed). Further, if the
Software is accompanied by a Unity “third-party notices” or similar file, you
acknowledge and agree that software identified in that file is governed by
those separate license terms.
6. DISCLAIMER, LIMITATION OF LIABILITY. THE SOFTWARE AND ANY DERIVATIVE WORKS
THEREOF IS PROVIDED ON AN "AS IS" BASIS, AND IS PROVIDED WITHOUT WARRANTY OF
ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR NONINFRINGEMENT. IN
NO EVENT SHALL ANY COPYRIGHT HOLDER OR AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES
(WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL,
INCLUDING PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR
PROFITS, AND BUSINESS INTERRUPTION), OR OTHER LIABILITY WHATSOEVER, WHETHER IN
AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM OR OUT OF, OR IN
CONNECTION WITH, THE SOFTWARE OR ANY DERIVATIVE WORKS THEREOF OR THE USE OF OR
OTHER DEALINGS IN SAME, EVEN WHERE ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7. USE IS ACCEPTANCE and License Versions. Your receipt and use of the Software
constitutes your acceptance of this License and its terms and conditions.
Software released by Unity under this License may be modified or updated and
the License with it; upon any such modification or update, you will comply with
the terms of the updated License for any use of any of the Software under the
updated License.
8. Use in Compliance with Law and Termination. Your exercise of the license
granted herein will at all times be in compliance with applicable law and will
not infringe any proprietary rights (including intellectual property rights);
this License will terminate immediately on any breach by you of this License.
9. Severability. If any provision of this License is held to be unenforceable
or invalid, that provision will be enforced to the maximum extent possible and
the other provisions will remain in full force and effect.
10. Governing Law and Venue. This License is governed by and construed in
accordance with the laws of Denmark, except for its conflict of laws rules; the
United Nations Convention on Contracts for the International Sale of Goods will
not apply. If you reside (or your principal place of business is) within the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the state and federal courts located in San
Francisco County, California concerning any dispute arising out of this License
(“Dispute”). If you reside (or your principal place of business is) outside the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the courts located in Copenhagen, Denmark
concerning any Dispute.

7
ScriptableRenderPipeline/HDRenderPipeline/LICENSE.meta


fileFormatVersion: 2
guid: 31351b1043fde6342afe25329f2e52f7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

9
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CopyStencilBuffer.shader.meta


fileFormatVersion: 2
guid: 3d1574f1cdfa0ce4995f9bc79ed7f8ec
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

97
ScriptableRenderPipeline/LightweightPipeline/LICENSE


Unity Companion License (“License”)
Software Copyright © 2017 Unity Technologies ApS
Unity Technologies ApS (“Unity”) grants to you a worldwide, non-exclusive,
no-charge, and royalty-free copyright license to reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense, and distribute the
software that is made available under this License (“Software”), subject to the
following terms and conditions:
1. Unity Companion Use Only. Exercise of the license granted herein is limited
to exercise for the creation, use, and/or distribution of applications,
software, or other content pursuant to a valid Unity content authoring and
rendering engine software license (“Engine License”). That means while use of
the Software is not limited to use in the software licensed under the Engine
License, the Software may not be used for any purpose other than the creation,
use, and/or distribution of Engine License-dependent applications, software, or
other content. No other exercise of the license granted herein is permitted,
and in no event may the Software be used for competitive analysis or to develop
a competing product or service.
2. No Modification of Engine License. Neither this License nor any exercise of
the license granted herein modifies the Engine License in any way.
3. Ownership & Grant Back to You.
3.1 You own your content. In this License, “derivative works” means derivatives
of the Software itself--works derived only from the Software by you under this
License (for example, modifying the code of the Software itself to improve its
efficacy); “derivative works” of the Software do not include, for example,
games, apps, or content that you create using the Software. You keep all right,
title, and interest to your own content.
3.2 Unity owns its content. While you keep all right, title, and interest to
your own content per the above, as between Unity and you, Unity will own all
right, title, and interest to all intellectual property rights (including
patent, trademark, and copyright) in the Software and derivative works of the
Software, and you hereby assign and agree to assign all such rights in those
derivative works to Unity.
3.3 You have a license to those derivative works. Subject to this License,
Unity grants to you the same worldwide, non-exclusive, no-charge, and
royalty-free copyright license to derivative works of the Software you create
as is granted to you for the Software under this License.
4. Trademarks. You are not granted any right or license under this License to
use any trademarks, service marks, trade names, products names, or branding of
Unity or its affiliates (“Trademarks”). Descriptive uses of Trademarks are
permitted; see, for example, Unity’s Branding Usage Guidelines at
https://unity3d.com/public-relations/brand.
5. Notices & Third-Party Rights. This License, including the copyright notice
associated with the Software, must be provided in all substantial portions of
the Software and derivative works thereof (or, if that is impracticable, in any
other location where such notices are customarily placed). Further, if the
Software is accompanied by a Unity “third-party notices” or similar file, you
acknowledge and agree that software identified in that file is governed by
those separate license terms.
6. DISCLAIMER, LIMITATION OF LIABILITY. THE SOFTWARE AND ANY DERIVATIVE WORKS
THEREOF IS PROVIDED ON AN "AS IS" BASIS, AND IS PROVIDED WITHOUT WARRANTY OF
ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR NONINFRINGEMENT. IN
NO EVENT SHALL ANY COPYRIGHT HOLDER OR AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES
(WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL,
INCLUDING PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR
PROFITS, AND BUSINESS INTERRUPTION), OR OTHER LIABILITY WHATSOEVER, WHETHER IN
AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM OR OUT OF, OR IN
CONNECTION WITH, THE SOFTWARE OR ANY DERIVATIVE WORKS THEREOF OR THE USE OF OR
OTHER DEALINGS IN SAME, EVEN WHERE ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7. USE IS ACCEPTANCE and License Versions. Your receipt and use of the Software
constitutes your acceptance of this License and its terms and conditions.
Software released by Unity under this License may be modified or updated and
the License with it; upon any such modification or update, you will comply with
the terms of the updated License for any use of any of the Software under the
updated License.
8. Use in Compliance with Law and Termination. Your exercise of the license
granted herein will at all times be in compliance with applicable law and will
not infringe any proprietary rights (including intellectual property rights);
this License will terminate immediately on any breach by you of this License.
9. Severability. If any provision of this License is held to be unenforceable
or invalid, that provision will be enforced to the maximum extent possible and
the other provisions will remain in full force and effect.
10. Governing Law and Venue. This License is governed by and construed in
accordance with the laws of Denmark, except for its conflict of laws rules; the
United Nations Convention on Contracts for the International Sale of Goods will
not apply. If you reside (or your principal place of business is) within the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the state and federal courts located in San
Francisco County, California concerning any dispute arising out of this License
(“Dispute”). If you reside (or your principal place of business is) outside the
United States, you and Unity agree to submit to the personal and exclusive
jurisdiction of and venue in the courts located in Copenhagen, Denmark
concerning any Dispute.

7
ScriptableRenderPipeline/LightweightPipeline/LICENSE.meta


fileFormatVersion: 2
guid: 0f4f03997ce061d4c9c0df390c8b92e5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

82
ScriptableRenderPipeline/Core/ShaderLibrary/Filtering.hlsl


// Ref: https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1 from MJP
// Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16.
// See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details
float4 SampleTextureCatmullRom(TEXTURE2D_ARGS(tex, linearSampler), float2 uv, float2 texSize)
{
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
// location [1, 1] in the grid, where [0, 0] is the top left corner.
float2 samplePos = uv * texSize;
float2 texPos1 = floor(samplePos - 0.5f) + 0.5f;
// Compute the fractional offset from our starting texel to our original sample location, which we'll
// feed into the Catmull-Rom spline function to get our filter weights.
float2 f = samplePos - texPos1;
float2 f2 = f * f;
float2 f3 = f2 * f;
// Compute the Catmull-Rom weights using the fractional offset that we calculated earlier.
// These equations are pre-expanded based on our knowledge of where the texels will be located,
// which lets us avoid having to evaluate a piece-wise function.
float2 w0 = (1.0f / 6.0) * (-3.0 * f3 + 6.0 * f2 - 3.0 * f);
float2 w1 = (1.0f / 6.0) * (9.0 * f3 - 15.0 * f2 + 6.0);
float2 w2 = (1.0f / 6.0) * (-9.0 * f3 + 12.0 * f2 + 3.0 * f);
float2 w3 = (1.0f / 6.0) * (3.0 * f3 - 3.0 * f2);
// Otim by Vlad, to test
// float2 w0 = (1.0 / 2.0) * f * (-1.0 + f * (2.0 - f));
// float2 w1 = (1.0 / 6.0) * f2 * (-15.0 + 9.0 * f)) + 1.0;
// float2 w2 = (1.0 / 6.0) * f * (3.0 + f * (12.0 - f * 9.0));
// float2 w3 = (1.0 / 2.0) * f2 * (f - 1.0);
// Work out weighting factors and sampling offsets that will let us use bilinear filtering to
// simultaneously evaluate the middle 2 samples from the 4x4 grid.
float2 w12 = w1 + w2;
float2 offset12 = w2 / (w1 + w2);
// Compute the final UV coordinates we'll use for sampling the texture
float2 texPos0 = texPos1 - 1;
float2 texPos3 = texPos1 + 2;
float2 texPos12 = texPos1 + offset12;
texPos0 /= texSize;
texPos3 /= texSize;
texPos12 /= texSize;
float4 result = 0.0;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos0.x, texPos0.y), 0.0) * w0.x * w0.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos12.x, texPos0.y), 0.0) * w12.x * w0.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos3.x, texPos0.y), 0.0) * w3.x * w0.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos0.x, texPos12.y), 0.0) * w0.x * w12.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos12.x, texPos12.y), 0.0) * w12.x * w12.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos3.x, texPos12.y), 0.0) * w3.x * w12.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos0.x, texPos3.y), 0.0) * w0.x * w3.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos12.x, texPos3.y), 0.0) * w12.x * w3.y;
result += TEXTURE2D_SAMPLE_LOD(tex, linearSampler, float2(texPos3.x, texPos3.y), 0.0) * w3.x * w3.y;
return result;
}
/*
// manual tri-linearly interpolated texture fetch
// not really needed: used hard-wired texture interpolation
vec4 manualTexture3D( sampler3D samp, vec3 p ){
vec3 qa = p*uvMapSize + vec3(0.5);
vec3 qi = floor(qa);
qa -= qi;
qi -= vec3(0.5);
return
mix( mix( mix( texture3D( samp, (qi+vec3(0.0,0.0,0.0))*oneOverUvMapSize ),
texture3D( samp, (qi+vec3(1.0,0.0,0.0))*oneOverUvMapSize ), qa.x ),
mix( texture3D( samp, (qi+vec3(0.0,1.0,0.0))*oneOverUvMapSize ),
texture3D( samp, (qi+vec3(1.0,1.0,0.0))*oneOverUvMapSize ), qa.x ), qa.y ),
mix( mix( texture3D( samp, (qi+vec3(0.0,0.0,1.0))*oneOverUvMapSize ),
texture3D( samp, (qi+vec3(1.0,0.0,1.0))*oneOverUvMapSize ), qa.x ),
mix( texture3D( samp, (qi+vec3(0.0,1.0,1.0))*oneOverUvMapSize ),
texture3D( samp, (qi+vec3(1.0,1.0,1.0))*oneOverUvMapSize ), qa.x ), qa.y ), qa.z );
}
*/

8
ScriptableRenderPipeline/Core/ShaderLibrary/Filtering.hlsl.meta


fileFormatVersion: 2
guid: dac42c6a533d53b41b931e02431564fa
timeCreated: 1474355143
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

10
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CopyStencilBuffer.shader.meta


fileFormatVersion: 2
guid: 7fd941b2d9d2a39429de64bde023932c
timeCreated: 1499946987
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

/ScriptableRenderPipeline/Core/ShaderLibrary/Sampling.hlsl.meta → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Sampling.hlsl.meta

/ScriptableRenderPipeline/Core/ShaderLibrary/Fibonacci.hlsl.meta → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Fibonacci.hlsl.meta

/ScriptableRenderPipeline/Core/ShaderLibrary/Hammersley.hlsl.meta → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Hammersley.hlsl.meta

/ScriptableRenderPipeline/Core/ShaderLibrary/Fibonacci.hlsl → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Fibonacci.hlsl

/ScriptableRenderPipeline/Core/ShaderLibrary/Hammersley.hlsl → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Hammersley.hlsl

/ScriptableRenderPipeline/Core/ShaderLibrary/SampleUVMappingNormalInternal.hlsl.meta → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl.meta

/ScriptableRenderPipeline/Core/ShaderLibrary/SampleUVMappingInternal.hlsl.meta → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl.meta

/ScriptableRenderPipeline/Core/ShaderLibrary/SampleUVMapping.hlsl.meta → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMapping.hlsl.meta

/ScriptableRenderPipeline/Core/ShaderLibrary/SampleUVMapping.hlsl → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMapping.hlsl

/ScriptableRenderPipeline/Core/ShaderLibrary/SampleUVMappingInternal.hlsl → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl

/ScriptableRenderPipeline/Core/ShaderLibrary/SampleUVMappingNormalInternal.hlsl → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl

/ScriptableRenderPipeline/Core/ShaderLibrary/Sampling.hlsl → /ScriptableRenderPipeline/Core/ShaderLibrary/Sampling/Sampling.hlsl

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute.meta → /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute.meta

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.shader.meta → /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.shader.meta

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineLighting.shader.meta → /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/CombineLighting.shader.meta

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineLighting.shader → /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/CombineLighting.shader

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CopyStencilBuffer.shader → /ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CopyStencilBuffer.shader

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.shader → /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.shader

/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute → /ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute

正在加载...
取消
保存