浏览代码

"Simple" LayeredLit WIP

/RenderPassXR_Sandbox
Julien Ignace 7 年前
当前提交
7d46e579
共有 20 个文件被更改,包括 2007 次插入265 次删除
  1. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/Editor/InfluenceLayeredLitUI.cs
  2. 30
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/InfluenceLayeredLit.shader
  3. 30
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/InfluenceLayeredLitTessellation.shader
  4. 13
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  5. 315
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  6. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  7. 138
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  8. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  9. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  10. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/UnlitUI.cs
  11. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit.meta
  12. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor.meta
  13. 543
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  14. 13
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs.meta
  15. 525
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  16. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader.meta
  17. 607
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  18. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader.meta

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/Editor/InfluenceLayeredLitUI.cs


m_MaterialEditor.ShaderProperty(objectScaleAffectTile, mainLayerModeInfluenceEnable ? styles.objectScaleAffectTileText2 : styles.objectScaleAffectTileText);
m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
//m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
EditorGUILayout.Space();

static public void SetupLayersMappingKeywords(Material material)
{
SetKeyword(material, "LAYERED_LIT_USE_SIMPLE_BLEND", true);
// object scale affect tile
SetKeyword(material, "_LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE", material.GetFloat(kObjectScaleAffectTile) > 0.0f);

30
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/InfluenceLayeredLit.shader


[ToggleOff] _UseDensityMode("Use Density mode", Float) = 0.0
[ToggleOff] _UseMainLayerInfluence("UseMainLayerInfluence", Float) = 0.0
_HeightFactor0("_HeightFactor0", Float) = 1
_HeightFactor1("_HeightFactor1", Float) = 1
_HeightFactor2("_HeightFactor2", Float) = 1
_HeightFactor3("_HeightFactor3", Float) = 1
// Store result of combination of _HeightFactor and _HeightAmplitude0
[HideInInspector] _LayerHeightAmplitude0("_LayerHeightAmplitude0", Float) = 1
[HideInInspector] _LayerHeightAmplitude1("_LayerHeightAmplitude1", Float) = 1
[HideInInspector] _LayerHeightAmplitude2("_LayerHeightAmplitude2", Float) = 1
[HideInInspector] _LayerHeightAmplitude3("_LayerHeightAmplitude3", Float) = 1
_HeightCenterOffset0("_HeightCenterOffset0", Float) = 0.0
_HeightCenterOffset1("_HeightCenterOffset1", Float) = 0.0
_HeightCenterOffset2("_HeightCenterOffset2", Float) = 0.0
_HeightCenterOffset3("_HeightCenterOffset3", Float) = 0.0
// Store result of combination of _HeightCenterOffset0 and _HeightCenter0
[HideInInspector] _LayerCenterOffset0("_LayerCenterOffset0", Float) = 0.0
[HideInInspector] _LayerCenterOffset1("_LayerCenterOffset1", Float) = 0.0
[HideInInspector] _LayerCenterOffset2("_LayerCenterOffset2", Float) = 0.0
[HideInInspector] _LayerCenterOffset3("_LayerCenterOffset3", Float) = 0.0
_BlendUsingHeight1("_BlendUsingHeight1", Float) = 0.0
_BlendUsingHeight2("_BlendUsingHeight2", Float) = 0.0
_BlendUsingHeight3("_BlendUsingHeight3", Float) = 0.0

_OpacityAsDensity3("_OpacityAsDensity3", Range(0, 1.0)) = 0.0
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
_LayerTiling0("_LayerTiling0", Float) = 1
_LayerTiling1("_LayerTiling1", Float) = 1
_LayerTiling2("_LayerTiling2", Float) = 1
_LayerTiling3("_LayerTiling3", Float) = 1
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0

// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
// WARNING
// All the following properties that concern the UV mapping are the same as in the Lit shader.
// This means that they will get overridden when synchronizing the various layers.
// To avoid this, make sure that all properties here are in the exclusion list in InfluenceLayeredLitUI.SynchronizeLayerProperties
_TexWorldScale0("Tiling", Float) = 1.0
_TexWorldScale1("Tiling", Float) = 1.0
_TexWorldScale2("Tiling", Float) = 1.0

30
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/InfluenceLayeredLitTessellation.shader


[ToggleOff] _UseDensityMode("Use Density mode", Float) = 0.0
[ToggleOff] _UseMainLayerInfluence("UseMainLayerInfluence", Float) = 0.0
_HeightFactor0("_HeightFactor0", Float) = 1
_HeightFactor1("_HeightFactor1", Float) = 1
_HeightFactor2("_HeightFactor2", Float) = 1
_HeightFactor3("_HeightFactor3", Float) = 1
// Store result of combination of _HeightFactor and _HeightAmplitude0
[HideInInspector] _LayerHeightAmplitude0("_LayerHeightAmplitude0", Float) = 1
[HideInInspector] _LayerHeightAmplitude1("_LayerHeightAmplitude1", Float) = 1
[HideInInspector] _LayerHeightAmplitude2("_LayerHeightAmplitude2", Float) = 1
[HideInInspector] _LayerHeightAmplitude3("_LayerHeightAmplitude3", Float) = 1
_HeightCenterOffset0("_HeightCenterOffset0", Float) = 0.0
_HeightCenterOffset1("_HeightCenterOffset1", Float) = 0.0
_HeightCenterOffset2("_HeightCenterOffset2", Float) = 0.0
_HeightCenterOffset3("_HeightCenterOffset3", Float) = 0.0
// Store result of combination of _HeightCenterOffset0 and _HeightCenter0
[HideInInspector] _LayerCenterOffset0("_LayerCenterOffset0", Float) = 0.0
[HideInInspector] _LayerCenterOffset1("_LayerCenterOffset1", Float) = 0.0
[HideInInspector] _LayerCenterOffset2("_LayerCenterOffset2", Float) = 0.0
[HideInInspector] _LayerCenterOffset3("_LayerCenterOffset3", Float) = 0.0
_BlendUsingHeight1("_BlendUsingHeight1", Float) = 0.0
_BlendUsingHeight2("_BlendUsingHeight2", Float) = 0.0
_BlendUsingHeight3("_BlendUsingHeight3", Float) = 0.0

_OpacityAsDensity3("_OpacityAsDensity3", Range(0, 1.0)) = 0.0
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
_LayerTiling0("_LayerTiling0", Float) = 1
_LayerTiling1("_LayerTiling1", Float) = 1
_LayerTiling2("_LayerTiling2", Float) = 1
_LayerTiling3("_LayerTiling3", Float) = 1
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0

// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
// WARNING
// All the following properties that concern the UV mapping are the same as in the Lit shader.
// This means that they will get overridden when synchronizing the various layers.
// To avoid this, make sure that all properties here are in the exclusion list in InfluenceLayeredLitUI.SynchronizeLayerProperties
_TexWorldScale0("Tiling", Float) = 1.0
_TexWorldScale1("Tiling", Float) = 1.0
_TexWorldScale2("Tiling", Float) = 1.0

13
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


// Material ID
public static GUIContent materialIDText = new GUIContent("Material type", "Subsurface Scattering: enable for translucent materials such as skin, vegetation, fruit, marble, wax and milk.");
public static GUIContent horizonFadeText = new GUIContent("Horizon Fade (Spec occlusion)", "horizon fade is use to control specular occlusion");
// Per pixel displacement
public static GUIContent enablePerPixelDisplacementText = new GUIContent("Enable Per Pixel Displacement", "");
public static GUIContent ppdMinSamplesText = new GUIContent("Minimum samples", "Minimum samples to use with per pixel displacement mapping");

protected const string kStencilRef = "_StencilRef";
protected MaterialProperty horizonFade = null;
protected const string kHorizonFade = "_HorizonFade";
// Wind
protected MaterialProperty windEnable = null;
protected const string kWindEnabled = "_EnableWind";

// MaterialID
materialID = FindProperty(kMaterialID, props, false); // InfluenceLayeredLit is force to be standard for now, so materialID could not exist
horizonFade = FindProperty(kHorizonFade, props);
// Per pixel displacement
enablePerPixelDisplacement = FindProperty(kEnablePerPixelDisplacement, props);

EditorGUI.indentLevel--;
}
m_MaterialEditor.ShaderProperty(horizonFade, StylesBaseLit.horizonFadeText);
GUILayout.Label(StylesBaseLit.tessellationText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(StylesBaseLit.tessellationText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
TessellationModePopup();
m_MaterialEditor.ShaderProperty(tessellationFactor, StylesBaseLit.tessellationFactorText);

protected override void VertexAnimationPropertiesGUI()
{
GUILayout.Label(StylesBaseLit.vertexAnimation, EditorStyles.boldLabel);
EditorGUILayout.LabelField(StylesBaseLit.vertexAnimation, EditorStyles.boldLabel);
EditorGUI.indentLevel++;

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


public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map (BC7/BC5/DXT5(nm))");
public static GUIContent normalMapOSText = new GUIContent("Normal Map OS", "Normal Map (BC7/DXT1/RGB)");
public static GUIContent specularOcclusionMapText = new GUIContent("Specular Occlusion Map (RGBA)", "Specular Occlusion Map");
public static GUIContent horizonFadeText = new GUIContent("Horizon Fade (Spec occlusion)", "horizon fade is use to control specular occlusion");
public static GUIContent heightMapText = new GUIContent("Height Map (R)", "Height Map");
public static GUIContent heightMapAmplitudeText = new GUIContent("Height Map Amplitude", "Height Map amplitude in world units.");

public static GUIContent normalMapSpaceWarning = new GUIContent("Object space normal can't be use with triplanar mapping.");
}
// Lit shader is not layered but some layered materials inherit from it. In order to share code we need LitUI to account for this.
protected const int kMaxLayerCount = 4;
protected int m_LayerCount = 1;
protected string[] m_PropertySuffixes = { "", "", "", "" };
Planar,
Triplanar
Planar = 4,
Triplanar = 5
}
public enum NormalMapSpace

UseEmissiveMask,
}
protected MaterialProperty UVBase = null;
protected MaterialProperty[] UVBase = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty TexWorldScale = null;
protected MaterialProperty[] TexWorldScale = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty UVMappingMask = null;
protected MaterialProperty[] UVMappingMask = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty baseColor = null;
protected MaterialProperty[] baseColor = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty baseColorMap = null;
protected MaterialProperty[] baseColorMap = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty metallic = null;
protected MaterialProperty[] metallic = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty smoothness = null;
protected MaterialProperty[] smoothness = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty maskMap = null;
protected MaterialProperty[] maskMap = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty specularOcclusionMap = null;
protected MaterialProperty[] specularOcclusionMap = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty horizonFade = null;
protected const string kHorizonFade = "_HorizonFade";
protected MaterialProperty normalMap = null;
protected MaterialProperty[] normalMap = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty normalMapOS = null;
protected MaterialProperty[] normalMapOS = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty normalScale = null;
protected MaterialProperty[] normalScale = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty normalMapSpace = null;
protected MaterialProperty[] normalMapSpace = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty heightMap = null;
protected MaterialProperty[] heightMap = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty heightAmplitude = null;
protected MaterialProperty[] heightAmplitude = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty heightCenter = null;
protected MaterialProperty[] heightCenter = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty tangentMap = null;
protected const string kTangentMap = "_TangentMap";
protected MaterialProperty tangentMapOS = null;
protected const string kTangentMapOS = "_TangentMapOS";
protected MaterialProperty anisotropy = null;
protected const string kAnisotropy = "_Anisotropy";
protected MaterialProperty anisotropyMap = null;
protected const string kAnisotropyMap = "_AnisotropyMap";
protected MaterialProperty specularColor = null;
protected const string kSpecularColor = "_SpecularColor";
protected MaterialProperty specularColorMap = null;
protected const string kSpecularColorMap = "_SpecularColorMap";
protected MaterialProperty UVDetail = null;
protected MaterialProperty[] UVDetail = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty UVDetailsMappingMask = null;
protected MaterialProperty[] UVDetailsMappingMask = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty detailMap = null;
protected MaterialProperty[] detailMap = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty detailMask = null;
protected MaterialProperty[] detailMask = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty detailAlbedoScale = null;
protected MaterialProperty[] detailAlbedoScale = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty detailNormalScale = null;
protected MaterialProperty[] detailNormalScale = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty detailSmoothnessScale = null;
protected MaterialProperty[] detailSmoothnessScale = new MaterialProperty[kMaxLayerCount];
protected MaterialProperty specularColor = null;
protected const string kSpecularColor = "_SpecularColor";
protected MaterialProperty specularColorMap = null;
protected const string kSpecularColorMap = "_SpecularColorMap";
protected MaterialProperty tangentMap = null;
protected const string kTangentMap = "_TangentMap";
protected MaterialProperty tangentMapOS = null;
protected const string kTangentMapOS = "_TangentMapOS";
protected MaterialProperty anisotropy = null;
protected const string kAnisotropy = "_Anisotropy";
protected MaterialProperty anisotropyMap = null;
protected const string kAnisotropyMap = "_AnisotropyMap";
protected SubsurfaceScatteringProfile subsurfaceProfile = null;
protected MaterialProperty subsurfaceProfileID = null;
protected const string kSubsurfaceProfileID = "_SubsurfaceProfile";

protected MaterialProperty emissiveIntensity = null;
protected const string kEmissiveIntensity = "_EmissiveIntensity";
protected void FindMaterialLayerProperties(MaterialProperty[] props)
{
for (int i = 0; i < m_LayerCount; ++i)
{
UVBase[i] = FindProperty(string.Format("{0}{1}", kUVBase, m_PropertySuffixes[i]), props);
TexWorldScale[i] = FindProperty(string.Format("{0}{1}", kTexWorldScale, m_PropertySuffixes[i]), props);
UVMappingMask[i] = FindProperty(string.Format("{0}{1}", kUVMappingMask, m_PropertySuffixes[i]), props);
baseColor[i] = FindProperty(string.Format("{0}{1}", kBaseColor, m_PropertySuffixes[i]), props);
baseColorMap[i] = FindProperty(string.Format("{0}{1}", kBaseColorMap, m_PropertySuffixes[i]), props);
metallic[i] = FindProperty(string.Format("{0}{1}", kMetallic, m_PropertySuffixes[i]), props);
smoothness[i] = FindProperty(string.Format("{0}{1}", kSmoothness, m_PropertySuffixes[i]), props);
maskMap[i] = FindProperty(string.Format("{0}{1}", kMaskMap, m_PropertySuffixes[i]), props);
specularOcclusionMap[i] = FindProperty(string.Format("{0}{1}", kSpecularOcclusionMap, m_PropertySuffixes[i]), props);
normalMap[i] = FindProperty(string.Format("{0}{1}", kNormalMap, m_PropertySuffixes[i]), props);
normalMapOS[i] = FindProperty(string.Format("{0}{1}", kNormalMapOS, m_PropertySuffixes[i]), props);
normalScale[i] = FindProperty(string.Format("{0}{1}", kNormalScale, m_PropertySuffixes[i]), props);
normalMapSpace[i] = FindProperty(string.Format("{0}{1}", kNormalMapSpace, m_PropertySuffixes[i]), props);
heightMap[i] = FindProperty(string.Format("{0}{1}", kHeightMap, m_PropertySuffixes[i]), props);
heightAmplitude[i] = FindProperty(string.Format("{0}{1}", kHeightAmplitude, m_PropertySuffixes[i]), props);
heightCenter[i] = FindProperty(string.Format("{0}{1}", kHeightCenter, m_PropertySuffixes[i]), props);
// Details
UVDetail[i] = FindProperty(string.Format("{0}{1}", kUVDetail, m_PropertySuffixes[i]), props);
UVDetailsMappingMask[i] = FindProperty(string.Format("{0}{1}", kUVDetailsMappingMask, m_PropertySuffixes[i]), props);
detailMap[i] = FindProperty(string.Format("{0}{1}", kDetailMap, m_PropertySuffixes[i]), props);
detailMask[i] = FindProperty(string.Format("{0}{1}", kDetailMask, m_PropertySuffixes[i]), props);
detailAlbedoScale[i] = FindProperty(string.Format("{0}{1}", kDetailAlbedoScale, m_PropertySuffixes[i]), props);
detailNormalScale[i] = FindProperty(string.Format("{0}{1}", kDetailNormalScale, m_PropertySuffixes[i]), props);
detailSmoothnessScale[i] = FindProperty(string.Format("{0}{1}", kDetailSmoothnessScale, m_PropertySuffixes[i]), props);
}
}
protected void FindMaterialEmissiveProperties(MaterialProperty[] props)
{
emissiveColorMode = FindProperty(kEmissiveColorMode, props);
emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
}
UVBase = FindProperty(kUVBase, props);
TexWorldScale = FindProperty(kTexWorldScale, props);
UVMappingMask = FindProperty(kUVMappingMask, props);
FindMaterialLayerProperties(props);
FindMaterialEmissiveProperties(props);
// The next properties are only supported for regular Lit shader (not layered ones) because it's complicated to blend those parameters if they are different on a per layer basis.
baseColor = FindProperty(kBaseColor, props);
baseColorMap = FindProperty(kBaseColorMap, props);
metallic = FindProperty(kMetallic, props);
smoothness = FindProperty(kSmoothness, props);
maskMap = FindProperty(kMaskMap, props);
specularOcclusionMap = FindProperty(kSpecularOcclusionMap, props);
horizonFade = FindProperty(kHorizonFade, props);
normalMap = FindProperty(kNormalMap, props);
normalMapOS = FindProperty(kNormalMapOS, props);
normalScale = FindProperty(kNormalScale, props);
normalMapSpace = FindProperty(kNormalMapSpace, props);
heightMap = FindProperty(kHeightMap, props);
heightAmplitude = FindProperty(kHeightAmplitude, props);
heightCenter = FindProperty(kHeightCenter, props);
// Specular Color
specularColor = FindProperty(kSpecularColor, props);
specularColorMap = FindProperty(kSpecularColorMap, props);
// Anisotropy
specularColor = FindProperty(kSpecularColor, props);
specularColorMap = FindProperty(kSpecularColorMap, props);
// Details
UVDetail = FindProperty(kUVDetail, props);
UVDetailsMappingMask = FindProperty(kUVDetailsMappingMask, props);
detailMap = FindProperty(kDetailMap, props);
detailMask = FindProperty(kDetailMask, props);
detailAlbedoScale = FindProperty(kDetailAlbedoScale, props);
detailNormalScale = FindProperty(kDetailNormalScale, props);
detailSmoothnessScale = FindProperty(kDetailSmoothnessScale, props);
// Sub surface
subsurfaceProfileID = FindProperty(kSubsurfaceProfileID, props);

thicknessMap = FindProperty(kThicknessMap, props);
// Emissive
emissiveColorMode = FindProperty(kEmissiveColorMode, props);
emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
}
protected void ShaderSSSInputGUI(Material material)

protected void ShaderAnisoInputGUI()
{
if ((NormalMapSpace)normalMapSpace.floatValue == NormalMapSpace.TangentSpace)
if ((NormalMapSpace)normalMapSpace[0].floatValue == NormalMapSpace.TangentSpace)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);
}

m_MaterialEditor.TexturePropertySingleLine(Styles.anisotropyMapText, anisotropyMap);
}
protected override void MaterialPropertiesGUI(Material material)
protected void DoLayerGUI(Material material, bool useEmissiveMask, int layerIndex)
bool useEmissiveMask = (EmissiveColorMode)emissiveColorMode.floatValue == EmissiveColorMode.UseEmissiveMask;
GUILayout.Label(Styles.InputsText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(Styles.InputsText, EditorStyles.boldLabel);
m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap, baseColor);
m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap[layerIndex], baseColor[layerIndex]);
if ((Lit.MaterialId)materialID.floatValue == Lit.MaterialId.LitStandard || (Lit.MaterialId)materialID.floatValue == Lit.MaterialId.LitAniso)
if ( materialID == null || // Will be the case for Layered materials where we only support standard and the parameter does not exist
(Lit.MaterialId)materialID.floatValue == Lit.MaterialId.LitStandard || (Lit.MaterialId)materialID.floatValue == Lit.MaterialId.LitAniso)
m_MaterialEditor.ShaderProperty(metallic, Styles.metallicText);
m_MaterialEditor.ShaderProperty(metallic[layerIndex], Styles.metallicText);
m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
m_MaterialEditor.ShaderProperty(smoothness[layerIndex], Styles.smoothnessText);
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapESText, maskMap);
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapESText, maskMap[layerIndex]);
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapSText, maskMap);
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapSText, maskMap[layerIndex]);
m_MaterialEditor.TexturePropertySingleLine(Styles.specularOcclusionMapText, specularOcclusionMap);
m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
m_MaterialEditor.TexturePropertySingleLine(Styles.specularOcclusionMapText, specularOcclusionMap[layerIndex]);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText);
m_MaterialEditor.ShaderProperty(normalMapSpace[layerIndex], Styles.normalMapSpaceText);
if ((NormalMapSpace)normalMapSpace.floatValue == NormalMapSpace.ObjectSpace && ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Triplanar))
if ((NormalMapSpace)normalMapSpace[layerIndex].floatValue == NormalMapSpace.ObjectSpace && ((UVBaseMapping)UVBase[layerIndex].floatValue == UVBaseMapping.Triplanar))
{
EditorGUILayout.HelpBox(Styles.normalMapSpaceWarning.text, MessageType.Error);
}

// 2. to avoid the warning that ask to fix the object normal map texture (normalOS are just linear RGB texture
if ((NormalMapSpace)normalMapSpace.floatValue == NormalMapSpace.TangentSpace)
if ((NormalMapSpace)normalMapSpace[layerIndex].floatValue == NormalMapSpace.TangentSpace)
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap[layerIndex], normalScale[layerIndex]);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapOSText, normalMapOS);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapOSText, normalMapOS[layerIndex]);
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap);
if (!heightMap.hasMixedValue && heightMap.textureValue != null)
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap[layerIndex]);
if (!heightMap[layerIndex].hasMixedValue && heightMap[layerIndex].textureValue != null)
m_MaterialEditor.ShaderProperty(heightAmplitude, Styles.heightMapAmplitudeText);
heightAmplitude.floatValue = Math.Max(0.0f, heightAmplitude.floatValue); // Must be positive
m_MaterialEditor.ShaderProperty(heightCenter, Styles.heightMapCenterText);
m_MaterialEditor.ShaderProperty(heightAmplitude[layerIndex], Styles.heightMapAmplitudeText);
heightAmplitude[layerIndex].floatValue = Math.Max(0.0f, heightAmplitude[layerIndex].floatValue); // Must be positive
m_MaterialEditor.ShaderProperty(heightCenter[layerIndex], Styles.heightMapCenterText);
switch ((Lit.MaterialId)materialID.floatValue)
if(materialID != null)
case Lit.MaterialId.LitSSS:
ShaderSSSInputGUI(material);
break;
case Lit.MaterialId.LitStandard:
// Nothing
break;
case Lit.MaterialId.LitAniso:
ShaderAnisoInputGUI();
break;
case Lit.MaterialId.LitSpecular:
m_MaterialEditor.TexturePropertySingleLine(Styles.specularColorText, specularColorMap, specularColor);
break;
default:
Debug.Assert(false, "Encountered an unsupported MaterialID.");
break;
switch ((Lit.MaterialId)materialID.floatValue)
{
case Lit.MaterialId.LitSSS:
ShaderSSSInputGUI(material);
break;
case Lit.MaterialId.LitStandard:
// Nothing
break;
case Lit.MaterialId.LitAniso:
ShaderAnisoInputGUI();
break;
case Lit.MaterialId.LitSpecular:
m_MaterialEditor.TexturePropertySingleLine(Styles.specularColorText, specularColorMap, specularColor);
break;
default:
Debug.Assert(false, "Encountered an unsupported MaterialID.");
break;
}
GUILayout.Label(" " + Styles.textureControlText, EditorStyles.label);
m_MaterialEditor.ShaderProperty(UVBase, Styles.UVBaseMappingText);
EditorGUILayout.LabelField(Styles.textureControlText, EditorStyles.label);
m_MaterialEditor.ShaderProperty(UVBase[layerIndex], Styles.UVBaseMappingText);
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))
UVMappingMask[layerIndex].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[layerIndex].floatValue == UVBaseMapping.Planar) || ((UVBaseMapping)UVBase[layerIndex].floatValue == UVBaseMapping.Triplanar))
m_MaterialEditor.ShaderProperty(TexWorldScale, Styles.texWorldScaleText);
m_MaterialEditor.ShaderProperty(TexWorldScale[layerIndex], Styles.texWorldScaleText);
m_MaterialEditor.TextureScaleOffsetProperty(baseColorMap);
m_MaterialEditor.TextureScaleOffsetProperty(baseColorMap[layerIndex]);
EditorGUI.indentLevel--;
GUILayout.Label(Styles.detailText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(Styles.detailText, EditorStyles.boldLabel);
m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
m_MaterialEditor.TexturePropertySingleLine(Styles.detailMapNormalText, detailMap);
EditorGUI.indentLevel++;
m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask[layerIndex]);
m_MaterialEditor.TexturePropertySingleLine(Styles.detailMapNormalText, detailMap[layerIndex]);
EditorGUI.indentLevel++;
if ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.UV0)
if ((UVBaseMapping)UVBase[layerIndex].floatValue == UVBaseMapping.UV0)
m_MaterialEditor.ShaderProperty(UVDetail, Styles.UVDetailMappingText);
m_MaterialEditor.ShaderProperty(UVDetail[layerIndex], Styles.UVDetailMappingText);
else if ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Planar)
else if ((UVBaseMapping)UVBase[layerIndex].floatValue == UVBaseMapping.Planar)
GUILayout.Label(" " + Styles.UVDetailMappingText.text + ": Planar");
EditorGUILayout.LabelField(Styles.UVDetailMappingText.text + ": Planar");
else if ((UVBaseMapping)UVBase.floatValue == UVBaseMapping.Triplanar)
else if ((UVBaseMapping)UVBase[layerIndex].floatValue == UVBaseMapping.Triplanar)
GUILayout.Label(" " + Styles.UVDetailMappingText.text + ": Triplanar");
EditorGUILayout.LabelField(Styles.UVDetailMappingText.text + ": Triplanar");
X = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV0) ? 1.0f : 0.0f;
Y = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV1) ? 1.0f : 0.0f;
Z = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV2) ? 1.0f : 0.0f;
W = ((UVDetailMapping)UVDetail.floatValue == UVDetailMapping.UV3) ? 1.0f : 0.0f;
UVDetailsMappingMask.colorValue = new Color(X, Y, Z, W);
X = ((UVDetailMapping)UVDetail[layerIndex].floatValue == UVDetailMapping.UV0) ? 1.0f : 0.0f;
Y = ((UVDetailMapping)UVDetail[layerIndex].floatValue == UVDetailMapping.UV1) ? 1.0f : 0.0f;
Z = ((UVDetailMapping)UVDetail[layerIndex].floatValue == UVDetailMapping.UV2) ? 1.0f : 0.0f;
W = ((UVDetailMapping)UVDetail[layerIndex].floatValue == UVDetailMapping.UV3) ? 1.0f : 0.0f;
UVDetailsMappingMask[layerIndex].colorValue = new Color(X, Y, Z, W);
m_MaterialEditor.TextureScaleOffsetProperty(detailMap[layerIndex]);
m_MaterialEditor.ShaderProperty(detailAlbedoScale[layerIndex], Styles.detailAlbedoScaleText);
m_MaterialEditor.ShaderProperty(detailNormalScale[layerIndex], Styles.detailNormalScaleText);
m_MaterialEditor.ShaderProperty(detailSmoothnessScale[layerIndex], Styles.detailSmoothnessScaleText);
m_MaterialEditor.TextureScaleOffsetProperty(detailMap);
m_MaterialEditor.ShaderProperty(detailAlbedoScale, Styles.detailAlbedoScaleText);
m_MaterialEditor.ShaderProperty(detailNormalScale, Styles.detailNormalScaleText);
m_MaterialEditor.ShaderProperty(detailSmoothnessScale, Styles.detailSmoothnessScaleText);
}
protected override void MaterialPropertiesGUI(Material material)
{
bool useEmissiveMask = (EmissiveColorMode)emissiveColorMode.floatValue == EmissiveColorMode.UseEmissiveMask;
DoLayerGUI(material, useEmissiveMask, 0);
GUILayout.Label(Styles.lightingText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(Styles.lightingText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText);
if (!useEmissiveMask)

m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
EditorGUI.indentLevel--;
// The parent Base.ShaderPropertiesGUI will call DoEmissionArea
}

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


[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
[Enum(UV0, 0, Planar, 1, TriPlanar, 2)] _UVBase("UV Set for base", Float) = 0
[Enum(UV0, 0, Planar, 4, TriPlanar, 5)] _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)
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0

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


#include "ShaderLibrary/SampleUVMapping.hlsl"
#include "../MaterialUtilities.hlsl"
#ifdef LAYERED_LIT_USE_SIMPLE_BLEND
static const float defaultHeightValue = 1.0f;
#else
static const float defaultHeightValue = 0.0f;
#endif
void GetBuiltinData(FragInputs input, SurfaceData surfaceData, float alpha, float depthOffset, out BuiltinData builtinData)
{
// Builtin Data

#endif
ComputeLayerTexCoord0( texCoord0, float2(0.0, 0.0), float2(0.0, 0.0), float2(0.0, 0.0),
positionWS, mappingType, _TexWorldScale0, layerTexCoord, _LayerTiling0
positionWS, mappingType, _TexWorldScale0, layerTexCoord, 1.0
#if !defined(_MAIN_LAYER_INFLUENCE_MODE)
* tileObjectScale // We only affect layer0 in case we are not in influence mode (i.e we should not change the base object)
#endif

mappingType = UV_MAPPING_TRIPLANAR;
#endif
ComputeLayerTexCoord1( texCoord0, texCoord1, texCoord2, texCoord3,
positionWS, mappingType, _TexWorldScale1, layerTexCoord, _LayerTiling1 * tileObjectScale);
positionWS, mappingType, _TexWorldScale1, layerTexCoord, tileObjectScale);
mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR2)

#endif
ComputeLayerTexCoord2( texCoord0, texCoord1, texCoord2, texCoord3,
positionWS, mappingType, _TexWorldScale2, layerTexCoord, _LayerTiling2 * tileObjectScale);
positionWS, mappingType, _TexWorldScale2, layerTexCoord, tileObjectScale);
mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR3)

#endif
ComputeLayerTexCoord3( texCoord0, texCoord1, texCoord2, texCoord3,
positionWS, mappingType, _TexWorldScale3, layerTexCoord, _LayerTiling3 * tileObjectScale);
positionWS, mappingType, _TexWorldScale3, layerTexCoord, tileObjectScale);
}
// This is call only in this file

tileObjectScale = length(float3(worldTransform._m00, worldTransform._m01, worldTransform._m02));
#endif
height0 /= _LayerTiling0 * max(_BaseColorMap0_ST.x, _BaseColorMap0_ST.y);
height0 /= max(_BaseColorMap0_ST.x, _BaseColorMap0_ST.y);
height1 /= tileObjectScale * _LayerTiling1 * max(_BaseColorMap1_ST.x, _BaseColorMap1_ST.y);
height2 /= tileObjectScale * _LayerTiling2 * max(_BaseColorMap2_ST.x, _BaseColorMap2_ST.y);
height3 /= tileObjectScale * _LayerTiling3 * max(_BaseColorMap3_ST.x, _BaseColorMap3_ST.y);
height1 /= tileObjectScale * max(_BaseColorMap1_ST.x, _BaseColorMap1_ST.y);
height2 /= tileObjectScale * max(_BaseColorMap2_ST.x, _BaseColorMap2_ST.y);
height3 /= tileObjectScale * max(_BaseColorMap3_ST.x, _BaseColorMap3_ST.y);
#endif
}

#ifndef _HEIGHTMAP0
height0 = 0.0;
height0 = defaultHeightValue;
height1 = 0.0;
height1 = defaultHeightValue;
height2 = 0.0;
height2 = defaultHeightValue;
height3 = 0.0;
height3 = defaultHeightValue;
height3 = 0.0;
height3 = defaultHeightValue;
height2 = 0.0;
height2 = defaultHeightValue;
#endif
}

float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP0)
maxDisplacement = max( _LayerHeightAmplitude0, maxDisplacement);
maxDisplacement = _HeightAmplitude0;
maxDisplacement = max( _LayerHeightAmplitude1
maxDisplacement = max( _HeightAmplitude1
+_LayerHeightAmplitude0 * _InheritBaseHeight1
+_HeightAmplitude0 * _InheritBaseHeight1
#endif
, maxDisplacement);
#endif

maxDisplacement = max( _LayerHeightAmplitude2
maxDisplacement = max( _HeightAmplitude2
+_LayerHeightAmplitude0 * _InheritBaseHeight2
+_HeightAmplitude0 * _InheritBaseHeight2
#endif
, maxDisplacement);
#endif

#if defined(_HEIGHTMAP3)
maxDisplacement = max( _LayerHeightAmplitude3
maxDisplacement = max( _HeightAmplitude3
+_LayerHeightAmplitude0 * _InheritBaseHeight3
+_HeightAmplitude0 * _InheritBaseHeight3
#endif
, maxDisplacement);
#endif

// For per pixel displacement we need to have normalized height scale to calculate the interesection (required by the algorithm we use)
// mean that we will normalize by the highest amplitude.
// We store this normalization factor with the weights as it will be multiply by the readed height.
ppdParam.weights[0] = weights[0] * (_LayerHeightAmplitude0) / maxHeight;
ppdParam.weights[1] = weights[1] * (_LayerHeightAmplitude1 + _LayerHeightAmplitude0 * _InheritBaseHeight1) / maxHeight;
ppdParam.weights[2] = weights[2] * (_LayerHeightAmplitude2 + _LayerHeightAmplitude0 * _InheritBaseHeight2) / maxHeight;
ppdParam.weights[3] = weights[3] * (_LayerHeightAmplitude3 + _LayerHeightAmplitude0 * _InheritBaseHeight3) / maxHeight;
ppdParam.weights[0] = weights[0] * (_HeightAmplitude0) / maxHeight;
ppdParam.weights[1] = weights[1] * (_HeightAmplitude1 + _HeightAmplitude0 * _InheritBaseHeight1) / maxHeight;
ppdParam.weights[2] = weights[2] * (_HeightAmplitude2 + _HeightAmplitude0 * _InheritBaseHeight2) / maxHeight;
ppdParam.weights[3] = weights[3] * (_HeightAmplitude3 + _HeightAmplitude0 * _InheritBaseHeight3) / maxHeight;
// Think that inheritbasedheight will be 0 if height0 is fully visible in weights. So there is no double contribution of height0
float mainHeightInfluence = BlendLayeredScalar(0.0, _InheritBaseHeight1, _InheritBaseHeight2, _InheritBaseHeight3, weights);

ComputeMaskWeights(blendMasks, weights);
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
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;
float height0 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0, lod).r - _HeightCenter0) * _HeightAmplitude0;
float height1 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1, lod).r - _HeightCenter1) * _HeightAmplitude1;
float height2 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2, lod).r - _HeightCenter2) * _HeightAmplitude2;
float height3 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3, lod).r - _HeightCenter3) * _HeightAmplitude3;
ApplyTessellationTileScale(height0, height1, height2, height3); // Only apply with per vertex displacement
SetEnabledHeightByLayer(height0, height1, height2, height3);
float heightResult = BlendLayeredScalar(height0, height1, height2, height3, weights);

{
float4 blendMasks = GetBlendMask(layerTexCoord, input.color);
#if defined(_DENSITY_MODE)
// Note: blendMasks.argb because a is main layer
float4 minOpaParam = float4(_MinimumOpacity0, _MinimumOpacity1, _MinimumOpacity2, _MinimumOpacity3);
float4 remapedOpacity = lerp(minOpaParam, float4(1.0, 1.0, 1.0, 1.0), inputAlphaMask); // Remap opacity mask from [0..1] to [minOpa..1]
float4 opacityAsDensity = saturate((inputAlphaMask - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks.argb)) * 20.0);
float4 useOpacityAsDensityParam = float4(_OpacityAsDensity0, _OpacityAsDensity1, _OpacityAsDensity2, _OpacityAsDensity3);
blendMasks.argb = lerp(blendMasks.argb * remapedOpacity, opacityAsDensity, useOpacityAsDensityParam);
#endif
#if defined(_HEIGHT_BASED_BLEND)
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;
float height0 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0).r - _HeightCenter0) * _HeightAmplitude0;
float height1 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1).r - _HeightCenter1) * _HeightAmplitude1;
float height2 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2).r - _HeightCenter2) * _HeightAmplitude2;
float height3 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3).r - _HeightCenter3) * _HeightAmplitude3;
// HACK: use height0 to avoid compiler error for unused sampler - To remove when we can have a sampler without a textures
#if !defined(_PER_PIXEL_DISPLACEMENT)
// We don't use height 0 for the height blend based mode
heights.y += (heights.x * 0.0001);
#endif
// HACK: use height0 to avoid compiler error for unused sampler - To remove when we can have a sampler without a textures
#if !defined(_PER_PIXEL_DISPLACEMENT)
// We don't use height 0 for the height blend based mode
heights.y += (heights.x * 0.0001);
#endif
float4 heights = float4(0.0, 0.0, 0.0, 0.0);
float4 heights = float4(defaultHeightValue, defaultHeightValue, defaultHeightValue, defaultHeightValue);
// don't apply on main layer
blendMasks.rgb = ApplyHeightBasedBlend(blendMasks.rgb, heights.yzw, float3(_BlendUsingHeight1, _BlendUsingHeight2, _BlendUsingHeight3));
#endif
#ifdef LAYERED_LIT_USE_SIMPLE_BLEND
//
//#if _LAYER_COUNT == 2
// float4 layerMask = float4(1.0, 1.0, 0.0, 0.0);
//#elif _LAYER_COUNT == 3
// float4 layerMask = float4(1.0, 1.0, 1.0, 0.0);
//#else
// float4 layerMask = float4(1.0, 1.0, 1.0, 1.0);
//#endif
//
blendMasks *= heights;
float normFactor = dot(blendMasks, 1.0) + 1e-6;
blendMasks /= normFactor;
outWeights[0] = blendMasks.r;
outWeights[1] = blendMasks.g;
outWeights[2] = blendMasks.b;
outWeights[3] = blendMasks.a;
#else
#if defined(_DENSITY_MODE)
// Note: blendMasks.argb because a is main layer
float4 minOpaParam = float4(_MinimumOpacity0, _MinimumOpacity1, _MinimumOpacity2, _MinimumOpacity3);
float4 remapedOpacity = lerp(minOpaParam, float4(1.0, 1.0, 1.0, 1.0), inputAlphaMask); // Remap opacity mask from [0..1] to [minOpa..1]
float4 opacityAsDensity = saturate((inputAlphaMask - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks.argb)) * 20.0);
float4 useOpacityAsDensityParam = float4(_OpacityAsDensity0, _OpacityAsDensity1, _OpacityAsDensity2, _OpacityAsDensity3);
blendMasks.argb = lerp(blendMasks.argb * remapedOpacity, opacityAsDensity, useOpacityAsDensityParam);
#endif
#if defined(_HEIGHT_BASED_BLEND)
// don't apply on main layer
blendMasks.rgb = ApplyHeightBasedBlend(blendMasks.rgb, heights.yzw, float3(_BlendUsingHeight1, _BlendUsingHeight2, _BlendUsingHeight3));
#endif
#endif
}
float3 ComputeMainNormalInfluence(FragInputs input, float3 normalTS0, float3 normalTS1, float3 normalTS2, float3 normalTS3, LayerTexCoord layerTexCoord, float weights[_MAX_LAYER])

float3 normalTS = ComputeMainNormalInfluence(input, normalTS0, normalTS1, normalTS2, normalTS3, layerTexCoord, weights);
#else
surfaceData.baseColor = SURFACEDATA_BLEND_VECTOR3(surfaceData, baseColor, weights);
//surfaceData.baseColor = float3(weights[0], weights[1], weights[2]);
//surfaceData.baseColor = float3(1.0, 0.0, 0.0);
float3 normalTS = BlendLayeredVector3(normalTS0, normalTS1, normalTS2, normalTS3, weights);
#endif

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


float _BlendUsingHeight1;
float _BlendUsingHeight2;
float _BlendUsingHeight3;
PROP_DECL(float, _LayerHeightAmplitude);
PROP_DECL(float, _LayerCenterOffset);
PROP_DECL(float, _MinimumOpacity);
PROP_DECL(float, _OpacityAsDensity);
float _InheritBaseNormal1;

float _InheritBaseColorThreshold2;
float _InheritBaseColorThreshold3;
float _LayerTilingBlendMask;
PROP_DECL(float, _LayerTiling);
float _TexWorldScaleBlendMask;
PROP_DECL(float, _TexWorldScale);

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs


protected virtual void BaseMaterialPropertiesGUI()
{
EditorGUI.indentLevel++;
GUILayout.Label(StylesBaseUnlit.optionText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(StylesBaseUnlit.optionText, EditorStyles.boldLabel);
SurfaceTypePopup();
if ((SurfaceType)surfaceType.floatValue == SurfaceType.Transparent)
{

DoEmissionArea(material);
GUILayout.Label(StylesBaseUnlit.advancedText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(StylesBaseUnlit.advancedText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.indentLevel--;
}
if (EditorGUI.EndChangeCheck())

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/UnlitUI.cs


protected override void MaterialPropertiesGUI(Material material)
{
GUILayout.Label(Styles.InputsText, EditorStyles.boldLabel);
EditorGUILayout.LabelField(Styles.InputsText, EditorStyles.boldLabel);
m_MaterialEditor.TexturePropertySingleLine(Styles.colorText, colorMap, color);

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit.meta


fileFormatVersion: 2
guid: 883e0e56c1d016841aca4ce3ed34be7b
folderAsset: yes
timeCreated: 1502111269
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor.meta


fileFormatVersion: 2
guid: 0536b6da718aae342b15a1b7c8a37eb2
folderAsset: yes
timeCreated: 1502111269
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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


using System;
using UnityEngine;
using UnityEngine.Rendering;
using System.Linq;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class LayeredLitGUI : LitGUI
{
public enum LayerUVBaseMapping
{
UV0,
UV1,
UV2,
UV3,
Planar,
Triplanar,
}
public enum VertexColorMode
{
None,
Multiply,
Add
}
private class StylesLayer
{
public readonly GUIContent[] layerLabels =
{
new GUIContent("Main layer"),
new GUIContent("Layer 1"),
new GUIContent("Layer 2"),
new GUIContent("Layer 3"),
};
public readonly GUIStyle[] layerLabelColors =
{
new GUIStyle(EditorStyles.foldout),
new GUIStyle(EditorStyles.foldout),
new GUIStyle(EditorStyles.foldout),
new GUIStyle(EditorStyles.foldout)
};
public readonly GUIContent materialLayerText = new GUIContent("Material");
public readonly GUIContent syncButtonText = new GUIContent("Re-Synchronize Layers", "Re-synchronize all layers's properties with the referenced Material");
public readonly GUIContent layersText = new GUIContent("Inputs");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask");
public readonly GUIContent vertexColorModeText = new GUIContent("Vertex Color Mode", "Mode multiply: vertex color is multiply with the mask. Mode additive: vertex color values are remapped between -1 and 1 and added to the mask (neutral at 0.5 vertex color).");
public readonly GUIContent layerCountText = new GUIContent("Layer Count", "Number of layers.");
public readonly GUIContent layerTilingBlendMaskText = new GUIContent("Tiling", "Tiling for the blend mask.");
public readonly GUIContent objectScaleAffectTileText = new GUIContent("Tiling 0123 follow object Scale", "Tiling will be affected by the object scale.");
public readonly GUIContent objectScaleAffectTileText2 = new GUIContent("Tiling 123 follow object Scale", "Tiling will be affected by the object scale.");
public readonly GUIContent layerTexWorldScaleText = new GUIContent("World Scale", "Tiling factor applied to Planar/Trilinear mapping");
public readonly GUIContent UVBlendMaskText = new GUIContent("BlendMask UV Mapping", "Base UV Mapping mode of the layer.");
public StylesLayer()
{
layerLabelColors[0].normal.textColor = Color.white;
layerLabelColors[1].normal.textColor = Color.red;
layerLabelColors[2].normal.textColor = Color.green;
layerLabelColors[3].normal.textColor = Color.blue;
}
}
static StylesLayer s_Styles = null;
private static StylesLayer styles { get { if (s_Styles == null) s_Styles = new StylesLayer(); return s_Styles; } }
// Needed for json serialization to work
[Serializable]
internal struct SerializeableGUIDs
{
public string[] GUIDArray;
}
const int kMaxLayerCount = 4;
const int kSyncButtonWidth = 58;
Material[] m_MaterialLayers = new Material[kMaxLayerCount];
// Layer options
MaterialProperty layerCount = null;
const string kLayerCount = "_LayerCount";
MaterialProperty layerMaskMap = null;
const string kLayerMaskMap = "_LayerMaskMap";
MaterialProperty vertexColorMode = null;
const string kVertexColorMode = "_VertexColorMode";
MaterialProperty objectScaleAffectTile = null;
const string kObjectScaleAffectTile = "_ObjectScaleAffectTile";
MaterialProperty UVBlendMask = null;
const string kUVBlendMask = "_UVBlendMask";
MaterialProperty layerTilingBlendMask = null;
const string kLayerTilingBlendMask = "_LayerTilingBlendMask";
MaterialProperty texWorldScaleBlendMask = null;
const string kTexWorldScaleBlendMask = "_TexWorldScaleBlendMask";
[SerializeField]
private bool[] showLayer = { false, false, false, false };
public LayeredLitGUI()
{
m_LayerCount = 4;
m_PropertySuffixes[0] = "0";
m_PropertySuffixes[1] = "1";
m_PropertySuffixes[2] = "2";
m_PropertySuffixes[3] = "3";
}
protected override void FindMaterialProperties(MaterialProperty[] props)
{
base.FindMaterialLayerProperties(props);
base.FindMaterialEmissiveProperties(props);
layerCount = FindProperty(kLayerCount, props);
layerMaskMap = FindProperty(kLayerMaskMap, props);
vertexColorMode = FindProperty(kVertexColorMode, props);
objectScaleAffectTile = FindProperty(kObjectScaleAffectTile, props);
UVBlendMask = FindProperty(kUVBlendMask, props);
layerTilingBlendMask = FindProperty(kLayerTilingBlendMask, props);
texWorldScaleBlendMask = FindProperty(kTexWorldScaleBlendMask, props);
}
int numLayer
{
set { layerCount.floatValue = (float)value; }
get { return (int)layerCount.floatValue; }
}
// This function is call by a script to help artists to ahve up to date material
// that why it is static
public static void SynchronizeAllLayers(Material material)
{
int layerCount = (int)material.GetFloat(kLayerCount);
AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));
Material[] layers = null;
InitializeMaterialLayers(materialImporter, ref layers);
// We could have no userData in the assets, so test if we have load something
if (layers != null)
{
for (int i = 0; i < layerCount; ++i)
{
SynchronizeLayerProperties(material, layers, i);
}
}
}
void SynchronizeAllLayersProperties()
{
for (int i = 0; i < numLayer; ++i)
{
SynchronizeLayerProperties(m_MaterialEditor.target as Material, m_MaterialLayers, i);
}
}
static void SynchronizeLayerProperties(Material material, Material[] layers, int layerIndex)
{
Material layerMaterial = layers[layerIndex];
if (layerMaterial != null)
{
Shader layerShader = layerMaterial.shader;
int propertyCount = ShaderUtil.GetPropertyCount(layerShader);
for (int i = 0; i < propertyCount; ++i)
{
string propertyName = ShaderUtil.GetPropertyName(layerShader, i);
string layerPropertyName = propertyName + layerIndex;
if (material.HasProperty(layerPropertyName))
{
ShaderUtil.ShaderPropertyType type = ShaderUtil.GetPropertyType(layerShader, i);
switch (type)
{
case ShaderUtil.ShaderPropertyType.Color:
{
material.SetColor(layerPropertyName, layerMaterial.GetColor(propertyName));
break;
}
case ShaderUtil.ShaderPropertyType.Float:
case ShaderUtil.ShaderPropertyType.Range:
{
material.SetFloat(layerPropertyName, layerMaterial.GetFloat(propertyName));
break;
}
case ShaderUtil.ShaderPropertyType.Vector:
{
material.SetVector(layerPropertyName, layerMaterial.GetVector(propertyName));
break;
}
case ShaderUtil.ShaderPropertyType.TexEnv:
{
material.SetTexture(layerPropertyName, layerMaterial.GetTexture(propertyName));
material.SetTextureOffset(layerPropertyName, layerMaterial.GetTextureOffset(propertyName));
material.SetTextureScale(layerPropertyName, layerMaterial.GetTextureScale(propertyName));
break;
}
}
}
}
}
}
// We use the user data to save a string that represent the referenced lit material
// so we can keep reference during serialization
static void InitializeMaterialLayers(AssetImporter materialImporter, ref Material[] layers)
{
if (materialImporter.userData != string.Empty)
{
SerializeableGUIDs layersGUID = JsonUtility.FromJson<SerializeableGUIDs>(materialImporter.userData);
if (layersGUID.GUIDArray.Length > 0)
{
layers = new Material[layersGUID.GUIDArray.Length];
for (int i = 0; i < layersGUID.GUIDArray.Length; ++i)
{
layers[i] = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(layersGUID.GUIDArray[i]), typeof(Material)) as Material;
}
}
}
}
void SaveMaterialLayers(AssetImporter materialImporter)
{
SerializeableGUIDs layersGUID;
layersGUID.GUIDArray = new string[m_MaterialLayers.Length];
for (int i = 0; i < m_MaterialLayers.Length; ++i)
{
if (m_MaterialLayers[i] != null)
layersGUID.GUIDArray[i] = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_MaterialLayers[i].GetInstanceID()));
}
materialImporter.userData = JsonUtility.ToJson(layersGUID);
}
bool DoLayersGUI(AssetImporter materialImporter)
{
Material material = m_MaterialEditor.target as Material;
bool layerChanged = false;
GUI.changed = false;
EditorGUILayout.LabelField(styles.layersText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.showMixedValue = layerCount.hasMixedValue;
EditorGUI.BeginChangeCheck();
int newLayerCount = EditorGUILayout.IntSlider(styles.layerCountText, (int)layerCount.floatValue, 2, 4);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(material, "Change layer count");
layerCount.floatValue = (float)newLayerCount;
SynchronizeAllLayersProperties();
layerChanged = true;
}
m_MaterialEditor.TexturePropertySingleLine(styles.layerMapMaskText, layerMaskMap);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(UVBlendMask, styles.UVBlendMaskText);
if (((LayerUVBaseMapping)UVBlendMask.floatValue == LayerUVBaseMapping.Planar) ||
((LayerUVBaseMapping)UVBlendMask.floatValue == LayerUVBaseMapping.Triplanar))
{
m_MaterialEditor.ShaderProperty(texWorldScaleBlendMask, styles.layerTexWorldScaleText);
}
else
{
m_MaterialEditor.ShaderProperty(layerTilingBlendMask, styles.layerTilingBlendMaskText);
}
EditorGUI.indentLevel--;
m_MaterialEditor.ShaderProperty(vertexColorMode, styles.vertexColorModeText);
m_MaterialEditor.ShaderProperty(objectScaleAffectTile, styles.objectScaleAffectTileText);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
for (int i = 0; i < numLayer; i++)
{
//showLayer[i] = EditorGUILayout.Foldout(showLayer[i], styles.layerLabels[i], styles.layerLabelColors[i]);
EditorGUI.indentLevel++;
showLayer[i] = EditorGUILayout.Foldout(showLayer[i], styles.layerLabels[i], styles.layerLabelColors[i]);
EditorGUI.indentLevel--;
if (!showLayer[i])
continue;
//EditorGUILayout.LabelField(styles.layerLabels[i], styles.layerLabelColors[i]);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
m_MaterialLayers[i] = EditorGUILayout.ObjectField(styles.materialLayerText, m_MaterialLayers[i], typeof(Material), true) as Material;
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(materialImporter, "Change layer material");
SynchronizeLayerProperties(material, m_MaterialLayers, i);
layerChanged = true;
}
//EditorGUI.indentLevel++;
DoLayerGUI(material, false, i);
EditorGUI.indentLevel--;
// 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)UVBase[i].floatValue;
float X, Y, Z, W;
X = (layerUVBaseMapping == LayerUVBaseMapping.UV0) ? 1.0f : 0.0f;
Y = (layerUVBaseMapping == LayerUVBaseMapping.UV1) ? 1.0f : 0.0f;
Z = (layerUVBaseMapping == LayerUVBaseMapping.UV2) ? 1.0f : 0.0f;
W = (layerUVBaseMapping == LayerUVBaseMapping.UV3) ? 1.0f : 0.0f;
UVMappingMask[i].colorValue = (i == 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
UVDetailMapping layerUVDetailMapping = (UVDetailMapping)UVDetail[i].floatValue;
X = (layerUVDetailMapping == UVDetailMapping.UV0) ? 1.0f : 0.0f;
Y = (layerUVDetailMapping == UVDetailMapping.UV1) ? 1.0f : 0.0f;
Z = (layerUVDetailMapping == UVDetailMapping.UV2) ? 1.0f : 0.0f;
W = (layerUVDetailMapping == UVDetailMapping.UV3) ? 1.0f : 0.0f;
UVDetailsMappingMask[i].colorValue = new Color(X, Y, Z, W);
}
EditorGUILayout.Space();
GUILayout.BeginHorizontal();
{
GUILayout.FlexibleSpace();
if (GUILayout.Button(styles.syncButtonText))
{
SynchronizeAllLayersProperties();
layerChanged = true;
}
}
GUILayout.EndHorizontal();
EditorGUI.indentLevel--;
layerChanged |= GUI.changed;
GUI.changed = false;
return layerChanged;
}
protected override bool ShouldEmissionBeEnabled(Material mat)
{
return mat.GetFloat(kEmissiveIntensity) > 0.0f;
}
protected override void SetupMaterialKeywordsAndPassInternal(Material material)
{
SetupMaterialKeywordsAndPass(material);
}
static public void SetupLayersMappingKeywords(Material material)
{
// object scale affect tile
SetKeyword(material, "_LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE", material.GetFloat(kObjectScaleAffectTile) > 0.0f);
// Blend mask
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);
// Layer
if (numLayer == 4)
{
SetKeyword(material, "_LAYEREDLIT_4_LAYERS", true);
SetKeyword(material, "_LAYEREDLIT_3_LAYERS", false);
}
else if (numLayer == 3)
{
SetKeyword(material, "_LAYEREDLIT_4_LAYERS", false);
SetKeyword(material, "_LAYEREDLIT_3_LAYERS", true);
}
else
{
SetKeyword(material, "_LAYEREDLIT_4_LAYERS", false);
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.
bool needUV3 = false;
bool needUV2 = false;
for (int i = 0; i < numLayer; ++i)
{
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);
string uvBase = string.Format("{0}{1}", kUVBase, i);
string uvDetail = string.Format("{0}{1}", kUVDetail, i);
if (((UVDetailMapping)material.GetFloat(uvDetail) == UVDetailMapping.UV2) ||
((LayerUVBaseMapping)material.GetFloat(uvBase) == LayerUVBaseMapping.UV2))
{
needUV2 = true;
}
if (((UVDetailMapping)material.GetFloat(uvDetail) == UVDetailMapping.UV3) ||
((LayerUVBaseMapping)material.GetFloat(uvBase) == LayerUVBaseMapping.UV3))
{
needUV3 = true;
break; // If we find it UV3 let's early out
}
}
if (needUV3)
{
material.DisableKeyword("_REQUIRE_UV2");
material.EnableKeyword("_REQUIRE_UV3");
}
else if (needUV2)
{
material.EnableKeyword("_REQUIRE_UV2");
material.DisableKeyword("_REQUIRE_UV3");
}
else
{
material.DisableKeyword("_REQUIRE_UV2");
material.DisableKeyword("_REQUIRE_UV3");
}
}
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
static new public void SetupMaterialKeywordsAndPass(Material material)
{
SetupBaseLitKeywords(material);
SetupBaseLitMaterialPass(material);
SetupLayersMappingKeywords(material);
for (int i = 0; i < kMaxLayerCount; ++i)
{
NormalMapSpace normalMapSpace = ((NormalMapSpace)material.GetFloat(kNormalMapSpace + i));
SetKeyword(material, "_NORMALMAP_TANGENT_SPACE" + i, normalMapSpace == NormalMapSpace.TangentSpace);
if (normalMapSpace == NormalMapSpace.TangentSpace)
{
SetKeyword(material, "_NORMALMAP" + i, material.GetTexture(kNormalMap + i) || material.GetTexture(kDetailMap + i));
}
else
{
SetKeyword(material, "_NORMALMAP" + i, material.GetTexture(kNormalMapOS + i) || material.GetTexture(kDetailMap + i));
}
SetKeyword(material, "_MASKMAP" + i, material.GetTexture(kMaskMap + i));
SetKeyword(material, "_SPECULAROCCLUSIONMAP" + i, material.GetTexture(kSpecularOcclusionMap + i));
SetKeyword(material, "_DETAIL_MAP" + i, material.GetTexture(kDetailMap + i));
SetKeyword(material, "_HEIGHTMAP" + i, material.GetTexture(kHeightMap + i));
}
SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap));
VertexColorMode VCMode = (VertexColorMode)material.GetFloat(kVertexColorMode);
if (VCMode == VertexColorMode.Multiply)
{
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", true);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", false);
}
else if (VCMode == VertexColorMode.Add)
{
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", false);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", true);
}
else
{
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", false);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", false);
}
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindBaseMaterialProperties(props);
FindMaterialProperties(props);
m_MaterialEditor = materialEditor;
// We should always do this call at the beginning
m_MaterialEditor.serializedObject.Update();
Material material = m_MaterialEditor.target as Material;
AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));
InitializeMaterialLayers(materialImporter, ref m_MaterialLayers);
bool optionsChanged = false;
EditorGUI.BeginChangeCheck();
{
BaseMaterialPropertiesGUI();
EditorGUILayout.Space();
VertexAnimationPropertiesGUI();
EditorGUILayout.Space();
}
if (EditorGUI.EndChangeCheck())
{
optionsChanged = true;
}
bool layerChanged = DoLayersGUI(materialImporter);
EditorGUILayout.Space();
EditorGUILayout.LabelField(Styles.lightingText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
DoEmissionArea(material);
EditorGUI.indentLevel--;
m_MaterialEditor.EnableInstancingField();
if (layerChanged || optionsChanged)
{
foreach (var obj in m_MaterialEditor.targets)
{
SetupMaterialKeywordsAndPassInternal((Material)obj);
}
// SaveAssetsProcessor the referenced material in the users data
SaveMaterialLayers(materialImporter);
}
// We should always do this call at the end
m_MaterialEditor.serializedObject.ApplyModifiedProperties();
}
}
} // namespace UnityEditor

13
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs.meta


fileFormatVersion: 2
guid: 18a9ee0f5a424d743b8ba33dd8b7c164
timeCreated: 1502111270
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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


Shader "HDRenderPipeline/LayeredLit"
{
Properties
{
// Following set of parameters represent the parameters node inside the MaterialGraph.
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist.
// All the following properties are filled by the referenced lit shader.
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear
_BaseColor0("BaseColor0", Color) = (1, 1, 1, 1)
_BaseColor1("BaseColor1", Color) = (1, 1, 1, 1)
_BaseColor2("BaseColor2", Color) = (1, 1, 1, 1)
_BaseColor3("BaseColor3", Color) = (1, 1, 1, 1)
_BaseColorMap0("BaseColorMap0", 2D) = "white" {}
_BaseColorMap1("BaseColorMap1", 2D) = "white" {}
_BaseColorMap2("BaseColorMap2", 2D) = "white" {}
_BaseColorMap3("BaseColorMap3", 2D) = "white" {}
_Metallic0("Metallic0", Range(0.0, 1.0)) = 0
_Metallic1("Metallic1", Range(0.0, 1.0)) = 0
_Metallic2("Metallic2", Range(0.0, 1.0)) = 0
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 1.0
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 1.0
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 1.0
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 1.0
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}
_MaskMap2("MaskMap2", 2D) = "white" {}
_MaskMap3("MaskMap3", 2D) = "white" {}
_SpecularOcclusionMap0("SpecularOcclusion0", 2D) = "white" {}
_SpecularOcclusionMap1("SpecularOcclusion1", 2D) = "white" {}
_SpecularOcclusionMap2("SpecularOcclusion2", 2D) = "white" {}
_SpecularOcclusionMap3("SpecularOcclusion3", 2D) = "white" {}
_NormalMap0("NormalMap0", 2D) = "bump" {}
_NormalMap1("NormalMap1", 2D) = "bump" {}
_NormalMap2("NormalMap2", 2D) = "bump" {}
_NormalMap3("NormalMap3", 2D) = "bump" {}
_NormalMapOS0("NormalMapOS0", 2D) = "white" {}
_NormalMapOS1("NormalMapOS1", 2D) = "white" {}
_NormalMapOS2("NormalMapOS2", 2D) = "white" {}
_NormalMapOS3("NormalMapOS3", 2D) = "white" {}
_NormalScale0("_NormalScale0", Range(0.0, 2.0)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 2.0)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 2.0)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 2.0)) = 1
_HeightMap0("HeightMap0", 2D) = "black" {}
_HeightMap1("HeightMap1", 2D) = "black" {}
_HeightMap2("HeightMap2", 2D) = "black" {}
_HeightMap3("HeightMap3", 2D) = "black" {}
_HeightAmplitude0("Height Scale0", Float) = 1
_HeightAmplitude1("Height Scale1", Float) = 1
_HeightAmplitude2("Height Scale2", Float) = 1
_HeightAmplitude3("Height Scale3", Float) = 1
_HeightCenter0("Height Bias0", Float) = 0
_HeightCenter1("Height Bias1", Float) = 0
_HeightCenter2("Height Bias2", Float) = 0
_HeightCenter3("Height Bias3", Float) = 0
_DetailMap0("DetailMap0", 2D) = "black" {}
_DetailMap1("DetailMap1", 2D) = "black" {}
_DetailMap2("DetailMap2", 2D) = "black" {}
_DetailMap3("DetailMap3", 2D) = "black" {}
_DetailMask0("DetailMask0", 2D) = "white" {}
_DetailMask1("DetailMask1", 2D) = "white" {}
_DetailMask2("DetailMask2", 2D) = "white" {}
_DetailMask3("DetailMask3", 2D) = "white" {}
_DetailAlbedoScale0("_DetailAlbedoScale0", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale1("_DetailAlbedoScale1", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale2("_DetailAlbedoScale2", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale3("_DetailAlbedoScale3", Range(-2.0, 2.0)) = 1
_DetailNormalScale0("_DetailNormalScale0", Range(0.0, 2.0)) = 1
_DetailNormalScale1("_DetailNormalScale1", Range(0.0, 2.0)) = 1
_DetailNormalScale2("_DetailNormalScale2", Range(0.0, 2.0)) = 1
_DetailNormalScale3("_DetailNormalScale3", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale0("_DetailSmoothnessScale0", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale1("_DetailSmoothnessScale1", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale2("_DetailSmoothnessScale2", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale3("_DetailSmoothnessScale3", Range(-2.0, 2.0)) = 1
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace0("NormalMap space", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace1("NormalMap space", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace2("NormalMap space", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace3("NormalMap space", Float) = 0
// All the following properties exist only in layered lit material
// Layer blending options
_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0
[Enum(None, 0, Multiply, 1, Add, 2)] _VertexColorMode("Vertex color mode", Float) = 0
[ToggleOff] _ObjectScaleAffectTile("_ObjectScaleAffectTile", Float) = 0.0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBlendMask("UV Set for blendMask", Float) = 0
_TexWorldScaleBlendMask("Tiling", Float) = 1.0
// Following are builtin properties
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
_TexWorldScale0("Tiling", Float) = 1.0
_TexWorldScale1("Tiling", Float) = 1.0
_TexWorldScale2("Tiling", Float) = 1.0
_TexWorldScale3("Tiling", Float) = 1.0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0
[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)
[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
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail2("UV Set for detail2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail3("UV Set for detail3", Float) = 0
[HideInInspector] _UVDetailsMappingMask0("_UVDetailsMappingMask0", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask1("_UVDetailsMappingMask1", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask2("_UVDetailsMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask3("_UVDetailsMappingMask3", Color) = (1, 0, 0, 0)
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
// #pragma enable_d3d11_debug_symbols
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON
#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE
#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
#pragma shader_feature _NORMALMAP_TANGENT_SPACE3
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3
#pragma shader_feature _EMISSIVE_COLOR
#pragma shader_feature _NORMALMAP0
#pragma shader_feature _NORMALMAP1
#pragma shader_feature _NORMALMAP2
#pragma shader_feature _NORMALMAP3
#pragma shader_feature _MASKMAP0
#pragma shader_feature _MASKMAP1
#pragma shader_feature _MASKMAP2
#pragma shader_feature _MASKMAP3
#pragma shader_feature _SPECULAROCCLUSIONMAP0
#pragma shader_feature _SPECULAROCCLUSIONMAP1
#pragma shader_feature _SPECULAROCCLUSIONMAP2
#pragma shader_feature _SPECULAROCCLUSIONMAP3
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP0
#pragma shader_feature _HEIGHTMAP1
#pragma shader_feature _HEIGHTMAP2
#pragma shader_feature _HEIGHTMAP3
#pragma shader_feature _DETAIL_MAP0
#pragma shader_feature _DETAIL_MAP1
#pragma shader_feature _DETAIL_MAP2
#pragma shader_feature _DETAIL_MAP3
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma shader_feature _VERTEX_WIND
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ?
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "../../../ShaderLibrary/common.hlsl"
#include "../../../ShaderLibrary/Wind.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#define _MAX_LAYER 4
#if defined(_LAYEREDLIT_4_LAYERS)
# define _LAYER_COUNT 4
#elif defined(_LAYEREDLIT_3_LAYERS)
# define _LAYER_COUNT 3
#else
# define _LAYER_COUNT 2
#endif
// Explicitely said that we are a layered shader as we share code between lit and layered lit
#define LAYERED_LIT_SHADER
#define LAYERED_LIT_USE_SIMPLE_BLEND
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#include "../../Material/Lit/LitProperties.hlsl"
// All our shaders use same name for entry point
#pragma vertex Vert
#pragma fragment Frag
ENDHLSL
SubShader
{
Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "GBufferDebugDisplay" // Name is not used
Tags{ "LightMode" = "GBufferDebugDisplay" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#define DEBUG_DISPLAY
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugDisplay.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitMetaPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.
HLSLPROGRAM
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitVelocityPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZClip Off
ZWrite On
ZTest LEqual
HLSLPROGRAM
#define SHADERPASS SHADERPASS_SHADOWS
#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Distortion" // Name is not used
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index
Blend One One
ZTest [_ZTestMode]
ZWrite off
Cull [_CullMode]
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DISTORTION
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDistortionPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#define SHADERPASS SHADERPASS_FORWARD
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardDisplayDebug" // Name is not used
Tags{ "LightMode" = "ForwardDisplayDebug" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#define DEBUG_DISPLAY
#define SHADERPASS SHADERPASS_FORWARD
#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugDisplay.hlsl"
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.LayeredLitGUI"
}

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader.meta


fileFormatVersion: 2
guid: 9070af10d08001e4d9219b84e1910d9b
timeCreated: 1502111273
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

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


Shader "HDRenderPipeline/InfluenceLayeredLitTessellation"
{
Properties
{
// Following set of parameters represent the parameters node inside the MaterialGraph.
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist.
// All the following properties are filled by the referenced lit shader.
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear
_BaseColor0("BaseColor0", Color) = (1, 1, 1, 1)
_BaseColor1("BaseColor1", Color) = (1, 1, 1, 1)
_BaseColor2("BaseColor2", Color) = (1, 1, 1, 1)
_BaseColor3("BaseColor3", Color) = (1, 1, 1, 1)
_BaseColorMap0("BaseColorMap0", 2D) = "white" {}
_BaseColorMap1("BaseColorMap1", 2D) = "white" {}
_BaseColorMap2("BaseColorMap2", 2D) = "white" {}
_BaseColorMap3("BaseColorMap3", 2D) = "white" {}
_Metallic0("Metallic0", Range(0.0, 1.0)) = 0
_Metallic1("Metallic1", Range(0.0, 1.0)) = 0
_Metallic2("Metallic2", Range(0.0, 1.0)) = 0
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 1.0
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 1.0
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 1.0
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 1.0
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}
_MaskMap2("MaskMap2", 2D) = "white" {}
_MaskMap3("MaskMap3", 2D) = "white" {}
_SpecularOcclusionMap0("SpecularOcclusion0", 2D) = "white" {}
_SpecularOcclusionMap1("SpecularOcclusion1", 2D) = "white" {}
_SpecularOcclusionMap2("SpecularOcclusion2", 2D) = "white" {}
_SpecularOcclusionMap3("SpecularOcclusion3", 2D) = "white" {}
_NormalMap0("NormalMap0", 2D) = "bump" {}
_NormalMap1("NormalMap1", 2D) = "bump" {}
_NormalMap2("NormalMap2", 2D) = "bump" {}
_NormalMap3("NormalMap3", 2D) = "bump" {}
_NormalMapOS0("NormalMapOS0", 2D) = "white" {}
_NormalMapOS1("NormalMapOS1", 2D) = "white" {}
_NormalMapOS2("NormalMapOS2", 2D) = "white" {}
_NormalMapOS3("NormalMapOS3", 2D) = "white" {}
_NormalScale0("_NormalScale0", Range(0.0, 2.0)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 2.0)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 2.0)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 2.0)) = 1
_HeightMap0("HeightMap0", 2D) = "black" {}
_HeightMap1("HeightMap1", 2D) = "black" {}
_HeightMap2("HeightMap2", 2D) = "black" {}
_HeightMap3("HeightMap3", 2D) = "black" {}
_HeightAmplitude0("Height Scale0", Float) = 1
_HeightAmplitude1("Height Scale1", Float) = 1
_HeightAmplitude2("Height Scale2", Float) = 1
_HeightAmplitude3("Height Scale3", Float) = 1
_HeightCenter0("Height Bias0", Float) = 0
_HeightCenter1("Height Bias1", Float) = 0
_HeightCenter2("Height Bias2", Float) = 0
_HeightCenter3("Height Bias3", Float) = 0
_DetailMap0("DetailMap0", 2D) = "black" {}
_DetailMap1("DetailMap1", 2D) = "black" {}
_DetailMap2("DetailMap2", 2D) = "black" {}
_DetailMap3("DetailMap3", 2D) = "black" {}
_DetailMask0("DetailMask0", 2D) = "white" {}
_DetailMask1("DetailMask1", 2D) = "white" {}
_DetailMask2("DetailMask2", 2D) = "white" {}
_DetailMask3("DetailMask3", 2D) = "white" {}
_DetailAlbedoScale0("_DetailAlbedoScale0", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale1("_DetailAlbedoScale1", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale2("_DetailAlbedoScale2", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale3("_DetailAlbedoScale3", Range(-2.0, 2.0)) = 1
_DetailNormalScale0("_DetailNormalScale0", Range(0.0, 2.0)) = 1
_DetailNormalScale1("_DetailNormalScale1", Range(0.0, 2.0)) = 1
_DetailNormalScale2("_DetailNormalScale2", Range(0.0, 2.0)) = 1
_DetailNormalScale3("_DetailNormalScale3", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale0("_DetailSmoothnessScale0", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale1("_DetailSmoothnessScale1", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale2("_DetailSmoothnessScale2", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale3("_DetailSmoothnessScale3", Range(-2.0, 2.0)) = 1
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace0("NormalMap space", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace1("NormalMap space", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace2("NormalMap space", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace3("NormalMap space", Float) = 0
// All the following properties exist only in layered lit material
// Layer blending options
_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0
// Layer blending options V2
[ToggleOff] _UseDensityMode("Use Density mode", Float) = 0.0
[ToggleOff] _UseMainLayerInfluence("UseMainLayerInfluence", Float) = 0.0
_BlendUsingHeight1("_BlendUsingHeight1", Float) = 0.0
_BlendUsingHeight2("_BlendUsingHeight2", Float) = 0.0
_BlendUsingHeight3("_BlendUsingHeight3", Float) = 0.0
_InheritBaseNormal1("_InheritBaseNormal1", Range(0, 1.0)) = 0.0
_InheritBaseNormal2("_InheritBaseNormal2", Range(0, 1.0)) = 0.0
_InheritBaseNormal3("_InheritBaseNormal3", Range(0, 1.0)) = 0.0
_InheritBaseHeight1("_InheritBaseHeight1", Range(0, 1.0)) = 0.0
_InheritBaseHeight2("_InheritBaseHeight2", Range(0, 1.0)) = 0.0
_InheritBaseHeight3("_InheritBaseHeight3", Range(0, 1.0)) = 0.0
_InheritBaseColor1("_InheritBaseColor1", Range(0, 1.0)) = 0.0
_InheritBaseColor2("_InheritBaseColor2", Range(0, 1.0)) = 0.0
_InheritBaseColor3("_InheritBaseColor3", Range(0, 1.0)) = 0.0
_InheritBaseColorThreshold1("_InheritBaseColorThreshold1", Range(0, 1.0)) = 1.0
_InheritBaseColorThreshold2("_InheritBaseColorThreshold2", Range(0, 1.0)) = 1.0
_InheritBaseColorThreshold3("_InheritBaseColorThreshold3", Range(0, 1.0)) = 1.0
_MinimumOpacity0("_MinimumOpacity0", Range(0, 1.0)) = 1.0
_MinimumOpacity1("_MinimumOpacity1", Range(0, 1.0)) = 1.0
_MinimumOpacity2("_MinimumOpacity2", Range(0, 1.0)) = 1.0
_MinimumOpacity3("_MinimumOpacity3", Range(0, 1.0)) = 1.0
_OpacityAsDensity0("_OpacityAsDensity0", Range(0, 1.0)) = 0.0
_OpacityAsDensity1("_OpacityAsDensity1", Range(0, 1.0)) = 0.0
_OpacityAsDensity2("_OpacityAsDensity2", Range(0, 1.0)) = 0.0
_OpacityAsDensity3("_OpacityAsDensity3", Range(0, 1.0)) = 0.0
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0
[Enum(None, 0, Multiply, 1, Add, 2)] _VertexColorMode("Vertex color mode", Float) = 0
[ToggleOff] _ObjectScaleAffectTile("_ObjectScaleAffectTile", Float) = 0.0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBlendMask("UV Set for blendMask", Float) = 0
_TexWorldScaleBlendMask("Tiling", Float) = 1.0
// Following are builtin properties
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Wind
[ToggleOff] _EnableWind("Enable Wind", Float) = 0.0
_InitialBend("Initial Bend", float) = 1.0
_Stiffness("Stiffness", float) = 1.0
_Drag("Drag", float) = 1.0
_ShiverDrag("Shiver Drag", float) = 0.2
_ShiverDirectionality("Shiver Directionality", Range(0.0, 1.0)) = 0.5
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting (fixed at compile time)
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
_TexWorldScale0("Tiling", Float) = 1.0
_TexWorldScale1("Tiling", Float) = 1.0
_TexWorldScale2("Tiling", Float) = 1.0
_TexWorldScale3("Tiling", Float) = 1.0
[Enum(UV0, 0, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 // no UV1/2/3 for main layer (matching Lit.shader and for PPDisplacement restriction)
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0
[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)
[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
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail2("UV Set for detail2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail3("UV Set for detail3", Float) = 0
[HideInInspector] _UVDetailsMappingMask0("_UVDetailsMappingMask0", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask1("_UVDetailsMappingMask1", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask2("_UVDetailsMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask3("_UVDetailsMappingMask3", Color) = (1, 0, 0, 0)
// Tesselation specific
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 1
_TessellationFactor("Tessellation Factor", Range(0.0, 15.0)) = 4.0
_TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0
_TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 50.0
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0
_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong
_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25
[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0
[ToggleOff] _TessellationTilingScale("Tessellation tiling scale", Float) = 1.0
// TODO: Handle culling mode for backface culling
}
HLSLINCLUDE
#pragma target 5.0
#pragma only_renderers d3d11 ps4 // TEMP: until we go further in dev
// #pragma enable_d3d11_debug_symbols
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON
#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _DOUBLESIDED_ON
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
// Default is _TESSELLATION_PHONG
#pragma shader_feature _ _TESSELLATION_DISPLACEMENT _TESSELLATION_DISPLACEMENT_PHONG
#pragma shader_feature _TESSELLATION_OBJECT_SCALE
#pragma shader_feature _TESSELLATION_TILING_SCALE
#pragma shader_feature _LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE
#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
#pragma shader_feature _NORMALMAP_TANGENT_SPACE3
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3
#pragma shader_feature _EMISSIVE_COLOR
#pragma shader_feature _NORMALMAP0
#pragma shader_feature _NORMALMAP1
#pragma shader_feature _NORMALMAP2
#pragma shader_feature _NORMALMAP3
#pragma shader_feature _MASKMAP0
#pragma shader_feature _MASKMAP1
#pragma shader_feature _MASKMAP2
#pragma shader_feature _MASKMAP3
#pragma shader_feature _SPECULAROCCLUSIONMAP0
#pragma shader_feature _SPECULAROCCLUSIONMAP1
#pragma shader_feature _SPECULAROCCLUSIONMAP2
#pragma shader_feature _SPECULAROCCLUSIONMAP3
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP0
#pragma shader_feature _HEIGHTMAP1
#pragma shader_feature _HEIGHTMAP2
#pragma shader_feature _HEIGHTMAP3
#pragma shader_feature _DETAIL_MAP0
#pragma shader_feature _DETAIL_MAP1
#pragma shader_feature _DETAIL_MAP2
#pragma shader_feature _DETAIL_MAP3
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD
#pragma shader_feature _MAIN_LAYER_INFLUENCE_MODE
#pragma shader_feature _DENSITY_MODE
#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma shader_feature _VERTEX_WIND
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ?
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#define TESSELLATION_ON
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet
#define SURFACE_GRADIENT
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "../../../ShaderLibrary/common.hlsl"
#include "../../../ShaderLibrary/Wind.hlsl"
#include "../../../ShaderLibrary/tessellation.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#define _MAX_LAYER 4
#if defined(_LAYEREDLIT_4_LAYERS)
# define _LAYER_COUNT 4
#elif defined(_LAYEREDLIT_3_LAYERS)
# define _LAYER_COUNT 3
#else
# define _LAYER_COUNT 2
#endif
// Explicitely said that we are a layered shader as we share code between lit and layered lit
#define LAYERED_LIT_SHADER
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#include "../../Material/Lit/LitProperties.hlsl"
// All our shaders use same name for entry point
#pragma vertex Vert
#pragma fragment Frag
ENDHLSL
SubShader
{
Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "GBufferDebugDisplay" // Name is not used
Tags{ "LightMode" = "GBufferDebugDisplay" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
Stencil
{
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define DEBUG_DISPLAY
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugDisplay.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
// No tessellation for Meta pass
#undef TESSELLATION_ON
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitMetaPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.
HLSLPROGRAM
// TODO: Tesselation can't work with velocity for now...
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitVelocityPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZClip Off
ZWrite On
ZTest LEqual
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_SHADOWS
#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Distortion" // Name is not used
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index
Blend One One
ZTest [_ZTestMode]
ZWrite off
Cull [_CullMode]
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DISTORTION
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDistortionPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_FORWARD
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardDisplayDebug" // Name is not used
Tags{ "LightMode" = "ForwardDisplayDebug" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#pragma hull Hull
#pragma domain Domain
#define DEBUG_DISPLAY
#define SHADERPASS SHADERPASS_FORWARD
#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugDisplay.hlsl"
#include "../../Lighting/Forward.hlsl"
// TEMP until pragma work in include
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.LayeredLitGUI"
}

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader.meta


fileFormatVersion: 2
guid: 5545a01b759c7594e8ded2415804ebb6
timeCreated: 1502111273
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存