Hey guys,
im trying to write a shader for gras, that takes his object local up vector to calculate the normals. I want this, so that every vertex is lit by the same color to have a smooth color transition between the ground and the gras. The problem is, that the gras (two planes crossing each other with a simple texture) dont batch. Everything is working fine when i have the Disablebatching set to true. But when i set it to false the lightning of the gras “jumps” when i move and rotate the ground. (Need the rotation, because the game is placed on a cube).
Im using Unity 5.3.4f1 and this is the shader:
Shader "Cubiverse/FX/Gras" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" "ForceNoShadowCasting"="True"} // Shader works fine when using "DisableBatching" = "True"
Cull Off
CGPROGRAM
#pragma surface surf Lambert vertex:vert
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
void vert (inout appdata_full v) {
// face the normal always to the top; all vertecies have the same "light direction"
v.normal = float3(0.0,1.0,0.0);
}
void surf (Input IN, inout SurfaceOutput o) {
float4 tex = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = tex.rgb;
clip(tex.a -0.1);
}
ENDCG
}
Fallback "Diffuse"
}
Can somebody help me with this? When do unity batch and when not?
Documentation says: “Some shaders (mostly ones that do object-space vertex deformations) do not work when Draw Call Batching is used.”
Thanks for any help!
Julian