浏览代码

Merge pull request #1733 from Unity-Technologies/HDRP/decals/v2_1/material_draw_order

Hdrp/decals/v2 1/material draw order
/main
GitHub 6 年前
当前提交
45feea45
共有 4 个文件被更改,包括 34 次插入9 次删除
  1. 1
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 16
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs
  3. 1
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
  4. 25
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalSystem.cs

1
com.unity.render-pipelines.high-definition/CHANGELOG.md


### Added
- Decal now support per channel selection mask. There is now two mode. One with BaseColor, Normal and Smoothness and another one more expensive with BaseColor, Normal, Smoothness, Metal and AO. Control is on HDRP Asset. This may require to launch an update script for old scene: 'Edit/Render Pipeline/Single step upgrade script/Upgrade all DecalMaterial MaskBlendMode'.
- Decal now supports depth bias for decal mesh, to prevent z-fighting
- Decal material now supports draw order for decal projectors
### Fixed
- Fixed an issue with PreIntegratedFGD texture being sometimes destroyed and not regenerated causing rendering to break

16
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(decalMeshDepthBias, Styles.MeshDecalDepthBiasText);
m_MaterialEditor.ShaderProperty(decalMeshDepthBias, Styles.MeshDecalDepthBiasText);
EditorGUI.indentLevel--;
EditorGUILayout.HelpBox(

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);
}
}
}

正在加载...
取消
保存