- Home /
Question by
honeywaffles · Nov 23, 2014 at 02:19 PM ·
shaderterraingrasscustom-shader
Shader LOD wont work on custom grass shader
I have edited the grass shader that comes with unity, and tried to implement LOD, but failed.
Shader "Hidden/TerrainEngine/Details/WavingDoublePass" {
Properties {
_MainTex ("Base (RGB) Transparency (A)", 2D) = "" {}
_Cutoff ("Alpha cutoff", Range (0,1)) = 0.5
}
SubShader {
Tags {
"Queue" = "Geometry+200"
"IgnoreProjector"="True"
"RenderType"="Grass"
}
LOD 700
Cull Off
ColorMask RGB
CGPROGRAM
#pragma surface surf Lambert vertex:WavingGrassVert noforwardadd
#pragma exclude_renderers flash
#include "TerrainEngine.cginc"
sampler2D _MainTex;
fixed _Cutoff;
struct Input {
fixed2 uv_MainTex;
fixed4 color : COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
o.Albedo = c.rgb;
o.Alpha = c.a;
clip (o.Alpha - _Cutoff);
o.Alpha *= IN.color.a;
}
ENDCG
}
SubShader {
Tags {
"Queue" = "Geometry+200"
"IgnoreProjector"="True"
"RenderType"="Grass"
}
LOD 1000
Cull Off
ColorMask RGB
CGPROGRAM
#pragma surface surf Lambert vertex:WavingGrassVert noforwardadd addshadow
#pragma exclude_renderers flash
#include "TerrainEngine.cginc"
sampler2D _MainTex;
fixed _Cutoff;
struct Input {
fixed2 uv_MainTex;
fixed4 color : COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
o.Albedo = c.rgb;
o.Alpha = c.a;
clip (o.Alpha - _Cutoff);
o.Alpha *= IN.color.a;
}
ENDCG
}
SubShader {
Pass {
Material {
Diffuse [_Color]
}
Lighting Off
}
}
}
If I change the LOD to 700, the grass keeps having shadows, if I turn it even a unit lower, the grass becomes black. I cant figure out why it does this? Can anyone help me?
Comment