浏览代码

Merge pull request #1875 from Unity-Technologies/gpu-terrain

GPU Terrain (2018.3) port to HDRP and LWRP
/main
GitHub 6 年前
当前提交
a6854ec4
共有 76 个文件被更改,包括 7181 次插入92 次删除
  1. 3
      TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset
  2. 31
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Common.hlsl
  3. 57
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/UnityInstancing.hlsl
  4. 21
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
  5. 1
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.hlsl
  6. 15
      com.unity.render-pipelines.high-definition/HDRP/Debug/MipMapDebug.cs
  7. 13
      com.unity.render-pipelines.high-definition/HDRP/Debug/MipMapDebug.cs.hlsl
  8. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/LitShaderPreprocessor.cs
  9. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDEditorUtils.cs
  10. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/UpgradeMenuItem.cs
  11. 1
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  12. 2
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs
  13. 1
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
  14. 1
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
  15. 1
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs
  16. 1
      com.unity.render-pipelines.high-definition/HDRP/ShaderPass/ShaderPassVelocity.hlsl
  17. 11
      com.unity.render-pipelines.high-definition/HDRP/ShaderPass/VertMesh.hlsl
  18. 2
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl
  19. 152
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl
  20. 23
      com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrain.shader
  21. 6
      com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrainAddPass.shader
  22. 35
      com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrainBase.shader
  23. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.meta
  24. 539
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.unity
  25. 7
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.unity.meta
  26. 1001
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1601_TerrainLit.png
  27. 88
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1601_TerrainLit.png.meta
  28. 8
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/TerrainLit.meta
  29. 8
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit.meta
  30. 41
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/DefaultHDTerrainMaterial.mat
  31. 8
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/DefaultHDTerrainMaterial.mat.meta
  32. 244
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Decal.mat
  33. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Decal.mat.meta
  34. 22
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02.terrainlayer
  35. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02.terrainlayer.meta
  36. 132
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02_BC.png.meta
  37. 132
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02_MSK.tga.meta
  38. 132
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02_N.png.meta
  39. 233
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/MeshMaterial.mat
  40. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/MeshMaterial.mat.meta
  41. 1001
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/New Terrain.asset
  42. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/New Terrain.asset.meta
  43. 1001
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Part02.FBX
  44. 122
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Part02.FBX.meta
  45. 22
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01.terrainlayer
  46. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01.terrainlayer.meta
  47. 132
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01_BC.tga.meta
  48. 132
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01_MSK.tga.meta
  49. 132
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01_N.tga.meta
  50. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/TerrainLit/TerrainLitUI.cs.meta
  51. 326
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/TerrainLit/TerrainLitUI.cs
  52. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit.shader.meta
  53. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData.hlsl.meta
  54. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitDataMeshModification.hlsl.meta
  55. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData_Basemap.hlsl.meta
  56. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSharePass.hlsl.meta
  57. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSplatCommon.hlsl.meta
  58. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap.shader.meta
  59. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap_Gen.shader.meta
  60. 35
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSharePass.hlsl
  61. 259
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap.shader
  62. 289
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit.shader
  63. 125
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap_Gen.shader
  64. 39
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitDataMeshModification.hlsl
  65. 113
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData.hlsl
  66. 108
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData_Basemap.hlsl
  67. 326
      com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSplatCommon.hlsl

3
TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset


path: Assets/GraphicTests/Scenes/1x_Materials/1501_Fabric.unity
guid: ce2b258da0df8d245b659390b6c2ac51
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.unity
guid: d52dbea61cf2f884fadf33f8cc6afc0c
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2001_Dynamic_Directional.unity
guid: 09baf18a7e1f6584f86675e6a2141c66
- enabled: 1

31
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Common.hlsl


}
// ----------------------------------------------------------------------------
// Terrain/Brush heightmap encoding/decoding
// ----------------------------------------------------------------------------
#if defined(SHADER_API_VULKAN) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
real4 PackHeightmap(real height)
{
uint a = (uint)(65535.0 * height);
return real4((a >> 0) & 0xFF, (a >> 8) & 0xFF, 0, 0) / 255.0;
}
real UnpackHeightmap(real4 height)
{
return (height.r + height.g * 256.0) / 257.0; // (255.0 * height.r + 255.0 * 256.0 * height.g) / 65535.0
}
#else
real4 PackHeightmap(real height)
{
return real4(height, 0, 0, 0);
}
real UnpackHeightmap(real4 height)
{
return height.r;
}
#endif
// ----------------------------------------------------------------------------
// Misc utilities
// ----------------------------------------------------------------------------

57
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/UnityInstancing.hlsl


#define UNITY_SUPPORT_STEREO_INSTANCING
#endif
#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_SWITCH)
#define UNITY_INSTANCING_AOS
#endif
#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN)
#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH)
#define UNITY_INSTANCING_SUPPORT_FLEXIBLE_ARRAY_SIZE
#endif

#endif
#endif
#ifdef UNITY_INSTANCING_AOS
#define UNITY_INSTANCING_BUFFER_START(buf) UNITY_INSTANCING_CBUFFER_SCOPE_BEGIN(UnityInstancing_##buf) struct {
#define UNITY_INSTANCING_BUFFER_END(arr) } arr##Array[UNITY_INSTANCED_ARRAY_SIZE]; UNITY_INSTANCING_CBUFFER_SCOPE_END
#define UNITY_DEFINE_INSTANCED_PROP(type, var) type var;
#define UNITY_ACCESS_INSTANCED_PROP(arr, var) arr##Array[unity_InstanceID].var
#else
#define UNITY_INSTANCING_BUFFER_START(buf) UNITY_INSTANCING_CBUFFER_SCOPE_BEGIN(UnityInstancing_##buf)
#define UNITY_INSTANCING_BUFFER_END(arr) UNITY_INSTANCING_CBUFFER_SCOPE_END
#define UNITY_DEFINE_INSTANCED_PROP(type, var) type var[UNITY_INSTANCED_ARRAY_SIZE];
#define UNITY_ACCESS_INSTANCED_PROP(arr, var) var[unity_InstanceID]
#endif
#define UNITY_INSTANCING_BUFFER_START(buf) UNITY_INSTANCING_CBUFFER_SCOPE_BEGIN(UnityInstancing_##buf) struct {
#define UNITY_INSTANCING_BUFFER_END(arr) } arr##Array[UNITY_INSTANCED_ARRAY_SIZE]; UNITY_INSTANCING_CBUFFER_SCOPE_END
#define UNITY_DEFINE_INSTANCED_PROP(type, var) type var;
#define UNITY_ACCESS_INSTANCED_PROP(arr, var) arr##Array[unity_InstanceID].var
// Put worldToObject array to a separate CB if UNITY_ASSUME_UNIFORM_SCALING is defined. Most of the time it will not be used.
#ifdef UNITY_ASSUME_UNIFORM_SCALING

#endif
UNITY_INSTANCING_BUFFER_START(PerDraw0)
UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_ObjectToWorldArray)
#if UNITY_WORLDTOOBJECTARRAY_CB == 0
UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_WorldToObjectArray)
#ifndef UNITY_DONT_INSTANCE_OBJECT_MATRICES
UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_ObjectToWorldArray)
#if UNITY_WORLDTOOBJECTARRAY_CB == 0
UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_WorldToObjectArray)
#endif
#endif
#if defined(UNITY_USE_LODFADE_ARRAY) && defined(UNITY_INSTANCING_SUPPORT_FLEXIBLE_ARRAY_SIZE)
UNITY_DEFINE_INSTANCED_PROP(float2, unity_LODFadeArray)

UNITY_INSTANCING_BUFFER_END(unity_Builtins0)
UNITY_INSTANCING_BUFFER_START(PerDraw1)
#if UNITY_WORLDTOOBJECTARRAY_CB == 1
#if !defined(UNITY_DONT_INSTANCE_OBJECT_MATRICES) && UNITY_WORLDTOOBJECTARRAY_CB == 1
UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_WorldToObjectArray)
#endif
#if defined(UNITY_USE_LODFADE_ARRAY) && !defined(UNITY_INSTANCING_SUPPORT_FLEXIBLE_ARRAY_SIZE)

#endif
UNITY_INSTANCING_BUFFER_END(unity_Builtins2)
#undef UNITY_MATRIX_M
#ifdef MODIFY_MATRIX_FOR_CAMERA_RELATIVE_RENDERING
#define UNITY_MATRIX_M ApplyCameraTranslationToMatrix(UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_ObjectToWorldArray))
#else
#define UNITY_MATRIX_M UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_ObjectToWorldArray)
#endif
#define MERGE_UNITY_BUILTINS_INDEX(X) unity_Builtins##X
#undef UNITY_MATRIX_I_M
#ifdef MODIFY_MATRIX_FOR_CAMERA_RELATIVE_RENDERING
#define UNITY_MATRIX_I_M ApplyCameraTranslationToInverseMatrix(UNITY_ACCESS_INSTANCED_PROP(MERGE_UNITY_BUILTINS_INDEX(UNITY_WORLDTOOBJECTARRAY_CB), unity_WorldToObjectArray))
#else
#define UNITY_MATRIX_I_M UNITY_ACCESS_INSTANCED_PROP(MERGE_UNITY_BUILTINS_INDEX(UNITY_WORLDTOOBJECTARRAY_CB), unity_WorldToObjectArray)
#ifndef UNITY_DONT_INSTANCE_OBJECT_MATRICES
#undef UNITY_MATRIX_M
#undef UNITY_MATRIX_I_M
#define MERGE_UNITY_BUILTINS_INDEX(X) unity_Builtins##X
#ifdef MODIFY_MATRIX_FOR_CAMERA_RELATIVE_RENDERING
#define UNITY_MATRIX_M ApplyCameraTranslationToMatrix(UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_ObjectToWorldArray))
#define UNITY_MATRIX_I_M ApplyCameraTranslationToInverseMatrix(UNITY_ACCESS_INSTANCED_PROP(MERGE_UNITY_BUILTINS_INDEX(UNITY_WORLDTOOBJECTARRAY_CB), unity_WorldToObjectArray))
#else
#define UNITY_MATRIX_M UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_ObjectToWorldArray)
#define UNITY_MATRIX_I_M UNITY_ACCESS_INSTANCED_PROP(MERGE_UNITY_BUILTINS_INDEX(UNITY_WORLDTOOBJECTARRAY_CB), unity_WorldToObjectArray)
#endif
#endif
#else // UNITY_INSTANCING_ENABLED

21
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs


return mipMapDebugSettings.debugMipMapMode;
}
public DebugMipMapModeTerrainTexture GetDebugMipMapModeTerrainTexture()
{
return mipMapDebugSettings.terrainTexture;
}
public ColorPickerDebugMode GetDebugColorPickerMode()
{
return colorPickerDebugSettings.colorPickerMode;

widgetList.AddRange(new DebugUI.Widget[]
{
new DebugUI.EnumField { displayName = "Fullscreen Debug Mode", getter = () => (int)fullScreenDebugMode, setter = value => fullScreenDebugMode = (FullScreenDebugMode)value, enumNames = renderingFullScreenDebugStrings, enumValues = renderingFullScreenDebugValues },
new DebugUI.EnumField { displayName = "MipMaps", getter = () => (int)mipMapDebugSettings.debugMipMapMode, setter = value => SetMipMapMode((DebugMipMapMode)value), autoEnum = typeof(DebugMipMapMode) },
new DebugUI.EnumField { displayName = "MipMaps", getter = () => (int)mipMapDebugSettings.debugMipMapMode, setter = value => SetMipMapMode((DebugMipMapMode)value), autoEnum = typeof(DebugMipMapMode), onValueChanged = RefreshRenderingDebug },
});
if (mipMapDebugSettings.debugMipMapMode != DebugMipMapMode.None)
{
widgetList.Add(new DebugUI.Container
{
children =
{
new DebugUI.EnumField { displayName = "Terrain Texture", getter = ()=>(int)mipMapDebugSettings.terrainTexture, setter = value => mipMapDebugSettings.terrainTexture = (DebugMipMapModeTerrainTexture)value, autoEnum = typeof(DebugMipMapModeTerrainTexture) }
}
});
}
widgetList.AddRange(new []
{
new DebugUI.Container
{
displayName = "Color Picker",

1
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.hlsl


int _DebugLightingSubMode;
int _DebugViewMaterial; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
int _DebugMipMapMode; // Match enum DebugMipMapMode
int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
int _ColorPickerMode; // Match enum ColorPickerDebugMode
int _DebugStep;
float4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse

15
com.unity.render-pipelines.high-definition/HDRP/Debug/MipMapDebug.cs


StreamingMip
}
[GenerateHLSL]
public enum DebugMipMapModeTerrainTexture
{
Control,
Layer0,
Layer1,
Layer2,
Layer3,
Layer4,
Layer5,
Layer6,
Layer7
}
public DebugMipMapModeTerrainTexture terrainTexture = DebugMipMapModeTerrainTexture.Control;
public bool IsDebugDisplayEnabled()
{

13
com.unity.render-pipelines.high-definition/HDRP/Debug/MipMapDebug.cs.hlsl


#define DEBUGMIPMAPMODE_STREAMING_MIP_BUDGET (4)
#define DEBUGMIPMAPMODE_STREAMING_MIP (5)
//
// UnityEngine.Experimental.Rendering.HDPipeline.DebugMipMapModeTerrainTexture: static fields
//
#define DEBUGMIPMAPMODETERRAINTEXTURE_CONTROL (0)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER0 (1)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER1 (2)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER2 (3)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER3 (4)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER4 (5)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER5 (6)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER6 (7)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER7 (8)
#endif

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/LitShaderPreprocessor.cs


stripperFuncs.Add("HDRenderPipeline/LitTessellation", LitShaderStripper);
stripperFuncs.Add("HDRenderPipeline/LayeredLit", LitShaderStripper);
stripperFuncs.Add("HDRenderPipeline/LayeredLitTessellation", LitShaderStripper);
stripperFuncs.Add("HDRenderPipeline/TerrainLit", LitShaderStripper);
stripperFuncs.Add("Hidden/HDRenderPipeline/TerrainLit_Basemap", LitShaderStripper);
}
}
}

3
com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDEditorUtils.cs


{ "HDRenderPipeline/LitTessellation", LitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Unlit", UnlitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Fabric", FabricGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Decal", DecalUI.SetupMaterialKeywordsAndPass }
{ "HDRenderPipeline/Decal", DecalUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/TerrainLit", TerrainLitGUI.SetupMaterialKeywordsAndPass }
};
public static T LoadAsset<T>(string relativePath) where T : UnityEngine.Object

3
com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/UpgradeMenuItem.cs


mat.shader.name == "HDRenderPipeline/StackLit" ||
mat.shader.name == "HDRenderPipeline/Unlit" ||
mat.shader.name == "HDRenderPipeline/Fabric" ||
mat.shader.name == "HDRenderPipeline/Decal"
mat.shader.name == "HDRenderPipeline/Decal" ||
mat.shader.name == "HDRenderPipeline/TerrainLit"
)
{
// We don't handle embed material as we can't rewrite fbx files

1
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


cmd.SetGlobalInt(HDShaderIDs._DebugLightingMode, (int)m_CurrentDebugDisplaySettings.GetDebugLightingMode());
cmd.SetGlobalInt(HDShaderIDs._DebugLightingSubMode, (int)m_CurrentDebugDisplaySettings.GetDebugLightingSubMode());
cmd.SetGlobalInt(HDShaderIDs._DebugMipMapMode, (int)m_CurrentDebugDisplaySettings.GetDebugMipMapMode());
cmd.SetGlobalInt(HDShaderIDs._DebugMipMapModeTerrainTexture, (int)m_CurrentDebugDisplaySettings.GetDebugMipMapModeTerrainTexture());
cmd.SetGlobalInt(HDShaderIDs._ColorPickerMode, (int)m_CurrentDebugDisplaySettings.GetDebugColorPickerMode());
cmd.SetGlobalVector(HDShaderIDs._DebugLightingAlbedo, debugAlbedo);

2
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs


public override Material GetDefaultTerrainMaterial()
{
return null;
return m_RenderPipelineResources.defaultTerrainMaterial;
}
public override Material GetDefaultUIMaterial()

1
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs


public static readonly int _DebugLightingSpecularColor = Shader.PropertyToID("_DebugLightingSpecularColor");
public static readonly int _AmbientOcclusionTexture = Shader.PropertyToID("_AmbientOcclusionTexture");
public static readonly int _DebugMipMapMode = Shader.PropertyToID("_DebugMipMapMode");
public static readonly int _DebugMipMapModeTerrainTexture = Shader.PropertyToID("_DebugMipMapModeTerrainTexture");
public static readonly int _UseTileLightList = Shader.PropertyToID("_UseTileLightList");

1
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset


defaultDiffuseMaterial: {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2}
defaultMirrorMaterial: {fileID: 2100000, guid: 6b17274157b33bc45b6a40e7d4ff51fe, type: 2}
defaultDecalMaterial: {fileID: 2100000, guid: 500e733574922d04ea961553b1b26a63, type: 2}
defaultTerrainMaterial: {fileID: 2100000, guid: 22ff8771d87ef27429e670136399094b, type: 2}
defaultShader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
debugFontTexture: {fileID: 2800000, guid: a3ad2df0e49aaa341a3b3a80f93b3f66, type: 3}
debugDisplayLatlongShader: {fileID: 4800000, guid: c1d1d149a043a5349ba367da6c2051ba, type: 3}

1
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs


public Material defaultDiffuseMaterial;
public Material defaultMirrorMaterial;
public Material defaultDecalMaterial;
public Material defaultTerrainMaterial;
public Shader defaultShader;
// Debug

1
com.unity.render-pipelines.high-definition/HDRP/ShaderPass/ShaderPassVelocity.hlsl


return normalize(mul((float3x3)unity_MatrixPreviousM, normalOS));
#else
// Normal need to be multiply by inverse transpose
// mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)}
return normalize(mul(normalOS, (float3x3)unity_MatrixPreviousMI));
#endif
}

11
com.unity.render-pipelines.high-definition/HDRP/ShaderPass/VertMesh.hlsl


#endif
// TODO: Here we will also have all the vertex deformation (GPU skinning, vertex animation, morph target...) or we will need to generate a compute shaders instead (better! but require work to deal with unpacking like fp16)
// Make it inout so that VelocityPass can get the modified input values later.
#if defined(HAVE_MESH_MODIFICATION)
input = ApplyMeshModification(input);
#endif
#if defined(HAVE_MESH_MODIFICATION)
input = ApplyMeshModification(input);
#endif
// This return the camera relative position (if enable)
float3 positionRWS = TransformObjectToWorld(input.positionOS);
#ifdef ATTRIBUTES_NEED_NORMAL

#endif
#ifdef ATTRIBUTES_NEED_TANGENT
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
#endif
// Do vertex modification in camera relative space (if enable)

2
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl


TEXTURE2D(_Splat2);
TEXTURE2D(_Splat3);
#ifdef _TERRAIN_NORMAL_MAP
#ifdef _NORMALMAP
TEXTURE2D(_Normal0); SAMPLER(sampler_Normal0);
TEXTURE2D(_Normal1);
TEXTURE2D(_Normal2);

152
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl


float4 tangent : TANGENT;
float3 normal : NORMAL;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 uvSplat01 : TEXCOORD0; // xy: splat0, zw: splat1
float4 uvSplat23 : TEXCOORD1; // xy: splat2, zw: splat3
float4 uvControlAndLM : TEXCOORD2; // xy: control, zw: lightmap
float4 uvMainAndLM : TEXCOORD0; // xy: control, zw: lightmap
#ifndef TERRAIN_SPLAT_BASEPASS
float4 uvSplat01 : TEXCOORD1; // xy: splat0, zw: splat1
float4 uvSplat23 : TEXCOORD2; // xy: splat2, zw: splat3
#endif
#if _TERRAIN_NORMAL_MAP
#if _NORMALMAP
half4 normal : TEXCOORD3; // xyz: normal, w: viewDir.x
half4 tangent : TEXCOORD4; // xyz: tangent, w: viewDir.y
half4 binormal : TEXCOORD5; // xyz: binormal, w: viewDir.z

input.positionWS = IN.positionWS;
#ifdef _TERRAIN_NORMAL_MAP
#ifdef _NORMALMAP
half3 viewDir = half3(IN.normal.w, IN.tangent.w, IN.binormal.w);
input.normalWS = TangentToWorldNormal(normalTS, IN.tangent.xyz, IN.binormal.xyz, IN.normal.xyz);
#else

input.vertexLighting = IN.fogFactorAndVertexLight.yzw;
#ifdef LIGHTMAP_ON
input.bakedGI = SampleLightmap(IN.uvControlAndLM.zw, input.normalWS);
input.bakedGI = SampleLightmap(IN.uvMainAndLM.zw, input.normalWS);
#ifndef TERRAIN_SPLAT_BASEPASS
splatControl = SAMPLE_TEXTURE2D(_Control, sampler_Control, IN.uvControlAndLM.xy);
splatControl = SAMPLE_TEXTURE2D(_Control, sampler_Control, IN.uvMainAndLM.xy);
weight = dot(splatControl, 1.0h);
#if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)

mixedDiffuse += SAMPLE_TEXTURE2D(_Splat2, sampler_Splat0, IN.uvSplat23.xy) * half4(splatControl.bbb, alpha.b);
mixedDiffuse += SAMPLE_TEXTURE2D(_Splat3, sampler_Splat0, IN.uvSplat23.zw) * half4(splatControl.aaa, alpha.a);
#ifdef _TERRAIN_NORMAL_MAP
#ifdef _NORMALMAP
half4 nrm = 0.0f;
nrm += SAMPLE_TEXTURE2D(_Normal0, sampler_Normal0, IN.uvSplat01.xy) * splatControl.r;
nrm += SAMPLE_TEXTURE2D(_Normal1, sampler_Normal0, IN.uvSplat01.zw) * splatControl.g;

mixedNormal = half3(0.0h, 0.0h, 1.0h);
#endif
}
#endif
#ifdef TERRAIN_SPLAT_ADDPASS
ApplyFogColor(color.rgb, half3(0.0h, 0.0h, 0.0h), fogCoord);
#else
ApplyFog(color.rgb, fogCoord);
#ifdef TERRAIN_SPLAT_ADDPASS
ApplyFogColor(color.rgb, half3(0,0,0), fogCoord);
#else
ApplyFog(color.rgb, fogCoord);
#endif
}
#ifdef UNITY_INSTANCING_ENABLED
TEXTURE2D(_TerrainHeightmapTexture);
TEXTURE2D(_TerrainNormalmapTexture);
float4 _TerrainHeightmapRecipSize; // float4(1.0f/width, 1.0f/height, 1.0f/(width-1), 1.0f/(height-1))
float4 _TerrainHeightmapScale; // float4(hmScale.x, hmScale.y / (float)(kMaxHeight), hmScale.z, 0.0f)
UNITY_INSTANCING_BUFFER_START(Terrain)
UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainPatchInstanceData) // float4(xBase, yBase, skipScale, ~)
UNITY_INSTANCING_BUFFER_END(Terrain)
void TerrainInstancing(inout float4 vertex, inout float3 normal, inout float2 uv)
{
#ifdef UNITY_INSTANCING_ENABLED
float2 patchVertex = vertex.xy;
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);
float2 sampleCoords = (patchVertex.xy + instanceData.xy) * instanceData.z; // (xy + float2(xBase,yBase)) * skipScale
float height = UnpackHeightmap(_TerrainHeightmapTexture.Load(int3(sampleCoords, 0)));
vertex.xz = sampleCoords * _TerrainHeightmapScale.xz;
vertex.y = height * _TerrainHeightmapScale.y;
normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb * 2 - 1;
uv = sampleCoords * _TerrainHeightmapRecipSize.zw;
#endif
}
void TerrainInstancing(inout float4 vertex, inout float3 normal)
{
float2 uv = { 0, 0 };
TerrainInstancing(vertex, normal, uv);
}
///////////////////////////////////////////////////////////////////////////////

{
VertexOutput o = (VertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
TerrainInstancing(v.vertex, v.normal, v.texcoord);
o.uvMainAndLM.xy = v.texcoord;
o.uvMainAndLM.zw = v.texcoord * unity_LightmapST.xy + unity_LightmapST.zw;
#ifndef TERRAIN_SPLAT_BASEPASS
o.uvControlAndLM.xy = TRANSFORM_TEX(v.texcoord, _Control);
o.uvControlAndLM.zw = v.texcoord1 * unity_LightmapST.xy + unity_LightmapST.zw;
#endif
#ifdef _TERRAIN_NORMAL_MAP
#ifdef _NORMALMAP
float4 vertexTangent = float4(cross(v.normal, float3(0, 0, 1)), -1.0);
OutputTangentToWorld(vertexTangent, v.normal, o.tangent.xyz, o.binormal.xyz, o.normal.xyz);

return o;
}
TEXTURE2D(_MetallicTex); SAMPLER(sampler_MetallicTex);
half4 SpatmapFragment(VertexOutput IN) : SV_TARGET
half4 SplatmapFragment(VertexOutput IN) : SV_TARGET
#ifdef TERRAIN_SPLAT_BASEPASS
half3 normalTS = float3(0, 1, 0);
half3 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uvMainAndLM.xy).rgb;
half smoothness = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uvMainAndLM.xy).a;
half metallic = SAMPLE_TEXTURE2D(_MetallicTex, sampler_MetallicTex, IN.uvMainAndLM.xy).r;
half alpha = 1;
#else
half4 splatControl;
half weight;
half4 mixedDiffuse;

half3 albedo = mixedDiffuse.rgb;
half smoothness = mixedDiffuse.a;
half metallic = dot(splatControl, half4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
half3 specular = half3(0.0h, 0.0h, 0.0h);
#endif
half4 color = LightweightFragmentPBR(inputData, albedo, metallic, specular, smoothness, /* occlusion */ 1.0h, /* emission */ half3(0.0h, 0.0h, 0.0h), alpha);
half4 color = LightweightFragmentPBR(inputData, albedo, metallic, half3(0.0h, 0.0h, 0.0h), smoothness, /* occlusion */ 1.0, /* emission */ half3(0, 0, 0), alpha);
}
// Shadow pass
// x: global clip space bias, y: normal world space bias
float4 _ShadowBias;
float3 _LightDirection;
struct VertexInputLean
{
float4 position : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
float4 ShadowPassVertex(VertexInputLean v) : SV_POSITION
{
VertexOutput o;
UNITY_SETUP_INSTANCE_ID(v);
TerrainInstancing(v.position, v.normal);
float3 positionWS = TransformObjectToWorld(v.position.xyz);
float3 normalWS = TransformObjectToWorldDir(v.normal);
float invNdotL = 1.0 - saturate(dot(_LightDirection, normalWS));
float scale = invNdotL * _ShadowBias.y;
// normal bias is negative since we want to apply an inset normal offset
positionWS = normalWS * scale.xxx + positionWS;
float4 clipPos = TransformWorldToHClip(positionWS);
// _ShadowBias.x sign depens on if platform has reversed z buffer
clipPos.z += _ShadowBias.x;
#if UNITY_REVERSED_Z
clipPos.z = min(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
#else
clipPos.z = max(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
#endif
return clipPos;
}
half4 ShadowPassFragment() : SV_TARGET
{
return 0;
}
// Depth pass
float4 DepthOnlyVertex(VertexInputLean v) : SV_POSITION
{
VertexOutput o = (VertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
TerrainInstancing(v.position, v.normal);
return TransformObjectToHClip(v.position.xyz);
}
half4 DepthOnlyFragment() : SV_TARGET
{
return 0;
}
#endif // LIGHTWEIGHT_PASS_LIT_TERRAIN_INCLUDED

23
com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrain.shader


#pragma target 3.0
#pragma vertex SplatmapVert
#pragma fragment SpatmapFragment
#pragma fragment SplatmapFragment
#define _METALLICSPECGLOSSMAP 1
#define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#pragma multi_compile __ _TERRAIN_NORMAL_MAP
#pragma shader_feature _NORMALMAP
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"
#include "LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl"

#pragma vertex ShadowPassVertex
#pragma fragment ShadowPassFragment
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"
#include "LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl"
ENDHLSL
}

#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"
#include "LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl"
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
}
Dependency "AddPassShader" = "Hidden/LightweightPipeline/Terrain/Standard Terrain Add Pass"
Dependency "BaseMapShader" = "Hidden/LightweightPipeline/Terrain/Standard Terrain Base"

6
com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrainAddPass.shader


#pragma target 3.0
#pragma vertex SplatmapVert
#pragma fragment SpatmapFragment
#pragma fragment SplatmapFragment
// -------------------------------------
// Lightweight Pipeline keywords

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#pragma multi_compile __ _TERRAIN_NORMAL_MAP
#pragma shader_feature _NORMALMAP
#define TERRAIN_SPLAT_ADDPASS 1
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"

35
com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrainBase.shader


#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fog
//--------------------------------------
// GPU Instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#pragma vertex LitPassVertex
#pragma fragment LitPassFragment
#pragma vertex SplatmapVert
#pragma fragment SplatmapFragment
#pragma shader_feature _NORMALMAP
#define TERRAIN_SPLAT_BASEPASS 1
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrainBase.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassLit.hlsl"
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"
#include "LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl"
ENDHLSL
}

#pragma exclude_renderers d3d11_9x
#pragma target 2.0
//--------------------------------------
// GPU Instancing
#define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrainBase.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"
#include "LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl"
ENDHLSL
}

#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#define _METALLICSPECGLOSSMAP 1
#define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
//--------------------------------------
// GPU Instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrainBase.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
#include "LWRP/ShaderLibrary/Terrain/InputSurfaceTerrain.hlsl"
#include "LWRP/ShaderLibrary/Terrain/LightweightPassLitTerrain.hlsl"
ENDHLSL
}

ENDHLSL
}
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
}
FallBack "Hidden/InternalErrorShader"
CustomEditor "LightweightStandardGUI"

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.meta


fileFormatVersion: 2
guid: c447e1eff96e6fe4fbdfc111c75f9885
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

539
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 0
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 0
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &476264687
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalPosition.x
value: -0.85279846
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalPosition.y
value: 10.345987
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalPosition.z
value: 72.13774
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.x
value: -0.18097067
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.y
value: -0.734918
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.z
value: 0.21555983
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.w
value: -0.61699206
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1132393308280272, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_Name
value: HDRP_Test_Camera
objectReference: {fileID: 0}
- target: {fileID: 20109210616973140, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: far clip plane
value: 500
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
--- !u!1 &822358699
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 822358702}
- component: {fileID: 822358701}
- component: {fileID: 822358700}
m_Layer: 0
m_Name: Terrain
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!154 &822358700
TerrainCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 822358699}
m_Material: {fileID: 0}
m_Enabled: 1
m_TerrainData: {fileID: 15600000, guid: 245a04c8ad46a5349bcbaad4da1da133, type: 2}
m_EnableTreeColliders: 1
--- !u!218 &822358701
Terrain:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 822358699}
m_Enabled: 1
serializedVersion: 3
m_TerrainData: {fileID: 15600000, guid: 245a04c8ad46a5349bcbaad4da1da133, type: 2}
m_TreeDistance: 2000
m_TreeBillboardDistance: 50
m_TreeCrossFadeLength: 5
m_TreeMaximumFullLODCount: 50
m_DetailObjectDistance: 80
m_DetailObjectDensity: 1
m_HeightmapPixelError: 5
m_SplatMapDistance: 1000
m_HeightmapMaximumLOD: 0
m_CastShadows: 1
m_DrawHeightmap: 1
m_DrawInstanced: 1
m_DrawTreesAndFoliage: 1
m_ReflectionProbeUsage: 1
m_MaterialType: 3
m_LegacySpecular:
serializedVersion: 2
rgba: 4286545791
m_LegacyShininess: 0.078125
m_MaterialTemplate: {fileID: 2100000, guid: 22ff8771d87ef27429e670136399094b, type: 2}
m_BakeLightProbesForTrees: 1
m_PreserveTreePrototypeLayers: 0
m_ScaleInLightmap: 0.0512
m_LightmapParameters: {fileID: 15203, guid: 0000000000000000f000000000000000, type: 0}
m_AllowAutoConnect: 1
--- !u!4 &822358702
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 822358699}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1327369485
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1327369487}
- component: {fileID: 1327369486}
m_Layer: 0
m_Name: Decal Projector
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1327369486
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1327369485}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f19d9143a39eb3b46bc4563e9889cfbd, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: 638b5db2a1568654e998f0152ad27948, type: 2}
m_DrawDistance: 1000
m_FadeScale: 0.9
m_UVScale: {x: 1, y: 1}
m_UVBias: {x: 0, y: 0}
m_AffectsTransparency: 0
m_Offset: {x: -6.749508, y: 3.085741, z: 7.9018707}
m_Size: {x: 16, y: 8.171482, z: 16}
--- !u!4 &1327369487
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1327369485}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 17.31, y: -1.35, z: 68.92}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1736369238
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1736369240}
- component: {fileID: 1736369239}
- component: {fileID: 1736369242}
- component: {fileID: 1736369241}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1736369239
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736369238}
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 3.1415927
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1736369240
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736369238}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &1736369241
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736369238}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c6c2871f720b2af4e9210febdac74517, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
shadowResolution: 512
shadowDimmer: 1
shadowFadeDistance: 10000
contactShadows: 0
viewBiasMin: 0.2
viewBiasMax: 100
viewBiasScale: 1
normalBiasMin: 0.5
normalBiasMax: 0.5
normalBiasScale: 1
sampleBiasScale: 0
edgeLeakFixup: 1
edgeToleranceNormal: 1
edgeTolerance: 1
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05
- 0.15
- 0.3
shadowCascadeBorders:
- 0
- 0
- 0
- 0.2
shadowAlgorithm: 0
shadowVariant: 3
shadowPrecision: 0
shadowData:
format: 0
data: 000000000000803f
shadowDatas:
- format: 0
data: 000000000000803f
--- !u!114 &1736369242
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736369238}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 2
m_Version: 2
directionalIntensity: 3.1415927
punctualIntensity: 600
areaIntensity: 200
enableSpotReflector: 0
m_InnerSpotPercent: 0
lightDimmer: 1
volumetricDimmer: 1
lightUnit: 2
fadeDistance: 10000
affectDiffuse: 1
affectSpecular: 1
nonLightmappedOnly: 0
lightTypeExtent: 0
spotLightShape: 0
shapeWidth: 0.5
shapeHeight: 0.5
aspectRatio: 1
shapeRadius: 0
maxSmoothness: 1
applyRangeAttenuation: 1
useOldInspector: 0
featuresFoldout: 1
showAdditionalSettings: 0
displayLightIntensity: 3.1415927
displayAreaLightEmissiveMesh: 0
lightLayers: 1
--- !u!33 &8798469937330876322
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798469937333842852}
m_Mesh: {fileID: 4300006, guid: ebcf3e09572f188498750733ca8d41aa, type: 3}
--- !u!23 &8798469937331842402
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798469937333842852}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 61e846cd580c3d84eb34916c1e123ad2, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!4 &8798469937333743492
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798469937333842852}
m_LocalRotation: {x: -0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: 22.98, y: -0.16, z: 13.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8798469937333842852
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8798469937333743492}
- component: {fileID: 8798469937330876322}
- component: {fileID: 8798469937331842402}
m_Layer: 0
m_Name: Part02_Inside_02
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1

7
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit.unity.meta


fileFormatVersion: 2
guid: d52dbea61cf2f884fadf33f8cc6afc0c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1601_TerrainLit.png
文件差异内容过多而无法显示
查看文件

88
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1601_TerrainLit.png.meta


fileFormatVersion: 2
guid: 2d7db642c35e03e46ac02ff38d2110b7
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/TerrainLit.meta


fileFormatVersion: 2
guid: fea4a321768eb97479028b1b3085d98e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit.meta


fileFormatVersion: 2
guid: 1f932325a7a46ff4cb10f98701de6911
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

41
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/DefaultHDTerrainMaterial.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: DefaultHDTerrainMaterial
m_Shader: {fileID: 4800000, guid: eb607f5e8fc16e140b732f33d26c8c31, type: 3}
m_ShaderKeywords: _TERRAIN_INSTANCED_PERPIXEL_NORMAL
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _CullMode: 2
- _EnableHeightBlend: 0
- _EnableInstancedPerPixelNormal: 1
- _HeightTransition: 0
- _StencilRef: 2
- _StencilRefMV: 128
- _StencilWriteMask: 7
- _StencilWriteMaskMV: 128
- _SupportDecals: 1
- _ZTestDepthEqualForOpaque: 3
- _ZTestGBuffer: 4
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}

8
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/DefaultHDTerrainMaterial.mat.meta


fileFormatVersion: 2
guid: 22ff8771d87ef27429e670136399094b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

244
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Decal.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Decal
m_Shader: {fileID: 4800000, guid: 1d64af84bdc970c4fae0c1e06dd95b73, type: 3}
m_ShaderKeywords: _ALBEDOCONTRIBUTION _COLORMAP
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DBufferMesh_M
- DBufferMesh_AO
- DBufferMesh_MAO
- DBufferMesh_MAOS
- DBufferMesh_MS
- DBufferMesh_AOS
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 2800000, guid: f4dff64dac409534285525caeac990f6, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _CoatMaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _IridescenceMaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _IridescenceThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceMaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TransmittanceColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AORemapMax: 1
- _AORemapMin: 0
- _ATDistance: 1
- _AlbedoAffectEmissive: 0
- _AlbedoMode: 1
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _AlphaCutoffPostpass: 0.5
- _AlphaCutoffPrepass: 0.5
- _Anisotropy: 0
- _BlendMode: 0
- _CoatMask: 0
- _CullMode: 2
- _CullModeForward: 2
- _Cutoff: 0.5
- _DecalBlend: 0.5
- _DecalMeshDepthBias: 0
- _DepthOffsetEnable: 0
- _DetailAlbedoScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DiffusionProfile: 0
- _DisplacementLockObjectScale: 1
- _DisplacementLockTilingScale: 1
- _DisplacementMode: 0
- _DistortionBlendMode: 0
- _DistortionBlurBlendMode: 0
- _DistortionBlurDstBlend: 0
- _DistortionBlurRemapMax: 1
- _DistortionBlurRemapMin: 0
- _DistortionBlurScale: 1
- _DistortionBlurSrcBlend: 0
- _DistortionDepthTest: 1
- _DistortionDstBlend: 0
- _DistortionEnable: 0
- _DistortionScale: 1
- _DistortionSrcBlend: 0
- _DistortionVectorBias: -1
- _DistortionVectorScale: 2
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _Drag: 1
- _DrawOrder: 0
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EnableBlendModePreserveSpecularLighting: 1
- _EnableFogOnTransparent: 1
- _EnableGeometricSpecularAA: 0
- _EnableMotionVectorForVertexAnimation: 0
- _EnableSpecularOcclusion: 0
- _EnableWind: 0
- _EnergyConservingSpecularColor: 1
- _HdrpVersion: 2
- _HeightAmplitude: 0.02
- _HeightCenter: 0.5
- _HeightMapParametrization: 0
- _HeightMax: 1
- _HeightMin: -1
- _HeightOffset: 0
- _HeightPoMAmplitude: 2
- _HeightTessAmplitude: 2
- _HeightTessCenter: 0.5
- _InitialBend: 1
- _InvTilingScale: 1
- _Ior: 1
- _IridescenceMask: 1
- _IridescenceThickness: 1
- _LinkDetailsWithBase: 1
- _MaskBlendMode: 4
- _MaskBlendSrc: 1
- _MaskmapAO: 0
- _MaskmapMetal: 0
- _MaskmapSmoothness: 1
- _MaterialID: 1
- _Metallic: 0
- _NormalBlendSrc: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _PPDPrimitiveLength: 1
- _PPDPrimitiveWidth: 1
- _PreRefractionPass: 0
- _RefractionModel: 0
- _SSRefractionProjectionModel: 0
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 1
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SpecularAAScreenSpaceVariance: 0.1
- _SpecularAAThreshold: 0.2
- _SrcBlend: 1
- _StencilRef: 2
- _StencilRefMV: 128
- _StencilWriteMask: 7
- _StencilWriteMaskMV: 128
- _Stiffness: 1
- _SubsurfaceMask: 1
- _SupportDecals: 1
- _SurfaceType: 0
- _TexWorldScale: 1
- _TexWorldScaleEmissive: 1
- _Thickness: 1
- _ThicknessMultiplier: 1
- _TransmissionEnable: 1
- _TransparentBackfaceEnable: 0
- _TransparentDepthPostpassEnable: 0
- _TransparentDepthPrepassEnable: 0
- _TransparentSortPriority: 0
- _UVBase: 0
- _UVDetail: 0
- _UVEmissive: 0
- _ZTestDepthEqualForOpaque: 4
- _ZTestGBuffer: 4
- _ZTestModeDistortion: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 0.5613208, b: 0.9299959, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
- _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0}

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Decal.mat.meta


fileFormatVersion: 2
guid: 638b5db2a1568654e998f0152ad27948
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

22
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02.terrainlayer


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1953259897 &8574412962073106934
TerrainLayer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Material_02
m_DiffuseTexture: {fileID: 2800000, guid: 199ab935729dea44caba5299e4833afb, type: 3}
m_NormalMapTexture: {fileID: 2800000, guid: 2ce0e34e745b7d540b242eec852460f1, type: 3}
m_MaskMapTexture: {fileID: 2800000, guid: f403431ade264ec4b8772a8ecf2974a0, type: 3}
m_TileSize: {x: 8, y: 8}
m_TileOffset: {x: 0, y: 0}
m_Specular: {r: 0, g: 0, b: 0, a: 0}
m_Metallic: 0
m_Smoothness: 0
m_NormalScale: 1
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02.terrainlayer.meta


fileFormatVersion: 2
guid: de71bec9c6430064eabb19621e3ac697
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 8574412962073106934
userData:
assetBundleName:
assetBundleVariant:

132
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02_BC.png.meta


fileFormatVersion: 2
guid: 199ab935729dea44caba5299e4833afb
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 4
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

132
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02_MSK.tga.meta


fileFormatVersion: 2
guid: f403431ade264ec4b8772a8ecf2974a0
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 4
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

132
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Material_02_N.png.meta


fileFormatVersion: 2
guid: 2ce0e34e745b7d540b242eec852460f1
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 4
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 1
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

233
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/MeshMaterial.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MeshMaterial
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _MAPPING_PLANAR _MASKMAP _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
- TransparentDepthPrepass
- TransparentDepthPostpass
- TransparentBackface
- MOTIONVECTORS
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 2800000, guid: 199ab935729dea44caba5299e4833afb, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _CoatMaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _IridescenceMaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _IridescenceThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 199ab935729dea44caba5299e4833afb, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 2800000, guid: f403431ade264ec4b8772a8ecf2974a0, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 2800000, guid: 2ce0e34e745b7d540b242eec852460f1, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceMaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TransmittanceColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AORemapMax: 1
- _AORemapMin: 0
- _ATDistance: 1
- _AlbedoAffectEmissive: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _AlphaCutoffPostpass: 0.5
- _AlphaCutoffPrepass: 0.5
- _Anisotropy: 0
- _BlendMode: 0
- _CoatMask: 0
- _CullMode: 2
- _CullModeForward: 2
- _Cutoff: 0.5
- _DepthOffsetEnable: 0
- _DetailAlbedoScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DiffusionProfile: 0
- _DisplacementLockObjectScale: 1
- _DisplacementLockTilingScale: 1
- _DisplacementMode: 0
- _DistortionBlendMode: 0
- _DistortionBlurBlendMode: 0
- _DistortionBlurDstBlend: 1
- _DistortionBlurRemapMax: 1
- _DistortionBlurRemapMin: 0
- _DistortionBlurScale: 1
- _DistortionBlurSrcBlend: 1
- _DistortionDepthTest: 1
- _DistortionDstBlend: 1
- _DistortionEnable: 0
- _DistortionScale: 1
- _DistortionSrcBlend: 1
- _DistortionVectorBias: -1
- _DistortionVectorScale: 2
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _Drag: 1
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EnableBlendModePreserveSpecularLighting: 1
- _EnableFogOnTransparent: 1
- _EnableGeometricSpecularAA: 0
- _EnableMotionVectorForVertexAnimation: 0
- _EnableSpecularOcclusion: 0
- _EnableWind: 0
- _EnergyConservingSpecularColor: 1
- _HdrpVersion: 2
- _HeightAmplitude: 0.02
- _HeightCenter: 0.5
- _HeightMapParametrization: 0
- _HeightMax: 1
- _HeightMin: -1
- _HeightOffset: 0
- _HeightPoMAmplitude: 2
- _HeightTessAmplitude: 2
- _HeightTessCenter: 0.5
- _InitialBend: 1
- _InvTilingScale: 8
- _Ior: 1
- _IridescenceMask: 1
- _IridescenceThickness: 1
- _LinkDetailsWithBase: 1
- _MaterialID: 1
- _Metallic: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _PPDPrimitiveLength: 1
- _PPDPrimitiveWidth: 1
- _PreRefractionPass: 0
- _RefractionModel: 0
- _SSRefractionProjectionModel: 0
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 1
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SpecularAAScreenSpaceVariance: 0.1
- _SpecularAAThreshold: 0.2
- _SrcBlend: 1
- _StencilRef: 2
- _StencilRefMV: 128
- _StencilWriteMask: 7
- _StencilWriteMaskMV: 128
- _Stiffness: 1
- _SubsurfaceMask: 1
- _SupportDecals: 1
- _SurfaceType: 0
- _TexWorldScale: 0.125
- _TexWorldScaleEmissive: 1
- _Thickness: 1
- _ThicknessMultiplier: 1
- _TransmissionEnable: 1
- _TransparentBackfaceEnable: 0
- _TransparentDepthPostpassEnable: 0
- _TransparentDepthPrepassEnable: 0
- _TransparentSortPriority: 0
- _UVBase: 4
- _UVDetail: 0
- _UVEmissive: 0
- _ZTestDepthEqualForOpaque: 3
- _ZTestGBuffer: 4
- _ZTestModeDistortion: 4
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
- _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 0, g: 0, b: 0, a: 0}
- _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0}

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/MeshMaterial.mat.meta


fileFormatVersion: 2
guid: 61e846cd580c3d84eb34916c1e123ad2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

1001
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/New Terrain.asset
文件差异内容过多而无法显示
查看文件

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/New Terrain.asset.meta


fileFormatVersion: 2
guid: 245a04c8ad46a5349bcbaad4da1da133
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 15600000
userData:
assetBundleName:
assetBundleVariant:

1001
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Part02.FBX
文件差异内容过多而无法显示
查看文件

122
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Part02.FBX.meta


fileFormatVersion: 2
guid: ebcf3e09572f188498750733ca8d41aa
ModelImporter:
serializedVersion: 23
fileIDToRecycleName:
100000: //RootNode
100002: Part02_Inside_01
100004: Part02_Inside_02
100006: Part02_Inside_03
100008: Part02_Inside_04
100010: Part02_Outside
400000: //RootNode
400002: Part02_Inside_01
400004: Part02_Inside_02
400006: Part02_Inside_03
400008: Part02_Inside_04
400010: Part02_Outside
2100000: Outside
2100002: Inside
2300000: Part02_Inside_01
2300002: Part02_Inside_02
2300004: Part02_Inside_03
2300006: Part02_Inside_04
2300008: Part02_Outside
3300000: Part02_Inside_01
3300002: Part02_Inside_02
3300004: Part02_Inside_03
3300006: Part02_Inside_04
3300008: Part02_Outside
4300000: Part02_Outside
4300002: Part02_Inside_01
4300004: Part02_Inside_03
4300006: Part02_Inside_02
4300008: Part02_Inside_04
7400000: Take 001
9500000: //RootNode
externalObjects: {}
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
previousCalculatedGlobalScale: 0.01
hasPreviousCalculatedGlobalScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

22
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01.terrainlayer


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1953259897 &8574412962073106934
TerrainLayer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Rock_01
m_DiffuseTexture: {fileID: 2800000, guid: d0ab2de4305d3f24e97132774d93313e, type: 3}
m_NormalMapTexture: {fileID: 2800000, guid: 9a196e547f02b1542808aab169006a32, type: 3}
m_MaskMapTexture: {fileID: 2800000, guid: 4ebf5c8d4907e074d97ce1a764fb1a21, type: 3}
m_TileSize: {x: 4, y: 4}
m_TileOffset: {x: 0, y: 0}
m_Specular: {r: 0, g: 0, b: 0, a: 0}
m_Metallic: 0
m_Smoothness: 0
m_NormalScale: 2
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_DiffuseRemapMax: {x: 0.75197834, y: 1, z: 0.3160377, w: 1}
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1.0000001}

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01.terrainlayer.meta


fileFormatVersion: 2
guid: d784bc0707f1414479544689726442e4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 8574412962073106934
userData:
assetBundleName:
assetBundleVariant:

132
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01_BC.tga.meta


fileFormatVersion: 2
guid: d0ab2de4305d3f24e97132774d93313e
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 4
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

132
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01_MSK.tga.meta


fileFormatVersion: 2
guid: 4ebf5c8d4907e074d97ce1a764fb1a21
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 4
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

132
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1601_TerrainLit/Rock_01_N.tga.meta


fileFormatVersion: 2
guid: 9a196e547f02b1542808aab169006a32
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 4
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 1
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/TerrainLit/TerrainLitUI.cs.meta


fileFormatVersion: 2
guid: 5bb8fef5b2375a64c8b063317f1c74b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

326
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/TerrainLit/TerrainLitUI.cs


using System;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System.Linq;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class TerrainLitGUI : LitGUI, ITerrainLayerCustomUI
{
private class StylesLayer
{
public readonly GUIContent enableHeightBlend = new GUIContent("Enable Height-based Blend", "Blend terrain layers based on height values.");
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.");
public readonly GUIContent diffuseTexture = new GUIContent("Diffuse");
public readonly GUIContent colorTint = new GUIContent("Color Tint");
public readonly GUIContent opacityAsDensity = new GUIContent("Opacity as Density", "Enable Density Blend");
public readonly GUIContent normalMapTexture = new GUIContent("Normal Map");
public readonly GUIContent normalScale = new GUIContent("Normal Scale");
public readonly GUIContent maskMapTexture = new GUIContent("Mask", "R: Metallic\nG: AO\nB: Height\nA: Smoothness");
public readonly GUIContent maskMapTextureWithoutHeight = new GUIContent("Mask Map", "R: Metallic\nG: AO\nA: Smoothness");
public readonly GUIContent channelRemapping = new GUIContent("Channel Remapping");
public readonly GUIContent defaultValues = new GUIContent("Channel Default Values");
public readonly GUIContent metallic = new GUIContent("R: Metallic");
public readonly GUIContent ao = new GUIContent("G: AO");
public readonly GUIContent height = new GUIContent("B: Height");
public readonly GUIContent heightParametrization = new GUIContent("Parametrization");
public readonly GUIContent heightAmplitude = new GUIContent("Amplitude (cm)");
public readonly GUIContent heightBase = new GUIContent("Base");
public readonly GUIContent heightMin = new GUIContent("Min (cm)");
public readonly GUIContent heightMax = new GUIContent("Max (cm)");
public readonly GUIContent heightCm = new GUIContent("B: Height (cm)");
public readonly GUIContent smoothness = new GUIContent("A: Smoothness");
}
static StylesLayer s_Styles = null;
private static StylesLayer styles { get { if (s_Styles == null) s_Styles = new StylesLayer(); return s_Styles; } }
public TerrainLitGUI()
{
}
MaterialProperty enableHeightBlend;
const string kEnableHeightBlend = "_EnableHeightBlend";
// Height blend
MaterialProperty heightTransition = null;
const string kHeightTransition = "_HeightTransition";
MaterialProperty enableInstancedPerPixelNormal = null;
const string kEnableInstancedPerPixelNormal = "_EnableInstancedPerPixelNormal";
protected override void FindMaterialProperties(MaterialProperty[] props)
{
enableHeightBlend = FindProperty(kEnableHeightBlend, props, false);
heightTransition = FindProperty(kHeightTransition, props, false);
enableInstancedPerPixelNormal = FindProperty(kEnableInstancedPerPixelNormal, props, false);
}
protected override bool ShouldEmissionBeEnabled(Material mat)
{
return false;
}
protected override void SetupMaterialKeywordsAndPassInternal(Material material)
{
SetupMaterialKeywordsAndPass(material);
}
static public void SetupLayersMappingKeywords(Material material)
{
const string kLayerMappingPlanar = "_LAYER_MAPPING_PLANAR";
const string kLayerMappingTriplanar = "_LAYER_MAPPING_TRIPLANAR";
for (int i = 0; i < kMaxLayerCount; ++i)
{
string layerUVBaseParam = string.Format("{0}{1}", kUVBase, i);
UVBaseMapping layerUVBaseMapping = (UVBaseMapping)material.GetFloat(layerUVBaseParam);
string currentLayerMappingPlanar = string.Format("{0}{1}", kLayerMappingPlanar, i);
CoreUtils.SetKeyword(material, currentLayerMappingPlanar, layerUVBaseMapping == UVBaseMapping.Planar);
string currentLayerMappingTriplanar = string.Format("{0}{1}", kLayerMappingTriplanar, i);
CoreUtils.SetKeyword(material, currentLayerMappingTriplanar, layerUVBaseMapping == UVBaseMapping.Triplanar);
}
}
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
static new public void SetupMaterialKeywordsAndPass(Material material)
{
SetupBaseLitKeywords(material);
SetupBaseLitMaterialPass(material);
// TODO: planar/triplannar supprt
//SetupLayersMappingKeywords(material);
bool enableHeightBlend = material.HasProperty(kEnableHeightBlend) && material.GetFloat(kEnableHeightBlend) > 0;
CoreUtils.SetKeyword(material, "_TERRAIN_BLEND_HEIGHT", enableHeightBlend);
bool enableInstancedPerPixelNormal = material.GetFloat(kEnableInstancedPerPixelNormal) > 0.0f;
CoreUtils.SetKeyword(material, "_TERRAIN_INSTANCED_PERPIXEL_NORMAL", enableInstancedPerPixelNormal);
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindBaseMaterialProperties(props);
FindMaterialProperties(props);
m_MaterialEditor = materialEditor;
// We should always do this call at the beginning
m_MaterialEditor.serializedObject.Update();
Material material = m_MaterialEditor.target as Material;
AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));
bool optionsChanged = false;
EditorGUI.BeginChangeCheck();
{
BaseMaterialPropertiesGUI();
if (enableHeightBlend != null)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(enableHeightBlend, styles.enableHeightBlend);
if (enableHeightBlend.floatValue > 0)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightTransition, styles.heightTransition);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
EditorGUILayout.Space();
}
if (EditorGUI.EndChangeCheck())
{
optionsChanged = true;
}
bool enablePerPixelNormalChanged = false;
EditorGUILayout.Space();
EditorGUILayout.LabelField(StylesBaseUnlit.advancedText, EditorStyles.boldLabel);
// NB RenderQueue editor is not shown on purpose: we want to override it based on blend mode
EditorGUI.indentLevel++;
m_MaterialEditor.EnableInstancingField();
if (m_MaterialEditor.IsInstancingEnabled())
{
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
m_MaterialEditor.ShaderProperty(enableInstancedPerPixelNormal, styles.enableInstancedPerPixelNormal);
enablePerPixelNormalChanged = EditorGUI.EndChangeCheck();
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
if (optionsChanged || enablePerPixelNormalChanged)
{
foreach (var obj in m_MaterialEditor.targets)
{
SetupMaterialKeywordsAndPassInternal((Material)obj);
}
}
// We should always do this call at the end
m_MaterialEditor.serializedObject.ApplyModifiedProperties();
}
private bool m_ShowChannelRemapping = false;
enum HeightParametrization
{
Amplitude,
MinMax
};
private HeightParametrization m_HeightParametrization = HeightParametrization.Amplitude;
private static bool DoesTerrainUseMaskMaps(TerrainLayer[] terrainLayers)
{
for (int i = 0; i < terrainLayers.Length; ++i)
{
if (terrainLayers[i].maskMapTexture != null)
return true;
}
return false;
}
bool ITerrainLayerCustomUI.OnTerrainLayerGUI(TerrainLayer terrainLayer, Terrain terrain)
{
var terrainLayers = terrain.terrainData.terrainLayers;
if (!DoesTerrainUseMaskMaps(terrainLayers))
return false;
// Don't use the member field enableHeightBlend as ShaderGUI.OnGUI might not be called if the material UI is folded.
bool heightBlend = terrain.materialTemplate.HasProperty(kEnableHeightBlend) && terrain.materialTemplate.GetFloat(kEnableHeightBlend) > 0;
terrainLayer.diffuseTexture = EditorGUILayout.ObjectField(styles.diffuseTexture, terrainLayer.diffuseTexture, typeof(Texture2D), false) as Texture2D;
TerrainLayerUtility.ValidateDiffuseTextureUI(terrainLayer.diffuseTexture);
var diffuseRemapMin = terrainLayer.diffuseRemapMin;
var diffuseRemapMax = terrainLayer.diffuseRemapMax;
EditorGUI.BeginChangeCheck();
bool enableDensity = false;
if (terrainLayer.diffuseTexture != null)
{
var rect = GUILayoutUtility.GetLastRect();
rect.y += 16 + 4;
rect.width = EditorGUIUtility.labelWidth + 64;
rect.height = 16;
++EditorGUI.indentLevel;
var diffuseTint = new Color(diffuseRemapMax.x, diffuseRemapMax.y, diffuseRemapMax.z);
diffuseTint = EditorGUI.ColorField(rect, styles.colorTint, diffuseTint, true, false, false);
diffuseRemapMax.x = diffuseTint.r;
diffuseRemapMax.y = diffuseTint.g;
diffuseRemapMax.z = diffuseTint.b;
diffuseRemapMin.x = diffuseRemapMin.y = diffuseRemapMin.z = 0;
if (!heightBlend)
{
rect.y = rect.yMax + 2;
enableDensity = EditorGUI.Toggle(rect, styles.opacityAsDensity, diffuseRemapMin.w > 0);
}
--EditorGUI.indentLevel;
}
diffuseRemapMax.w = 1;
diffuseRemapMin.w = enableDensity ? 1 : 0;
if (EditorGUI.EndChangeCheck())
{
terrainLayer.diffuseRemapMin = diffuseRemapMin;
terrainLayer.diffuseRemapMax = diffuseRemapMax;
}
terrainLayer.normalMapTexture = EditorGUILayout.ObjectField(styles.normalMapTexture, terrainLayer.normalMapTexture, typeof(Texture2D), false) as Texture2D;
TerrainLayerUtility.ValidateNormalMapTextureUI(terrainLayer.normalMapTexture, TerrainLayerUtility.CheckNormalMapTextureType(terrainLayer.normalMapTexture));
if (terrainLayer.normalMapTexture != null)
{
var rect = GUILayoutUtility.GetLastRect();
rect.y += 16 + 4;
rect.width = EditorGUIUtility.labelWidth + 64;
rect.height = 16;
++EditorGUI.indentLevel;
terrainLayer.normalScale = EditorGUI.FloatField(rect, styles.normalScale, terrainLayer.normalScale);
--EditorGUI.indentLevel;
}
terrainLayer.maskMapTexture = EditorGUILayout.ObjectField(heightBlend ? styles.maskMapTexture : styles.maskMapTextureWithoutHeight, terrainLayer.maskMapTexture, typeof(Texture2D), false) as Texture2D;
TerrainLayerUtility.ValidateMaskMapTextureUI(terrainLayer.maskMapTexture);
var maskMapRemapMin = terrainLayer.maskMapRemapMin;
var maskMapRemapMax = terrainLayer.maskMapRemapMax;
++EditorGUI.indentLevel;
EditorGUI.BeginChangeCheck();
m_ShowChannelRemapping = EditorGUILayout.Foldout(m_ShowChannelRemapping, terrainLayer.maskMapTexture != null ? s_Styles.channelRemapping : s_Styles.defaultValues);
if (m_ShowChannelRemapping)
{
if (terrainLayer.maskMapTexture != null)
{
float min, max;
min = maskMapRemapMin.x; max = maskMapRemapMax.x;
EditorGUILayout.MinMaxSlider(s_Styles.metallic, ref min, ref max, 0, 1);
maskMapRemapMin.x = min; maskMapRemapMax.x = max;
min = maskMapRemapMin.y; max = maskMapRemapMax.y;
EditorGUILayout.MinMaxSlider(s_Styles.ao, ref min, ref max, 0, 1);
maskMapRemapMin.y = min; maskMapRemapMax.y = max;
if (heightBlend)
{
EditorGUILayout.LabelField(styles.height);
++EditorGUI.indentLevel;
m_HeightParametrization = (HeightParametrization)EditorGUILayout.EnumPopup(styles.heightParametrization, m_HeightParametrization);
if (m_HeightParametrization == HeightParametrization.Amplitude)
{
// (height - heightBase) * amplitude
float amplitude = Mathf.Max(maskMapRemapMax.z - maskMapRemapMin.z, Mathf.Epsilon); // to avoid divide by zero
float heightBase = -maskMapRemapMin.z / amplitude;
amplitude = EditorGUILayout.FloatField(styles.heightAmplitude, amplitude * 100) / 100;
heightBase = EditorGUILayout.FloatField(styles.heightBase, heightBase);
maskMapRemapMin.z = -heightBase * amplitude;
maskMapRemapMax.z = (1 - heightBase) * amplitude;
}
else
{
maskMapRemapMin.z = EditorGUILayout.FloatField(styles.heightMin, maskMapRemapMin.z * 100) / 100;
maskMapRemapMax.z = EditorGUILayout.FloatField(styles.heightMax, maskMapRemapMax.z * 100) / 100;
}
--EditorGUI.indentLevel;
}
min = maskMapRemapMin.w; max = maskMapRemapMax.w;
EditorGUILayout.MinMaxSlider(s_Styles.smoothness, ref min, ref max, 0, 1);
maskMapRemapMin.w = min; maskMapRemapMax.w = max;
}
else
{
maskMapRemapMin.x = maskMapRemapMax.x = EditorGUILayout.Slider(s_Styles.metallic, maskMapRemapMin.x, 0, 1);
maskMapRemapMin.y = maskMapRemapMax.y = EditorGUILayout.Slider(s_Styles.ao, maskMapRemapMin.y, 0, 1);
if (heightBlend)
maskMapRemapMin.z = maskMapRemapMax.z = EditorGUILayout.FloatField(s_Styles.heightCm, maskMapRemapMin.z * 100) / 100;
maskMapRemapMin.w = maskMapRemapMax.w = EditorGUILayout.Slider(s_Styles.smoothness, maskMapRemapMin.w, 0, 1);
}
}
if (EditorGUI.EndChangeCheck())
{
terrainLayer.maskMapRemapMin = maskMapRemapMin;
terrainLayer.maskMapRemapMax = maskMapRemapMax;
}
--EditorGUI.indentLevel;
EditorGUILayout.Space();
TerrainLayerUtility.TilingSettingsUI(terrainLayer);
return true;
}
}
} // namespace UnityEditor

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit.shader.meta


fileFormatVersion: 2
guid: eb607f5e8fc16e140b732f33d26c8c31
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData.hlsl.meta


fileFormatVersion: 2
guid: 0463ada9ab11ac74cb4c89d2669143e1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitDataMeshModification.hlsl.meta


fileFormatVersion: 2
guid: 93bcd6e92dff8254099e6bf7a93fe916
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData_Basemap.hlsl.meta


fileFormatVersion: 2
guid: afe6299a74bbe5f4f97e7e67ee2a5380
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSharePass.hlsl.meta


fileFormatVersion: 2
guid: f40e9a8738fa994458c1629679d9ed19
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSplatCommon.hlsl.meta


fileFormatVersion: 2
guid: ed77d85672562684bbe9b32c0c1f4748
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap.shader.meta


fileFormatVersion: 2
guid: e96e3b8a4797c8f47b7ae6759a3e66af
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap_Gen.shader.meta


fileFormatVersion: 2
guid: 263f12c7593cf8841b5ccdbb717e3389
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

35
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSharePass.hlsl


#ifndef SHADERPASS
#error Undefine_SHADERPASS
#endif
// This first set of define allow to say which attributes will be use by the mesh in the vertex and domain shader (for tesselation)
// Attributes
#define ATTRIBUTES_NEED_NORMAL
#define ATTRIBUTES_NEED_TEXCOORD0
#define ATTRIBUTES_NEED_TANGENT // will be filled by ApplyMeshModification()
#if SHADERPASS == SHADERPASS_LIGHT_TRANSPORT
#define ATTRIBUTES_NEED_TEXCOORD1
#define ATTRIBUTES_NEED_TEXCOORD2
#endif
// Varying - Use for pixel shader
// This second set of define allow to say which varyings will be output in the vertex (no more tesselation)
#define VARYINGS_NEED_POSITION_WS
#define VARYINGS_NEED_TANGENT_TO_WORLD
#define VARYINGS_NEED_TEXCOORD0
#if defined(UNITY_INSTANCING_ENABLED) && defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL)
#define ENABLE_TERRAIN_PERPIXEL_NORMAL
#endif
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
// With per-pixel normal enabled, tangent space is created in the pixel shader.
#undef ATTRIBUTES_NEED_NORMAL
#undef ATTRIBUTES_NEED_TANGENT
#undef VARYINGS_NEED_TANGENT_TO_WORLD
#endif
// This include will define the various Attributes/Varyings structure
#include "../../ShaderPass/VaryingMesh.hlsl"

259
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap.shader


Shader "Hidden/HDRenderPipeline/TerrainLit_Basemap"
{
Properties
{
// Following are builtin properties
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
// Blending state
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
// TODO: Fix the code in legacy unity so we can customize the behavior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
_MetallicTex("Metallic (R)", 2D) = "white" {}
// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes.
_MainTex("Albedo", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)
[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal
#pragma shader_feature _DISABLE_DECALS
#pragma shader_feature _TERRAIN_INSTANCED_PERPIXEL_NORMAL
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#define SURFACE_GRADIENT
#define HAVE_MESH_MODIFICATION
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#define TERRAINLIT_BASEMAP_SHADER
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
// All our shaders use same name for entry point
#pragma vertex Vert
#pragma fragment Frag
ENDHLSL
SubShader
{
// This tags allow to use the shader replacement features
Tags{ "RenderPipeline" = "HDRenderPipeline" "RenderType" = "Opaque" }
// Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass.
Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
ZTest[_ZTestGBuffer]
Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#pragma multi_compile _ LIGHT_LAYERS
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#ifdef DEBUG_DISPLAY
#include "../../Debug/DebugDisplay.hlsl"
#endif
#include "../../Material/Material.hlsl"
#include "TerrainLitSharePass.hlsl"
#include "TerrainLitData_Basemap.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "TerrainLitSharePass.hlsl"
#include "TerrainLitData_Basemap.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZClip [_ZClip]
ZWrite On
ZTest LEqual
ColorMask 0
HLSLPROGRAM
#define SHADERPASS SHADERPASS_SHADOWS
#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "TerrainLitData_Basemap.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
// In deferred, depth only pass don't output anything.
// In forward it output the normal buffer
#pragma multi_compile _ WRITE_NORMAL_BUFFER
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#else
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#endif
#include "TerrainLitData_Basemap.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}
// In case of forward we want to have depth equal for opaque mesh
ZTest [_ZTestDepthEqualForOpaque]
ZWrite [_ZWrite]
Cull [_CullMode]
HLSLPROGRAM
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#define LIGHTLOOP_TILE_PASS
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
#define SHADERPASS SHADERPASS_FORWARD
// In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI)
#ifndef _SURFACE_TYPE_TRANSPARENT
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
#endif
#include "../../ShaderVariables.hlsl"
#ifdef DEBUG_DISPLAY
#include "../../Debug/DebugDisplay.hlsl"
#endif
#include "../../Lighting/Lighting.hlsl"
#include "TerrainLitSharePass.hlsl"
#include "TerrainLitData_Basemap.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
}
}

289
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit.shader


Shader "HDRenderPipeline/TerrainLit"
{
Properties
{
[HideInInspector] [ToggleUI] _EnableHeightBlend("EnableHeightBlend", Float) = 0.0
_HeightTransition("Height Transition", Range(0, 1.0)) = 0.0
// TODO: support tri-planar?
// TODO: support more maps?
//[HideInInspector] _TexWorldScale0("Tiling", Float) = 1.0
//[HideInInspector] _TexWorldScale1("Tiling", Float) = 1.0
//[HideInInspector] _TexWorldScale2("Tiling", Float) = 1.0
//[HideInInspector] _TexWorldScale3("Tiling", Float) = 1.0
// Following are builtin properties
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
// Blending state
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4
[ToggleUI] _EnableInstancedPerPixelNormal("Instanced per pixel normal", Float) = 1.0
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
// TODO: Fix the code in legacy unity so we can customize the behavior for GI
_EmissionColor("Color", Color) = (1, 1, 1)
// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes.
_MainTex("Albedo", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)
[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal
#pragma shader_feature _TERRAIN_8_LAYERS
#pragma shader_feature _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 _ _LAYER_MAPPING_PLANAR0 _LAYER_MAPPING_TRIPLANAR0
//#pragma shader_feature _ _LAYER_MAPPING_PLANAR1 _LAYER_MAPPING_TRIPLANAR1
//#pragma shader_feature _ _LAYER_MAPPING_PLANAR2 _LAYER_MAPPING_TRIPLANAR2
//#pragma shader_feature _ _LAYER_MAPPING_PLANAR3 _LAYER_MAPPING_TRIPLANAR3
#pragma shader_feature _DISABLE_DECALS
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#define SURFACE_GRADIENT
#define HAVE_MESH_MODIFICATION
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
// All our shaders use same name for entry point
#pragma vertex Vert
#pragma fragment Frag
ENDHLSL
SubShader
{
// This tags allow to use the shader replacement features
Tags
{
"RenderPipeline" = "HDRenderPipeline"
"RenderType" = "Opaque"
"SplatCount" = "8"
"MaskMapR" = "Metallic"
"MaskMapG" = "AO"
"MaskMapB" = "Height"
"MaskMapA" = "Smoothness"
"DiffuseA" = "Smoothness (becomes Density when Mask map is assigned)" // when MaskMap is disabled
"DiffuseA_MaskMapUsed" = "Density" // when MaskMap is enabled
}
// Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass.
Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
ZTest[_ZTestGBuffer]
Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#pragma multi_compile _ LIGHT_LAYERS
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../ShaderVariables.hlsl"
#ifdef DEBUG_DISPLAY
#include "../../Debug/DebugDisplay.hlsl"
#endif
#include "../../Material/Material.hlsl"
#include "TerrainLitSharePass.hlsl"
#include "TerrainLitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "TerrainLitSharePass.hlsl"
#include "TerrainLitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZClip [_ZClip]
ZWrite On
ZTest LEqual
ColorMask 0
HLSLPROGRAM
#define SHADERPASS SHADERPASS_SHADOWS
#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "TerrainLitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
// In deferred, depth only pass don't output anything.
// In forward it output the normal buffer
#pragma multi_compile _ WRITE_NORMAL_BUFFER
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#else
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#endif
#include "TerrainLitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}
// In case of forward we want to have depth equal for opaque mesh
ZTest [_ZTestDepthEqualForOpaque]
ZWrite [_ZWrite]
Cull [_CullMode]
HLSLPROGRAM
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#define LIGHTLOOP_TILE_PASS
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
#define SHADERPASS SHADERPASS_FORWARD
// In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI)
#ifndef _SURFACE_TYPE_TRANSPARENT
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
#endif
#include "../../ShaderVariables.hlsl"
#ifdef DEBUG_DISPLAY
#include "../../Debug/DebugDisplay.hlsl"
#endif
#include "../../Lighting/Lighting.hlsl"
#include "TerrainLitSharePass.hlsl"
#include "TerrainLitData.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
}
Dependency "BaseMapShader" = "Hidden/HDRenderPipeline/TerrainLit_Basemap"
Dependency "BaseMapGenShader" = "Hidden/HDRenderPipeline/TerrainLit_Basemap_Gen"
CustomEditor "UnityEditor.Experimental.Rendering.HDPipeline.TerrainLitGUI"
}

125
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLit_Basemap_Gen.shader


Shader "Hidden/HDRenderPipeline/TerrainLit_Basemap_Gen"
{
Properties
{
[HideInInspector] _DstBlend("DstBlend", Float) = 0.0
}
SubShader
{
Tags { "SplatCount" = "8" }
HLSLINCLUDE
#define USE_LEGACY_UNITY_MATRIX_VARIABLES
#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../Material.hlsl"
#pragma shader_feature _TERRAIN_8_LAYERS
#pragma shader_feature _TERRAIN_BLEND_HEIGHT
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
#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 Attributes {
float3 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
ENDHLSL
Pass
{
Tags
{
"Name" = "_MainTex"
"Format" = "ARGB32"
"Size" = "1"
}
ZTest Always Cull Off ZWrite Off
Blend One [_DstBlend]
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = TransformWorldToHClip(input.vertex);
output.texcoord = input.texcoord;
return output;
}
float4 Frag(Varyings input) : SV_Target
{
float4 albedo;
float3 normalTS;
float metallic;
float ao;
TerrainSplatBlend(input.texcoord, float3(0, 0, 0), float3(0, 0, 0),
albedo.xyz, normalTS, albedo.w, metallic, ao);
return albedo;
}
ENDHLSL
}
Pass
{
Tags
{
"Name" = "_MetallicTex"
"Format" = "RG16"
"Size" = "1/4"
}
ZTest Always Cull Off ZWrite Off
Blend One [_DstBlend]
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = TransformWorldToHClip(input.vertex);
output.texcoord = input.texcoord;
return output;
}
float2 Frag(Varyings input) : SV_Target
{
float4 albedo;
float3 normalTS;
float metallic;
float ao;
TerrainSplatBlend(input.texcoord, float3(0, 0, 0), float3(0, 0, 0),
albedo.xyz, normalTS, albedo.w, metallic, ao);
return float2(metallic, ao);
}
ENDHLSL
}
}
Fallback Off
}

39
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitDataMeshModification.hlsl


UNITY_INSTANCING_BUFFER_START(Terrain)
UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainPatchInstanceData) // float4(xBase, yBase, skipScale, ~)
UNITY_INSTANCING_BUFFER_END(Terrain)
AttributesMesh ApplyMeshModification(AttributesMesh input)
{
#ifdef UNITY_INSTANCING_ENABLED
float2 patchVertex = input.positionOS.xy;
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);
float2 sampleCoords = (patchVertex.xy + instanceData.xy) * instanceData.z; // (xy + float2(xBase,yBase)) * skipScale
float height = UnpackHeightmap(_TerrainHeightmapTexture.Load(int3(sampleCoords, 0)));
input.positionOS.xz = sampleCoords * _TerrainHeightmapScale.xz;
input.positionOS.y = height * _TerrainHeightmapScale.y;
#ifdef ATTRIBUTES_NEED_NORMAL
input.normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb * 2 - 1;
#endif
#if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0)
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
input.uv0 = sampleCoords;
#else
input.uv0 = sampleCoords * _TerrainHeightmapRecipSize.zw;
#endif
#endif
#endif
#ifdef ATTRIBUTES_NEED_TANGENT
input.tangentOS.xyz = cross(float3(0,0,1), input.normalOS);
input.tangentOS.w = 1;
#endif
return input;
}
void ApplyVertexModification(AttributesMesh input, float3 normalWS, inout float3 positionWS, float4 time)
{
}

113
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData.hlsl


//-------------------------------------------------------------------------------------
// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
#include "CoreRP/ShaderLibrary/Sampling/SampleUVMapping.hlsl"
#include "../MaterialUtilities.hlsl"
#include "TerrainLitSplatCommon.hlsl"
// We don't use emission for terrain
#define _EmissiveColor float3(0,0,0)
#define _AlbedoAffectEmissive 0
#include "../Lit/LitBuiltinData.hlsl"
#undef _EmissiveColor
#undef _AlbedoAffectEmissive
#include "../Decal/DecalUtilities.hlsl"
void GetSurfaceAndBuiltinData(inout FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
{
float3 normalOS = SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_Control0, (input.texCoord0 + 0.5f) * _TerrainHeightmapRecipSize.xy).rgb * 2 - 1;
float3 normalWS = mul((float3x3)GetObjectToWorldMatrix(), normalOS);
float3 tangentWS = cross(GetObjectToWorldMatrix()._13_23_33, normalWS);
float renormFactor = 1.0 / length(normalWS);
// bitangent on the fly option in xnormal to reduce vertex shader outputs.
// this is the mikktspace transformation (must use unnormalized attributes)
float3x3 worldToTangent = CreateWorldToTangent(normalWS, tangentWS.xyz, 1);
// surface gradient based formulation requires a unit length initial normal. We can maintain compliance with mikkts
// by uniformly scaling all 3 vectors since normalization of the perturbed normal will cancel it.
input.worldToTangent[0] = worldToTangent[0] * renormFactor;
input.worldToTangent[1] = worldToTangent[1] * renormFactor;
input.worldToTangent[2] = worldToTangent[2] * renormFactor; // normalizes the interpolated vertex normal
input.texCoord0 *= _TerrainHeightmapRecipSize.zw;
}
#endif
// terrain lightmap uvs are always taken from uv0
input.texCoord1 = input.texCoord2 = input.texCoord0;
float3 normalTS;
TerrainSplatBlend(input.texCoord0, input.worldToTangent[0], input.worldToTangent[1],
surfaceData.baseColor, normalTS, surfaceData.perceptualSmoothness, surfaceData.metallic, surfaceData.ambientOcclusion);
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. Tag: SURFACE_GRADIENT
surfaceData.subsurfaceMask = 0;
surfaceData.thickness = 1;
surfaceData.diffusionProfile = 0;
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
// Init other parameters
surfaceData.anisotropy = 0.0;
surfaceData.specularColor = float3(0.0, 0.0, 0.0);
surfaceData.coatMask = 0.0;
surfaceData.iridescenceThickness = 0.0;
surfaceData.iridescenceMask = 0.0;
// Transparency parameters
// Use thickness from SSS
surfaceData.ior = 1.0;
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
surfaceData.atDistance = 1000000.0;
surfaceData.transmittanceMask = 0.0;
GetNormalWS(input, normalTS, surfaceData.normalWS);
float3 bentNormalWS = surfaceData.normalWS;
// By default we use the ambient occlusion with Tri-ace trick (apply outside) for specular occlusion.
#ifdef _MASKMAP
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
#else
surfaceData.specularOcclusion = 1.0;
#endif
#if HAVE_DECALS
float alpha = 1;
AddDecalContribution(posInput, surfaceData, alpha);
#endif
#ifdef DEBUG_DISPLAY
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_CONTROL)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0, _Control0, _Control0_TexelSize, _Control0_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER0)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat0_ST.xy + _Splat0_ST.zw, _Splat0, _Splat0_TexelSize, _Splat0_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER1)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat1_ST.xy + _Splat1_ST.zw, _Splat1, _Splat1_TexelSize, _Splat1_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER2)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat2_ST.xy + _Splat2_ST.zw, _Splat2, _Splat2_TexelSize, _Splat2_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER3)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat3_ST.xy + _Splat3_ST.zw, _Splat3, _Splat3_TexelSize, _Splat3_MipInfo, surfaceData.baseColor);
#ifdef _TERRAIN_8_LAYERS
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER4)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat4_ST.xy + _Splat4_ST.zw, _Splat4, _Splat4_TexelSize, _Splat4_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER5)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat5_ST.xy + _Splat5_ST.zw, _Splat5, _Splat5_TexelSize, _Splat5_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER6)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat6_ST.xy + _Splat6_ST.zw, _Splat6, _Splat6_TexelSize, _Splat6_MipInfo, surfaceData.baseColor);
else if (_DebugMipMapModeTerrainTexture == DEBUGMIPMAPMODETERRAINTEXTURE_LAYER7)
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0 * _Splat7_ST.xy + _Splat7_ST.zw, _Splat7, _Splat7_TexelSize, _Splat7_MipInfo, surfaceData.baseColor);
#endif
surfaceData.metallic = 0;
}
#endif
GetBuiltinData(input, V, posInput, surfaceData, 1, bentNormalWS, 0, builtinData);
}

108
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitData_Basemap.hlsl


//-------------------------------------------------------------------------------------
// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
#include "CoreRP/ShaderLibrary/Sampling/SampleUVMapping.hlsl"
#include "../MaterialUtilities.hlsl"
#include "TerrainLitSplatCommon.hlsl"
TEXTURE2D(_MainTex);
TEXTURE2D(_MetallicTex);
SAMPLER(sampler_MainTex);
#ifdef DEBUG_DISPLAY
float4 _MainTex_TexelSize;
float4 _MainTex_MipInfo;
#endif
// We don't use emission for terrain
#define _EmissiveColor float3(0,0,0)
#define _AlbedoAffectEmissive 0
#include "../Lit/LitBuiltinData.hlsl"
#undef _EmissiveColor
#undef _AlbedoAffectEmissive
#include "../Decal/DecalUtilities.hlsl"
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
{
float3 normalOS = SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_MainTex, (input.texCoord0 + 0.5f) * _TerrainHeightmapRecipSize.xy).rgb * 2 - 1;
float3 normalWS = mul((float3x3)GetObjectToWorldMatrix(), normalOS);
float3 tangentWS = cross(GetObjectToWorldMatrix()._13_23_33, normalWS);
float renormFactor = 1.0 / length(normalWS);
// bitangent on the fly option in xnormal to reduce vertex shader outputs.
// this is the mikktspace transformation (must use unnormalized attributes)
float3x3 worldToTangent = CreateWorldToTangent(normalWS, tangentWS.xyz, 1);
// surface gradient based formulation requires a unit length initial normal. We can maintain compliance with mikkts
// by uniformly scaling all 3 vectors since normalization of the perturbed normal will cancel it.
input.worldToTangent[0] = worldToTangent[0] * renormFactor;
input.worldToTangent[1] = worldToTangent[1] * renormFactor;
input.worldToTangent[2] = worldToTangent[2] * renormFactor; // normalizes the interpolated vertex normal
input.texCoord0 *= _TerrainHeightmapRecipSize.zw;
}
#endif
// terrain lightmap uvs are always taken from uv0
input.texCoord1 = input.texCoord2 = input.texCoord0;
surfaceData.baseColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.texCoord0).rgb;
surfaceData.perceptualSmoothness = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.texCoord0).a;
surfaceData.ambientOcclusion = SAMPLE_TEXTURE2D(_MetallicTex, sampler_MainTex, input.texCoord0).g;
surfaceData.metallic = SAMPLE_TEXTURE2D(_MetallicTex, sampler_MainTex, input.texCoord0).r;
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. Tag: SURFACE_GRADIENT
surfaceData.subsurfaceMask = 0;
surfaceData.thickness = 1;
surfaceData.diffusionProfile = 0;
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
// Init other parameters
surfaceData.anisotropy = 0.0;
surfaceData.specularColor = float3(0.0, 0.0, 0.0);
surfaceData.coatMask = 0.0;
surfaceData.iridescenceThickness = 0.0;
surfaceData.iridescenceMask = 0.0;
// Transparency parameters
// Use thickness from SSS
surfaceData.ior = 1.0;
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
surfaceData.atDistance = 1000000.0;
surfaceData.transmittanceMask = 0.0;
#ifdef SURFACE_GRADIENT
float3 normalTS = float3(0.0, 0.0, 0.0); // No gradient
#else
float3 normalTS = float3(0.0, 0.0, 1.0);
#endif
GetNormalWS(input, normalTS, surfaceData.normalWS);
float3 bentNormalWS = surfaceData.normalWS;
if (surfaceData.ambientOcclusion != 1.0f)
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
else
surfaceData.specularOcclusion = 1.0f;
#if HAVE_DECALS
float alpha = 1;
AddDecalContribution(posInput, surfaceData, alpha);
#endif
#ifdef DEBUG_DISPLAY
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input.texCoord0, _MainTex, _MainTex_TexelSize, _MainTex_MipInfo, surfaceData.baseColor);
surfaceData.metallic = 0;
}
#endif
GetBuiltinData(input, V, posInput, surfaceData, 1, bentNormalWS, 0, builtinData);
}

326
com.unity.render-pipelines.high-definition/HDRP/Material/TerrainLit/TerrainLitSplatCommon.hlsl


#ifdef _TERRAIN_8_LAYERS
#define _LAYER_COUNT 8
#else
#define _LAYER_COUNT 4
#endif
#define DECLARE_TERRAIN_LAYER_TEXS(n) \
TEXTURE2D(_Splat##n); \
TEXTURE2D(_Normal##n); \
TEXTURE2D(_Mask##n)
DECLARE_TERRAIN_LAYER_TEXS(0);
DECLARE_TERRAIN_LAYER_TEXS(1);
DECLARE_TERRAIN_LAYER_TEXS(2);
DECLARE_TERRAIN_LAYER_TEXS(3);
#ifdef _TERRAIN_8_LAYERS
DECLARE_TERRAIN_LAYER_TEXS(4);
DECLARE_TERRAIN_LAYER_TEXS(5);
DECLARE_TERRAIN_LAYER_TEXS(6);
DECLARE_TERRAIN_LAYER_TEXS(7);
TEXTURE2D(_Control1);
#endif
#undef DECLARE_TERRAIN_LAYER_TEXS
TEXTURE2D(_Control0);
SAMPLER(sampler_Splat0);
SAMPLER(sampler_Control0);
#ifdef UNITY_INSTANCING_ENABLED
TEXTURE2D(_TerrainHeightmapTexture);
TEXTURE2D(_TerrainNormalmapTexture);
#endif
#define DECLARE_TERRAIN_LAYER_PROPS(n) \
float4 _Splat##n##_ST; \
float _Metallic##n; \
float _Smoothness##n; \
float _NormalScale##n; \
float4 _DiffuseRemapScale##n; \
float4 _MaskMapRemapOffset##n; \
float4 _MaskMapRemapScale##n
CBUFFER_START(UnityTerrain)
#ifdef DEBUG_DISPLAY
float4 _Control0_TexelSize;
float4 _Control0_MipInfo;
float4 _Splat0_TexelSize;
float4 _Splat0_MipInfo;
float4 _Splat1_TexelSize;
float4 _Splat1_MipInfo;
float4 _Splat2_TexelSize;
float4 _Splat2_MipInfo;
float4 _Splat3_TexelSize;
float4 _Splat3_MipInfo;
#ifdef _TERRAIN_8_LAYERS
float4 _Splat4_TexelSize;
float4 _Splat4_MipInfo;
float4 _Splat5_TexelSize;
float4 _Splat5_MipInfo;
float4 _Splat6_TexelSize;
float4 _Splat6_MipInfo;
float4 _Splat7_TexelSize;
float4 _Splat7_MipInfo;
#endif
#endif
DECLARE_TERRAIN_LAYER_PROPS(0);
DECLARE_TERRAIN_LAYER_PROPS(1);
DECLARE_TERRAIN_LAYER_PROPS(2);
DECLARE_TERRAIN_LAYER_PROPS(3);
#ifdef _TERRAIN_8_LAYERS
DECLARE_TERRAIN_LAYER_PROPS(4);
DECLARE_TERRAIN_LAYER_PROPS(5);
DECLARE_TERRAIN_LAYER_PROPS(6);
DECLARE_TERRAIN_LAYER_PROPS(7);
#endif
float _HeightTransition;
#ifdef UNITY_INSTANCING_ENABLED
float4 _TerrainHeightmapRecipSize; // float4(1.0f/width, 1.0f/height, 1.0f/(width-1), 1.0f/(height-1))
float4 _TerrainHeightmapScale; // float4(hmScale.x, hmScale.y / (float)(kMaxHeight), hmScale.z, 0.0f)
#endif
CBUFFER_END
#undef DECLARE_TERRAIN_LAYER_PROPS
#ifdef HAVE_MESH_MODIFICATION
#include "TerrainLitDataMeshModification.hlsl"
#endif
// Declare distortion variables just to make the code compile with the Debug Menu.
// See LitBuiltinData.hlsl:73.
TEXTURE2D(_DistortionVectorMap);
SAMPLER(sampler_DistortionVectorMap);
float _DistortionScale;
float _DistortionVectorScale;
float _DistortionVectorBias;
float _DistortionBlurScale;
float _DistortionBlurRemapMin;
float _DistortionBlurRemapMax;
float GetSumHeight(float4 heights0, float4 heights1)
{
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;
}
float3 SampleNormalGrad(TEXTURE2D_ARGS(textureName, samplerName), float2 uv, float2 dxuv, float2 dyuv, float scale, float3 tangentWS, float3 bitangentWS)
{
float4 nrm = SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, uv, dxuv, dyuv);
#ifdef SURFACE_GRADIENT
#ifdef UNITY_NO_DXT5nm
real2 deriv = UnpackDerivativeNormalRGB(nrm, scale);
#else
real2 deriv = UnpackDerivativeNormalRGorAG(nrm, scale);
#endif
return SurfaceGradientFromTBN(deriv, tangentWS, bitangentWS);
#else
#ifdef UNITY_NO_DXT5nm
return UnpackNormalRGB(nrm, scale);
#else
return UnpackNormalmapRGorAG(nrm, scale);
#endif
#endif
}
float4 RemapMasks(float4 masks, float blendMask, float4 remapOffset, float4 remapScale)
{
float4 ret = masks;
ret.b *= blendMask; // height needs to be weighted before remapping
ret = ret * remapScale + remapOffset;
return ret;
}
#ifdef OVERRIDE_SAMPLER_NAME
#define sampler_Splat0 OVERRIDE_SAMPLER_NAME
#endif
void TerrainSplatBlend(float2 uv, float3 tangentWS, float3 bitangentWS,
out float3 outAlbedo, out float3 outNormalTS, out float outSmoothness, out float outMetallic, out float outAO)
{
// TODO: triplanar and SURFACE_GRADIENT?
// TODO: POM
float4 albedo[_LAYER_COUNT];
float3 normal[_LAYER_COUNT];
float4 masks[_LAYER_COUNT];
#ifdef _NORMALMAP
#define SampleNormal(i) SampleNormalGrad(_Normal##i, sampler_Splat0, splatuv, splatdxuv, splatdyuv, _NormalScale##i, tangentWS, bitangentWS)
#else
#define SampleNormal(i) float3(0, 0, 1)
#endif
#ifdef _MASKMAP
#define SampleMasks(i, blendMask) RemapMasks(SAMPLE_TEXTURE2D_GRAD(_Mask##i, sampler_Splat0, splatuv, splatdxuv, splatdyuv), blendMask, _MaskMapRemapOffset##i, _MaskMapRemapScale##i)
#define NullMask(i) float4(0, 1, _MaskMapRemapOffset##i.z, 0) // only height matters when weight is zero.
#else
#define SampleMasks(i, blendMask) float4(_Metallic##i, 1, 0, albedo[i].a * _Smoothness##i)
#define NullMask(i) float4(0, 1, 0, 0)
#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); \
albedo[i].rgb *= _DiffuseRemapScale##i.xyz; \
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] = NullMask(i); \
}
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);
#ifdef _MASKMAP
#ifdef _TERRAIN_BLEND_HEIGHT
// Modify blendMask to take into account the height of the layer. Higher height should be more visible.
float maxHeight = masks[0].z;
maxHeight = max(maxHeight, masks[1].z);
maxHeight = max(maxHeight, masks[2].z);
maxHeight = max(maxHeight, masks[3].z);
#ifdef _TERRAIN_8_LAYERS
maxHeight = max(maxHeight, masks[4].z);
maxHeight = max(maxHeight, masks[5].z);
maxHeight = max(maxHeight, masks[6].z);
maxHeight = max(maxHeight, masks[7].z);
#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].z, masks[1].z, masks[2].z, masks[3].z };
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].z, masks[5].z, masks[6].z, masks[7].z };
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
#else
// 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 = { _DiffuseRemapScale0.w, _DiffuseRemapScale1.w, _DiffuseRemapScale2.w, _DiffuseRemapScale3.w }; // 1 is off
blendMasks0 = lerp(opacityAsDensity0, blendMasks0, 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 = { _DiffuseRemapScale4.w, _DiffuseRemapScale5.w, _DiffuseRemapScale6.w, _DiffuseRemapScale7.w };
blendMasks1 = lerp(opacityAsDensity1, blendMasks1, useOpacityAsDensityParam1);
#endif
#endif // if _TERRAIN_BLEND_HEIGHT
#endif // if _MASKMAP
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(_MASKMAP) && !defined(_TERRAIN_BLEND_HEIGHT)
bool densityBlendEnabled = any(useOpacityAsDensityParam0 < 1);
#ifdef _TERRAIN_8_LAYERS
densityBlendEnabled = densityBlendEnabled || any(useOpacityAsDensityParam1 < 1);
#endif
// 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;
if (densityBlendEnabled)
{
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;
float3 outMasks = 0;
UNITY_UNROLL for (int i = 0; i < _LAYER_COUNT; ++i)
{
outAlbedo += albedo[i].rgb * weights[i];
outNormalTS += normal[i].rgb * weights[i]; // no need to normalize
outMasks += masks[i].xyw * 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.z;
outMetallic = outMasks.x;
outAO = outMasks.y;
}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存