OSDN Git Service

new project
[mindgames/Mindgames_main.git] / Mindgames / Library / PackageCache / com.unity.render-pipelines.high-definition@6.9.0-preview / Runtime / Material / TerrainLit / TerrainLit_BasemapGen.shader
1 Shader "Hidden/HDRP/TerrainLit_BasemapGen"
2 {
3     Properties
4     {
5         [HideInInspector] _DstBlend("DstBlend", Float) = 0.0
6     }
7
8     SubShader
9     {
10         Tags { "SplatCount" = "8" }
11
12         HLSLINCLUDE
13
14         #pragma target 4.5
15         #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
16
17         #define SURFACE_GRADIENT // Must use Surface Gradient as the normal map texture format is now RG floating point
18         #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
19         #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
20         #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
21         #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
22         #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLitSurfaceData.hlsl"
23
24         // Terrain builtin keywords
25         #pragma shader_feature_local _TERRAIN_8_LAYERS
26         #pragma shader_feature_local _NORMALMAP
27         #pragma shader_feature_local _MASKMAP
28
29         #pragma shader_feature_local _TERRAIN_BLEND_HEIGHT
30
31         #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Splatmap_Includes.hlsl"
32
33         CBUFFER_START(UnityTerrain)
34             UNITY_TERRAIN_CB_VARS
35             float4 _Control0_ST;
36             float4 _Control0_TexelSize;
37         CBUFFER_END
38
39         struct Varyings
40         {
41             float4 positionCS : SV_POSITION;
42             float4 texcoord : TEXCOORD0;
43         };
44
45         #pragma vertex Vert
46         #pragma fragment Frag
47
48         float2 ComputeControlUV(float2 uv)
49         {
50             // adjust splatUVs so the edges of the terrain tile lie on pixel centers
51             return (uv * (_Control0_TexelSize.zw - 1.0f) + 0.5f) * _Control0_TexelSize.xy;
52         }
53
54         Varyings Vert(uint vertexID : SV_VertexID)
55         {
56             Varyings output;
57             output.positionCS = GetFullScreenTriangleVertexPosition(vertexID);
58             output.texcoord.xy = TRANSFORM_TEX(GetFullScreenTriangleTexCoord(vertexID), _Control0);
59             output.texcoord.zw = ComputeControlUV(output.texcoord.xy);
60             return output;
61         }
62
63         ENDHLSL
64
65         Pass
66         {
67             Tags
68             {
69                 "Name" = "_MainTex"
70                 "Format" = "ARGB32"
71                 "Size" = "1"
72             }
73
74             ZTest Always Cull Off ZWrite Off
75             Blend One [_DstBlend]
76
77             HLSLPROGRAM
78
79             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Splatmap.hlsl"
80
81             float4 Frag(Varyings input) : SV_Target
82             {
83                 TerrainLitSurfaceData surfaceData;
84                 InitializeTerrainLitSurfaceData(surfaceData);
85                 TerrainSplatBlend(input.texcoord.zw, input.texcoord.xy, surfaceData);
86                 return float4(surfaceData.albedo, surfaceData.smoothness);
87             }
88
89             ENDHLSL
90         }
91
92         Pass
93         {
94             Tags
95             {
96                 "Name" = "_MetallicTex"
97                 "Format" = "RG16"
98                 "Size" = "1/4"
99             }
100
101             ZTest Always Cull Off ZWrite Off
102             Blend One [_DstBlend]
103
104             HLSLPROGRAM
105
106             #define OVERRIDE_SPLAT_SAMPLER_NAME sampler_Mask0
107             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Splatmap.hlsl"
108
109             float2 Frag(Varyings input) : SV_Target
110             {
111                 TerrainLitSurfaceData surfaceData;
112                 InitializeTerrainLitSurfaceData(surfaceData);
113                 TerrainSplatBlend(input.texcoord.zw, input.texcoord.xy, surfaceData);
114                 return float2(surfaceData.metallic, surfaceData.ao);
115             }
116
117             ENDHLSL
118         }
119     }
120     Fallback Off
121 }