浏览代码

added depth bias to mesh decals

/main
Paul Melamed 6 年前
当前提交
bf15dbc1
共有 4 个文件被更改,包括 20 次插入0 次删除
  1. 6
      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. 1
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProperties.hlsl
  4. 12
      com.unity.render-pipelines.high-definition/HDRP/ShaderPass/ShaderPassDBuffer.hlsl

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


public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map (BC7/BC5/DXT5(nm))");
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[] maskMapText =
{

protected MaterialProperty maskmapSmoothness = new MaterialProperty();
protected const string kMaskmapSmoothness = "_MaskmapSmoothness";
protected MaterialProperty decalMeshDepthBias = new MaterialProperty();
protected const string kDecalMeshDepthBias = "_DecalMeshDepthBias";
protected MaterialEditor m_MaterialEditor;
// This is call by the inspector

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

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

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


[ToggleUI] _MaskmapMetal("_MaskmapMetal", Range(0.0, 1.0)) = 0.0
[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
}
HLSLINCLUDE

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


float _DecalBlend;
float4 _BaseColor;
float _DecalMeshDepthBias;
#endif

12
com.unity.render-pipelines.high-definition/HDRP/ShaderPass/ShaderPassDBuffer.hlsl


#include "VertMesh.hlsl"
void MeshDecalsPositionZBias(inout VaryingsToPS input)
{
#if defined(UNITY_REVERSED_Z)
input.vmesh.positionCS.z -= _DecalMeshDepthBias * input.vmesh.positionCS.w;
#else
input.vmesh.positionCS.z += _DecalMeshDepthBias * input.vmesh.positionCS.w;
#endif
}
#if (SHADERPASS == SHADERPASS_DBUFFER_MESH)
MeshDecalsPositionZBias(varyingsType);
#endif
return PackVaryingsType(varyingsType);
}

正在加载...
取消
保存