Hello everyone,
I’m trying to create a snow shader that I can use as a secondary material on any object that already has a material on it. I sort of want to just add it to assets that I already have but were not made with snow environments in mind. I’m very new to scripting shaders so i’m also very lost. I have started with the snow shader found on Unity Gems, but I’m pretty much stuck.
There are a few things that I would like to do.
- I’d like to make the texture reference the first materials normal map and blend it with my own snow normal map on the second material.
- I’d also like the snow to have a texture rather than just a flat color, and a spectacular map.
Any help you could provide would be much appreciated! Or if you have any shader scripting references that I could look at to try and learn it myself I would be happy with that too!
Shader "Custom/SnowShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Bump ("Bump", 2D) = "bump" {}
_Snow ("Snow Level", Range(0,1) ) = 0
_SnowColor ("Snow Color", Color) = (1.0,1.0,1.0,1.0)
_SnowDirection ("Snow Direction", Vector) = (0,1,0)
}
SubShader {
Tags { "RenderType"="Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
sampler2D _Bump;
float _Snow;
float4 _SnowColor;
float4 _SnowDirection;
struct Input {
float2 uv_MainTex;
float2 uv_Bump;
float3 worldNormal;
INTERNAL_DATA
};
void vert (inout appdata_full v) {
//Convert the normal to world coortinates
float4 sn = mul(UNITY_MATRIX_IT_MV, _SnowDirection);
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Normal = UnpackNormal (tex2D (_Bump, IN.uv_Bump));
if(dot(WorldNormalVector(IN, o.Normal), _SnowDirection.xyz)>=lerp(1,-1,_Snow))
o.Albedo = _SnowColor.rgb;
else
o.Albedo = c.rgb;
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}
Thanks Guys!