Yao Xiaoling
7 年前
当前提交
5639b1fc
共有 5 个文件被更改,包括 1476 次插入 和 18 次删除
-
45ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/BaseUnlitUI.cs
-
772ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/LayeredLit/TerrainUI.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/LayeredLit/TerrainUI.cs.meta
-
657ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/Terrain.shader
-
9ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/Terrain.shader.meta
|
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
using System.Linq; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class TerrainGUI : LitGUI |
|||
{ |
|||
public enum VertexColorMode |
|||
{ |
|||
None, |
|||
Multiply, |
|||
Add |
|||
} |
|||
|
|||
private class StylesLayer |
|||
{ |
|||
public readonly Color[] layerColors = |
|||
{ |
|||
Color.white, |
|||
Color.red, |
|||
Color.green, |
|||
Color.blue |
|||
}; |
|||
|
|||
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 syncAllButtonText = new GUIContent("Re-Synchronize", "Re-synchronize all layers material properties with the referenced Materials"); |
|||
public readonly GUIContent syncAllButUVButtonText = new GUIContent("Re-Synchronize Without UV Mapping", "Re-synchronize all but UV Mapping properties with the referenced Materials"); |
|||
public readonly GUIContent layersText = new GUIContent("Inputs"); |
|||
public readonly GUIContent emissiveText = new GUIContent("Emissive"); |
|||
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask"); |
|||
public readonly GUIContent layerInfluenceMapMaskText = new GUIContent("Layer Influence 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 objectScaleAffectTileText = new GUIContent("Lock layers 0123 tiling with object Scale", "Tiling of each layers will be affected by the object scale."); |
|||
public readonly GUIContent objectScaleAffectTileText2 = new GUIContent("Lock layers 123 tiling with object Scale", "Tiling of each influenced layers (all except main layer) 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 readonly GUIContent layeringOptionText = new GUIContent("Layering Options"); |
|||
|
|||
public readonly GUIContent useHeightBasedBlendText = new GUIContent("Use Height Based Blend", "Layer will be blended with the underlying layer based on the height."); |
|||
public readonly GUIContent useMainLayerInfluenceModeText = new GUIContent("Main Layer Influence", "Switch between regular layers mode and base/layers mode"); |
|||
|
|||
public readonly GUIContent opacityAsDensityText = new GUIContent("Use Opacity map as Density map", "Use opacity map as (alpha channel of base color) as Density map."); |
|||
public readonly GUIContent inheritBaseNormalText = new GUIContent("Normal influence", "Inherit the normal from the base layer."); |
|||
public readonly GUIContent inheritBaseHeightText = new GUIContent("Heightmap influence", "Inherit the height from the base layer."); |
|||
public readonly GUIContent inheritBaseColorText = new GUIContent("BaseColor influence", "Inherit the base color from the base layer."); |
|||
public readonly GUIContent heightTransition = new GUIContent("Height Transition", "Size in world units of the smooth transition between layers."); |
|||
|
|||
public readonly GUIContent perPixelDisplacementLayersWarning = new GUIContent("For pixel displacement to work correctly, all layers with a heightmap must use the same UV mapping"); |
|||
|
|||
public readonly GUIContent materialReferencesText = new GUIContent("Material References"); |
|||
|
|||
public StylesLayer() |
|||
{ |
|||
layerLabelColors[0].normal.textColor = layerColors[0]; |
|||
layerLabelColors[1].normal.textColor = layerColors[1]; |
|||
layerLabelColors[2].normal.textColor = layerColors[2]; |
|||
layerLabelColors[3].normal.textColor = layerColors[3]; |
|||
} |
|||
} |
|||
|
|||
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 kSyncButtonWidth = 58; |
|||
|
|||
public TerrainGUI() |
|||
{ |
|||
m_LayerCount = 4; |
|||
m_PropertySuffixes[0] = "0"; |
|||
m_PropertySuffixes[1] = "1"; |
|||
m_PropertySuffixes[2] = "2"; |
|||
m_PropertySuffixes[3] = "3"; |
|||
} |
|||
|
|||
Material[] m_MaterialLayers = new Material[kMaxLayerCount]; |
|||
|
|||
// Layer options
|
|||
MaterialProperty layerCount = null; |
|||
const string kLayerCount = "_LayerCount"; |
|||
MaterialProperty layerMaskMap = null; |
|||
const string kLayerMaskMap = "_LayerMaskMap"; |
|||
MaterialProperty layerInfluenceMaskMap = null; |
|||
const string kLayerInfluenceMaskMap = "_LayerInfluenceMaskMap"; |
|||
MaterialProperty vertexColorMode = null; |
|||
const string kVertexColorMode = "_VertexColorMode"; |
|||
MaterialProperty objectScaleAffectTile = null; |
|||
const string kObjectScaleAffectTile = "_ObjectScaleAffectTile"; |
|||
MaterialProperty UVBlendMask = null; |
|||
const string kUVBlendMask = "_UVBlendMask"; |
|||
MaterialProperty UVMappingMaskBlendMask = null; |
|||
const string kUVMappingMaskBlendMask = "_UVMappingMaskBlendMask"; |
|||
MaterialProperty texWorldScaleBlendMask = null; |
|||
const string kTexWorldScaleBlendMask = "_TexWorldScaleBlendMask"; |
|||
MaterialProperty useMainLayerInfluence = null; |
|||
const string kkUseMainLayerInfluence = "_UseMainLayerInfluence"; |
|||
MaterialProperty useHeightBasedBlend = null; |
|||
const string kUseHeightBasedBlend = "_UseHeightBasedBlend"; |
|||
|
|||
// Density/opacity mode
|
|||
MaterialProperty[] opacityAsDensity = new MaterialProperty[kMaxLayerCount]; |
|||
const string kOpacityAsDensity = "_OpacityAsDensity"; |
|||
|
|||
// Influence
|
|||
MaterialProperty[] inheritBaseNormal = new MaterialProperty[kMaxLayerCount - 1]; |
|||
const string kInheritBaseNormal = "_InheritBaseNormal"; |
|||
MaterialProperty[] inheritBaseHeight = new MaterialProperty[kMaxLayerCount - 1]; |
|||
const string kInheritBaseHeight = "_InheritBaseHeight"; |
|||
MaterialProperty[] inheritBaseColor = new MaterialProperty[kMaxLayerCount - 1]; |
|||
const string kInheritBaseColor = "_InheritBaseColor"; |
|||
|
|||
// Height blend
|
|||
MaterialProperty heightTransition = null; |
|||
const string kHeightTransition = "_HeightTransition"; |
|||
|
|||
// UI
|
|||
MaterialProperty showMaterialReferences = null; |
|||
const string kShowMaterialReferences = "_ShowMaterialReferences"; |
|||
MaterialProperty[] showLayer = new MaterialProperty[kMaxLayerCount]; |
|||
const string kShowLayer = "_ShowLayer"; |
|||
|
|||
bool m_UseHeightBasedBlend; |
|||
|
|||
protected override void FindMaterialProperties(MaterialProperty[] props) |
|||
{ |
|||
base.FindMaterialLayerProperties(props); |
|||
base.FindMaterialEmissiveProperties(props); |
|||
|
|||
layerCount = FindProperty(kLayerCount, props); |
|||
layerMaskMap = FindProperty(kLayerMaskMap, props); |
|||
layerInfluenceMaskMap = FindProperty(kLayerInfluenceMaskMap, props); |
|||
vertexColorMode = FindProperty(kVertexColorMode, props); |
|||
objectScaleAffectTile = FindProperty(kObjectScaleAffectTile, props); |
|||
UVBlendMask = FindProperty(kUVBlendMask, props); |
|||
UVMappingMaskBlendMask = FindProperty(kUVMappingMaskBlendMask, props); |
|||
texWorldScaleBlendMask = FindProperty(kTexWorldScaleBlendMask, props); |
|||
|
|||
useMainLayerInfluence = FindProperty(kkUseMainLayerInfluence, props); |
|||
useHeightBasedBlend = FindProperty(kUseHeightBasedBlend, props); |
|||
heightTransition = FindProperty(kHeightTransition, props); |
|||
|
|||
showMaterialReferences = FindProperty(kShowMaterialReferences, props); |
|||
|
|||
for (int i = 0; i < kMaxLayerCount; ++i) |
|||
{ |
|||
// Density/opacity mode
|
|||
opacityAsDensity[i] = FindProperty(string.Format("{0}{1}", kOpacityAsDensity, i), props); |
|||
showLayer[i] = FindProperty(string.Format("{0}{1}", kShowLayer, i), props); |
|||
|
|||
if (i != 0) |
|||
{ |
|||
// Influence
|
|||
inheritBaseNormal[i - 1] = FindProperty(string.Format("{0}{1}", kInheritBaseNormal, i), props); |
|||
inheritBaseHeight[i - 1] = FindProperty(string.Format("{0}{1}", kInheritBaseHeight, i), props); |
|||
inheritBaseColor[i - 1] = FindProperty(string.Format("{0}{1}", kInheritBaseColor, i), 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, true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void SynchronizeAllLayersProperties(bool excludeUVMappingProperties) |
|||
{ |
|||
for (int i = 0; i < numLayer; ++i) |
|||
{ |
|||
SynchronizeLayerProperties(m_MaterialEditor.target as Material, m_MaterialLayers, i, excludeUVMappingProperties); |
|||
} |
|||
} |
|||
|
|||
// This function will look for all referenced lit material, and assign value from Lit to layered lit layers.
|
|||
// This is based on the naming of the variables, i.E BaseColor will match BaseColor0, if a properties shouldn't be override
|
|||
// put the name in the exclusionList below
|
|||
static void SynchronizeLayerProperties(Material material, Material[] layers, int layerIndex, bool excludeUVMappingProperties) |
|||
{ |
|||
Material layerMaterial = layers[layerIndex]; |
|||
string[] exclusionList = { kTexWorldScale, kUVBase, kUVMappingMask, kUVDetail, kUVDetailsMappingMask }; |
|||
|
|||
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 (!exclusionList.Contains(propertyName) || !excludeUVMappingProperties) |
|||
{ |
|||
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)); |
|||
if(!excludeUVMappingProperties) |
|||
{ |
|||
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 DoLayerGUI(AssetImporter materialImporter, int layerIndex) |
|||
{ |
|||
bool result = false; |
|||
|
|||
showLayer[layerIndex].floatValue = EditorGUILayout.Foldout(showLayer[layerIndex].floatValue != 0.0f, styles.layerLabels[layerIndex], styles.layerLabelColors[layerIndex]) ? 1.0f : 0.0f; |
|||
if (showLayer[layerIndex].floatValue == 0.0f) |
|||
return false; |
|||
; |
|||
|
|||
Material material = m_MaterialEditor.target as Material; |
|||
|
|||
bool mainLayerInfluenceEnable = useMainLayerInfluence.floatValue > 0.0f; |
|||
|
|||
// Main layer does not have any options but height base blend.
|
|||
if (layerIndex > 0) |
|||
{ |
|||
EditorGUILayout.LabelField(styles.layeringOptionText, EditorStyles.boldLabel); |
|||
EditorGUI.indentLevel++; |
|||
|
|||
int paramIndex = layerIndex - 1; |
|||
|
|||
m_MaterialEditor.ShaderProperty(opacityAsDensity[layerIndex], styles.opacityAsDensityText); |
|||
|
|||
if (mainLayerInfluenceEnable) |
|||
{ |
|||
m_MaterialEditor.ShaderProperty(inheritBaseColor[paramIndex], styles.inheritBaseColorText); |
|||
m_MaterialEditor.ShaderProperty(inheritBaseNormal[paramIndex], styles.inheritBaseNormalText); |
|||
// Main height influence is only available if the shader use the heightmap for displacement (per vertex or per level)
|
|||
// We always display it as it can be tricky to know when per pixel displacement is enabled or not
|
|||
m_MaterialEditor.ShaderProperty(inheritBaseHeight[paramIndex], styles.inheritBaseHeightText); |
|||
} |
|||
|
|||
EditorGUI.indentLevel--; |
|||
} |
|||
else |
|||
{ |
|||
if (!useMainLayerInfluence.hasMixedValue && useMainLayerInfluence.floatValue != 0.0f) |
|||
{ |
|||
EditorGUILayout.LabelField(styles.layeringOptionText, EditorStyles.boldLabel); |
|||
EditorGUI.indentLevel++; |
|||
|
|||
m_MaterialEditor.TexturePropertySingleLine(styles.layerInfluenceMapMaskText, layerInfluenceMaskMap); |
|||
|
|||
EditorGUI.indentLevel--; |
|||
} |
|||
} |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
DoLayerGUI(material, layerIndex, true, m_UseHeightBasedBlend); |
|||
|
|||
if (layerIndex == 0) |
|||
EditorGUILayout.Space(); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
void DoLayeringInputGUI() |
|||
{ |
|||
EditorGUI.indentLevel++; |
|||
GUILayout.Label(styles.layersText, EditorStyles.boldLabel); |
|||
|
|||
EditorGUI.showMixedValue = layerCount.hasMixedValue; |
|||
EditorGUI.BeginChangeCheck(); |
|||
int newLayerCount = EditorGUILayout.IntSlider(styles.layerCountText, (int)layerCount.floatValue, 2, 4); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Material material = m_MaterialEditor.target as Material; |
|||
Undo.RecordObject(material, "Change layer count"); |
|||
layerCount.floatValue = (float)newLayerCount; |
|||
} |
|||
|
|||
m_MaterialEditor.TexturePropertySingleLine(styles.layerMapMaskText, layerMaskMap); |
|||
|
|||
EditorGUI.indentLevel++; |
|||
m_MaterialEditor.ShaderProperty(UVBlendMask, styles.UVBlendMaskText); |
|||
UVBaseMapping uvBlendMask = (UVBaseMapping)UVBlendMask.floatValue; |
|||
|
|||
float X, Y, Z, W; |
|||
X = (uvBlendMask == UVBaseMapping.UV0) ? 1.0f : 0.0f; |
|||
Y = (uvBlendMask == UVBaseMapping.UV1) ? 1.0f : 0.0f; |
|||
Z = (uvBlendMask == UVBaseMapping.UV2) ? 1.0f : 0.0f; |
|||
W = (uvBlendMask == UVBaseMapping.UV3) ? 1.0f : 0.0f; |
|||
|
|||
UVMappingMaskBlendMask.colorValue = new Color(X, Y, Z, W); |
|||
|
|||
if (((UVBaseMapping)UVBlendMask.floatValue == UVBaseMapping.Planar) || |
|||
((UVBaseMapping)UVBlendMask.floatValue == UVBaseMapping.Triplanar)) |
|||
{ |
|||
m_MaterialEditor.ShaderProperty(texWorldScaleBlendMask, styles.layerTexWorldScaleText); |
|||
} |
|||
m_MaterialEditor.TextureScaleOffsetProperty(layerMaskMap); |
|||
EditorGUI.indentLevel--; |
|||
|
|||
m_MaterialEditor.ShaderProperty(vertexColorMode, styles.vertexColorModeText); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.showMixedValue = useMainLayerInfluence.hasMixedValue; |
|||
bool mainLayerModeInfluenceEnable = EditorGUILayout.Toggle(styles.useMainLayerInfluenceModeText, useMainLayerInfluence.floatValue > 0.0f); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
useMainLayerInfluence.floatValue = mainLayerModeInfluenceEnable ? 1.0f : 0.0f; |
|||
} |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.showMixedValue = useHeightBasedBlend.hasMixedValue; |
|||
m_UseHeightBasedBlend = EditorGUILayout.Toggle(styles.useHeightBasedBlendText, useHeightBasedBlend.floatValue > 0.0f); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
useHeightBasedBlend.floatValue = m_UseHeightBasedBlend ? 1.0f : 0.0f; |
|||
} |
|||
|
|||
if (m_UseHeightBasedBlend) |
|||
{ |
|||
EditorGUI.indentLevel++; |
|||
m_MaterialEditor.ShaderProperty(heightTransition, styles.heightTransition); |
|||
EditorGUI.indentLevel--; |
|||
} |
|||
|
|||
m_MaterialEditor.ShaderProperty(objectScaleAffectTile, mainLayerModeInfluenceEnable ? styles.objectScaleAffectTileText2 : styles.objectScaleAffectTileText); |
|||
EditorGUI.indentLevel--; |
|||
} |
|||
|
|||
bool DoMaterialReferencesGUI(AssetImporter materialImporter) |
|||
{ |
|||
showMaterialReferences.floatValue = EditorGUILayout.Foldout(showMaterialReferences.floatValue != 0.0f, styles.materialReferencesText, styles.layerLabelColors[0]) ? 1.0f : 0.0f; |
|||
if (showMaterialReferences.floatValue == 0.0f) |
|||
return false; |
|||
|
|||
bool layersChanged = false; |
|||
Material material = m_MaterialEditor.target as Material; |
|||
|
|||
Color originalContentColor = GUI.contentColor; |
|||
|
|||
for (int layerIndex = 0; layerIndex < numLayer; ++layerIndex) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
GUI.contentColor = styles.layerColors[layerIndex]; |
|||
|
|||
m_MaterialLayers[layerIndex] = EditorGUILayout.ObjectField(styles.layerLabels[layerIndex], m_MaterialLayers[layerIndex], typeof(Material), true) as Material; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Undo.RecordObject(materialImporter, "Change layer material"); |
|||
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true); |
|||
layersChanged = true; |
|||
} |
|||
|
|||
GUI.contentColor = originalContentColor; |
|||
|
|||
GUILayout.BeginHorizontal(); |
|||
{ |
|||
GUILayout.FlexibleSpace(); |
|||
if (GUILayout.Button(styles.syncAllButUVButtonText)) |
|||
{ |
|||
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true); |
|||
layersChanged = true; |
|||
} |
|||
if (GUILayout.Button(styles.syncAllButtonText)) |
|||
{ |
|||
SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, false); |
|||
layersChanged = true; |
|||
} |
|||
} |
|||
GUILayout.EndHorizontal(); |
|||
} |
|||
|
|||
return layersChanged; |
|||
} |
|||
|
|||
bool DoLayersGUI(AssetImporter materialImporter) |
|||
{ |
|||
bool layerChanged = false; |
|||
|
|||
GUI.changed = false; |
|||
|
|||
DoLayeringInputGUI(); |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
layerChanged |= DoMaterialReferencesGUI(materialImporter); |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
for (int i = 0; i < numLayer; i++) |
|||
{ |
|||
layerChanged |= DoLayerGUI(materialImporter, i); |
|||
} |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
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
|
|||
CoreUtils.SetKeyword(material, "_LAYER_TILING_COUPLED_WITH_UNIFORM_OBJECT_SCALE", material.GetFloat(kObjectScaleAffectTile) > 0.0f); |
|||
|
|||
// Blend mask
|
|||
UVBaseMapping UVBlendMaskMapping = (UVBaseMapping)material.GetFloat(kUVBlendMask); |
|||
CoreUtils.SetKeyword(material, "_LAYER_MAPPING_PLANAR_BLENDMASK", UVBlendMaskMapping == UVBaseMapping.Planar); |
|||
CoreUtils.SetKeyword(material, "_LAYER_MAPPING_TRIPLANAR_BLENDMASK", UVBlendMaskMapping == UVBaseMapping.Triplanar); |
|||
|
|||
int numLayer = (int)material.GetFloat(kLayerCount); |
|||
|
|||
// Layer
|
|||
if (numLayer == 4) |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_LAYEREDLIT_4_LAYERS", true); |
|||
CoreUtils.SetKeyword(material, "_LAYEREDLIT_3_LAYERS", false); |
|||
} |
|||
else if (numLayer == 3) |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_LAYEREDLIT_4_LAYERS", false); |
|||
CoreUtils.SetKeyword(material, "_LAYEREDLIT_3_LAYERS", true); |
|||
} |
|||
else |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_LAYEREDLIT_4_LAYERS", false); |
|||
CoreUtils.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); |
|||
UVBaseMapping layerUVBaseMapping = (UVBaseMapping)material.GetFloat(layerUVBaseParam); |
|||
string currentLayerMappingPlanar = string.Format("{0}{1}", kLayerMappingPlanar, i); |
|||
CoreUtils.SetKeyword(material, currentLayerMappingPlanar, layerUVBaseMapping == UVBaseMapping.Planar); |
|||
string currentLayerMappingTriplanar = string.Format("{0}{1}", kLayerMappingTriplanar, i); |
|||
CoreUtils.SetKeyword(material, currentLayerMappingTriplanar, layerUVBaseMapping == UVBaseMapping.Triplanar); |
|||
|
|||
string uvBase = string.Format("{0}{1}", kUVBase, i); |
|||
string uvDetail = string.Format("{0}{1}", kUVDetail, i); |
|||
|
|||
if (((UVDetailMapping)material.GetFloat(uvDetail) == UVDetailMapping.UV2) || ((UVBaseMapping)material.GetFloat(uvBase) == UVBaseMapping.UV2)) |
|||
{ |
|||
needUV2 = true; |
|||
} |
|||
|
|||
if (((UVDetailMapping)material.GetFloat(uvDetail) == UVDetailMapping.UV3) || ((UVBaseMapping)material.GetFloat(uvBase) == UVBaseMapping.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)); |
|||
|
|||
CoreUtils.SetKeyword(material, "_NORMALMAP_TANGENT_SPACE" + i, normalMapSpace == NormalMapSpace.TangentSpace); |
|||
|
|||
if (normalMapSpace == NormalMapSpace.TangentSpace) |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_NORMALMAP" + i, material.GetTexture(kNormalMap + i) || material.GetTexture(kDetailMap + i)); |
|||
CoreUtils.SetKeyword(material, "_BENTNORMALMAP" + i, material.GetTexture(kBentNormalMap + i)); |
|||
} |
|||
else |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_NORMALMAP" + i, material.GetTexture(kNormalMapOS + i) || material.GetTexture(kDetailMap + i)); |
|||
CoreUtils.SetKeyword(material, "_BENTNORMALMAP" + i, material.GetTexture(kBentNormalMapOS + i)); |
|||
} |
|||
|
|||
CoreUtils.SetKeyword(material, "_MASKMAP" + i, material.GetTexture(kMaskMap + i)); |
|||
|
|||
CoreUtils.SetKeyword(material, "_DETAIL_MAP" + i, material.GetTexture(kDetailMap + i)); |
|||
|
|||
CoreUtils.SetKeyword(material, "_HEIGHTMAP" + i, material.GetTexture(kHeightMap + i)); |
|||
|
|||
CoreUtils.SetKeyword(material, "_SUBSURFACE_MASK_MAP" + i, material.GetTexture(kSubsurfaceMaskMap + i)); |
|||
CoreUtils.SetKeyword(material, "_THICKNESSMAP" + i, material.GetTexture(kThicknessMap + i)); |
|||
} |
|||
|
|||
CoreUtils.SetKeyword(material, "_INFLUENCEMASK_MAP", material.GetTexture(kLayerInfluenceMaskMap) && material.GetFloat(kkUseMainLayerInfluence) != 0.0f); |
|||
|
|||
CoreUtils.SetKeyword(material, "_EMISSIVE_MAPPING_PLANAR", ((UVBaseMapping)material.GetFloat(kUVEmissive)) == UVBaseMapping.Planar && material.GetTexture(kEmissiveColorMap)); |
|||
CoreUtils.SetKeyword(material, "_EMISSIVE_MAPPING_TRIPLANAR", ((UVBaseMapping)material.GetFloat(kUVEmissive)) == UVBaseMapping.Triplanar && material.GetTexture(kEmissiveColorMap)); |
|||
CoreUtils.SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap)); |
|||
CoreUtils.SetKeyword(material, "_ENABLESPECULAROCCLUSION", material.GetFloat(kEnableSpecularOcclusion) > 0.0f); |
|||
|
|||
CoreUtils.SetKeyword(material, "_MAIN_LAYER_INFLUENCE_MODE", material.GetFloat(kkUseMainLayerInfluence) != 0.0f); |
|||
|
|||
VertexColorMode VCMode = (VertexColorMode)material.GetFloat(kVertexColorMode); |
|||
if (VCMode == VertexColorMode.Multiply) |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", true); |
|||
CoreUtils.SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", false); |
|||
} |
|||
else if (VCMode == VertexColorMode.Add) |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", false); |
|||
CoreUtils.SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", true); |
|||
} |
|||
else |
|||
{ |
|||
CoreUtils.SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", false); |
|||
CoreUtils.SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", false); |
|||
} |
|||
|
|||
bool useHeightBasedBlend = material.GetFloat(kUseHeightBasedBlend) != 0.0f; |
|||
CoreUtils.SetKeyword(material, "_HEIGHT_BASED_BLEND", useHeightBasedBlend); |
|||
|
|||
bool useDensityModeEnable = false; |
|||
for (int i = 0; i < material.GetInt(kLayerCount); ++i ) |
|||
{ |
|||
useDensityModeEnable |= material.GetFloat(kOpacityAsDensity + i) != 0.0f; |
|||
} |
|||
CoreUtils.SetKeyword(material, "_DENSITY_MODE", useDensityModeEnable); |
|||
|
|||
BaseLitGUI.MaterialId materialId = (BaseLitGUI.MaterialId)material.GetFloat(kMaterialID); |
|||
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_SUBSURFACE_SCATTERING", materialId == BaseLitGUI.MaterialId.LitSSS); |
|||
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_TRANSMISSION", materialId == BaseLitGUI.MaterialId.LitTranslucent || (materialId == BaseLitGUI.MaterialId.LitSSS && material.GetFloat(kTransmissionEnable) > 0.0f)); |
|||
} |
|||
|
|||
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; |
|||
} |
|||
|
|||
// In case of pixel displacement and layered shader, all layers must used the same texture mapping for layer that have a heightmap
|
|||
// (Else the algorithm will not work correctly)
|
|||
if ((DisplacementMode)displacementMode.floatValue == DisplacementMode.Pixel) |
|||
{ |
|||
float compareValue = -1.0f; |
|||
bool match = true; |
|||
|
|||
if (material.GetTexture(kHeightMap + 0)) |
|||
{ |
|||
compareValue = UVBase[0].floatValue; |
|||
} |
|||
if (material.GetTexture(kHeightMap + 1)) |
|||
{ |
|||
if (compareValue == -1.0f) |
|||
compareValue = UVBase[1].floatValue; |
|||
else if (compareValue != UVBase[1].floatValue) |
|||
match = false; |
|||
} |
|||
if (material.GetTexture(kHeightMap + 2)) |
|||
{ |
|||
if (compareValue == -1.0f) |
|||
compareValue = UVBase[2].floatValue; |
|||
else if (compareValue != UVBase[2].floatValue) |
|||
match = false; |
|||
} |
|||
if (material.GetTexture(kHeightMap + 3)) |
|||
{ |
|||
if (compareValue == -1.0f) |
|||
compareValue = UVBase[3].floatValue; |
|||
else if (compareValue != UVBase[3].floatValue) |
|||
match = false; |
|||
} |
|||
|
|||
if (!match) |
|||
{ |
|||
EditorGUILayout.HelpBox(styles.perPixelDisplacementLayersWarning.text, MessageType.Warning); |
|||
} |
|||
} |
|||
|
|||
|
|||
bool layerChanged = DoLayersGUI(materialImporter); |
|||
EditorGUI.BeginChangeCheck(); |
|||
{ |
|||
DoEmissiveGUI(material); |
|||
} |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
optionsChanged = true; |
|||
} |
|||
|
|||
DoEmissionArea(material); |
|||
|
|||
EditorGUILayout.Space(); |
|||
EditorGUILayout.LabelField(StylesBaseUnlit.advancedText, EditorStyles.boldLabel); |
|||
// NB RenderQueue editor is not shown on purpose: we want to override it based on blend mode
|
|||
EditorGUI.indentLevel++; |
|||
m_MaterialEditor.EnableInstancingField(); |
|||
m_MaterialEditor.ShaderProperty(enableSpecularOcclusion, Styles.enableSpecularOcclusionText); |
|||
EditorGUI.indentLevel--; |
|||
|
|||
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
|
|
|||
fileFormatVersion: 2 |
|||
guid: 78c37e59d7a0b984dbe6f0a32ef67f2f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "HDRenderPipeline/Terrain" |
|||
{ |
|||
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 |
|||
|
|||
_SmoothnessRemapMin0("SmoothnessRemapMin0", Range(0.0, 1.0)) = 0.0 |
|||
_SmoothnessRemapMin1("SmoothnessRemapMin1", Range(0.0, 1.0)) = 0.0 |
|||
_SmoothnessRemapMin2("SmoothnessRemapMin2", Range(0.0, 1.0)) = 0.0 |
|||
_SmoothnessRemapMin3("SmoothnessRemapMin3", Range(0.0, 1.0)) = 0.0 |
|||
|
|||
_SmoothnessRemapMax0("SmoothnessRemapMax0", Range(0.0, 1.0)) = 1.0 |
|||
_SmoothnessRemapMax1("SmoothnessRemapMax1", Range(0.0, 1.0)) = 1.0 |
|||
_SmoothnessRemapMax2("SmoothnessRemapMax2", Range(0.0, 1.0)) = 1.0 |
|||
_SmoothnessRemapMax3("SmoothnessRemapMax3", Range(0.0, 1.0)) = 1.0 |
|||
|
|||
_AORemapMin0("AORemapMin0", Range(0.0, 1.0)) = 0.0 |
|||
_AORemapMin1("AORemapMin1", Range(0.0, 1.0)) = 0.0 |
|||
_AORemapMin2("AORemapMin2", Range(0.0, 1.0)) = 0.0 |
|||
_AORemapMin3("AORemapMin3", Range(0.0, 1.0)) = 0.0 |
|||
|
|||
_AORemapMax0("AORemapMax0", Range(0.0, 1.0)) = 1.0 |
|||
_AORemapMax1("AORemapMax1", Range(0.0, 1.0)) = 1.0 |
|||
_AORemapMax2("AORemapMax2", Range(0.0, 1.0)) = 1.0 |
|||
_AORemapMax3("AORemapMax3", Range(0.0, 1.0)) = 1.0 |
|||
|
|||
_MaskMap0("MaskMap0", 2D) = "white" {} |
|||
_MaskMap1("MaskMap1", 2D) = "white" {} |
|||
_MaskMap2("MaskMap2", 2D) = "white" {} |
|||
_MaskMap3("MaskMap3", 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 |
|||
|
|||
_BentNormalMap0("BentNormalMap0", 2D) = "bump" {} |
|||
_BentNormalMap1("BentNormalMap1", 2D) = "bump" {} |
|||
_BentNormalMap2("BentNormalMap2", 2D) = "bump" {} |
|||
_BentNormalMap3("BentNormalMap3", 2D) = "bump" {} |
|||
|
|||
_BentNormalMapOS0("BentNormalMapOS0", 2D) = "white" {} |
|||
_BentNormalMapOS1("BentNormalMapOS1", 2D) = "white" {} |
|||
_BentNormalMapOS2("BentNormalMapOS2", 2D) = "white" {} |
|||
_BentNormalMapOS3("BentNormalMapOS3", 2D) = "white" {} |
|||
|
|||
_HeightMap0("HeightMap0", 2D) = "black" {} |
|||
_HeightMap1("HeightMap1", 2D) = "black" {} |
|||
_HeightMap2("HeightMap2", 2D) = "black" {} |
|||
_HeightMap3("HeightMap3", 2D) = "black" {} |
|||
|
|||
// Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 |
|||
// Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. |
|||
[HideInInspector] _HeightAmplitude0("Height Scale0", Float) = 0.02 |
|||
[HideInInspector] _HeightAmplitude1("Height Scale1", Float) = 0.02 |
|||
[HideInInspector] _HeightAmplitude2("Height Scale2", Float) = 0.02 |
|||
[HideInInspector] _HeightAmplitude3("Height Scale3", Float) = 0.02 |
|||
[HideInInspector] _HeightCenter0("Height Bias0", Range(0.0, 1.0)) = 0.5 |
|||
[HideInInspector] _HeightCenter1("Height Bias1", Range(0.0, 1.0)) = 0.5 |
|||
[HideInInspector] _HeightCenter2("Height Bias2", Range(0.0, 1.0)) = 0.5 |
|||
[HideInInspector] _HeightCenter3("Height Bias3", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization0("Heightmap Parametrization0", Int) = 0 |
|||
[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization1("Heightmap Parametrization1", Int) = 0 |
|||
[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization2("Heightmap Parametrization2", Int) = 0 |
|||
[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization3("Heightmap Parametrization3", Int) = 0 |
|||
// These parameters are for vertex displacement/Tessellation |
|||
_HeightOffset0("Height Offset0", Float) = 0 |
|||
_HeightOffset1("Height Offset1", Float) = 0 |
|||
_HeightOffset2("Height Offset2", Float) = 0 |
|||
_HeightOffset3("Height Offset3", Float) = 0 |
|||
// MinMax mode |
|||
_HeightMin0("Height Min0", Float) = -1 |
|||
_HeightMin1("Height Min1", Float) = -1 |
|||
_HeightMin2("Height Min2", Float) = -1 |
|||
_HeightMin3("Height Min3", Float) = -1 |
|||
_HeightMax0("Height Max0", Float) = 1 |
|||
_HeightMax1("Height Max1", Float) = 1 |
|||
_HeightMax2("Height Max2", Float) = 1 |
|||
_HeightMax3("Height Max3", Float) = 1 |
|||
|
|||
// Amplitude mode |
|||
_HeightTessAmplitude0("Amplitude0", Float) = 2.0 // in Centimeters |
|||
_HeightTessAmplitude1("Amplitude1", Float) = 2.0 // in Centimeters |
|||
_HeightTessAmplitude2("Amplitude2", Float) = 2.0 // in Centimeters |
|||
_HeightTessAmplitude3("Amplitude3", Float) = 2.0 // in Centimeters |
|||
_HeightTessCenter0("Height Bias0", Range(0.0, 1.0)) = 0.5 |
|||
_HeightTessCenter1("Height Bias1", Range(0.0, 1.0)) = 0.5 |
|||
_HeightTessCenter2("Height Bias2", Range(0.0, 1.0)) = 0.5 |
|||
_HeightTessCenter3("Height Bias3", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
// These parameters are for pixel displacement |
|||
_HeightPoMAmplitude0("Height Amplitude0", Float) = 2.0 // In centimeters |
|||
_HeightPoMAmplitude1("Height Amplitude1", Float) = 2.0 // In centimeters |
|||
_HeightPoMAmplitude2("Height Amplitude2", Float) = 2.0 // In centimeters |
|||
_HeightPoMAmplitude3("Height Amplitude3", Float) = 2.0 // In centimeters |
|||
|
|||
_DetailMap0("DetailMap0", 2D) = "black" {} |
|||
_DetailMap1("DetailMap1", 2D) = "black" {} |
|||
_DetailMap2("DetailMap2", 2D) = "black" {} |
|||
_DetailMap3("DetailMap3", 2D) = "black" {} |
|||
|
|||
_DetailAlbedoScale0("_DetailAlbedoScale0", Range(0.0, 2.0)) = 1 |
|||
_DetailAlbedoScale1("_DetailAlbedoScale1", Range(0.0, 2.0)) = 1 |
|||
_DetailAlbedoScale2("_DetailAlbedoScale2", Range(0.0, 2.0)) = 1 |
|||
_DetailAlbedoScale3("_DetailAlbedoScale3", Range(0.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(0.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale1("_DetailSmoothnessScale1", Range(0.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale2("_DetailSmoothnessScale2", Range(0.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale3("_DetailSmoothnessScale3", Range(0.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 |
|||
|
|||
_DiffusionProfile0("Diffusion Profile0", Int) = 0 |
|||
_DiffusionProfile1("Diffusion Profile1", Int) = 0 |
|||
_DiffusionProfile2("Diffusion Profile2", Int) = 0 |
|||
_DiffusionProfile3("Diffusion Profile3", Int) = 0 |
|||
|
|||
_SubsurfaceMask0("Subsurface Mask0", Range(0.0, 1.0)) = 1.0 |
|||
_SubsurfaceMask1("Subsurface Mask1", Range(0.0, 1.0)) = 1.0 |
|||
_SubsurfaceMask2("Subsurface Mask2", Range(0.0, 1.0)) = 1.0 |
|||
_SubsurfaceMask3("Subsurface Mask3", Range(0.0, 1.0)) = 1.0 |
|||
|
|||
_SubsurfaceMaskMap0("Subsurface Mask Map0", 2D) = "white" {} |
|||
_SubsurfaceMaskMap1("Subsurface Mask Map1", 2D) = "white" {} |
|||
_SubsurfaceMaskMap2("Subsurface Mask Map2", 2D) = "white" {} |
|||
_SubsurfaceMaskMap3("Subsurface Mask Map3", 2D) = "white" {} |
|||
|
|||
_Thickness0("Thickness", Range(0.0, 1.0)) = 1.0 |
|||
_Thickness1("Thickness", Range(0.0, 1.0)) = 1.0 |
|||
_Thickness2("Thickness", Range(0.0, 1.0)) = 1.0 |
|||
_Thickness3("Thickness", Range(0.0, 1.0)) = 1.0 |
|||
|
|||
_ThicknessMap0("Thickness Map", 2D) = "white" {} |
|||
_ThicknessMap1("Thickness Map", 2D) = "white" {} |
|||
_ThicknessMap2("Thickness Map", 2D) = "white" {} |
|||
_ThicknessMap3("Thickness Map", 2D) = "white" {} |
|||
|
|||
_ThicknessRemap0("Thickness Remap", Vector) = (0, 1, 0, 0) |
|||
_ThicknessRemap1("Thickness Remap", Vector) = (0, 1, 0, 0) |
|||
_ThicknessRemap2("Thickness Remap", Vector) = (0, 1, 0, 0) |
|||
_ThicknessRemap3("Thickness Remap", Vector) = (0, 1, 0, 0) |
|||
|
|||
// All the following properties exist only in layered lit material |
|||
|
|||
// Layer blending options |
|||
_LayerMaskMap("LayerMaskMap", 2D) = "white" {} |
|||
_LayerInfluenceMaskMap("LayerInfluenceMaskMap", 2D) = "white" {} |
|||
[ToggleUI] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0 |
|||
|
|||
_HeightTransition("Height Transition", Range(0, 1.0)) = 0.0 |
|||
|
|||
[ToggleUI] _UseDensityMode("Use Density mode", Float) = 0.0 |
|||
[ToggleUI] _UseMainLayerInfluence("UseMainLayerInfluence", 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 |
|||
|
|||
[ToggleUI] _OpacityAsDensity0("_OpacityAsDensity0", Float) = 0.0 |
|||
[ToggleUI] _OpacityAsDensity1("_OpacityAsDensity1", Float) = 0.0 |
|||
[ToggleUI] _OpacityAsDensity2("_OpacityAsDensity2", Float) = 0.0 |
|||
[ToggleUI] _OpacityAsDensity3("_OpacityAsDensity3", Float) = 0.0 |
|||
|
|||
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0 |
|||
|
|||
[Enum(None, 0, Multiply, 1, Add, 2)] _VertexColorMode("Vertex color mode", Float) = 0 |
|||
|
|||
[ToggleUI] _ObjectScaleAffectTile("_ObjectScaleAffectTile", Float) = 0.0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBlendMask("UV Set for blendMask", Float) = 0 |
|||
[HideInInspector] _UVMappingMaskBlendMask("_UVMappingMaskBlendMask", Color) = (1, 0, 0, 0) |
|||
_TexWorldScaleBlendMask("Tiling", Float) = 1.0 |
|||
|
|||
// Following are builtin properties |
|||
|
|||
[ToggleUI] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0 |
|||
|
|||
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1) |
|||
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} |
|||
_EmissiveIntensity("EmissiveIntensity", Float) = 0 |
|||
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 |
|||
|
|||
// Stencil state |
|||
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting |
|||
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time) |
|||
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time) |
|||
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time) |
|||
|
|||
// Blending state |
|||
[HideInInspector] _ZWrite ("__zw", Float) = 1.0 |
|||
[HideInInspector] _CullMode("__cullmode", Float) = 2.0 |
|||
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal |
|||
[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 |
|||
|
|||
[ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 |
|||
[Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 |
|||
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) |
|||
|
|||
// For layering, due to combinatorial explosion, we only support SSS/Transmission and Standard. We let other case for the shader graph |
|||
[Enum(Subsurface Scattering, 0, Standard, 1, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard |
|||
[ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 |
|||
|
|||
[Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 |
|||
[ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 |
|||
[ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 |
|||
[ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 |
|||
|
|||
[ToggleUI] _EnableMotionVectorForVertexAnimation("EnableMotionVectorForVertexAnimation", 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 |
|||
_PPDPrimitiveLength("Primitive length for POM", Float) = 1 |
|||
_PPDPrimitiveWidth("Primitive width for POM", Float) = 1 |
|||
[HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) |
|||
|
|||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 |
|||
[Enum(UV0, 0, Planar, 4, TriPlanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 |
|||
_TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 |
|||
[HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) |
|||
|
|||
// Wind |
|||
[ToggleUI] _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 |
|||
|
|||
// 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 |
|||
|
|||
[HideInInspector] _InvTilingScale0("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 |
|||
[HideInInspector] _InvTilingScale1("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 |
|||
[HideInInspector] _InvTilingScale2("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 |
|||
[HideInInspector] _InvTilingScale3("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 |
|||
|
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, 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) |
|||
|
|||
[ToggleUI] _LinkDetailsWithBase0("LinkDetailsWithBase0", Float) = 1.0 |
|||
[ToggleUI] _LinkDetailsWithBase1("LinkDetailsWithBase1", Float) = 1.0 |
|||
[ToggleUI] _LinkDetailsWithBase2("LinkDetailsWithBase2", Float) = 1.0 |
|||
[ToggleUI] _LinkDetailsWithBase3("LinkDetailsWithBase3", Float) = 1.0 |
|||
|
|||
[HideInInspector] _ShowMaterialReferences("_ShowMaterialReferences", Float) = 0 |
|||
[HideInInspector] _ShowLayer0("_ShowLayer0", Float) = 0 |
|||
[HideInInspector] _ShowLayer1("_ShowLayer1", Float) = 0 |
|||
[HideInInspector] _ShowLayer2("_ShowLayer2", Float) = 0 |
|||
[HideInInspector] _ShowLayer3("_ShowLayer3", Float) = 0 |
|||
|
|||
// Transparency |
|||
[ToggleUI] _PreRefractionPass("PreRefractionPass", Float) = 0.0 |
|||
|
|||
// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. |
|||
_MainTex("Albedo", 2D) = "white" {} |
|||
_Color("Color", Color) = (1,1,1,1) |
|||
|
|||
[ToggleUI] _SupportDBuffer("Support DBuffer", Float) = 1.0 |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal |
|||
|
|||
#pragma shader_feature _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT |
|||
#pragma shader_feature _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE |
|||
#pragma shader_feature _DISPLACEMENT_LOCK_TILING_SCALE |
|||
#pragma shader_feature _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE |
|||
|
|||
#pragma shader_feature _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR |
|||
#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 _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 _BENTNORMALMAP0 |
|||
#pragma shader_feature _BENTNORMALMAP1 |
|||
#pragma shader_feature _BENTNORMALMAP2 |
|||
#pragma shader_feature _BENTNORMALMAP3 |
|||
#pragma shader_feature _EMISSIVE_COLOR_MAP |
|||
#pragma shader_feature _ENABLESPECULAROCCLUSION |
|||
#pragma shader_feature _DETAIL_MAP0 |
|||
#pragma shader_feature _DETAIL_MAP1 |
|||
#pragma shader_feature _DETAIL_MAP2 |
|||
#pragma shader_feature _DETAIL_MAP3 |
|||
#pragma shader_feature _HEIGHTMAP0 |
|||
#pragma shader_feature _HEIGHTMAP1 |
|||
#pragma shader_feature _HEIGHTMAP2 |
|||
#pragma shader_feature _HEIGHTMAP3 |
|||
#pragma shader_feature _SUBSURFACE_MASK_MAP0 |
|||
#pragma shader_feature _SUBSURFACE_MASK_MAP1 |
|||
#pragma shader_feature _SUBSURFACE_MASK_MAP2 |
|||
#pragma shader_feature _SUBSURFACE_MASK_MAP3 |
|||
#pragma shader_feature _THICKNESSMAP0 |
|||
#pragma shader_feature _THICKNESSMAP1 |
|||
#pragma shader_feature _THICKNESSMAP2 |
|||
#pragma shader_feature _THICKNESSMAP3 |
|||
|
|||
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD |
|||
#pragma shader_feature _MAIN_LAYER_INFLUENCE_MODE |
|||
#pragma shader_feature _INFLUENCEMASK_MAP |
|||
#pragma shader_feature _DENSITY_MODE |
|||
#pragma shader_feature _HEIGHT_BASED_BLEND |
|||
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS |
|||
|
|||
#pragma shader_feature _DISABLE_DBUFFER |
|||
|
|||
// MaterialFeature are used as shader feature to allow compiler to optimize properly |
|||
#pragma shader_feature _MATERIAL_FEATURE_SUBSURFACE_SCATTERING |
|||
#pragma shader_feature _MATERIAL_FEATURE_TRANSMISSION |
|||
|
|||
//enable GPU instancing support |
|||
#pragma multi_compile_instancing |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// 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 |
|||
// This shader support vertex modification |
|||
#define HAVE_VERTEX_MODIFICATION |
|||
|
|||
// If we use subsurface scattering, enable output split lighting (for forward pass) |
|||
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT) |
|||
#define OUTPUT_SPLIT_LIGHTING |
|||
#endif |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "CoreRP/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 |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "../../Material/Lit/LitProperties.hlsl" |
|||
|
|||
// All our shaders use same name for entry point |
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
// This tags allow to use the shader replacement features |
|||
Tags{ "RenderPipeline" = "HDRenderPipeline" "RenderType" = "HDLitShader" } |
|||
|
|||
// Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. |
|||
Pass |
|||
{ |
|||
Name "GBuffer" // Name is not used |
|||
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index |
|||
|
|||
Cull [_CullMode] |
|||
ZTest[_ZTestGBuffer] |
|||
|
|||
Stencil |
|||
{ |
|||
WriteMask [_StencilWriteMask] |
|||
Ref [_StencilRef] |
|||
Comp Always |
|||
Pass Replace |
|||
} |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma multi_compile _ DEBUG_DISPLAY |
|||
#pragma multi_compile _ LIGHTMAP_ON |
|||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON |
|||
#pragma multi_compile _ SHADOWS_SHADOWMASK |
|||
|
|||
#define SHADERPASS SHADERPASS_GBUFFER |
|||
#include "../../ShaderVariables.hlsl" |
|||
#ifdef DEBUG_DISPLAY |
|||
#include "../../Debug/DebugDisplay.hlsl" |
|||
#endif |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitSharePass.hlsl" |
|||
#include "LayeredLitData.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/LitSharePass.hlsl" |
|||
#include "LayeredLitData.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) |
|||
|
|||
// If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity |
|||
Stencil |
|||
{ |
|||
WriteMask [_StencilWriteMaskMV] |
|||
Ref [_StencilRefMV] |
|||
Comp Always |
|||
Pass Replace |
|||
} |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#define SHADERPASS SHADERPASS_VELOCITY |
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitVelocityPass.hlsl" |
|||
#include "LayeredLitData.hlsl" |
|||
#include "../../ShaderPass/ShaderPassVelocity.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "ShadowCaster" |
|||
Tags{ "LightMode" = "ShadowCaster" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZClip [_ZClip] |
|||
ZWrite On |
|||
ZTest LEqual |
|||
|
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#define SHADERPASS SHADERPASS_SHADOWS |
|||
#define USE_LEGACY_UNITY_MATRIX_VARIABLES |
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitDepthPass.hlsl" |
|||
#include "LayeredLitData.hlsl" |
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{ "LightMode" = "DepthOnly" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
|
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitDepthPass.hlsl" |
|||
#include "LayeredLitData.hlsl" |
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Forward" // Name is not used |
|||
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Stencil |
|||
{ |
|||
WriteMask [_StencilWriteMask] |
|||
Ref [_StencilRef] |
|||
Comp Always |
|||
Pass Replace |
|||
} |
|||
|
|||
// In case of forward we want to have depth equal for opaque mesh |
|||
ZTest [_ZTestDepthEqualForOpaque] |
|||
ZWrite [_ZWrite] |
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma multi_compile _ DEBUG_DISPLAY |
|||
#pragma multi_compile _ LIGHTMAP_ON |
|||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON |
|||
#pragma multi_compile _ SHADOWS_SHADOWMASK |
|||
// #include "../../Lighting/Forward.hlsl" |
|||
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS |
|||
#define LIGHTLOOP_TILE_PASS |
|||
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST |
|||
|
|||
#define SHADERPASS SHADERPASS_FORWARD |
|||
// In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) |
|||
#ifndef _SURFACE_TYPE_TRANSPARENT |
|||
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST |
|||
#endif |
|||
#include "../../ShaderVariables.hlsl" |
|||
#ifdef DEBUG_DISPLAY |
|||
#include "../../Debug/DebugDisplay.hlsl" |
|||
#endif |
|||
#include "../../Lighting/Lighting.hlsl" |
|||
#include "../Lit/ShaderPass/LitSharePass.hlsl" |
|||
#include "LayeredLitData.hlsl" |
|||
#include "../../ShaderPass/ShaderPassForward.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
CustomEditor "UnityEditor.Experimental.Rendering.HDPipeline.TerrainGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 19e129e21de2c4042995eefba8405e9e |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue