hi guys…
i have came across a billboard shader and i added a alpha cutout in it to make it work as a tree billboard shader
but now i want to add some shadows in it as i want my trees to cast shadows
so i tried some tags but no use so guys plz help me in adding shadows in it
code given blow
Shader "MyShader/billboards" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
_CutOff("Cut off", float) = 0.1
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// User-specified uniforms
uniform sampler2D _MainTex;
uniform float _CutOff;
struct vertexInput {
float4 vertex : POSITION;
float4 tex : TEXCOORD0;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
};
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_P,
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
- float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
output.tex = -input.tex;
return output;
}
float4 frag(vertexOutput input) : COLOR
{
float4 color = tex2D(_MainTex, float2(input.tex.xy));
if(color.a < _CutOff) discard;
return color;
}
ENDCG
}
}
}
plz help i am realy confused with shadows
i am able to cast some shadows by adding
FallBack “Transparent/Cutout/Diffuse” but it dosse not cast a cutout shadow
for example i am using a planer for my trees so the shader is casting the shadow of a planer instead of cutout
Plz need help
Thanks
AR
This shouldn't be necessary and might cause you some extra problems clip(color.a - _CutOff) ;
– Izolaiztaccihuatl