2,538
社区成员
发帖
与我相关
我的任务
分享
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "Nature/Terrain/Standard" {
Properties {
// set by terrain engine
[HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
[HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}
[HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}
[HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}
[HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}
[HideInInspector] _Normal3 ("Normal 3 (A)", 2D) = "bump" {}
[HideInInspector] _Normal2 ("Normal 2 (B)", 2D) = "bump" {}
[HideInInspector] _Normal1 ("Normal 1 (G)", 2D) = "bump" {}
[HideInInspector] _Normal0 ("Normal 0 (R)", 2D) = "bump" {}
[HideInInspector] [Gamma] _Metallic0 ("Metallic 0", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic1 ("Metallic 1", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic2 ("Metallic 2", Range(0.0, 1.0)) = 0.0
[HideInInspector] [Gamma] _Metallic3 ("Metallic 3", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness0 ("Smoothness 0", Range(0.0, 1.0)) = 1.0
[HideInInspector] _Smoothness1 ("Smoothness 1", Range(0.0, 1.0)) = 1.0
[HideInInspector] _Smoothness2 ("Smoothness 2", Range(0.0, 1.0)) = 1.0
[HideInInspector] _Smoothness3 ("Smoothness 3", Range(0.0, 1.0)) = 1.0
// used in fallback on old cards & base map
[HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
[HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Tags {
"Queue" = "Geometry-100"
"RenderType" = "Opaque"
}
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
struct Input
{
float2 uv_Splat0 : TEXCOORD0;
float2 uv_Control : TEXCOORD4;
};
sampler2D _Control,_Splat0,_Splat1,_Splat2,_Splat3;
half _Metallic0;
half _Metallic1;
half _Metallic2;
half _Metallic3;
void surf (Input IN, inout SurfaceOutput o) {
half4 BlendTex = tex2D(_Control, IN.uv_Control);
half4 lay0={0.0,0.0,0.0,0.0},lay1={0.0,0.0,0.0,0.0},lay2={0.0,0.0,0.0,0.0},lay3={0.0,0.0,0.0,0.0};
float2 xy;half k;
k = round(BlendTex.r * 256.0);
if(k>0&&k<33){
xy.x = floor(k / 4)/8;
xy.y = (3-fmod(k, 4))/4;
lay0 = tex2D(_Splat0,frac(IN.uv_Splat0)/float2(8,4)+xy,ddx(IN.uv_Splat0/float2(8,4)),ddy(IN.uv_Splat0/float2(8,4)));
}
k = round(BlendTex.g * 256.0);
if(k>0&&k<33){
xy.x = floor(k / 4)/8;
xy.y = (3-fmod(k, 4))/4;
lay1 = tex2D(_Splat1,frac(IN.uv_Splat0)/float2(8,4)+xy,ddx(IN.uv_Splat0/float2(8,4)),ddy(IN.uv_Splat0/float2(8,4)));
}
k = round(BlendTex.b * 256.0);
if(k>0&&k<33){
xy.x = floor(k / 4)/8;
xy.y = (3-fmod(k, 4))/4;
lay2 = tex2D(_Splat2,frac(IN.uv_Splat0)/float2(8,4)+xy,ddx(IN.uv_Splat0/float2(8,4)),ddy(IN.uv_Splat0/float2(8,4)));
}
k = round(BlendTex.a * 256.0);
if(k>0&&k<33){
xy.x = floor(k / 4)/8;
xy.y = (3-fmod(k, 4))/4;
lay3 = tex2D(_Splat3,frac(IN.uv_Splat0)/float2(8,4)+xy,ddx(IN.uv_Splat0/float2(8,4)),ddy(IN.uv_Splat0/float2(8,4)));
}
float4 finalColor;
finalColor=lerp(lay0,lay1,lay1.a);
finalColor=lerp(finalColor,lay2,lay2.a);
finalColor=lerp(finalColor,lay3,lay3.a);
o.Albedo.rgb=finalColor;
}
ENDCG
}
Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Standard-AddPass"
Dependency "BaseMapShader" = "Hidden/TerrainEngine/Splatmap/Standard-Base"
Fallback "Nature/Terrain/Diffuse"
}