浏览代码

Remove uvmapping for blend mask because terrain always uses uv0.

/main
Yao Xiaoling 7 年前
当前提交
fe1e3424
共有 3 个文件被更改,包括 4 次插入56 次删除
  1. 40
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/LayeredLit/TerrainLitUI.cs
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/TerrainLit.shader
  3. 15
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/TerrainLitData.hlsl

40
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/LayeredLit/TerrainLitUI.cs


{
public readonly GUIContent layersText = new GUIContent("Inputs");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask");
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 readonly GUIContent useMainLayerInfluenceModeText = new GUIContent("Main Layer Influence", "Switch between regular layers mode and base/layers mode");
public readonly GUIContent heightTransition = new GUIContent("Height Transition", "Size in world units of the smooth transition between layers.");
}

}
// Layer options
MaterialProperty UVBlendMask = null;
const string kUVBlendMask = "_UVBlendMask";
MaterialProperty UVMappingMaskBlendMask = null;
const string kUVMappingMaskBlendMask = "_UVMappingMaskBlendMask";
MaterialProperty texWorldScaleBlendMask = null;
const string kTexWorldScaleBlendMask = "_TexWorldScaleBlendMask";
MaterialProperty useHeightBasedBlend = null;
const string kUseHeightBasedBlend = "_UseHeightBasedBlend";

protected override void FindMaterialProperties(MaterialProperty[] props)
{
UVBlendMask = FindProperty(kUVBlendMask, props);
UVMappingMaskBlendMask = FindProperty(kUVMappingMaskBlendMask, props);
texWorldScaleBlendMask = FindProperty(kTexWorldScaleBlendMask, props);
useHeightBasedBlend = FindProperty(kUseHeightBasedBlend, props);
heightTransition = FindProperty(kHeightTransition, props);

EditorGUI.indentLevel++;
GUILayout.Label(styles.layersText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(UVBlendMask, styles.UVBlendMaskText);
UVBaseMapping uvBlendMask = (UVBaseMapping)UVBlendMask.floatValue;
float X, Y, Z, W;
X = (uvBlendMask == UVBaseMapping.UV0) ? 1.0f : 0.0f;
Y = (uvBlendMask == UVBaseMapping.UV1) ? 1.0f : 0.0f;
Z = (uvBlendMask == UVBaseMapping.UV2) ? 1.0f : 0.0f;
W = (uvBlendMask == UVBaseMapping.UV3) ? 1.0f : 0.0f;
UVMappingMaskBlendMask.colorValue = new Color(X, Y, Z, W);
if (((UVBaseMapping)UVBlendMask.floatValue == UVBaseMapping.Planar) ||
((UVBaseMapping)UVBlendMask.floatValue == UVBaseMapping.Triplanar))
{
m_MaterialEditor.ShaderProperty(texWorldScaleBlendMask, styles.layerTexWorldScaleText);
}
EditorGUI.indentLevel--;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = useHeightBasedBlend.hasMixedValue;
m_UseHeightBasedBlend = EditorGUILayout.Toggle(styles.useHeightBasedBlendText, useHeightBasedBlend.floatValue > 0.0f);

static public void SetupLayersMappingKeywords(Material material)
{
// Blend mask
UVBaseMapping UVBlendMaskMapping = (UVBaseMapping)material.GetFloat(kUVBlendMask);
CoreUtils.SetKeyword(material, "_LAYER_MAPPING_PLANAR_BLENDMASK", UVBlendMaskMapping == UVBaseMapping.Planar);
CoreUtils.SetKeyword(material, "_LAYER_MAPPING_TRIPLANAR_BLENDMASK", UVBlendMaskMapping == UVBaseMapping.Triplanar);
const string kLayerMappingPlanar = "_LAYER_MAPPING_PLANAR";
const string kLayerMappingTriplanar = "_LAYER_MAPPING_TRIPLANAR";

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/TerrainLit.shader


_InheritBaseColor2("_InheritBaseColor2", Range(0, 1.0)) = 0.0
_InheritBaseColor3("_InheritBaseColor3", Range(0, 1.0)) = 0.0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBlendMask("UV Set for blendMask", Float) = 0
[HideInInspector] _UVMappingMaskBlendMask("_UVMappingMaskBlendMask", Color) = (1, 0, 0, 0)
_TexWorldScaleBlendMask("Tiling", Float) = 1.0
// Following are builtin properties
[ToggleUI] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0

#pragma shader_feature _DOUBLESIDED_ON
//#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

15
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/TerrainLitData.hlsl


layerTexCoord.vertexNormalWS = vertexNormalWS;
layerTexCoord.triplanarWeights = ComputeTriplanarWeights(vertexNormalWS);
int mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR_BLENDMASK)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR_BLENDMASK)
mappingType = UV_MAPPING_TRIPLANAR;
#endif
ComputeLayerTexCoord0( texCoord0, texCoord1, texCoord2, texCoord3, _UVMappingMaskBlendMask, _UVMappingMaskBlendMask,
ComputeLayerTexCoord0( texCoord0, texCoord1, texCoord2, texCoord3, float4(1, 0, 0, 0), float4(0, 0, 0, 0),
positionWS, _TexWorldScaleBlendMask,
mappingType, layerTexCoord);
positionWS, 1,
UV_MAPPING_UVSET, layerTexCoord);
layerTexCoord.blendMask = layerTexCoord.base0;

mappingType = UV_MAPPING_UVSET;
int mappingType = UV_MAPPING_UVSET;
#if defined(_LAYER_MAPPING_PLANAR0)
mappingType = UV_MAPPING_PLANAR;
#elif defined(_LAYER_MAPPING_TRIPLANAR0)

正在加载...
取消
保存