浏览代码

HDRenderPipeline: Change LayerUV to UVMapping + add keyword MAPPING_PLANAR

- added _LAYER_MAPPING_PLANAR0 keyword
- Planar mapping is now a shader feature
- Move all SampleLayer to  to ShaderLibrary and rename LayerUV to
UVMapping
- Create an enum UVMappingType instead of using isPlanar / is Triplanar
- Move double/mirror sided function to materialUtilities
- Update a lot of materials in test scene
/Branch_Batching2
Sebastien Lagarde 8 年前
当前提交
0365d4e5
共有 49 个文件被更改,包括 707 次插入504 次删除
  1. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  2. 18
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  3. 18
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  4. 9
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  5. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  6. 247
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  7. 79
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  8. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  9. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  10. 32
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/MaterialUtilities.hlsl
  11. 4
      Assets/ScriptableRenderPipeline/ShaderLibrary/NormalSurfaceGradient.hlsl
  12. 13
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendColor.mat
  13. 13
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat
  14. 16
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat
  15. 11
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
  16. 9
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
  17. 8
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
  18. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat
  19. 8
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat
  20. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat
  21. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV1.mat
  22. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV2.mat
  23. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat
  24. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat
  25. 9
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat
  26. 11
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV0.mat
  27. 11
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV1.mat
  28. 12
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV2.mat
  29. 12
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat
  30. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat
  31. 9
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat
  32. 8
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV0.mat
  33. 8
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV1.mat
  34. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV2.mat
  35. 10
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat
  36. 38
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_UVChart_Layer0_Detail.mat
  37. 37
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_UVChart_Layer1_Detail.mat
  38. 31
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_UVChart_Layer2_Detail.mat
  39. 37
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_UVChart_Layer3_Detail.mat
  40. 28
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_White_Detail.mat
  41. 69
      Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMapping.hlsl
  42. 57
      Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingInternal.hlsl
  43. 55
      Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingNormalInternal.hlsl
  44. 66
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayer.hlsl
  45. 57
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayerInternal.hlsl
  46. 55
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayerNormalInternal.hlsl
  47. 0
      /Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMapping.hlsl.meta
  48. 0
      /Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingInternal.hlsl.meta
  49. 0
      /Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingNormalInternal.hlsl.meta

16
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


const string kObjectScaleAffectTile = "_ObjectScaleAffectTile";
MaterialProperty UVBlendMask = null;
const string kUVBlendMask = "_UVBlendMask";
MaterialProperty UVMappingPlanarBlendMask = null;
const string kUVMappingPlanarBlendMask = "_UVMappingPlanarBlendMask";
MaterialProperty layerTilingBlendMask = null;
const string kLayerTilingBlendMask = "_LayerTilingBlendMask";
MaterialProperty texWorldScaleBlendMask = null;

MaterialProperty[] layerTexWorldScale = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVBase = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVMappingMask = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVMappingPlanar = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVDetail = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVDetailsMappingMask = new MaterialProperty[kMaxLayerCount];
// This one is specific to layer lit

vertexColorMode = FindProperty(kVertexColorMode, props);
objectScaleAffectTile = FindProperty(kObjectScaleAffectTile, props);
UVBlendMask = FindProperty(kUVBlendMask, props);
UVMappingPlanarBlendMask = FindProperty(kUVMappingPlanarBlendMask, props);
layerTilingBlendMask = FindProperty(kLayerTilingBlendMask, props);
texWorldScaleBlendMask = FindProperty(kTexWorldScaleBlendMask, props);

layerTexWorldScale[i] = FindProperty(string.Format("{0}{1}", kTexWorldScale, i), props);
layerUVBase[i] = FindProperty(string.Format("{0}{1}", kUVBase, i), props);
layerUVMappingMask[i] = FindProperty(string.Format("{0}{1}", kUVMappingMask, i), props);
layerUVMappingPlanar[i] = FindProperty(string.Format("{0}{1}", kUVMappingPlanar, i), props);
layerUVDetail[i] = FindProperty(string.Format("{0}{1}", kUVDetail, i), props);
layerUVDetailsMappingMask[i] = FindProperty(string.Format("{0}{1}", kUVDetailsMappingMask, i), props);
layerTiling[i] = FindProperty(string.Format("{0}{1}", kLayerTiling, i), props);

// put the name in the exclusionList below
static void SynchronizeLayerProperties(Material material, Material[] layers, int layerIndex)
{
string[] exclusionList = { kTexWorldScale, kUVBase, kUVMappingMask, kUVMappingPlanar, kUVDetail, kUVDetailsMappingMask };
string[] exclusionList = { kTexWorldScale, kUVBase, kUVMappingMask, kUVDetail, kUVDetailsMappingMask };
Material layerMaterial = layers[layerIndex];

}
}
UVMappingPlanarBlendMask.floatValue = ((LayerUVBaseMapping)UVBlendMask.floatValue == LayerUVBaseMapping.Planar) ? 1.0f : 0.0f;
// We setup the masking map based on the enum for each layer.
// using mapping mask allow to reduce the number of generated combination for a very small increase in ALU
LayerUVBaseMapping layerUVBaseMapping = (LayerUVBaseMapping)layerUVBase[layerIndex].floatValue;

Z = (layerUVBaseMapping == LayerUVBaseMapping.UV2) ? 1.0f : 0.0f;
W = (layerUVBaseMapping == LayerUVBaseMapping.UV3) ? 1.0f : 0.0f;
layerUVMappingMask[layerIndex].colorValue = (layerIndex == 0) ? new Color(1.0f, 0.0f, 0.0f, 0.0f) : new Color(X, Y, Z, W); // Special case for Main Layer and Blend Mask, only UV0. As Layer0 is share by both here, need to force X to 1.0 in all case
layerUVMappingPlanar[layerIndex].floatValue = (layerUVBaseMapping == LayerUVBaseMapping.Planar) ? 1.0f : 0.0f; // Planar have priority on UV0
UVDetailMapping layerUVDetailMapping = (UVDetailMapping)layerUVDetail[layerIndex].floatValue;
X = (layerUVDetailMapping == UVDetailMapping.UV0) ? 1.0f : 0.0f;

SetKeyword(material, "_LAYER_TILING_UNIFORM_SCALE", material.GetFloat(kObjectScaleAffectTile) > 0.0f);
// Blend mask
LayerUVBaseMapping UVBlendMaskMapping = (LayerUVBaseMapping)material.GetFloat(kUVBlendMask);
LayerUVBaseMapping UVBlendMaskMapping = (LayerUVBaseMapping)material.GetFloat(kUVBlendMask);
SetKeyword(material, "_LAYER_MAPPING_PLANAR_BLENDMASK", UVBlendMaskMapping == LayerUVBaseMapping.Planar);
SetKeyword(material, "_LAYER_MAPPING_TRIPLANAR_BLENDMASK", UVBlendMaskMapping == LayerUVBaseMapping.Triplanar);
int numLayer = (int)material.GetFloat(kLayerCount);

SetKeyword(material, "_LAYEREDLIT_3_LAYERS", false);
}
const string kLayerMappingPlanar = "_LAYER_MAPPING_PLANAR";
const string kLayerMappingTriplanar = "_LAYER_MAPPING_TRIPLANAR";
// We have to check for each layer if the UV2 or UV3 is needed.

{
string layerUVBaseParam = string.Format("{0}{1}", kUVBase, i);
LayerUVBaseMapping layerUVBaseMapping = (LayerUVBaseMapping)material.GetFloat(layerUVBaseParam);
string currentLayerMappingPlanar = string.Format("{0}{1}", kLayerMappingPlanar, i);
SetKeyword(material, currentLayerMappingPlanar, layerUVBaseMapping == LayerUVBaseMapping.Planar);
string currentLayerMappingTriplanar = string.Format("{0}{1}", kLayerMappingTriplanar, i);
SetKeyword(material, currentLayerMappingTriplanar, layerUVBaseMapping == LayerUVBaseMapping.Triplanar);

18
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


[ToggleOff] _ObjectScaleAffectTile("_ObjectScaleAffectTile", Float) = 0.0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBlendMask("UV Set for blendMask", Float) = 0
[HideInInspector] _UVMappingPlanarBlendMask("_UVMappingPlanarBlendMask", Float) = 0.0
_TexWorldScaleBlendMask("Tiling", Float) = 1.0
// Following are builtin properties

[HideInInspector] _UVMappingMask0("_UVMappingMask0", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask1("_UVMappingMask1", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask2("_UVMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask3("_UVMappingMask3", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingPlanar0("_UVMappingPlanar0", Float) = 0.0
[HideInInspector] _UVMappingPlanar1("_UVMappingPlanar1", Float) = 0.0
[HideInInspector] _UVMappingPlanar2("_UVMappingPlanar2", Float) = 0.0
[HideInInspector] _UVMappingPlanar3("_UVMappingPlanar3", Float) = 0.0
[HideInInspector] _UVMappingMask3("_UVMappingMask3", Color) = (1, 0, 0, 0)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail0("UV Set for detail0", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail1("UV Set for detail1", Float) = 0

#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _LAYER_TILING_UNIFORM_SCALE
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_BLENDMASK
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR0
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR1
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR2
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR3
#pragma shader_feature _ _LAYER_MAPPING_PLANAR_BLENDMASK _LAYER_MAPPING_TRIPLANAR_BLENDMASK
#pragma shader_feature _ _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_TRIPLANAR0
#pragma shader_feature _ _LAYER_MAPPING_PLANAR1 _LAYER_MAPPING_TRIPLANAR1
#pragma shader_feature _ _LAYER_MAPPING_PLANAR2 _LAYER_MAPPING_TRIPLANAR2
#pragma shader_feature _ _LAYER_MAPPING_PLANAR3 _LAYER_MAPPING_TRIPLANAR3
#pragma shader_feature _NORMALMAP_TANGENT_SPACE0
#pragma shader_feature _NORMALMAP_TANGENT_SPACE1
#pragma shader_feature _NORMALMAP_TANGENT_SPACE2

18
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


[ToggleOff] _ObjectScaleAffectTile("_ObjectScaleAffectTile", Float) = 0.0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBlendMask("UV Set for blendMask", Float) = 0
[HideInInspector] _UVMappingPlanarBlendMask("_UVMappingPlanarBlendMask", Float) = 0.0
_TexWorldScaleBlendMask("Tiling", Float) = 1.0
// Following are builtin properties

[HideInInspector] _UVMappingMask0("_UVMappingMask0", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask1("_UVMappingMask1", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask2("_UVMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask3("_UVMappingMask3", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingPlanar0("_UVMappingPlanar0", Float) = 0.0
[HideInInspector] _UVMappingPlanar1("_UVMappingPlanar1", Float) = 0.0
[HideInInspector] _UVMappingPlanar2("_UVMappingPlanar2", Float) = 0.0
[HideInInspector] _UVMappingPlanar3("_UVMappingPlanar3", Float) = 0.0
[HideInInspector] _UVMappingMask3("_UVMappingMask3", Color) = (1, 0, 0, 0)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail0("UV Set for detail0", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail1("UV Set for detail1", Float) = 0

#pragma shader_feature _TESSELLATION_OBJECT_SCALE
#pragma shader_feature _LAYER_TILING_UNIFORM_SCALE
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_BLENDMASK
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR0
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR1
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR2
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR3
#pragma shader_feature _ _LAYER_MAPPING_PLANAR_BLENDMASK _LAYER_MAPPING_TRIPLANAR_BLENDMASK
#pragma shader_feature _ _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_TRIPLANAR0
#pragma shader_feature _ _LAYER_MAPPING_PLANAR1 _LAYER_MAPPING_TRIPLANAR1
#pragma shader_feature _ _LAYER_MAPPING_PLANAR2 _LAYER_MAPPING_TRIPLANAR2
#pragma shader_feature _ _LAYER_MAPPING_PLANAR3 _LAYER_MAPPING_TRIPLANAR3
#pragma shader_feature _NORMALMAP_TANGENT_SPACE0
#pragma shader_feature _NORMALMAP_TANGENT_SPACE1
#pragma shader_feature _NORMALMAP_TANGENT_SPACE2

9
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


protected const string kTexWorldScale = "_TexWorldScale";
protected MaterialProperty UVMappingMask = null;
protected const string kUVMappingMask = "_UVMappingMask";
protected MaterialProperty UVMappingPlanar = null;
protected const string kUVMappingPlanar = "_UVMappingPlanar";
protected MaterialProperty baseColor = null;
protected const string kBaseColor = "_BaseColor";

UVBase = FindProperty(kUVBase, props);
TexWorldScale = FindProperty(kTexWorldScale, props);
UVMappingMask = FindProperty(kUVMappingMask, props);
UVMappingPlanar = FindProperty(kUVMappingPlanar, props);
baseColor = FindProperty(kBaseColor, props);
baseColorMap = FindProperty(kBaseColorMap, props);

GUILayout.Label(" " + Styles.textureControlText, EditorStyles.label);
m_MaterialEditor.ShaderProperty(UVBase, Styles.UVBaseMappingText);
// UVSet0 is always set, planar and triplanar will override it.
UVMappingMask.colorValue = new Color(1.0f, 0.0f, 0.0f, 0.0f); // This is override in the shader anyway but just in case.
UVMappingPlanar.floatValue = ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Planar) ? 1.0f : 0.0f;
UVMappingMask.colorValue = new Color(1.0f, 0.0f, 0.0f, 0.0f); // This is override in the shader anyway but just in case.
if (((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Planar) || ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Triplanar))
{
m_MaterialEditor.ShaderProperty(TexWorldScale, Styles.texWorldScaleText);

GUILayout.Label(" " + Styles.UVDetailMappingText.text + ": Triplanar");
}
// IF planar/triplanar is not chose, setup the UVSet chosen
// Setup the UVSet for detail, if planar/triplanar is use for base, it will override the mapping of detail (See shader code)
float X, Y, Z, W;
X = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV0) ? 1.0f : 0.0f;
Y = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV1) ? 1.0f : 0.0f;

// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
// (MaterialProperty value might come from renderer material property block)
SetKeyword(material, "_MAPPING_PLANAR", ((UVBaseMapping)material.GetFloat(kUVBase)) == UVBaseMapping.Planar);
SetKeyword(material, "_MAPPING_TRIPLANAR", ((UVBaseMapping)material.GetFloat(kUVBase)) == UVBaseMapping.Triplanar);
SetKeyword(material, "_NORMALMAP_TANGENT_SPACE", ((NormalMapSpace)material.GetFloat(kNormalMapSpace)) == NormalMapSpace.TangentSpace);
SetKeyword(material, "_EMISSIVE_COLOR", ((EmissiveColorMode)material.GetFloat(kEmissiveColorMode)) == EmissiveColorMode.UseEmissiveColor);

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


[Enum(UV0, 0, Planar, 1, TriPlanar, 2)] _UVBase("UV Set for base", Float) = 0
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2, Specular Color, 3)] _MaterialID("MaterialId", Int) = 0

#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go futher in dev
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant

#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _MAPPING_TRIPLANAR
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3
#pragma shader_feature _EMISSIVE_COLOR

247
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
#include "../MaterialUtilities.hlsl"
#include "../SampleLayer.hlsl"
#include "ShaderLibrary/SampleUVMapping.hlsl"
void GetBuiltinData(FragInputs input, SurfaceData surfaceData, float alpha, float depthOffset, out BuiltinData builtinData)
{

builtinData.depthOffset = depthOffset;
}
// Struct that gather UVMapping info of all layers + common calculation
// This is use to abstract the mapping that can differ on layers
LayerUV base;
LayerUV details;
UVMapping base;
UVMapping details;
LayerUV base0;
LayerUV base1;
LayerUV base2;
LayerUV base3;
UVMapping base0;
UVMapping base1;
UVMapping base2;
UVMapping base3;
LayerUV details0;
LayerUV details1;
LayerUV details2;
LayerUV details3;
UVMapping details0;
UVMapping details1;
UVMapping details2;
UVMapping details3;
LayerUV blendMask;
UVMapping blendMask;
CommonLayerUV common;
};
// Store information that will be share by all UVMapping
float3 triplanarWeights;
// To flip in case of double sided, we must flip the vertex normal and this will apply to the whole process either in surface gradient or not.
// As here we are in the function call GetSurfaceAndBuiltinData(), the tangent space is already built, so we need to flip both normal and bitangent.
// This function will modify FragInputs and this is not propagate outside of GetSurfaceAndBuiltinData(). This is ok as tangent space is not use outside of GetSurfaceAndBuiltinData().
void ApplyDoubleSidedFlip(inout FragInputs input)
{
#ifdef _DOUBLESIDED_ON
// _DoubleSidedConstants is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : _DoubleSidedConstants.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
input.worldToTangent[1] = flipSign * input.worldToTangent[1]; // bitangent
input.worldToTangent[2] = flipSign * input.worldToTangent[2]; // normal
#ifdef SURFACE_GRADIENT
float3 vertexNormalWS; // TODO: store also object normal map for object triplanar
#ifdef SURFACE_GRADIENT
// TOCHECK: seems that we don't need to invert any genBasisTB(), sign cancel. Which is expected as we deal with surface gradient.
#endif
// tangent basis for each UVSet - up to 4 for now
float3 vertexTangentWS0, vertexBitangentWS0;
float3 vertexTangentWS1, vertexBitangentWS1;
float3 vertexTangentWS2, vertexBitangentWS1;
float3 vertexTangentWS3, vertexBitangentWS2;
}
};
// To mirror a normal: in ws reflect around the vertex normal / in tangent space apply minus on the z component.
// For surface gradient it is sufficient to take the opposite of the surface gradient.
void ApplyDoubleSidedMirror(FragInputs input, inout float3 normalTS)
void FillCommonLayerTexCoord(FragInputs input, inout LayerTexCoord layerTexCoord)
#ifdef _DOUBLESIDED_ON
// _DoubleSidedConstants is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : -_DoubleSidedConstants.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
#ifdef SURFACE_GRADIENT
normalTS = flipSign * normalTS;
#else
normalTS.z *= flipSign;
float3 vertexNormalWS = input.worldToTangent[2];
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(vertexNormalWS);
#ifdef SURFACE_GRADIENT
layerTexCoord.vertexNormalWS = vertexNormalWS;
layerTexCoord.vertexTangentWS0 = input.worldToTangent[1];
layerTexCoord.vertexBitangentWS0 = input.worldToTangent[2];
// TODO: We should use relative camera position here - This will be automatic when we will move to camera relative space.
float3 dPdx = ddx_fine(input.positionWS);
float3 dPdy = ddy_fine(input.positionWS);
float3 sigmaX = dPdx - dot(dPdx, vertexNormalWS) * vertexNormalWS;
float3 sigmaY = dPdy - dot(dPdy, vertexNormalWS) * vertexNormalWS;
//float flipSign = dot(sigmaY, cross(nrmVertexNormal, sigmaX) ) ? -1.0 : 1.0;
float flipSign = dot(dPdy, cross(vertexNormalWS, dPdx)) < 0.0 ? -1.0 : 1.0; // gives same as the commented out line above
// TODO: Optimize! The compiler will not be able to remove the tangent space that are not use because it can't know due to our UVMapping constant we use for both base and details
// To solve this we should track which UVSet is use for normal mapping... Maybe not as simple as it sounds
SurfaceGradientGenBasisTB(vertexNormalWS, sigmaX, sigmaY, flipSign, input.texCoord1, layerTexCoord.vertexTangentWS1, layerTexCoord.vertexBitangentWS1);
#if defined(_REQUIRE_UV2) || defined(_REQUIRE_UV3)
SurfaceGradientGenBasisTB(vertexNormalWS, sigmaX, sigmaY, flipSign, input.texCoord1, layerTexCoord.vertexTangentWS2, layerTexCoord.vertexBitangentWS2);
#if defined(_REQUIRE_UV3)
SurfaceGradientGenBasisTB(vertexNormalWS, sigmaX, sigmaY, flipSign, input.texCoord1, layerTexCoord.vertexTangentWS3, layerTexCoord.vertexBitangentWS3);
#endif
#ifndef LAYERED_LIT_SHADER
#define SAMPLER_NORMALMAP_IDX sampler_NormalMap

{
ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
bool isTriplanar = false;
#ifdef _MAPPING_TRIPLANAR
#ifdef SURFACE_GRADIENT
layerTexCoord.common.vertexNormalWS = normalWS;
#endif
layerTexCoord.common.triplanarWeights = ComputeTriplanarWeights(normalWS);
isTriplanar = true;
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(normalWS);
int mappingType = UV_MAPPING_UVSET;
#if defined(_MAPPING_PLANAR)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_MAPPING_TRIPLANAR)
mappingType = UV_MAPPING_TRIPLANAR;
// Be sure that the compiler is aware that we don't touch UV1 to UV3 for main layer so it can optimize code
// Also we have always UVset to 1, if planar/triplanar is enable, it will override it.
// Be sure that the compiler is aware that we don't use UV1 to UV3 for main layer so it can optimize code
positionWS, normalWS, _UVMappingPlanar > 0.0, isTriplanar, _TexWorldScale, layerTexCoord);
}
float GetMaxDisplacement()

float2 minUvSize = float2(FLT_MAX, FLT_MAX);
#if defined(_HEIGHTMAP)
if (layerTexCoord.base.isTriplanar)
if (layerTexCoord.base.mappingType == UV_MAPPING_TRIPLANAR)
{
minUvSize = min(layerTexCoord.base.uvZY * _HeightMap_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base.uvXZ * _HeightMap_TexelSize.zw, minUvSize);

#if defined(_PER_PIXEL_DISPLACEMENT) && defined(_HEIGHTMAP)
ppdEnable = true;
isPlanar = layerTexCoord.base.isPlanar;
isTriplanar = layerTexCoord.base.isTriplanar;
isPlanar = layerTexCoord.base.mappingType == UV_MAPPING_PLANAR;
isTriplanar = layerTexCoord.base.mappingType == UV_MAPPING_TRIPLANAR;
#endif
if (ppdEnable)

// Calculate displacement for per vertex displacement mapping
float ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod)
{
return (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap, sampler_HeightMap, layerTexCoord.base, lod).r - _HeightCenter) * _HeightAmplitude;
return (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap, sampler_HeightMap, layerTexCoord.base, lod).r - _HeightCenter) * _HeightAmplitude;
}
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)

{
ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
#if defined(_LAYER_MAPPING_TRIPLANAR_BLENDMASK) || defined(_LAYER_MAPPING_TRIPLANAR0) || defined(_LAYER_MAPPING_TRIPLANAR1) || defined(_LAYER_MAPPING_TRIPLANAR2) || defined(_LAYER_MAPPING_TRIPLANAR3)
#ifdef SURFACE_GRADIENT
layerTexCoord.common.vertexNormalWS = normalWS;
#endif
layerTexCoord.common.triplanarWeights = ComputeTriplanarWeights(normalWS);
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(normalWS);
int mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR_BLENDMASK)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR_BLENDMASK)
mappingType = UV_MAPPING_TRIPLANAR;
bool isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR_BLENDMASK
isTriplanar = true;
#endif
// Be sure that the compiler is aware that we don't use UV1 to UV3 for main layer and blend mask so it can optimize code
// Note: Blend mask have its dedicated mapping and tiling. And as Main layer it only use UV0
_UVMappingMask0 = float4(1.0, 0.0, 0.0, 0.0);
// Be sure that the compiler is aware that we don't touch UV1 to UV3 for main layer so it can optimize code
_UVMappingMask0.yzw = float3(0.0, 0.0, 0.0);
// Note: Blend mask have its dedicated mapping adn tiling. And as Main layer it only use UV0
// To share code, we simply call the regular code from the main layer for it save the result, then do regular call for all layers.
// To share code, we simply call the regular code from the main layer for it then save the result, then do regular call for all layers.
positionWS, normalWS, _UVMappingPlanarBlendMask > 0.0, isTriplanar, _TexWorldScaleBlendMask, layerTexCoord, _LayerTilingBlendMask);
positionWS, normalWS, mappingType, _TexWorldScaleBlendMask, layerTexCoord, _LayerTilingBlendMask);
layerTexCoord.blendMask = layerTexCoord.base0;

tileObjectScale = length(float3(worldTransform._m00, worldTransform._m01, worldTransform._m02));
#endif
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR0
isTriplanar = true;
mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR0)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR0)
mappingType = UV_MAPPING_TRIPLANAR;
positionWS, normalWS, _UVMappingPlanar0 > 0.0, isTriplanar, _TexWorldScale0, layerTexCoord, _LayerTiling0
positionWS, normalWS, mappingType, _TexWorldScale0, layerTexCoord, _LayerTiling0
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR1
isTriplanar = true;
mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR1)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR1)
mappingType = UV_MAPPING_TRIPLANAR;
positionWS, normalWS, _UVMappingPlanar1 > 0.0, isTriplanar, _TexWorldScale1, layerTexCoord, _LayerTiling1 * tileObjectScale);
positionWS, normalWS, mappingType, _TexWorldScale1, layerTexCoord, _LayerTiling1 * tileObjectScale);
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR2
isTriplanar = true;
mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR2)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR2)
mappingType = UV_MAPPING_TRIPLANAR;
positionWS, normalWS, _UVMappingPlanar2 > 0.0, isTriplanar, _TexWorldScale2, layerTexCoord, _LayerTiling2 * tileObjectScale);
positionWS, normalWS, mappingType, _TexWorldScale2, layerTexCoord, _LayerTiling2 * tileObjectScale);
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR3
isTriplanar = true;
mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR3)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR3)
mappingType = UV_MAPPING_TRIPLANAR;
positionWS, normalWS, _UVMappingPlanar3 > 0.0, isTriplanar, _TexWorldScale3, layerTexCoord, _LayerTiling3 * tileObjectScale);
positionWS, normalWS, mappingType, _TexWorldScale3, layerTexCoord, _LayerTiling3 * tileObjectScale);
}
// This function is just syntaxic sugar to nullify height not used based on heightmap avaibility and layer

// Blend mask are Main Layer A - Layer 1 R - Layer 2 G - Layer 3 B
// Value for main layer is not use for blending itself but for alternate weighting like density.
// Settings this specific Main layer blend mask in alpha allow to be transparent in case we don't use it and 1 is provide by default.
float4 blendMasks = useLodSampling ? SAMPLE_LAYER_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask, lod) : SAMPLE_LAYER_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask);
float4 blendMasks = useLodSampling ? SAMPLE_UVMAPPING_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask, lod) : SAMPLE_UVMAPPING_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask);
#if defined(_LAYER_MASK_VERTEX_COLOR_MUL)
blendMasks *= vertexColor;

float2 minUvSize = float2(FLT_MAX, FLT_MAX);
#if defined(_HEIGHTMAP0)
if (layerTexCoord.base0.isTriplanar)
if (layerTexCoord.base0.mappingType == UV_MAPPING_TRIPLANAR)
{
minUvSize = min(layerTexCoord.base0.uvZY * _HeightMap0_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base0.uvXZ * _HeightMap0_TexelSize.zw, minUvSize);

#endif
#if defined(_HEIGHTMAP1)
if (layerTexCoord.base1.isTriplanar)
if (layerTexCoord.base1.mappingType == UV_MAPPING_TRIPLANAR)
{
minUvSize = min(layerTexCoord.base1.uvZY * _HeightMap1_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base1.uvXZ * _HeightMap1_TexelSize.zw, minUvSize);

#if _LAYER_COUNT >= 3
#if defined(_HEIGHTMAP2)
if (layerTexCoord.base2.isTriplanar)
if (layerTexCoord.base2.mappingType == UV_MAPPING_TRIPLANAR)
{
minUvSize = min(layerTexCoord.base2.uvZY * _HeightMap2_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base2.uvXZ * _HeightMap2_TexelSize.zw, minUvSize);

#if _LAYER_COUNT >= 4
#if defined(_HEIGHTMAP3)
if (layerTexCoord.base3.isTriplanar)
if (layerTexCoord.base3.mappingType == UV_MAPPING_TRIPLANAR)
{
minUvSize = min(layerTexCoord.base3.uvZY * _HeightMap3_TexelSize.zw, minUvSize);
minUvSize = min(layerTexCoord.base3.uvXZ * _HeightMap3_TexelSize.zw, minUvSize);

// To know if we are planar or triplanar just need to check if any of the active heightmap layer is true as they are enforce to be the same mapping
#if defined(_HEIGHTMAP0)
ppdEnable = true;
isPlanar = layerTexCoord.base0.isPlanar;
isTriplanar = layerTexCoord.base0.isTriplanar;
isPlanar = layerTexCoord.base0.mappingType == UV_MAPPING_PLANAR;
isTriplanar = layerTexCoord.base0.mappingType == UV_MAPPING_TRIPLANAR;
isPlanar = layerTexCoord.base1.isPlanar;
isTriplanar = layerTexCoord.base1.isTriplanar;
isPlanar = layerTexCoord.base1.mappingType == UV_MAPPING_PLANAR;
isTriplanar = layerTexCoord.base1.mappingType == UV_MAPPING_TRIPLANAR;
isPlanar = layerTexCoord.base2.isPlanar;
isTriplanar = layerTexCoord.base2.isTriplanar;
isPlanar = layerTexCoord.base2.mappingType == UV_MAPPING_PLANAR;
isTriplanar = layerTexCoord.base2.mappingType == UV_MAPPING_TRIPLANAR;
#endif
#endif

isPlanar = layerTexCoord.base3.isPlanar;
isTriplanar = layerTexCoord.base3.isTriplanar;
isPlanar = layerTexCoord.base3.mappingType == UV_MAPPING_PLANAR;
isTriplanar = layerTexCoord.base3.mappingType == UV_MAPPING_TRIPLANAR;
#endif
#endif

int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam);
// Apply offset to all planar uvset
// _UVMappingPlanar0 will be 1.0 is planar is used - _UVMappingMask0.x will be 1.0 is UVSet0 is used;
float4 offsetWeights = isPlanar ? float4(_UVMappingPlanar0, _UVMappingPlanar1, _UVMappingPlanar2, _UVMappingPlanar3) : float4(_UVMappingMask0.x, _UVMappingMask1.x, _UVMappingMask2.x, _UVMappingMask3.x);
// Apply offset to all planar UV if applicable
float4 planarWeight = float4( layerTexCoord.base0.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
layerTexCoord.base1.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
layerTexCoord.base2.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
layerTexCoord.base3.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0);
// _UVMappingMask0.x will be 1.0 is UVSet0 is used;
float4 offsetWeights = isPlanar ? planarWeight : float4(_UVMappingMask0.x, _UVMappingMask1.x, _UVMappingMask2.x, _UVMappingMask3.x);
layerTexCoord.base0.uv += offsetWeights.x * offset;
layerTexCoord.base1.uv += offsetWeights.y * offset;

offsetWeights = isPlanar ? float4(_UVMappingPlanar0, _UVMappingPlanar1, _UVMappingPlanar2, _UVMappingPlanar3) : float4(_UVDetailsMappingMask0.x, _UVDetailsMappingMask1.x, _UVDetailsMappingMask2.x, _UVDetailsMappingMask3.x);
offsetWeights = isPlanar ? planarWeight : float4(_UVDetailsMappingMask0.x, _UVDetailsMappingMask1.x, _UVDetailsMappingMask2.x, _UVDetailsMappingMask3.x);
layerTexCoord.details0.uv += offsetWeights.x * offset;
layerTexCoord.details1.uv += offsetWeights.y * offset;

ComputeMaskWeights(blendMasks, weights);
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
float height0 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0, lod).r - _LayerCenterOffset0) * _LayerHeightAmplitude0;
float height1 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1, lod).r - _LayerCenterOffset1) * _LayerHeightAmplitude1;
float height2 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2, lod).r - _LayerCenterOffset2) * _LayerHeightAmplitude2;
float height3 = (SAMPLE_LAYER_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3, lod).r - _LayerCenterOffset3) * _LayerHeightAmplitude3;
float height0 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0, lod).r - _LayerCenterOffset0) * _LayerHeightAmplitude0;
float height1 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1, lod).r - _LayerCenterOffset1) * _LayerHeightAmplitude1;
float height2 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2, lod).r - _LayerCenterOffset2) * _LayerHeightAmplitude2;
float height3 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3, lod).r - _LayerCenterOffset3) * _LayerHeightAmplitude3;
SetEnabledHeightByLayer(height0, height1, height2, height3);
float heightResult = BlendLayeredScalar(height0, height1, height2, height3, weights);

#if defined(_HEIGHT_BASED_BLEND)
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
float height0 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0).r - _LayerCenterOffset0) * _LayerHeightAmplitude0;
float height1 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1).r - _LayerCenterOffset1) * _LayerHeightAmplitude1;
float height2 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2).r - _LayerCenterOffset2) * _LayerHeightAmplitude2;
float height3 = (SAMPLE_LAYER_TEXTURE2D(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3).r - _LayerCenterOffset3) * _LayerHeightAmplitude3;
float height0 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0).r - _LayerCenterOffset0) * _LayerHeightAmplitude0;
float height1 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1).r - _LayerCenterOffset1) * _LayerHeightAmplitude1;
float height2 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2).r - _LayerCenterOffset2) * _LayerHeightAmplitude2;
float height3 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3).r - _LayerCenterOffset3) * _LayerHeightAmplitude3;
SetEnabledHeightByLayer(height0, height1, height2, height3);
float4 heights = float4(height0, height1, height2, height3);

// We want to calculate the mean color of the texture. For this we will sample a low mipmap
float textureBias = 15.0; // Use maximum bias
float3 baseMeanColor0 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap0, sampler_BaseColorMap0, layerTexCoord.base0, textureBias).rgb *_BaseColor0.rgb;
float3 baseMeanColor1 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap1, sampler_BaseColorMap0, layerTexCoord.base1, textureBias).rgb *_BaseColor1.rgb;
float3 baseMeanColor2 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap2, sampler_BaseColorMap0, layerTexCoord.base2, textureBias).rgb *_BaseColor2.rgb;
float3 baseMeanColor3 = SAMPLE_LAYER_TEXTURE2D_BIAS(_BaseColorMap3, sampler_BaseColorMap0, layerTexCoord.base3, textureBias).rgb *_BaseColor3.rgb;
float3 baseMeanColor0 = SAMPLE_UVMAPPING_TEXTURE2D_BIAS(_BaseColorMap0, sampler_BaseColorMap0, layerTexCoord.base0, textureBias).rgb *_BaseColor0.rgb;
float3 baseMeanColor1 = SAMPLE_UVMAPPING_TEXTURE2D_BIAS(_BaseColorMap1, sampler_BaseColorMap0, layerTexCoord.base1, textureBias).rgb *_BaseColor1.rgb;
float3 baseMeanColor2 = SAMPLE_UVMAPPING_TEXTURE2D_BIAS(_BaseColorMap2, sampler_BaseColorMap0, layerTexCoord.base2, textureBias).rgb *_BaseColor2.rgb;
float3 baseMeanColor3 = SAMPLE_UVMAPPING_TEXTURE2D_BIAS(_BaseColorMap3, sampler_BaseColorMap0, layerTexCoord.base3, textureBias).rgb *_BaseColor3.rgb;
float3 meanColor = BlendLayeredVector3(baseMeanColor0, baseMeanColor1, baseMeanColor2, baseMeanColor3, weights);

79
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


void ADD_IDX(ComputeLayerTexCoord)( float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3,
float3 positionWS, float3 vertexNormalWS, bool isPlanar, bool isTriplanar, float worldScale, inout LayerTexCoord layerTexCoord, float additionalTiling = 1.0)
float3 positionWS, float3 vertexNormalWS, int mappingType, float worldScale, inout LayerTexCoord layerTexCoord, float additionalTiling = 1.0)
{
// Handle uv0, uv1, uv2, uv3 based on _UVMappingMask weight (exclusif 0..1)
float2 uvBase = ADD_IDX(_UVMappingMask).x * texCoord0 +

ADD_IDX(_UVDetailsMappingMask).w * texCoord3;
// If base is planar/triplanar then detail map is forced to be planar/triplanar
ADD_IDX(layerTexCoord.base).isPlanar = isPlanar;
ADD_IDX(layerTexCoord.base).isTriplanar = isTriplanar;
ADD_IDX(layerTexCoord.details).isPlanar = isPlanar;
ADD_IDX(layerTexCoord.details).isTriplanar = isTriplanar;
ADD_IDX(layerTexCoord.details).mappingType = ADD_IDX(layerTexCoord.base).mappingType = mappingType;
// Copy data for the uvmapping
ADD_IDX(layerTexCoord.details).triplanarWeights = ADD_IDX(layerTexCoord.base).triplanarWeights = layerTexCoord.triplanarWeights;
// TODO: Currently we only handle world planar/triplanar but we may want local planar/triplanar.
// In this case both position and normal need to be convert to object space.

float2 uvZY;
GetTriplanarCoordinate(positionWS * worldScale, vertexNormalWS, uvXZ, uvXY, uvZY);
if (isPlanar)
// Planar is just XZ of triplanar
if (mappingType == UV_MAPPING_PLANAR)
{
uvBase = uvDetails = uvXZ;
}

ADD_IDX(layerTexCoord.details).uvZY = TRANSFORM_TEX(uvZY, ADD_IDX(_DetailMap));
#ifdef SURFACE_GRADIENT
// TODO:... how to pass argument, how to deal with vertex level call (like tessellation)
ADD_IDX(layerTexCoord.base).vT = ADD_IDX(_UVMappingMask).x * worlToTangent[0] +
ADD_IDX(_UVMappingMask).y * vT1 +
ADD_IDX(_UVMappingMask).z * vT2 +
ADD_IDX(_UVMappingMask).w * vT3;
ADD_IDX(layerTexCoord.details).normalWS = ADD_IDX(layerTexCoord.base).normalWS = layerTexCoord.vertexNormalWS;
ADD_IDX(layerTexCoord.base).vB = ADD_IDX(_UVMappingMask).x * worlToTangent[1] +
ADD_IDX(_UVMappingMask).y * vB1 +
ADD_IDX(_UVMappingMask).z * vB2 +
ADD_IDX(_UVMappingMask).w * vB3;
// This part is only relevant for normal mapping with UV_MAPPING_UVSET
// Note: This code work only in pixel shader (as we rely on ddx), it should not be use in other context
ADD_IDX(layerTexCoord.base).tangentWS = ADD_IDX(_UVMappingMask).x * layerTexCoord.vertexTangentWS0 +
ADD_IDX(_UVMappingMask).y * layerTexCoord.vertexTangentWS1 +
ADD_IDX(_UVMappingMask).z * layerTexCoord.vertexTangentWS2 +
ADD_IDX(_UVMappingMask).w * layerTexCoord.vertexTangentWS3;
ADD_IDX(layerTexCoord.details).vT = ADD_IDX(_UVMappingMask).x * worlToTangent[0] +
ADD_IDX(_UVMappingMask).y * vT1 +
ADD_IDX(_UVMappingMask).z * vT2 +
ADD_IDX(_UVMappingMask).w * vT3;
ADD_IDX(layerTexCoord.base).bitangentWS = ADD_IDX(_UVMappingMask).x * layerTexCoord.vertexBitangentWS0 +
ADD_IDX(_UVMappingMask).y * layerTexCoord.vertexBitangentWS1 +
ADD_IDX(_UVMappingMask).z * layerTexCoord.vertexBitangentWS2 +
ADD_IDX(_UVMappingMask).w * layerTexCoord.vertexBitangentWS3;
ADD_IDX(layerTexCoord.details).tangentWS = ADD_IDX(_UVDetailsMappingMask).x * layerTexCoord.vertexTangentWS0 +
ADD_IDX(_UVDetailsMappingMask).y * layerTexCoord.vertexTangentWS1 +
ADD_IDX(_UVDetailsMappingMask).z * layerTexCoord.vertexTangentWS2 +
ADD_IDX(_UVDetailsMappingMask).w * layerTexCoord.vertexTangentWS3;
ADD_IDX(layerTexCoord.details).vB = ADD_IDX(_UVMappingMask).x * worlToTangent[1] +
ADD_IDX(_UVMappingMask).y * vB1 +
ADD_IDX(_UVMappingMask).z * vB2 +
ADD_IDX(_UVMappingMask).w * vB3;
ADD_IDX(layerTexCoord.details).bitangentWS = ADD_IDX(_UVDetailsMappingMask).x * layerTexCoord.vertexBitangentWS0 +
ADD_IDX(_UVDetailsMappingMask).y * layerTexCoord.vertexBitangentWS1 +
ADD_IDX(_UVDetailsMappingMask).z * layerTexCoord.vertexBitangentWS2 +
ADD_IDX(_UVDetailsMappingMask).w * layerTexCoord.vertexBitangentWS3;
#endif
}

#ifdef _NORMALMAP_TANGENT_SPACE_IDX
if (useBias)
{
normalTS = SAMPLE_LAYER_NORMALMAP_BIAS(ADD_IDX(_NormalMap), SAMPLER_NORMALMAP_IDX, ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale), bias);
normalTS = SAMPLE_UVMAPPING_NORMALMAP_BIAS(ADD_IDX(_NormalMap), SAMPLER_NORMALMAP_IDX, ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale), bias);
normalTS = SAMPLE_LAYER_NORMALMAP(ADD_IDX(_NormalMap), SAMPLER_NORMALMAP_IDX, ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale));
normalTS = SAMPLE_UVMAPPING_NORMALMAP(ADD_IDX(_NormalMap), SAMPLER_NORMALMAP_IDX, ADD_IDX(layerTexCoord.base), ADD_IDX(_NormalScale));
}
#else // Object space
// to be able to combine object space normal with detail map or to apply a "scale" we transform it to tangent space (object space normal composition is complex operation).

// Return opacity
float ADD_IDX(GetSurfaceData)(FragInputs input, LayerTexCoord layerTexCoord, out SurfaceData surfaceData, out float3 normalTS)
{
float alpha = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).a * ADD_IDX(_BaseColor).a;
float alpha = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).a * ADD_IDX(_BaseColor).a;
// Perform alha test very early to save performance (a killed pixel will not sample textures)
#if defined(_ALPHATEST_ON) && !defined(LAYERED_LIT_SHADER)

float3 detailNormalTS = float3(0.0, 0.0, 0.0);
float detailMask = 0.0;
#ifdef _DETAIL_MAP_IDX
detailMask = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_DetailMask), SAMPLER_DETAILMASK_IDX, ADD_IDX(layerTexCoord.base)).g;
float2 detailAlbedoAndSmoothness = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_DetailMap), SAMPLER_DETAILMAP_IDX, ADD_IDX(layerTexCoord.details)).rb;
detailMask = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_DetailMask), SAMPLER_DETAILMASK_IDX, ADD_IDX(layerTexCoord.base)).g;
float2 detailAlbedoAndSmoothness = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_DetailMap), SAMPLER_DETAILMAP_IDX, ADD_IDX(layerTexCoord.details)).rb;
detailNormalTS = SAMPLE_LAYER_NORMALMAP_AG(ADD_IDX(_DetailMap), SAMPLER_DETAILMAP_IDX, ADD_IDX(layerTexCoord.details), ADD_ZERO_IDX(_DetailNormalScale));
detailNormalTS = SAMPLE_UVMAPPING_NORMALMAP_AG(ADD_IDX(_DetailMap), SAMPLER_DETAILMAP_IDX, ADD_IDX(layerTexCoord.details), ADD_ZERO_IDX(_DetailNormalScale));
surfaceData.baseColor = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).rgb * ADD_IDX(_BaseColor).rgb;
surfaceData.baseColor = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).rgb * ADD_IDX(_BaseColor).rgb;
#ifdef _DETAIL_MAP_IDX
surfaceData.baseColor *= LerpWhiteTo(2.0 * saturate(detailAlbedo * ADD_IDX(_DetailAlbedoScale)), detailMask);
#endif

surfaceData.specularOcclusion = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_SpecularOcclusionMap), SAMPLER_SPECULAROCCLUSIONMAP_IDX, ADD_IDX(layerTexCoord.base)).a;
surfaceData.specularOcclusion = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_SpecularOcclusionMap), SAMPLER_SPECULAROCCLUSIONMAP_IDX, ADD_IDX(layerTexCoord.base)).a;
#else
// The specular occlusion will be perform outside the internal loop
surfaceData.specularOcclusion = 1.0;

normalTS = ADD_IDX(GetNormalTS)(input, layerTexCoord, detailNormalTS, detailMask, false, 0.0);
#if defined(_MASKMAP_IDX)
surfaceData.perceptualSmoothness = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).a;
surfaceData.perceptualSmoothness = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).a;
#else
surfaceData.perceptualSmoothness = 1.0;
#endif

// MaskMap is RGBA: Metallic, Ambient Occlusion (Optional), emissive Mask (Optional), Smoothness
#ifdef _MASKMAP_IDX
surfaceData.metallic = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).r;
surfaceData.ambientOcclusion = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).g;
surfaceData.metallic = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).r;
surfaceData.ambientOcclusion = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).g;
#else
surfaceData.metallic = 1.0;
surfaceData.ambientOcclusion = 1.0;

// TODO: think about using BC5
#ifdef _TANGENTMAP
#ifdef _NORMALMAP_TANGENT_SPACE_IDX // Normal and tangent use same space
float3 tangentTS = SAMPLE_LAYER_NORMALMAP(_TangentMap, sampler_TangentMap, layerTexCoord.base, 1.0);
float3 tangentTS = SAMPLE_UVMAPPING_NORMALMAP(_TangentMap, sampler_TangentMap, layerTexCoord.base, 1.0);
surfaceData.tangentWS = TransformTangentToWorld(tangentTS, input.worldToTangent);
#else // Object space
// Note: There is no such a thing like triplanar with object space normal, so we call directly 2D function

#endif
#ifdef _ANISOTROPYMAP
surfaceData.anisotropy = SAMPLE_LAYER_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, layerTexCoord.base).b;
surfaceData.anisotropy = SAMPLE_UVMAPPING_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, layerTexCoord.base).b;
#else
surfaceData.anisotropy = 1.0;
#endif

surfaceData.subsurfaceProfile = _SubsurfaceProfile;
#ifdef _SUBSURFACE_RADIUS_MAP
surfaceData.subsurfaceRadius = SAMPLE_LAYER_TEXTURE2D(_SubsurfaceRadiusMap, sampler_SubsurfaceRadiusMap, layerTexCoord.base).r * _SubsurfaceRadius;
surfaceData.subsurfaceRadius = SAMPLE_UVMAPPING_TEXTURE2D(_SubsurfaceRadiusMap, sampler_SubsurfaceRadiusMap, layerTexCoord.base).r * _SubsurfaceRadius;
surfaceData.thickness = SAMPLE_LAYER_TEXTURE2D(_ThicknessMap, sampler_ThicknessMap, layerTexCoord.base).r;
surfaceData.thickness = SAMPLE_UVMAPPING_TEXTURE2D(_ThicknessMap, sampler_ThicknessMap, layerTexCoord.base).r;
#else
surfaceData.thickness = _Thickness;
#endif

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl


//SAMPLER2D(sampler_CoatRoughnessMap);
float _TexWorldScale;
float _UVMappingPlanar;
float4 _UVMappingMask;
float4 _UVDetailsMappingMask;

float _TexWorldScaleBlendMask;
PROP_DECL(float, _TexWorldScale);
float _UVMappingPlanarBlendMask;
PROP_DECL(float, _UVMappingPlanar);
PROP_DECL(float4, _UVMappingMask);
PROP_DECL(float4, _UVDetailsMappingMask);

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


[Enum(UV0, 0, Planar, 1, TriPlanar, 2)] _UVBase("UV Set for base", Float) = 0
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2, Specular Color, 3)] _MaterialID("MaterialId", Int) = 0

#pragma shader_feature _ _TESSELLATION_DISPLACEMENT _TESSELLATION_DISPLACEMENT_PHONG
#pragma shader_feature _TESSELLATION_OBJECT_SCALE
#pragma shader_feature _MAPPING_TRIPLANAR
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3
#pragma shader_feature _EMISSIVE_COLOR

32
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/MaterialUtilities.hlsl


#endif
}
// To flip in case of double sided, we must flip the vertex normal and this will apply to the whole process either in surface gradient or not.
// As here we are in the function call GetSurfaceAndBuiltinData(), the tangent space is already built, so we need to flip both normal and bitangent.
// This function will modify FragInputs and this is not propagate outside of GetSurfaceAndBuiltinData(). This is ok as tangent space is not use outside of GetSurfaceAndBuiltinData().
void ApplyDoubleSidedFlip(inout FragInputs input)
{
#ifdef _DOUBLESIDED_ON
// _DoubleSidedConstants is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : _DoubleSidedConstants.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
input.worldToTangent[1] = flipSign * input.worldToTangent[1]; // bitangent
input.worldToTangent[2] = flipSign * input.worldToTangent[2]; // normal
#ifdef SURFACE_GRADIENT
// TOCHECK: seems that we don't need to invert any genBasisTB(), sign cancel. Which is expected as we deal with surface gradient.
#endif
#endif
}
// To mirror a normal: in ws reflect around the vertex normal / in tangent space apply minus on the z component.
// For surface gradient it is sufficient to take the opposite of the surface gradient.
void ApplyDoubleSidedMirror(FragInputs input, inout float3 normalTS)
{
#ifdef _DOUBLESIDED_ON
// _DoubleSidedConstants is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : -_DoubleSidedConstants.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
#ifdef SURFACE_GRADIENT
normalTS = flipSign * normalTS;
#else
normalTS.z *= flipSign;
#endif
#endif
}
// This function convert the tangent space normal/tangent to world space and orthonormalize it + apply a correction of the normal if it is not pointing towards the near plane
void GetNormalAndTangentWS(FragInputs input, float3 V, float3 normalTS, inout float3 normalWS, inout float3 tangentWS, bool wantNegativeNormal = false)
{

4
Assets/ScriptableRenderPipeline/ShaderLibrary/NormalSurfaceGradient.hlsl


// this produces an orthonormal basis of the tangent and bitangent WITHOUT vertex level tangent/bitangent for any UV including procedurally generated
// method released with the demo for publication of "bump mapping unparametrized surfaces on the GPU"
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
void SurfaceGradientGenBasisTB(float3 nrmVertexNormal, float3 sigmaX, float3 sigmaY, float flip sign, out float3 vT, out float3 vB, float2 texST)
void SurfaceGradientGenBasisTB(float3 nrmVertexNormal, float3 sigmaX, float3 sigmaY, float flipSign, float2 texST, out float3 vT, out float3 vB)
{
float2 dSTdx = ddx_fine(texST), dSTdy = ddy_fine(texST);

vT = sigmaX * invC0.x + sigmaY * invC0.y;
if (abs(det) > 0.0)
vT = normalize(vT);
vB = (sign_det * flip_sign) * cross(nrmVertexNormal, vT);
vB = (sign_det * flipSign) * cross(nrmVertexNormal, vT);
}
// surface gradient from an on the fly TBN (deriv obtained using tspaceNormalToDerivative()) or from conventional vertex level TBN (mikktspace compliant and deriv obtained using tspaceNormalToDerivative())

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_BlendColor
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYER _LAYEREDLIT_4_LAYERS
_LAYERMASKMAP _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_PLANAR_0 _LAYER_MAPPING_PLANAR_1
_LAYER_MAPPING_PLANAR_2 _LAYER_MAPPING_PLANAR_3 _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _LAYEREDLIT_4_LAYERS _LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _LayerTiling3: 1
- _LayerTilingBlendMask: 1
- _MaterialID: 0
- _StencilRef: 1
- _Metalic: 0
- _Metalic0: 0
- _Metalic1: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0, g: 1, b: 0, a: 1}
- _BaseColor3: {r: 0, g: 0, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor0: {r: 0, g: 0, b: 0, a: 1}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_BlendMask
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYER _LAYEREDLIT_4_LAYERS
_LAYERMASKMAP _LAYERMASKVERTEXCOLOR_OFF _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_PLANAR_0
_LAYER_MAPPING_PLANAR_1 _LAYER_MAPPING_PLANAR_2 _LAYER_MAPPING_PLANAR_3 _NORMALMAP_TANGENT_SPACE
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _LAYEREDLIT_4_LAYERS _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _LayerTiling3: 1
- _LayerTilingBlendMask: 1
- _MaterialID: 0
- _StencilRef: 1
- _Metalic: 0
- _Metalic0: 0
- _Metalic1: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0, g: 1, b: 0, a: 1}
- _BaseColor3: {r: 0, g: 0, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor0: {r: 0, g: 0, b: 0, a: 1}

16
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat


m_PrefabInternal: {fileID: 0}
m_Name: Layered_HeightBased
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _HEIGHTMAP
_HEIGHTMAP0 _HEIGHTMAP00 _HEIGHTMAP01 _HEIGHTMAP02 _HEIGHTMAP03 _HEIGHTMAP1 _HEIGHTMAP2
_HEIGHTMAP3 _LAYEREDLIT_4_LAYERS _LAYERMASKVERTEXCOLOR_OFF _LAYER_MASK_VERTEX_COLOR_MUL
_MASKMAP _MASKMAP0 _MASKMAP1 _MASKMAP2 _MASKMAP3 _NORMALMAP _NORMALMAP0 _NORMALMAP1
_NORMALMAP2 _NORMALMAP3 _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _HEIGHTMAP0 _HEIGHTMAP1 _HEIGHTMAP2 _HEIGHTMAP3 _LAYEREDLIT_4_LAYERS
_LAYER_MAPPING_PLANAR1 _LAYER_MAPPING_PLANAR2 _LAYER_MAPPING_PLANAR3 _LAYER_MASK_VERTEX_COLOR_MUL
_MASKMAP0 _MASKMAP1 _MASKMAP2 _MASKMAP3 _NORMALMAP0 _NORMALMAP1 _NORMALMAP2 _NORMALMAP3
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale0: 0.1
- _TexWorldScale1: 0.1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask0: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer0_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR
_LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _LAYER_MAPPING_PLANAR0 _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 0.2

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer0_Triplanar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _DOUBLESIDED _EMISSION _EMISSIVE_COLOR
_LAYER_MAPPING_TRIPLANAR0 _LAYER_MAPPING_TRIPLANAR_0 _LAYER_MASK_VERTEX_COLOR
_LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _LAYER_MAPPING_TRIPLANAR0 _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 0.2

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer0_UV0
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR
_LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer1_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_1
_LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _LAYER_MAPPING_PLANAR1 _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer1_Triplanar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _DOUBLESIDED _EMISSION _EMISSIVE_COLOR
_LAYER_MAPPING_TRIPLANAR1 _LAYER_MAPPING_TRIPLANAR_1 _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _LAYER_MAPPING_TRIPLANAR1 _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer1_UV0
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer1_UV1
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

10
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV2.mat


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer1_UV2
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2 _REQUIRE_UV2_OR_UV3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer1_UV3
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer2_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION
_EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MAPPING_TRIPLANAR_2 _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _LAYEREDLIT_3_LAYERS _LAYER_MAPPING_PLANAR2
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer2_Triplanar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _DOUBLESIDED
_EMISSION _EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MAPPING_TRIPLANAR2 _LAYER_MAPPING_TRIPLANAR_2
_LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _LAYEREDLIT_3_LAYERS _LAYER_MAPPING_TRIPLANAR2
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer2_UV0
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION
_EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _LAYEREDLIT_3_LAYERS _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer2_UV1
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION
_EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _LAYEREDLIT_3_LAYERS _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer2_UV2
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION
_EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2 _REQUIRE_UV2_OR_UV3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _LAYEREDLIT_3_LAYERS _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
_REQUIRE_UV2
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer2_UV3
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF _EMISSION
_EMISSIVE_COLOR _LAYEREDLIT_3_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _LAYEREDLIT_3_LAYERS _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
_REQUIRE_UV3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _BaseColor3: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP3 _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MAPPING_TRIPLANAR_3 _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _LAYEREDLIT_4_LAYERS
_LAYER_MAPPING_PLANAR3 _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 0.6602435, g: 0.63235295, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_Triplanar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP3 _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_DOUBLESIDED _EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MAPPING_TRIPLANAR3
_LAYER_MAPPING_TRIPLANAR_3 _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0
_NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _LAYEREDLIT_4_LAYERS
_LAYER_MAPPING_TRIPLANAR3 _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1
_NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_UV0
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP3 _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _LAYEREDLIT_4_LAYERS
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 0.6602435, g: 0.63235295, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_UV1
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP3 _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _LAYEREDLIT_4_LAYERS
_NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2
_NORMALMAP_TANGENT_SPACE3
m_LightmapFlags: 1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 0.6602435, g: 0.63235295, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

10
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV2.mat


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_UV2
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP3 _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _LAYEREDLIT_4_LAYERS
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2 _REQUIRE_UV2_OR_UV3
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 0.6602435, g: 0.63235295, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Layered_Layer3_UV3
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2
_DETAIL_MAP3 _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_EMISSION _EMISSIVE_COLOR _LAYEREDLIT_4_LAYERS _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
m_ShaderKeywords: _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _LAYEREDLIT_4_LAYERS
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
_NORMALMAP_TANGENT_SPACE3 _REQUIRE_UV3
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StencilRef: 2
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScale0: 1

- _BaseColor2: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor3: {r: 0.6602435, g: 0.63235295, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Lit_UVChart_Layer0_Detail
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_ShaderKeywords: _DETAIL_MAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

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

- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HorizonFade: 1
- _StencilRef: 1
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _StencilRef: 2
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _Thickness: 1
- _ZTestMode: 8
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Lit_UVChart_Layer1_Detail
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _NORMALMAP _NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
m_ShaderKeywords: _DETAIL_MAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

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

- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HorizonFade: 1
- _StencilRef: 1
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _StencilRef: 2
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _Thickness: 1
- _ZTestMode: 8
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Lit_UVChart_Layer2_Detail
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _NORMALMAP _NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
m_ShaderKeywords: _DETAIL_MAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HorizonFade: 1
- _StencilRef: 1
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _StencilRef: 2
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _Thickness: 1
- _UVBase: 0
- _UVDetail: 0
- _UVMappingPlanar: 0

m_Colors:
- _BaseColor: {r: 0.61764705, g: 1, b: 0.74685603, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Lit_UVChart_Layer3_Detail
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _NORMALMAP _NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
m_ShaderKeywords: _DETAIL_MAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

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

- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HorizonFade: 1
- _StencilRef: 1
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _StencilRef: 2
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _Thickness: 1
- _ZTestMode: 8
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

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


m_PrefabInternal: {fileID: 0}
m_Name: Lit_White_Detail
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _NORMALMAP _NORMALMAP_TANGENT_SPACE _REQUIRE_UV3
m_ShaderKeywords: _DETAIL_MAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedMirrorEnable: 1
- _EnablePerPixelDisplacement: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HorizonFade: 1
- _StencilRef: 1
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _StencilRef: 2
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _Thickness: 1
- _UVBase: 0
- _UVDetail: 0
- _UVMappingPlanar: 0

m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}

69
Assets/ScriptableRenderPipeline/ShaderLibrary/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
#define UV_MAPPING_UVSET 0
#define UV_MAPPING_PLANAR 1
#define UV_MAPPING_TRIPLANAR 2
struct UVMapping
{
int mappingType;
float2 uv; // Current uv or planar uv
// Triplanar specific
float2 uvZY;
float2 uvXZ;
float2 uvXY;
float3 triplanarWeights;
#ifdef SURFACE_GRADIENT
// tangent basis to use when mappingType is UV_MAPPING_UVSET
// these are vertex level in world space
float3 tangentWS;
float3 bitangentWS;
// normal only use with planar / triplanar
float3 normalWS;
// TODO: store also object normal map for object triplanar
#endif
};
// Multiple includes of the file to handle all variations of textures sampling for regular, lod and bias
// Regular sampling functions
#define ADD_FUNC_SUFFIX(Name) Name
#define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, unused) SAMPLE_TEXTURE2D(textureName, samplerName, uvMapping)
#include "SampleUVMappingInternal.hlsl"
#undef ADD_FUNC_SUFFIX
#undef SAMPLE_TEXTURE_FUNC
// Lod sampling functions
#define ADD_FUNC_SUFFIX(Name) Name##Lod
#define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, uvMapping, lod)
#include "SampleUVMappingInternal.hlsl"
#undef ADD_FUNC_SUFFIX
#undef SAMPLE_TEXTURE_FUNC
// Bias sampling functions
#define ADD_FUNC_SUFFIX(Name) Name##Bias
#define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, bias) SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, uvMapping, bias)
#include "SampleUVMappingInternal.hlsl"
#undef ADD_FUNC_SUFFIX
#undef SAMPLE_TEXTURE_FUNC
// Macro to improve readibility of surface data
#define SAMPLE_UVMAPPING_TEXTURE2D(textureName, samplerName, uvMapping) SampleUVMapping(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, 0.0) // Last 0.0 is unused
#define SAMPLE_UVMAPPING_TEXTURE2D_LOD(textureName, samplerName, uvMapping, lod) SampleUVMappingLod(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, lod)
#define SAMPLE_UVMAPPING_TEXTURE2D_BIAS(textureName, samplerName, uvMapping, bias) SampleUVMappingBias(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, bias)
#define SAMPLE_UVMAPPING_NORMALMAP(textureName, samplerName, uvMapping, scale) SampleUVMappingNormal(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, 0.0)
#define SAMPLE_UVMAPPING_NORMALMAP_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalLod(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, lod)
#define SAMPLE_UVMAPPING_NORMALMAP_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalBias(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, bias)
#define SAMPLE_UVMAPPING_NORMALMAP_AG(textureName, samplerName, uvMapping, scale) SampleUVMappingNormalAG(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, 0.0)
#define SAMPLE_UVMAPPING_NORMALMAP_AG_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalAGLod(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, lod)
#define SAMPLE_UVMAPPING_NORMALMAP_AG_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalAGBias(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, bias)
#define SAMPLE_UVMAPPING_NORMALMAP_RGB(textureName, samplerName, uvMapping, scale) SampleUVMappingNormalRGB(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, 0.0)
#define SAMPLE_UVMAPPING_NORMALMAP_RGB_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalRGBLod(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, lod)
#define SAMPLE_UVMAPPING_NORMALMAP_RGB_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalRGBBias(TEXTURE2D_PARAM(textureName, samplerName), uvMapping, scale, bias)

57
Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingInternal.hlsl


// These functions are use to hide the handling of triplanar mapping
// Normal need a specific treatment as they use special encoding for both base and detail map
// Also we use multiple inclusion to handle the various variation for lod and bias
// param can be unused, lod or bias
float4 ADD_FUNC_SUFFIX(SampleUVMapping)(TEXTURE2D_ARGS(textureName, samplerName), UVMapping uvMapping, float param)
{
if (uvMapping.mappingType == UV_MAPPING_TRIPLANAR)
{
float3 triplanarWeights = uvMapping.triplanarWeights;
float4 val = float4(0.0, 0.0, 0.0, 0.0);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvZY, param);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXY, param);
return val;
}
else // UV_MAPPING_UVSET / UV_MAPPING_PLANAR
{
return SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param);
}
}
// Nested multiple includes of the file to handle all variations of normal map (AG, RG or RGB)
// TODO: Handle BC5 format, currently this code is for DXT5nm - After the change, rename this function UnpackNormalmapRGorAG
// This version is use for the base normal map
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name
#define UNPACK_NORMAL_FUNC UnpackNormalAG
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalAG
#include "SampleUVMappingNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC
#undef UNPACK_DERIVATIVE_FUNC
// This version is for normalmap with AG encoding only. Mainly use with details map.
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name##AG
#define UNPACK_NORMAL_FUNC UnpackNormalAG
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalAG
#include "SampleUVMappingNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC
#undef UNPACK_DERIVATIVE_FUNC
// This version is for normalmap with RGB encoding only, i.e uncompress or BC7.
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name##RGB
#define UNPACK_NORMAL_FUNC UnpackNormalRGB
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGB
#include "SampleUVMappingNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC
#undef UNPACK_DERIVATIVE_FUNC

55
Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingNormalInternal.hlsl


float3 ADD_FUNC_SUFFIX(ADD_NORMAL_FUNC_SUFFIX(SampleUVMappingNormal))(TEXTURE2D_ARGS(textureName, samplerName), UVMapping uvMapping, float scale, float param)
{
if (uvMapping.mappingType == UV_MAPPING_TRIPLANAR)
{
float3 triplanarWeights = uvMapping.triplanarWeights;
#ifdef SURFACE_GRADIENT
float2 derivXplane;
float2 derivYPlane;
float2 derivZPlane;
derivXplane = derivYPlane = derivZPlane = float2(0.0, 0.0);
if (triplanarWeights.x > 0.0)
derivXplane = triplanarWeights.x * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvZY, param), scale);
if (triplanarWeights.y > 0.0)
derivYPlane = triplanarWeights.y * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param), scale);
if (triplanarWeights.z > 0.0)
derivZPlane = triplanarWeights.z * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXY, param), scale);
// Assume derivXplane, derivYPlane and derivZPlane sampled using (z,y), (z,x) and (x,y) respectively.
// TODO: Check with morten convention! Do it follow ours ?
float3 volumeGrad = float3(derivZPlane.x + derivYPlane.y, derivZPlane.y + derivXplane.y, derivXplane.x + derivYPlane.x);
return surfgradFromVolumeGradient(uvMapping.normalWS, volumeGrad);
#else
float3 val = float3(0.0, 0.0, 0.0);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvZY, param), scale);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param), scale);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXY, param), scale);
return normalize(val);
#endif
}
#ifdef SURFACE_GRADIENT
else if (uvMapping.mappingType == UV_MAPPING_PLANAR)
{
float2 derivYPlane = UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param), scale);
// See comment above
float3 volumeGrad = float3(derivYPlane.y, 0.0, derivYPlane.x);
return surfgradFromVolumeGradient(uvMapping.normalWS, volumeGrad);
}
#endif
else
{
#ifdef SURFACE_GRADIENT
float2 deriv = UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param), scale);
return SurfaceGradientFromTBN(deriv, uvMapping.tangentWS, uvMapping.bitangentWS);
#else
return UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param), scale);
#endif
}
}

66
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayer.hlsl


// Gather all kind of mapping in one struct, allow to improve code readability
struct LayerUV
{
float2 uv;
bool isPlanar; // mutually exclusive with isTriplanar
// triplanar
bool isTriplanar;
float2 uvZY;
float2 uvXZ;
float2 uvXY;
#ifdef SURFACE_GRADIENT
// tangent basis to use for this UV set
float3 vT, vB;
// vertex normal for planar/triplanar
float3 vertexNormalWS; // TODO: Should be part of LayerCoord but require to
#endif
};
struct CommonLayerUV
{
#ifdef SURFACE_GRADIENT
float3 vertexNormalWS;
#endif
float3 triplanarWeights;
};
// Multiple includes of the file to handle all variations of textures sampling for regular, lod and bias
// Regular sampling functions
#define ADD_FUNC_SUFFIX(Name) Name
#define SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV, unused) SAMPLE_TEXTURE2D(layerTex, layerSampler, layerUV)
#include "SampleLayerInternal.hlsl"
#undef ADD_FUNC_SUFFIX
#undef SAMPLE_TEXTURE_FUNC
// Lod sampling functions
#define ADD_FUNC_SUFFIX(Name) Name##Lod
#define SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV, lod) SAMPLE_TEXTURE2D_LOD(layerTex, layerSampler, layerUV, lod)
#include "SampleLayerInternal.hlsl"
#undef ADD_FUNC_SUFFIX
#undef SAMPLE_TEXTURE_FUNC
// Bias sampling functions
#define ADD_FUNC_SUFFIX(Name) Name##Bias
#define SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV, bias) SAMPLE_TEXTURE2D_BIAS(layerTex, layerSampler, layerUV, bias)
#include "SampleLayerInternal.hlsl"
#undef ADD_FUNC_SUFFIX
#undef SAMPLE_TEXTURE_FUNC
// Macro to improve readibility of surface data
#define SAMPLE_LAYER_TEXTURE2D(textureName, samplerName, coord) SampleLayer(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, 0.0) // Last 0.0 is unused
#define SAMPLE_LAYER_TEXTURE2D_LOD(textureName, samplerName, coord, lod) SampleLayerLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, lod)
#define SAMPLE_LAYER_TEXTURE2D_BIAS(textureName, samplerName, coord, bias) SampleLayerBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, bias)
#define SAMPLE_LAYER_NORMALMAP(textureName, samplerName, coord, scale) SampleLayerNormal(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, bias)
#define SAMPLE_LAYER_NORMALMAP_AG(textureName, samplerName, coord, scale) SampleLayerNormalAG(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_AG_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalAGLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_AG_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalAGBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, bias)
#define SAMPLE_LAYER_NORMALMAP_RGB(textureName, samplerName, coord, scale) SampleLayerNormalRGB(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, 0.0)
#define SAMPLE_LAYER_NORMALMAP_RGB_LOD(textureName, samplerName, coord, scale, lod) SampleLayerNormalRGBLod(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, lod)
#define SAMPLE_LAYER_NORMALMAP_RGB_BIAS(textureName, samplerName, coord, scale, bias) SampleLayerNormalRGBBias(TEXTURE2D_PARAM(textureName, samplerName), coord, layerTexCoord.common, scale, bias)

57
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayerInternal.hlsl


// These functions are use to hide the handling of triplanar mapping
// Normal need a specific treatment as they use special encoding for both base and detail map
// Also we use multiple inclusion to handle the various variation for lod and bias
// param can be unused, lod or bias
float4 ADD_FUNC_SUFFIX(SampleLayer)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, CommonLayerUV common, float param)
{
if (layerUV.isTriplanar)
{
float3 triplanarWeights = common.triplanarWeights;
float4 val = float4(0.0, 0.0, 0.0, 0.0);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZY, param);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXZ, param);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param);
return val;
}
else
{
return SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uv, param);
}
}
// Nested multiple includes of the file to handle all variations of normal map (AG, RG or RGB)
// TODO: Handle BC5 format, currently this code is for DXT5nm - After the change, rename this function UnpackNormalmapRGorAG
// This version is use for the base normal map
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name
#define UNPACK_NORMAL_FUNC UnpackNormalAG
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalAG
#include "SampleLayerNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC
#undef UNPACK_DERIVATIVE_FUNC
// This version is for normalmap with AG encoding only. Mainly use with details map.
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name##AG
#define UNPACK_NORMAL_FUNC UnpackNormalAG
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalAG
#include "SampleLayerNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC
#undef UNPACK_DERIVATIVE_FUNC
// This version is for normalmap with RGB encoding only, i.e uncompress or BC7.
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name##RGB
#define UNPACK_NORMAL_FUNC UnpackNormalRGB
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGB
#include "SampleLayerNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC
#undef UNPACK_DERIVATIVE_FUNC

55
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayerNormalInternal.hlsl


float3 ADD_FUNC_SUFFIX(ADD_NORMAL_FUNC_SUFFIX(SampleLayerNormal))(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, CommonLayerUV common, float scale, float param)
{
if (layerUV.isTriplanar)
{
float3 triplanarWeights = common.triplanarWeights;
#ifdef SURFACE_GRADIENT
float2 derivXplane;
float2 derivYPlane;
float2 derivZPlane;
derivXplane = derivYPlane = derivZPlane = float2(0.0, 0.0);
if (triplanarWeights.x > 0.0)
derivXplane = triplanarWeights.x * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZY, param), scale);
if (triplanarWeights.y > 0.0)
derivYPlane = triplanarWeights.y * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXZ, param), scale);
if (triplanarWeights.z > 0.0)
derivZPlane = triplanarWeights.z * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
// Assume derivXplane, derivYPlane and derivZPlane sampled using (z,y), (z,x) and (x,y) respectively.
// TODO: Check with morten convention! Do it follow ours ?
float3 volumeGrad = float3(derivZPlane.x + derivYPlane.y, derivZPlane.y + derivXplane.y, derivXplane.x + derivYPlane.x);
return surfgradFromVolumeGradient(layerUV.vertexNormalWS, volumeGrad);
#else
float3 val = float3(0.0, 0.0, 0.0);
if (triplanarWeights.x > 0.0)
val += triplanarWeights.x * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvZY, param), scale);
if (triplanarWeights.y > 0.0)
val += triplanarWeights.y * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXZ, param), scale);
if (triplanarWeights.z > 0.0)
val += triplanarWeights.z * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXY, param), scale);
return normalize(val);
#endif
}
#ifdef SURFACE_GRADIENT
else if (layerUV.isPlanar)
{
float2 derivYPlane = UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uvXZ, param), scale);
// See comment above
float3 volumeGrad = float3(derivYPlane.y, 0.0, derivYPlane.x);
return surfgradFromVolumeGradient(layerUV.vertexNormalWS, volumeGrad);
}
#endif
else
{
#ifdef SURFACE_GRADIENT
float2 deriv = UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uv, param), scale);
return SurfaceGradientFromTBN(deriv, layerUV.vT, layerUV.vB);
#else
return UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(layerTex, layerSampler, layerUV.uv, param), scale);
#endif
}
}

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayer.hlsl.meta → /Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMapping.hlsl.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayerInternal.hlsl.meta → /Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingInternal.hlsl.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/SampleLayerNormalInternal.hlsl.meta → /Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingNormalInternal.hlsl.meta

正在加载...
取消
保存