浏览代码

Merge branch 'HDRP/staging' into Decal-compilation

/main
Sebastien Lagarde 6 年前
当前提交
699fec18
共有 4 个文件被更改,包括 44 次插入10 次删除
  1. 1
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 15
      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. 37
      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

15
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(decalBlend, Styles.decalBlendText);
m_MaterialEditor.ShaderProperty(drawOrder, Styles.DrawOrderText);
m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);
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

37
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 SortedList<int, List<DecalSet>> m_DecalSetsRenderList = new SortedList<int, List<DecalSet>>(); // list of decalset lists sorted by material draw order
// 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);
foreach(var decalSet in pair.Value)
{
decalSet.RenderIntoDBuffer(cmd);
}
}
}

m_MaskTextureScaleBias = new TextureScaleBias[newDecalDatasSize];
m_BaseColor = new Vector4[newDecalDatasSize];
}
m_DecalSetsRenderList.Clear();
pair.Value.CreateDrawData();
if (pair.Value.CreateDrawData())
{
int key = pair.Value.DrawOrder;
List<DecalSet> decalSetList;
if (!m_DecalSetsRenderList.TryGetValue(key, out decalSetList))
{
decalSetList = new List<DecalSet>();
m_DecalSetsRenderList.Add(key, decalSetList);
}
decalSetList.Add(pair.Value);
}
}
}

正在加载...
取消
保存