Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/TerrainShader" {
- Properties {
- _ColorLow ("_ColorLow", Color) = (0,1,0,1)
- _ColorHigh ("_ColorHigh", Color) = (1,1,1,1)
- _ColorSlope ("_ColorHigh", Color) = (1,0,0,1)
- _MainTex ("Albedo (RGB)", 2D) = "white" {}
- _BumpMap ("BumpMapLow", 2D) = "white" {}
- _BumpMapHigh ("BumpMapHigh", 2D) = "white" {}
- _BumpMapSlope ("BumpMapSlope", 2D) = "white" {}
- _Glossiness ("Smoothness", Range(0,1)) = 0.5
- _HeightFactor ("HeightFactor", Float) = 0.05
- _SlopeFactor ("SlopeFactor", Float) = 0.7
- //_Metallic ("Metallic", Range(0,1)) = 0.0
- }
- SubShader {
- Tags { "RenderType"="Opaque" }
- LOD 200
- CGPROGRAM
- // Physically based Standard lighting model, and enable shadows on all light types
- #pragma surface surf Standard
- // Use shader model 3.0 target, to get nicer looking lighting
- #pragma target 3.0
- fixed4 _ColorLow,_ColorHigh,_ColorSlope;
- sampler2D _MainTex,_BumpMap,_BumpMapHigh,_BumpMapSlope;
- float _HeightFactor,_SlopeFactor;
- struct Input {
- float2 uv_MainTex;
- float2 uv_BumpMap;
- float3 worldPos;
- float3 worldNormal; INTERNAL_DATA
- };
- half _Glossiness;
- half _Metallic;
- fixed4 _Color;
- void surf (Input IN, inout SurfaceOutputStandard o) {
- // Albedo comes from a texture tinted by color
- fixed4 col = tex2D (_MainTex, IN.uv_MainTex);
- float h = saturate(IN.worldPos.y*_HeightFactor);
- o.Normal = UnpackNormal ( lerp( tex2D (_BumpMap, IN.uv_BumpMap), tex2D (_BumpMapHigh, IN.uv_BumpMap), h ) );
- float3 worldNorm = WorldNormalVector (IN, o.Normal);
- float slope = abs( dot(worldNorm, float3(0,1,0) ) );
- fixed4 c = lerp( _ColorLow, _ColorHigh, h*h );
- if (slope > _SlopeFactor)
- c.rgb = c;
- else{
- c.rgb = lerp(col, c, slope*slope );
- o.Normal = UnpackNormal ( tex2D (_BumpMapSlope, IN.uv_MainTex) );
- }
- //o.Normal = worldNorm;
- o.Albedo = c.rgb;
- // Metallic and smoothness come from slider variables
- o.Metallic = 0.0;
- o.Smoothness = c.a*_Glossiness;
- o.Alpha = 1.0;
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement