|
| 1 | +Shader "Custom/PuddleShader" { |
| 2 | + Properties { |
| 3 | + _Color ("Color", Color) = (1,1,1,1) |
| 4 | + _MainTex ("Albedo (RGB)", 2D) = "white" {} |
| 5 | + _NormalTex ("Normal Map", 2D) = "white" {} |
| 6 | + _NormalValue("Normal Value", Float) = 5 |
| 7 | + _HeightMap ("Height Map", 2D) = "white" {} |
| 8 | + _HeightMapScale ("Height", Range(0,1)) = 0.0 |
| 9 | + _OcclusionMap("OcclusionMap", 2D) = "white" {} |
| 10 | + _OcclusionStrength("Occlusion Strength", Range(0,1)) = 0.0 |
| 11 | + _EmissionColor("Emission Color", Color) = (0,0,0,0) |
| 12 | + _EmissionValue("Emission Value", Range(0,1)) = 0.0 |
| 13 | + _PuddleTex("Puddle", 2D) = "white" {} |
| 14 | + _PuddleColor("Puddle Color", Color) = (1,1,1,1) |
| 15 | + _Intensity("Puddle Intensity", Range(0,1)) = 0.5 |
| 16 | + _Wet("Wetness", Range(0,1)) = 0.0 |
| 17 | + } |
| 18 | + SubShader { |
| 19 | + Tags { "RenderType"="Opaque" } |
| 20 | + LOD 200 |
| 21 | + |
| 22 | + CGPROGRAM |
| 23 | + // Physically based Standard lighting model, and enable shadows on all light types |
| 24 | + #pragma surface surf StandardSpecular fullforwardshadows |
| 25 | + |
| 26 | + // Use shader model 3.0 target, to get nicer looking lighting |
| 27 | + #pragma target 3.0 |
| 28 | + |
| 29 | + sampler2D _MainTex; |
| 30 | + sampler2D _NormalTex; |
| 31 | + sampler2D _PuddleTex; |
| 32 | + sampler2D _OcclusionMap; |
| 33 | + sampler2D _HeightMap; |
| 34 | + |
| 35 | + struct Input { |
| 36 | + float2 uv_MainTex; |
| 37 | + float2 uv_PuddleTex; |
| 38 | + }; |
| 39 | + |
| 40 | + fixed4 _Color; |
| 41 | + fixed4 _PuddleColor; |
| 42 | + fixed4 _EmissionColor; |
| 43 | + half _Wet; |
| 44 | + half _Intensity; |
| 45 | + half _OcclusionStrength; |
| 46 | + half _HeightMapScale; |
| 47 | + half _EmissionValue; |
| 48 | + half _NormalValue; |
| 49 | + |
| 50 | + // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. |
| 51 | + // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. |
| 52 | + // #pragma instancing_options assumeuniformscaling |
| 53 | + UNITY_INSTANCING_CBUFFER_START(Props) |
| 54 | + // put more per-instance properties here |
| 55 | + UNITY_INSTANCING_CBUFFER_END |
| 56 | + |
| 57 | + void surf (Input IN, inout SurfaceOutputStandardSpecular o) |
| 58 | + { |
| 59 | + float3 normalMap = UnpackNormal(tex2D(_NormalTex, IN.uv_MainTex)); |
| 60 | + half4 puddleSpec = tex2D(_PuddleTex, IN.uv_PuddleTex); |
| 61 | + fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; |
| 62 | + |
| 63 | + // Albedo comes from a texture tinted by color |
| 64 | + o.Albedo = c.rgb; |
| 65 | + o.Normal = normalMap.rgb*_NormalValue; |
| 66 | + o.Alpha = c.a; |
| 67 | + o.Specular = puddleSpec.a * _Wet * _PuddleColor; |
| 68 | + o.Occlusion = tex2D(_OcclusionMap, IN.uv_MainTex) * _OcclusionStrength; |
| 69 | + o.Smoothness = _Intensity * puddleSpec.a; |
| 70 | + o.Emission = _EmissionColor.rgb * _EmissionValue; |
| 71 | + } |
| 72 | + ENDCG |
| 73 | + } |
| 74 | + FallBack "Diffuse" |
| 75 | +} |
0 commit comments