Julien Ignace
7 年前
当前提交
7d46e579
共有 20 个文件被更改,包括 2007 次插入 和 265 次删除
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/Editor/InfluenceLayeredLitUI.cs
-
30Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/InfluenceLayeredLit.shader
-
30Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/InfluenceLayeredLit/InfluenceLayeredLitTessellation.shader
-
13Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
-
315Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
-
138Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
6Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/UnlitUI.cs
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit.meta
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor.meta
-
543Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
-
13Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs.meta
-
525Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader.meta
-
607Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 883e0e56c1d016841aca4ce3ed34be7b |
|||
folderAsset: yes |
|||
timeCreated: 1502111269 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0536b6da718aae342b15a1b7c8a37eb2 |
|||
folderAsset: yes |
|||
timeCreated: 1502111269 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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
|
|
|||
fileFormatVersion: 2 |
|||
guid: 18a9ee0f5a424d743b8ba33dd8b7c164 |
|||
timeCreated: 1502111270 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9070af10d08001e4d9219b84e1910d9b |
|||
timeCreated: 1502111273 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5545a01b759c7594e8ded2415804ebb6 |
|||
timeCreated: 1502111273 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue