浏览代码

Refactor: Moved all blending stuff into one single nice function TerrainSplatBlend that can be used by either splat shader and basemap shader.

Added density blend mode.
/main
Yao Xiaoling 6 年前
当前提交
27b8d556
共有 6 个文件被更改,包括 314 次插入499 次删除
  1. 26
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/TerrainLit/TerrainLitUI.cs
  2. 72
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLit.shader
  3. 214
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLitData.hlsl
  4. 315
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLitSplatCommon.hlsl
  5. 145
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLit_Basemap_Gen.shader
  6. 41
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DefaultHDTerrainMaterial.mat

26
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/TerrainLit/TerrainLitUI.cs


{
public readonly GUIContent layersText = new GUIContent("Inputs");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask");
public readonly GUIContent enableHeightBlending = new GUIContent("Enable Height Blending", "Enables layer blending using heightmaps.");
public readonly GUIContent layerBlendMode = new GUIContent("Layer Blend Mode", "Controls how terrain layers are blended.");
public readonly GUIContent heightTransition = new GUIContent("Height Transition", "Size in world units of the smooth transition between layers.");
public readonly GUIContent enableInstancedPerPixelNormal = new GUIContent("Enable Per-pixel Normal", "Enable per-pixel normal when the terrain uses instanced rendering.");
}

{
}
// Density/opacity mode
MaterialProperty[] opacityAsDensity = new MaterialProperty[kMaxLayerCount];
const string kOpacityAsDensity = "_OpacityAsDensity";
MaterialProperty layerBlendMode;
const string kLayerBlendMode = "_LayerBlendMode";
MaterialProperty enableHeightBlending = null;
const string kEnableHeightBlending = "_EnableHeightBlending";
MaterialProperty heightTransition = null;
const string kHeightTransition = "_HeightTransition";

protected override void FindMaterialProperties(MaterialProperty[] props)
{
enableHeightBlending = FindProperty(kEnableHeightBlending, props, false);
layerBlendMode = FindProperty(kLayerBlendMode, props, false);
for (int i = 0; i < kMaxLayerCount; ++i)
{
// Density/opacity mode
opacityAsDensity[i] = FindProperty(string.Format("{0}{1}", kOpacityAsDensity, i), props);
}
enableInstancedPerPixelNormal = FindProperty(kEnableInstancedPerPixelNormal, props, false);
}

EditorGUI.indentLevel++;
GUILayout.Label(styles.layersText, EditorStyles.boldLabel);
if (enableHeightBlending != null)
if (layerBlendMode != null)
m_MaterialEditor.ShaderProperty(enableHeightBlending, styles.enableHeightBlending);
if (enableHeightBlending.floatValue > 0)
m_MaterialEditor.ShaderProperty(layerBlendMode, styles.layerBlendMode);
if (layerBlendMode.floatValue == 2)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightTransition, styles.heightTransition);

// TODO: planar/triplannar supprt
//SetupLayersMappingKeywords(material);
int layerBlendMode = (int)material.GetFloat(kLayerBlendMode);
CoreUtils.SetKeyword(material, "_TERRAIN_BLEND_DENSITY", layerBlendMode == 1);
CoreUtils.SetKeyword(material, "_TERRAIN_BLEND_HEIGHT", layerBlendMode == 2);
bool enableInstancedPerPixelNormal = material.GetFloat(kEnableInstancedPerPixelNormal) > 0.0f;
CoreUtils.SetKeyword(material, "_TERRAIN_INSTANCED_PERPIXEL_NORMAL", enableInstancedPerPixelNormal);

72
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLit.shader


[HideInInspector] _Smoothness6("Smoothness 6", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness7("Smoothness 7", Range(0.0, 1.0)) = 0.0
// TODO: route values from terrain layers. enable _DENSITY_MODE if any of these enabled.
[HideInInspector] [ToggleUI] _OpacityAsDensity0("_OpacityAsDensity0", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity1("_OpacityAsDensity1", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity2("_OpacityAsDensity2", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity3("_OpacityAsDensity3", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity4("_OpacityAsDensity4", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity5("_OpacityAsDensity5", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity6("_OpacityAsDensity6", Float) = 0.0
[HideInInspector] [ToggleUI] _OpacityAsDensity7("_OpacityAsDensity7", Float) = 0.0
[HideInInspector] [Enum(Alpha, 0, Density, 1, Height, 2)] _LayerBlendMode("Layer Blend Mode", Int) = 0
[ToggleUI] _EnableHeightBlending("Enable Height Blending", Float) = 1.0 // Hint Unity if heightmaps are ever used
[HideInInspector] _Mask0("Mask 0", 2D) = "black" {}
[HideInInspector] _Mask1("Mask 1", 2D) = "black" {}
[HideInInspector] _Mask2("Mask 2", 2D) = "black" {}
[HideInInspector] _Mask3("Mask 3", 2D) = "black" {}
[HideInInspector] _Mask4("Mask 4", 2D) = "black" {}
[HideInInspector] _Mask5("Mask 5", 2D) = "black" {}
[HideInInspector] _Mask6("Mask 6", 2D) = "black" {}
[HideInInspector] _Mask7("Mask 7", 2D) = "black" {}
[HideInInspector] _Density0("_Density0", Float) = 1.0
[HideInInspector] _Density1("_Density1", Float) = 1.0
[HideInInspector] _Density2("_Density2", Float) = 1.0
[HideInInspector] _Density3("_Density3", Float) = 1.0
[HideInInspector] _Density4("_Density4", Float) = 1.0
[HideInInspector] _Density5("_Density5", Float) = 1.0
[HideInInspector] _Density6("_Density6", Float) = 1.0
[HideInInspector] _Density7("_Density7", Float) = 1.0
// Height in mask.r
[HideInInspector] _Height0("Height 0", 2D) = "black" {}
[HideInInspector] _Height1("Height 1", 2D) = "black" {}
[HideInInspector] _Height2("Height 2", 2D) = "black" {}
[HideInInspector] _Height3("Height 3", 2D) = "black" {}
[HideInInspector] _Height4("Height 4", 2D) = "black" {}
[HideInInspector] _Height5("Height 5", 2D) = "black" {}
[HideInInspector] _Height6("Height 6", 2D) = "black" {}
[HideInInspector] _Height7("Height 7", 2D) = "black" {}
[HideInInspector] _HeightAmplitude0("Height Scale0", Float) = 0.02
[HideInInspector] _HeightAmplitude1("Height Scale1", Float) = 0.02
[HideInInspector] _HeightAmplitude2("Height Scale2", Float) = 0.02

_AORemapMax1("AORemapMax1", Range(0.0, 1.0)) = 1.0
_AORemapMax2("AORemapMax2", Range(0.0, 1.0)) = 1.0
_AORemapMax3("AORemapMax3", Range(0.0, 1.0)) = 1.0
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}
_MaskMap2("MaskMap2", 2D) = "white" {}
_MaskMap3("MaskMap3", 2D) = "white" {}
*/
// All the following properties exist only in layered lit material

#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal
#pragma shader_feature _TERRAIN_8_LAYERS
#pragma shader_feature _ _TERRAIN_BLEND_DENSITY _TERRAIN_BLEND_HEIGHT
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
// Sample normal in pixel shader when doing instancing
#pragma shader_feature _TERRAIN_INSTANCED_PERPIXEL_NORMAL
#pragma shader_feature _DOUBLESIDED_ON
//#pragma shader_feature _ _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_TRIPLANAR0

#pragma shader_feature _TERRAIN_NORMAL_MAP
#pragma shader_feature _TERRAIN_HEIGHT_MAP
// #pragma shader_feature _HEIGHT_BASED_BLEND // _HEIGHT_BASED_BLEND is implied if heightmap is used.
// Sample normal in pixel shader when doing instancing
#pragma shader_feature _TERRAIN_INSTANCED_PERPIXEL_NORMAL
//#pragma shader_feature _MASKMAP0
//#pragma shader_feature _MASKMAP1
//#pragma shader_feature _MASKMAP2
//#pragma shader_feature _MASKMAP3
#pragma shader_feature _DENSITY_MODE
#pragma shader_feature _TERRAIN_1_SPLAT _TERRAIN_2_SPLATS _TERRAIN_3_SPLATS _TERRAIN_4_SPLATS _TERRAIN_5_SPLATS _TERRAIN_6_SPLATS _TERRAIN_7_SPLATS _TERRAIN_8_SPLATS
#pragma shader_feature _DISABLE_DBUFFER
//enable GPU instancing support

#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#define _MAX_LAYER 8
//-------------------------------------------------------------------------------------
// variable declaration

214
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLitData.hlsl


ApplyDoubleSidedFlipOrMirror(input); // Apply double sided flip on the vertex normal
// TODO: triplanar and SURFACE_GRADIENT?
// TODO: POM
float2 uv = input.texCoord0;
float2 uvSplats[_MAX_LAYER];
uvSplats[0] = uv * _Splat0_ST.xy + _Splat0_ST.zw;
#if _LAYER_COUNT > 1
uvSplats[1] = uv * _Splat1_ST.xy + _Splat1_ST.zw;
#endif
#if _LAYER_COUNT > 2
uvSplats[2] = uv * _Splat2_ST.xy + _Splat2_ST.zw;
#endif
#if _LAYER_COUNT > 3
uvSplats[3] = uv * _Splat3_ST.xy + _Splat3_ST.zw;
#endif
#if _LAYER_COUNT > 4
uvSplats[4] = uv * _Splat4_ST.xy + _Splat4_ST.zw;
#endif
#if _LAYER_COUNT > 5
uvSplats[5] = uv * _Splat5_ST.xy + _Splat5_ST.zw;
#endif
#if _LAYER_COUNT > 6
uvSplats[6] = uv * _Splat6_ST.xy + _Splat6_ST.zw;
#endif
#if _LAYER_COUNT > 7
uvSplats[7] = uv * _Splat7_ST.xy + _Splat7_ST.zw;
#endif
// sample weights from Control maps
float4 blendMasks0 = SAMPLE_TEXTURE2D(_Control0, sampler_Control0, uv);
#if _LAYER_COUNT > 4
float4 blendMasks1 = SAMPLE_TEXTURE2D(_Control1, sampler_Control0, uv);
#else
float4 blendMasks1 = float4(0, 0, 0, 0);
#endif
// adjust weights for density mode
#ifdef _DENSITY_MODE
// 20.0 is the number of steps in inputAlphaMask (Density mask. We decided 20 empirically)
float4 opacityAsDensity0 = saturate((float4(1.0, 1.0, 1.0, 1.0) - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks0)) * 20.0);
float4 useOpacityAsDensityParam0 = float4(_OpacityAsDensity0, _OpacityAsDensity1, _OpacityAsDensity2, _OpacityAsDensity3);
blendMasks0 = lerp(blendMasks0, opacityAsDensity0, useOpacityAsDensityParam0);
#if _LAYER_COUNT > 4
float4 opacityAsDensity1 = saturate((float4(1.0, 1.0, 1.0, 1.0) - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks0)) * 20.0);
float4 useOpacityAsDensityParam1 = float4(_OpacityAsDensity4, _OpacityAsDensity5, _OpacityAsDensity6, _OpacityAsDensity7);
blendMasks1 = lerp(blendMasks1, opacityAsDensity1, useOpacityAsDensityParam1);
#endif
#endif
// adjust weights for height based blending
#ifdef _TERRAIN_HEIGHT_MAP
float4 heights0 = float4(0, 0, 0, 0);
float4 heights1 = float4(0, 0, 0, 0);
heights0.r = (SAMPLE_TEXTURE2D(_Height0, sampler_Splat0, uvSplats[0]).r * blendMasks0.r - _HeightCenter0) * _HeightAmplitude0;
#if _LAYER_COUNT > 1
heights0.g = (SAMPLE_TEXTURE2D(_Height1, sampler_Splat0, uvSplats[1]).r * blendMasks0.g - _HeightCenter1) * _HeightAmplitude1;
#endif
#if _LAYER_COUNT > 2
heights0.b = (SAMPLE_TEXTURE2D(_Height2, sampler_Splat0, uvSplats[2]).r * blendMasks0.b - _HeightCenter2) * _HeightAmplitude2;
#endif
#if _LAYER_COUNT > 3
heights0.a = (SAMPLE_TEXTURE2D(_Height3, sampler_Splat0, uvSplats[3]).r * blendMasks0.a - _HeightCenter3) * _HeightAmplitude3;
#endif
#if _LAYER_COUNT > 4
heights1.r = (SAMPLE_TEXTURE2D(_Height4, sampler_Splat0, uvSplats[4]).r * blendMasks1.r - _HeightCenter4) * _HeightAmplitude4;
#endif
#if _LAYER_COUNT > 5
heights1.g = (SAMPLE_TEXTURE2D(_Height5, sampler_Splat0, uvSplats[5]).r * blendMasks1.g - _HeightCenter5) * _HeightAmplitude5;
#endif
#if _LAYER_COUNT > 6
heights1.b = (SAMPLE_TEXTURE2D(_Height6, sampler_Splat0, uvSplats[6]).r * blendMasks1.b - _HeightCenter6) * _HeightAmplitude6;
#endif
#if _LAYER_COUNT > 7
heights1.a = (SAMPLE_TEXTURE2D(_Height7, sampler_Splat0, uvSplats[7]).r * blendMasks1.a - _HeightCenter7) * _HeightAmplitude7;
#endif
// Modify blendMask to take into account the height of the layer. Higher height should be more visible.
ApplyHeightBlend(heights0, heights1, blendMasks0, blendMasks1);
#endif
float weights[_MAX_LAYER];
ZERO_INITIALIZE_ARRAY(float, weights, _MAX_LAYER);
#if defined(_DENSITY_MODE)
// calculate weight of each layers
// Algorithm is like this:
// Top layer have priority on others layers
// If a top layer doesn't use the full weight, the remaining can be use by the following layer.
float weightsSum = 0.0f;
#if _LAYER_COUNT > 7
weights[7] = min(blendMasks1.a, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[7]);
#endif
#if _LAYER_COUNT > 6
weights[6] = min(blendMasks1.b, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[6]);
#endif
#if _LAYER_COUNT > 5
weights[5] = min(blendMasks1.g, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[5]);
#endif
#if _LAYER_COUNT > 4
weights[4] = min(blendMasks1.r, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[4]);
#endif
#if _LAYER_COUNT > 3
weights[3] = min(blendMasks0.a, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[3]);
#endif
#if _LAYER_COUNT > 2
weights[2] = min(blendMasks0.b, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[2]);
#endif
#if _LAYER_COUNT > 1
weights[1] = min(blendMasks0.g, (1.0f - weightsSum));
weightsSum = saturate(weightsSum + weights[1]);
#endif
weights[0] = min(blendMasks0.r, (1.0f - weightsSum));
#else
weights[0] = blendMasks0.r;
weights[1] = blendMasks0.g;
weights[2] = blendMasks0.b;
weights[3] = blendMasks0.a;
weights[4] = blendMasks1.r;
weights[5] = blendMasks1.g;
weights[6] = blendMasks1.b;
weights[7] = blendMasks1.a;
#endif
// TODO: conditional samplings
surfaceData.baseColor = SAMPLE_TEXTURE2D(_Splat0, sampler_Splat0, uvSplats[0]).rgb * weights[0];
surfaceData.perceptualSmoothness = SAMPLE_TEXTURE2D(_Splat0, sampler_Splat0, uvSplats[0]).a * _Smoothness0 * weights[0];
surfaceData.metallic = _Metallic0 * weights[0];
#if _LAYER_COUNT > 1
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat1, sampler_Splat0, uvSplats[1]).rgb * weights[1];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat1, sampler_Splat0, uvSplats[1]).a * _Smoothness1 * weights[1];
surfaceData.metallic += _Metallic1 * weights[1];
#endif
#if _LAYER_COUNT > 2
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat2, sampler_Splat0, uvSplats[2]).rgb * weights[2];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat2, sampler_Splat0, uvSplats[2]).a * _Smoothness2 * weights[2];
surfaceData.metallic += _Metallic2 * weights[2];
#endif
#if _LAYER_COUNT > 3
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat3, sampler_Splat0, uvSplats[3]).rgb * weights[3];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat3, sampler_Splat0, uvSplats[3]).a * _Smoothness3 * weights[3];
surfaceData.metallic += _Metallic3 * weights[3];
#endif
#if _LAYER_COUNT > 4
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat4, sampler_Splat0, uvSplats[4]).rgb * weights[4];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat4, sampler_Splat0, uvSplats[4]).a * _Smoothness4 * weights[4];
surfaceData.metallic += _Metallic4 * weights[4];
#endif
#if _LAYER_COUNT > 5
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat5, sampler_Splat0, uvSplats[5]).rgb * weights[5];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat5, sampler_Splat0, uvSplats[5]).a * _Smoothness5 * weights[5];
surfaceData.metallic += _Metallic5 * weights[5];
#endif
#if _LAYER_COUNT > 6
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat6, sampler_Splat0, uvSplats[6]).rgb * weights[6];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat6, sampler_Splat0, uvSplats[6]).a * _Smoothness6 * weights[6];
surfaceData.metallic += _Metallic6 * weights[6];
#endif
#if _LAYER_COUNT > 7
surfaceData.baseColor += SAMPLE_TEXTURE2D(_Splat7, sampler_Splat0, uvSplats[7]).rgb * weights[7];
surfaceData.perceptualSmoothness += SAMPLE_TEXTURE2D(_Splat7, sampler_Splat0, uvSplats[7]).a * _Smoothness7 * weights[7];
surfaceData.metallic += _Metallic7 * weights[7];
#endif
#if defined(_TERRAIN_NORMAL_MAP)
UVMapping normalUV;
normalUV.mappingType = UV_MAPPING_UVSET;
#ifdef SURFACE_GRADIENT
normalUV.tangentWS = input.worldToTangent[0];
normalUV.bitangentWS = input.worldToTangent[1];
#endif
normalUV.uv = uvSplats[0];
float3 normalTS = SAMPLE_UVMAPPING_NORMALMAP(_Normal0, sampler_Splat0, normalUV, 1) * weights[0];
#if _LAYER_COUNT > 1
normalUV.uv = uvSplats[1];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal1, sampler_Splat0, normalUV, 1) * weights[1];
#endif
#if _LAYER_COUNT > 2
normalUV.uv = uvSplats[2];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal2, sampler_Splat0, normalUV, 1) * weights[2];
#endif
#if _LAYER_COUNT > 3
normalUV.uv = uvSplats[3];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal3, sampler_Splat0, normalUV, 1) * weights[3];
#endif
#if _LAYER_COUNT > 4
normalUV.uv = uvSplats[4];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal4, sampler_Splat0, normalUV, 1) * weights[4];
#endif
#if _LAYER_COUNT > 5
normalUV.uv = uvSplats[5];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal5, sampler_Splat0, normalUV, 1) * weights[5];
#endif
#if _LAYER_COUNT > 6
normalUV.uv = uvSplats[6];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal6, sampler_Splat0, normalUV, 1) * weights[6];
#endif
#if _LAYER_COUNT > 7
normalUV.uv = uvSplats[7];
normalTS += SAMPLE_UVMAPPING_NORMALMAP(_Normal7, sampler_Splat0, normalUV, 1) * weights[7];
#endif
#elif defined(SURFACE_GRADIENT)
float3 normalTS = float3(0.0, 0.0, 0.0); // No gradient
#else
float3 normalTS = float3(0.0, 0.0, 1.0);
#endif
float3 normalTS;
TerrainSplatBlend(input.texCoord0, input.worldToTangent[0], input.worldToTangent[1],
surfaceData.baseColor, normalTS, surfaceData.perceptualSmoothness, surfaceData.metallic);
surfaceData.ambientOcclusion = 1;
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. Tag: SURFACE_GRADIENT

315
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLitSplatCommon.hlsl


#if defined(_TERRAIN_8_SPLATS)
#ifdef _TERRAIN_8_LAYERS
#elif defined(_TERRAIN_7_SPLATS)
#define _LAYER_COUNT 7
#elif defined(_TERRAIN_6_SPLATS)
#define _LAYER_COUNT 6
#elif defined(_TERRAIN_5_SPLATS)
#define _LAYER_COUNT 5
#elif defined(_TERRAIN_4_SPLATS)
#define _LAYER_COUNT 4
#elif defined(_TERRAIN_3_SPLATS)
#define _LAYER_COUNT 3
#elif defined(_TERRAIN_2_SPLATS)
#define _LAYER_COUNT 2
#define _LAYER_COUNT 1
#define _LAYER_COUNT 4
TEXTURE2D(_Height##n); \
TEXTURE2D(_Mask##n); \
float _Density##n; \
float _HeightCenter##n; \
float _HeightAmplitude##n

DECLARE_TERRAIN_LAYER(3);
DECLARE_TERRAIN_LAYER(4);
DECLARE_TERRAIN_LAYER(5);
DECLARE_TERRAIN_LAYER(6);
DECLARE_TERRAIN_LAYER(7);
#undef DECLARE_TERRAIN_LAYER
TEXTURE2D(_Control1);
float GetMaxHeight(float4 heights0
#if _LAYER_COUNT > 4
, float4 heights1
#ifdef _TERRAIN_8_LAYERS
DECLARE_TERRAIN_LAYER(4);
DECLARE_TERRAIN_LAYER(5);
DECLARE_TERRAIN_LAYER(6);
DECLARE_TERRAIN_LAYER(7);
TEXTURE2D(_Control1);
)
#undef DECLARE_TERRAIN_LAYER
float _HeightTransition;
float GetSumHeight(float4 heights0, float4 heights1)
float maxHeight = heights0.r;
#if _LAYER_COUNT > 1
maxHeight = max(maxHeight, heights0.g);
#endif
#if _LAYER_COUNT > 2
maxHeight = max(maxHeight, heights0.b);
#endif
#if _LAYER_COUNT > 3
maxHeight = max(maxHeight, heights0.a);
#endif
#if _LAYER_COUNT > 4
maxHeight = max(maxHeight, heights1.r);
#endif
#if _LAYER_COUNT > 5
maxHeight = max(maxHeight, heights1.g);
#endif
#if _LAYER_COUNT > 6
maxHeight = max(maxHeight, heights1.b);
#endif
#if _LAYER_COUNT > 7
maxHeight = max(maxHeight, heights1.a);
#endif
return maxHeight;
float sumHeight = heights0.x;
sumHeight += heights0.y;
sumHeight += heights0.z;
sumHeight += heights0.w;
#ifdef _TERRAIN_8_LAYERS
sumHeight += heights1.x;
sumHeight += heights1.y;
sumHeight += heights1.z;
sumHeight += heights1.w;
#endif
return sumHeight;
float GetSumHeight(float4 heights0
#if _LAYER_COUNT > 4
, float4 heights1
#endif
)
float3 SampleNormalGrad(TEXTURE2D_ARGS(textureName, samplerName), float2 uv, float2 dxuv, float2 dyuv, float3 tangentWS, float3 bitangentWS)
float sumHeight = heights0.r;
#if _LAYER_COUNT > 1
sumHeight += heights0.g;
#endif
#if _LAYER_COUNT > 2
sumHeight += heights0.b;
#endif
#if _LAYER_COUNT > 3
sumHeight += heights0.a;
#endif
#if _LAYER_COUNT > 4
sumHeight += heights1.r;
float4 nrm = SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, uv, dxuv, dyuv);
#ifdef SURFACE_GRADIENT
#ifdef UNITY_NO_DXT5nm
real2 deriv = UnpackDerivativeNormalRGB(nrm, 1);
#else
real2 deriv = UnpackDerivativeNormalRGorAG(nrm, 1);
#endif
return SurfaceGradientFromTBN(deriv, tangentWS, bitangentWS);
#else
#ifdef UNITY_NO_DXT5nm
return UnpackNormalRGB(nrm, 1);
#else
return UnpackNormalmapRGorAG(nrm, 1);
#endif
#if _LAYER_COUNT > 5
sumHeight += heights1.g;
#endif
#if _LAYER_COUNT > 6
sumHeight += heights1.b;
#endif
#if _LAYER_COUNT > 7
sumHeight += heights1.a;
#endif
return sumHeight;
}
float4 RemapMasks(float4 masks, float blendMask, float heightCenter, float heightAmplitude, float smoothness, float metallic)
{
return float4(
(masks.r * blendMask - heightCenter) * heightAmplitude,
masks.g * smoothness,
masks.b * metallic,
0);
float _HeightTransition;
#ifdef OVERRIDE_SAMPLER_NAME
#define sampler_Splat0 OVERRIDE_SAMPLER_NAME
#endif
// Returns layering blend mask after application of height based blend.
void ApplyHeightBlend(float4 weightedHeights0, float4 weightedHeights1, inout float4 blendMasks0, inout float4 blendMasks1)
void TerrainSplatBlend(float2 uv, float3 tangentWS, float3 bitangentWS,
out float3 outAlbedo, out float3 outNormalTS, out float outSmoothness, out float outMetallic)
float maxHeight = GetMaxHeight(weightedHeights0
#if _LAYER_COUNT > 4
, weightedHeights1
#endif
);
// Make sure that transition is not zero otherwise the next computation will be wrong.
// The epsilon here also has to be bigger than the epsilon in the next computation.
float transition = max(_HeightTransition, 1e-5);
// TODO: triplanar and SURFACE_GRADIENT?
// TODO: POM
// The goal here is to have all but the highest layer at negative heights, then we add the transition so that if the next highest layer is near transition it will have a positive value.
// Then we clamp this to zero and normalize everything so that highest layer has a value of 1.
weightedHeights0 = weightedHeights0 - maxHeight.xxxx;
// We need to add an epsilon here for active layers (hence the blendMask again) so that at least a layer shows up if everything's too low.
weightedHeights0 = (max(0, weightedHeights0 + transition) + 1e-6) * blendMasks0;
float4 albedo[_LAYER_COUNT];
float3 normal[_LAYER_COUNT];
float4 masks[_LAYER_COUNT];
#if _LAYER_COUNT > 4
weightedHeights1 = weightedHeights1 - maxHeight.xxxx;
weightedHeights1 = (max(0, weightedHeights1 + transition) + 1e-6) * blendMasks1;
#ifdef _NORMALMAP
#define SampleNormal(i) SampleNormalGrad(_Normal##i, sampler_Splat0, splatuv, splatdxuv, splatdyuv, tangentWS, bitangentWS)
#else
#define SampleNormal(i) float3(0, 0, 1)
// Normalize
float totalHeight = GetSumHeight(weightedHeights0
#if _LAYER_COUNT > 4
, weightedHeights1
#ifdef _MASKMAP
#define SampleMasks(i, blendMask) RemapMasks(SAMPLE_TEXTURE2D_GRAD(_Mask##i, sampler_Splat0, splatuv, splatdxuv, splatdyuv), blendMask, _HeightCenter##i, _HeightAmplitude##i, _Smoothness##i, _Metallic##i)
#else
#define SampleMasks(i, blendMask) float4(0, albedo[i].a * _Smoothness##i, _Metallic##i, 0)
);
blendMasks0 = weightedHeights0 / totalHeight.xxxx;
#if _LAYER_COUNT > 4
blendMasks1 = weightedHeights1 / totalHeight.xxxx;
#endif
#define SampleResults(i, mask) \
UNITY_BRANCH if (mask > 0) \
{ \
float2 splatuv = uv * _Splat##i##_ST.xy + _Splat##i##_ST.zw; \
float2 splatdxuv = dxuv * _Splat##i##_ST.x; \
float2 splatdyuv = dyuv * _Splat##i##_ST.y; \
albedo[i] = SAMPLE_TEXTURE2D_GRAD(_Splat##i, sampler_Splat0, splatuv, splatdxuv, splatdyuv); \
normal[i] = SampleNormal(i); \
masks[i] = SampleMasks(i, mask); \
} \
else \
{ \
albedo[i] = float4(0, 0, 0, 0); \
normal[i] = float3(0, 0, 0); \
masks[i] = float4(-1, 0, 0, 0); \
}
float2 dxuv = ddx(uv);
float2 dyuv = ddy(uv);
float4 blendMasks0 = SAMPLE_TEXTURE2D(_Control0, sampler_Control0, uv);
#ifdef _TERRAIN_8_LAYERS
float4 blendMasks1 = SAMPLE_TEXTURE2D(_Control1, sampler_Control0, uv);
#else
float4 blendMasks1 = float4(0, 0, 0, 0);
#endif
SampleResults(0, blendMasks0.x);
SampleResults(1, blendMasks0.y);
SampleResults(2, blendMasks0.z);
SampleResults(3, blendMasks0.w);
#ifdef _TERRAIN_8_LAYERS
SampleResults(4, blendMasks1.x);
SampleResults(5, blendMasks1.y);
SampleResults(6, blendMasks1.z);
SampleResults(7, blendMasks1.w);
#endif
#undef SampleNormal
#undef SampleMasks
#undef SampleResults
float weights[_LAYER_COUNT];
ZERO_INITIALIZE_ARRAY(float, weights, _LAYER_COUNT);
#if defined(_TERRAIN_BLEND_HEIGHT) && defined(_MASKMAP)
// Modify blendMask to take into account the height of the layer. Higher height should be more visible.
float maxHeight = masks[0].x;
maxHeight = max(maxHeight, masks[1].x);
maxHeight = max(maxHeight, masks[2].x);
maxHeight = max(maxHeight, masks[3].x);
#ifdef _TERRAIN_8_LAYERS
maxHeight = max(maxHeight, masks[4].x);
maxHeight = max(maxHeight, masks[5].x);
maxHeight = max(maxHeight, masks[6].x);
maxHeight = max(maxHeight, masks[7].x);
#endif
// Make sure that transition is not zero otherwise the next computation will be wrong.
// The epsilon here also has to be bigger than the epsilon in the next computation.
float transition = max(_HeightTransition, 1e-5);
// The goal here is to have all but the highest layer at negative heights, then we add the transition so that if the next highest layer is near transition it will have a positive value.
// Then we clamp this to zero and normalize everything so that highest layer has a value of 1.
float4 weightedHeights0 = { masks[0].x, masks[1].x, masks[2].x, masks[3].x };
weightedHeights0 = weightedHeights0 - maxHeight.xxxx;
// We need to add an epsilon here for active layers (hence the blendMask again) so that at least a layer shows up if everything's too low.
weightedHeights0 = (max(0, weightedHeights0 + transition) + 1e-6) * blendMasks0;
#ifdef _TERRAIN_8_LAYERS
float4 weightedHeights1 = { masks[4].x, masks[5].x, masks[6].x, masks[7].x };
weightedHeights1 = weightedHeights1 - maxHeight.xxxx;
weightedHeights1 = (max(0, weightedHeights1 + transition) + 1e-6) * blendMasks1;
#else
float4 weightedHeights1 = { 0, 0, 0, 0 };
#endif
// Normalize
float sumHeight = GetSumHeight(weightedHeights0, weightedHeights1);
blendMasks0 = weightedHeights0 / sumHeight.xxxx;
#ifdef _TERRAIN_8_LAYERS
blendMasks1 = weightedHeights1 / sumHeight.xxxx;
#endif
#elif defined(_TERRAIN_BLEND_DENSITY) && defined(_MASKMAP)
// Denser layers are more visible.
float4 opacityAsDensity0 = saturate((float4(albedo[0].a, albedo[1].a, albedo[2].a, albedo[3].a) - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks0)) * 20.0); // 20.0 is the number of steps in inputAlphaMask (Density mask. We decided 20 empirically)
float4 useOpacityAsDensityParam0 = { _Density0, _Density1, _Density2, _Density3 };
blendMasks0 = lerp(blendMasks0, opacityAsDensity0, useOpacityAsDensityParam0);
#ifdef _TERRAIN_8_LAYERS
float4 opacityAsDensity1 = saturate((float4(albedo[4].a, albedo[5].a, albedo[6].a, albedo[7].a) - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks1)) * 20.0); // 20.0 is the number of steps in inputAlphaMask (Density mask. We decided 20 empirically)
float4 useOpacityAsDensityParam1 = { _Density4, _Density5, _Density6, _Density7 };
blendMasks1 = lerp(blendMasks1, opacityAsDensity1, useOpacityAsDensityParam1);
#endif
#endif
weights[0] = blendMasks0.x;
weights[1] = blendMasks0.y;
weights[2] = blendMasks0.z;
weights[3] = blendMasks0.w;
#ifdef _TERRAIN_8_LAYERS
weights[4] = blendMasks1.x;
weights[5] = blendMasks1.y;
weights[6] = blendMasks1.z;
weights[7] = blendMasks1.w;
#endif
#if defined(_TERRAIN_BLEND_DENSITY) && defined(_MASKMAP)
// calculate weight of each layers
// Algorithm is like this:
// Top layer have priority on others layers
// If a top layer doesn't use the full weight, the remaining can be use by the following layer.
float weightsSum = 0.0;
UNITY_UNROLL
for (int i = _LAYER_COUNT - 1; i >= 0; --i)
{
weights[i] = min(weights[i], (1.0 - weightsSum));
weightsSum = saturate(weightsSum + weights[i]);
}
#endif
outAlbedo = 0;
outNormalTS = 0;
float2 outMasks = 0;
UNITY_UNROLL for (int i = 0; i < _LAYER_COUNT; ++i)
{
outAlbedo += albedo[i].rgb * weights[i];
outNormalTS += normal[i].rgb * weights[i];
outMasks += masks[i].yz * weights[i];
}
#ifndef _NORMALMAP
#ifdef SURFACE_GRADIENT
outNormalTS = float3(0.0, 0.0, 0.0); // No gradient
#else
outNormalTS = float3(0.0, 0.0, 1.0);
#endif
#endif
outSmoothness = outMasks.x;
outMetallic = outMasks.y;
}

145
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/TerrainLit/TerrainLit_Basemap_Gen.shader


Shader "Hidden/HDRenderPipeline/TerrainLit_Basemap_Gen"
{
Properties
{
[HideInInspector] _Control0("AlphaMap", 2D) = "" {}
[HideInInspector] _Control1("AlphaMap", 2D) = "" {}
[HideInInspector] _Splat0("Layer 0", 2D) = "white" {}
[HideInInspector] _Splat1("Layer 1", 2D) = "white" {}
[HideInInspector] _Splat2("Layer 2", 2D) = "white" {}
[HideInInspector] _Splat3("Layer 3", 2D) = "white" {}
[HideInInspector] _Splat4("Layer 4", 2D) = "white" {}
[HideInInspector] _Splat5("Layer 5", 2D) = "white" {}
[HideInInspector] _Splat6("Layer 6", 2D) = "white" {}
[HideInInspector] _Splat7("Layer 7", 2D) = "white" {}
[HideInInspector] _Height0("Height 0", 2D) = "black" {}
[HideInInspector] _Height1("Height 1", 2D) = "black" {}
[HideInInspector] _Height2("Height 2", 2D) = "black" {}
[HideInInspector] _Height3("Height 3", 2D) = "black" {}
[HideInInspector] _Height4("Height 4", 2D) = "black" {}
[HideInInspector] _Height5("Height 5", 2D) = "black" {}
[HideInInspector] _Height6("Height 6", 2D) = "black" {}
[HideInInspector] _Height7("Height 7", 2D) = "black" {}
[HideInInspector] _HeightAmplitude0("Height Scale0", Float) = 0.02
[HideInInspector] _HeightAmplitude1("Height Scale1", Float) = 0.02
[HideInInspector] _HeightAmplitude2("Height Scale2", Float) = 0.02
[HideInInspector] _HeightAmplitude3("Height Scale3", Float) = 0.02
[HideInInspector] _HeightAmplitude4("Height Scale4", Float) = 0.02
[HideInInspector] _HeightAmplitude5("Height Scale5", Float) = 0.02
[HideInInspector] _HeightAmplitude6("Height Scale6", Float) = 0.02
[HideInInspector] _HeightAmplitude7("Height Scale7", Float) = 0.02
[HideInInspector] _HeightCenter0("Height Bias0", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter1("Height Bias1", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter2("Height Bias2", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter3("Height Bias3", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter4("Height Bias4", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter5("Height Bias5", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter6("Height Bias6", Range(0.0, 1.0)) = 0.5
[HideInInspector] _HeightCenter7("Height Bias7", Range(0.0, 1.0)) = 0.5
[HideInInspector] _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness4("Smoothness 4", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness5("Smoothness 5", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness6("Smoothness 6", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness7("Smoothness 7", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic4("Metallic 4", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic5("Metallic 5", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic6("Metallic 6", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic7("Metallic 7", Range(0.0, 1.0)) = 0.0
}
SubShader
{
Tags { "SplatCount" = "8" }

#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "../../ShaderVariables.hlsl"
#define _TERRAIN_8_SPLATS
#include "TerrainLitSplatCommon.hlsl"
#include "../Material.hlsl"
#pragma shader_feature _TERRAIN_HEIGHT_MAP
// Needed because unity tries to match the name of the used textures to samplers. Heights can be used without splats.
SAMPLER(sampler_Height0);
#pragma shader_feature _TERRAIN_8_LAYERS
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
#pragma shader_feature _ _TERRAIN_BLEND_DENSITY _TERRAIN_BLEND_HEIGHT
void FetchWeights(float2 uv, out float4 weights0, out float4 weights1)
{
weights0 = SAMPLE_TEXTURE2D(_Control0, sampler_Control0, uv);
weights1 = SAMPLE_TEXTURE2D(_Control1, sampler_Control0, uv);
#ifdef _TERRAIN_HEIGHT_MAP
float4 weightedHeights0;
float4 weightedHeights1;
weightedHeights0.r = (SAMPLE_TEXTURE2D(_Height0, sampler_Height0, TRANSFORM_TEX(uv, _Splat0)).r * weights0.r - _HeightCenter0) * _HeightAmplitude0;
weightedHeights0.g = (SAMPLE_TEXTURE2D(_Height1, sampler_Height0, TRANSFORM_TEX(uv, _Splat1)).r * weights0.g - _HeightCenter1) * _HeightAmplitude1;
weightedHeights0.b = (SAMPLE_TEXTURE2D(_Height2, sampler_Height0, TRANSFORM_TEX(uv, _Splat2)).r * weights0.b - _HeightCenter2) * _HeightAmplitude2;
weightedHeights0.a = (SAMPLE_TEXTURE2D(_Height3, sampler_Height0, TRANSFORM_TEX(uv, _Splat3)).r * weights0.a - _HeightCenter3) * _HeightAmplitude3;
weightedHeights1.r = (SAMPLE_TEXTURE2D(_Height4, sampler_Height0, TRANSFORM_TEX(uv, _Splat4)).r * weights1.r - _HeightCenter4) * _HeightAmplitude4;
weightedHeights1.g = (SAMPLE_TEXTURE2D(_Height5, sampler_Height0, TRANSFORM_TEX(uv, _Splat5)).r * weights1.g - _HeightCenter5) * _HeightAmplitude5;
weightedHeights1.b = (SAMPLE_TEXTURE2D(_Height6, sampler_Height0, TRANSFORM_TEX(uv, _Splat6)).r * weights1.b - _HeightCenter6) * _HeightAmplitude6;
weightedHeights1.a = (SAMPLE_TEXTURE2D(_Height7, sampler_Height0, TRANSFORM_TEX(uv, _Splat7)).r * weights1.a - _HeightCenter7) * _HeightAmplitude7;
// Modify blendMask to take into account the height of the layer. Higher height should be more visible.
ApplyHeightBlend(weightedHeights0, weightedHeights1, weights0, weights1);
#endif
}
#ifdef _MASKMAP
// Needed because unity tries to match the name of the used textures to samplers. Masks can be used without splats in Metallic pass.
SAMPLER(sampler_Mask0);
#define OVERRIDE_SAMPLER_NAME sampler_Mask0
#endif
#include "TerrainLitSplatCommon.hlsl"
struct appdata_t {
float3 vertex : POSITION;

float4 frag(v2f i) : SV_Target
{
float4 weights0, weights1;
FetchWeights(i.texcoord, weights0, weights1);
float4 splat0 = SAMPLE_TEXTURE2D(_Splat0, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat0));
float4 splat1 = SAMPLE_TEXTURE2D(_Splat1, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat1));
float4 splat2 = SAMPLE_TEXTURE2D(_Splat2, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat2));
float4 splat3 = SAMPLE_TEXTURE2D(_Splat3, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat3));
float4 splat4 = SAMPLE_TEXTURE2D(_Splat4, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat4));
float4 splat5 = SAMPLE_TEXTURE2D(_Splat5, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat5));
float4 splat6 = SAMPLE_TEXTURE2D(_Splat6, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat6));
float4 splat7 = SAMPLE_TEXTURE2D(_Splat7, sampler_Splat0, TRANSFORM_TEX(i.texcoord, _Splat7));
splat0.a *= _Smoothness0;
splat1.a *= _Smoothness1;
splat2.a *= _Smoothness2;
splat3.a *= _Smoothness3;
splat4.a *= _Smoothness4;
splat5.a *= _Smoothness5;
splat6.a *= _Smoothness6;
splat7.a *= _Smoothness7;
float4 albedo;
float3 normalTS;
float metallic;
TerrainSplatBlend(i.texcoord, float3(0, 0, 0), float3(0, 0, 0),
albedo.xyz, normalTS, albedo.w, metallic);
float4 albedoSmoothness = splat0 * weights0.x;
albedoSmoothness += splat1 * weights0.y;
albedoSmoothness += splat2 * weights0.z;
albedoSmoothness += splat3 * weights0.w;
albedoSmoothness += splat4 * weights1.x;
albedoSmoothness += splat5 * weights1.y;
albedoSmoothness += splat6 * weights1.z;
albedoSmoothness += splat7 * weights1.w;
return albedoSmoothness;
return albedo;
}
ENDHLSL

float4 frag(v2f i) : SV_Target
{
float4 weights0, weights1;
FetchWeights(i.texcoord, weights0, weights1);
float4 albedo;
float3 normalTS;
float metallic;
TerrainSplatBlend(i.texcoord, float3(0, 0, 0), float3(0, 0, 0),
albedo.xyz, normalTS, albedo.w, metallic);
float4 metallic = { _Metallic0 * weights0.x, 0, 0, 0 };
metallic.r += _Metallic1 * weights0.y;
metallic.r += _Metallic2 * weights0.z;
metallic.r += _Metallic3 * weights0.w;
metallic.r += _Metallic4 * weights1.x;
metallic.r += _Metallic5 * weights1.y;
metallic.r += _Metallic6 * weights1.z;
metallic.r += _Metallic7 * weights1.w;
return metallic;
}

41
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DefaultHDTerrainMaterial.mat


m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask0:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask1:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask2:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask3:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask4:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask5:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask6:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask7:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Normal0:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

m_Offset: {x: 0, y: 0}
m_Floats:
- _CullMode: 2
- _Density0: 1
- _Density1: 1
- _Density2: 1
- _Density3: 1
- _Density4: 1
- _Density5: 1
- _Density6: 1
- _Density7: 1
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _EnableHeightBlending: 1

- _HeightCenter6: 0.5
- _HeightCenter7: 0.5
- _HeightTransition: 0
- _LayerBlendMode: 0
- _Metallic0: 0
- _Metallic1: 0
- _Metallic2: 0

正在加载...
取消
保存