//Grass shader ver 1.0 by saeed rasti Shader "Sshaders/Glass" { Properties { _MainColor("_MainColor", Color) = (1,1,1,1) _MainTex("Base (RGB) Gloss (A)", 2D) = "white" {} _Dirt("_Dirt", 2D) = "black" {} _Cube("Reflection Cubemap", Cube) = "black" {} _ReflectRip("_ReflectRip", Range(0.3,9) ) = 0.3 _Gloss("_Gloss", Range(0.2,9) ) = 0.5 _Spec("_Spec", Range(0,3) ) = 2 } SubShader { Tags { "Queue" = "Transparent" "IgnoreProjector" = "False" "RenderType" = "Transparent" } Cull Back ZWrite On ZTest LEqual ColorMask RGBA LOD 100 Fog { } CGPROGRAM #pragma surface surf BlinnPhongEditor exclude_path:prepass fullforwardshadows softvegetation alpha decal:add #pragma target 3.0 float4 _MainColor; sampler2D _MainTex; sampler2D _Dirt; samplerCUBE _Cube; float _ReflectRip; float _Gloss; float _Spec; struct EditorSurfaceOutput { half3 Albedo; half3 Normal; half3 Emission; half3 Gloss; half Specular; half Alpha; half4 Custom; }; inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light) { half3 spec = light.a * s.Gloss; half4 c; c.rgb = (s.Albedo * light.rgb + light.rgb * spec); c.a = s.Alpha; return c; } inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 h = normalize (lightDir + viewDir); half diff = max (0, dot ( lightDir, s.Normal )); float nh = max (0, dot (s.Normal, h)); float spec = pow (nh, s.Specular*128.0); half4 res; res.rgb = _LightColor0.rgb * diff; res.w = spec * Luminance (_LightColor0.rgb); res *= atten * 2.0; return LightingBlinnPhongEditor_PrePass( s, res ); } inline half4 LightingBlinnPhongEditor_DirLightmap (EditorSurfaceOutput s, fixed4 color, fixed4 scale, half3 viewDir, bool surfFuncWritesNormal, out half3 specColor) { UNITY_DIRBASIS half3 scalePerBasisVector; half3 lm = DirLightmapDiffuse (unity_DirBasis, color, scale, s.Normal, surfFuncWritesNormal, scalePerBasisVector); half3 lightDir = normalize (scalePerBasisVector.x * unity_DirBasis[0] + scalePerBasisVector.y * unity_DirBasis[1] + scalePerBasisVector.z * unity_DirBasis[2]); half3 h = normalize (lightDir + viewDir); float nh = max (0, dot (s.Normal, h)); float spec = pow (nh, s.Specular * 128.0); specColor = lm * _SpecColor.rgb * s.Gloss * spec; return half4(lm, spec); } struct Input { float2 uv_MainTex; float2 uv_Dirt; float3 viewDir; float3 worldRefl; INTERNAL_DATA }; void surf (Input IN, inout EditorSurfaceOutput o) { o.Normal = float3(0.0,0.0,1.0); o.Alpha = 1.0; o.Albedo = 0.0; o.Emission = 0.0; o.Gloss = 0.0; o.Specular = 0.0; o.Custom = 0.0; float4 Sampled2D0=tex2D(_MainTex,IN.uv_MainTex.xy); float4 Multiply1=_MainColor * Sampled2D0; float4 Sampled2D1=tex2D(_Dirt,IN.uv_Dirt.xy); float4 Add0=Multiply1 + Sampled2D1; float4 Fresnel0_1_NoInput = float4(0,0,1,1); float4 Fresnel0=(1.0 - dot( normalize( float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ).xyz), normalize( Fresnel0_1_NoInput.xyz ) )).xxxx; float4 Pow0=pow(Fresnel0,_ReflectRip.xxxx); float4 WorldReflection0_0_NoInput = float4(0,0,1,1); float4 WorldReflection0=float4( WorldReflectionVector (IN, WorldReflection0_0_NoInput), 1.0); float4 TexCUBE0=texCUBE(_Cube,WorldReflection0); float4 Multiply0=Pow0 * TexCUBE0; float4 Invert0= float4(1.0, 1.0, 1.0, 1.0) - Sampled2D1.aaaa; float4 Multiply3=Multiply0 * Invert0; float4 Add1=Sampled2D1.aaaa + _Spec.xxxx; float4 Master0_1_NoInput = float4(0,0,1,1); float4 Master0_7_NoInput = float4(0,0,0,0); float4 Master0_6_NoInput = float4(1,1,1,1); o.Albedo = Add0; o.Emission = Multiply3; o.Specular = _Gloss.xxxx; o.Gloss = Add1; o.Alpha = Sampled2D0.aaaa; o.Normal = normalize(o.Normal); } ENDCG } Fallback "Diffuse" }