浏览代码

decal material draw order

/main
Paul Melamed 6 年前
当前提交
d0f8d66e
共有 3 个文件被更改,包括 30 次插入8 次删除
  1. 12
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs
  2. 1
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
  3. 25
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalSystem.cs

12
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs


public static GUIContent decalBlendText = new GUIContent("Global Opacity", "Whole decal Opacity");
public static GUIContent AlbedoModeText = new GUIContent("Affect BaseColor", "Base color + Opacity, Opacity only");
public static GUIContent MeshDecalDepthBiasText = new GUIContent("Mesh decal depth bias", "prevents z-fighting");
public static GUIContent DrawOrderText = new GUIContent("Draw order", "Controls draw order of decal projectors");
public static GUIContent[] maskMapText =
{

protected MaterialProperty decalMeshDepthBias = new MaterialProperty();
protected const string kDecalMeshDepthBias = "_DecalMeshDepthBias";
protected MaterialProperty drawOrder = new MaterialProperty();
protected const string kDrawOrder = "_DrawOrder";
protected MaterialEditor m_MaterialEditor;
// This is call by the inspector

maskBlendMode = FindProperty(kMaskBlendMode, props);
maskmapMetal = FindProperty(kMaskmapMetal, props);
maskmapAO = FindProperty(kMaskmapAO, props);
maskmapSmoothness = FindProperty(kMaskmapSmoothness, props);
decalMeshDepthBias = FindProperty(kDecalMeshDepthBias, props);
maskmapSmoothness = FindProperty(kMaskmapSmoothness, props);
decalMeshDepthBias = FindProperty(kDecalMeshDepthBias, props);
drawOrder = FindProperty(kDrawOrder, props);
// always instanced
SerializedProperty instancing = m_MaterialEditor.serializedObject.FindProperty("m_EnableInstancingVariants");
instancing.boolValue = true;

}
EditorGUI.indentLevel--;
}
m_MaterialEditor.ShaderProperty(drawOrder, Styles.DrawOrderText);
m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);
m_MaterialEditor.ShaderProperty(decalMeshDepthBias, Styles.MeshDecalDepthBiasText);
EditorGUI.indentLevel--;

1
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader


[ToggleUI] _MaskmapAO("_MaskmapAO", Range(0.0, 1.0)) = 0.0
[ToggleUI] _MaskmapSmoothness("_MaskmapSmoothness", Range(0.0, 1.0)) = 1.0
[HideInInspector] _DecalMeshDepthBias("_DecalMeshDepthBias", Float) = 0.0
[HideInInspector] _DrawOrder("_DrawOrder", Int) = 0
}
HLSLINCLUDE

25
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalSystem.cs


static public float[] m_BoundingDistances = new float[1];
private Dictionary<int, DecalSet> m_DecalSets = new Dictionary<int, DecalSet>();
private SortedDictionary<int, DecalSet> m_DecalSetsRenderList = new SortedDictionary<int, DecalSet>();
// current camera
private Camera m_Camera;

}
}
public void CreateDrawData()
public bool CreateDrawData()
return;
return false;
return;
return false;
int instanceCount = 0;
int batchCount = 0;

{
AddToTextureList(ref instance.m_TextureList);
}
return true;
}
public void EndCull()

}
}
public int DrawOrder
{
get
{
return this.m_Material.GetInt("_DrawOrder");
}
}
private List<Matrix4x4[]> m_DecalToWorld = new List<Matrix4x4[]>();
private List<Matrix4x4[]> m_NormalToWorld = new List<Matrix4x4[]>();

if (m_DecalMesh == null)
m_DecalMesh = CoreUtils.CreateCubeMesh(kMin, kMax);
foreach (var pair in m_DecalSets)
foreach (var pair in m_DecalSetsRenderList)
{
pair.Value.RenderIntoDBuffer(cmd);
}

m_MaskTextureScaleBias = new TextureScaleBias[newDecalDatasSize];
m_BaseColor = new Vector4[newDecalDatasSize];
}
m_DecalSetsRenderList.Clear();
pair.Value.CreateDrawData();
if (pair.Value.CreateDrawData())
{
m_DecalSetsRenderList.Add(pair.Value.DrawOrder, pair.Value);
}
}
}

正在加载...
取消
保存