- Home /
Shader and Dynamic batching problem
my car model has 290 verts and 210 tris . When i use Diffuse shader dynamic batching is happening but when i use legacy/lightmapped/bumped diffuse , dynamic batching is not happening . As mentioned in official doc . 300 or less verts that i require for dynamic batching . So, what's going wrong ??
Answer by CHPedersen · Oct 10, 2013 at 08:15 AM
Did you see this page on Dynamic Batching?
Study all the points under the "Tips" section and make sure the shader you want to use obeys all of them. For example, something which is bumpmapped will certainly need more data than just Vertex Position, Normal and single UV. It also needs tangent, for instance. In that case, the max vertex count drops to 180 and then your mesh violates the limit.
There is also a note about lightmapped shaders:
"Objects with lightmaps have additional renderer parameter: lightmap index and offset/scale into the lightmap. So generally dynamic lightmapped objects should point to exactly the same lightmap location to be batched."
Does your setup obey this requirement?
thanx @CHPedersen . I used mobile/diffuseBumpedmap , then it in edit option and it gives me list
In highlighted part ..I am guessing that i have 5 Requirement for this shader . Now if i am correct then i need a shader which can fulfill my normal and light map requirements . I don't know the shader program$$anonymous$$g . Can you suggest me some free online shaders which can fulfill my needs ????????
Sorry, I can't. :-/ I haven't browsed a lot for bump/light mapped shaders online as my project has pretty weird requirements that require me to write custom shaders myself. But I can tell you that no matter where you look, there is no shader that will give you bumpmapping without using tangent vectors. This is simply because the mathematical solution for bump mapping requires them. So you won't find a shader that will magically give you bump mapping while still bypassing the 180 vertex limit. You will have to either simplify your mesh, choose a non-bumpmapped shader or forego dynamic batching.
As for the last option, do you absolutely need dynamic batching? I'm guessing you're on a mobile platform and are worried about performance, but have you tried to go without it and see what happens to the framerate?
yes i am developing for mobile platform and concern about draw calls as there are too many objects . Please guide me in following problem also .... For static object i am planning to use unity's inbuild light-mapping .But for moving cars i can't use it and if i use external lightmaps then i need to use legecy/lightmapped/Bumped Diffuse shader as i am using a normal also . And in this case i am loosing dynamic batching . What to do ??
If using these shaders is critical to you, then dynamic batching is out of the question. If your performance suffers because of this, you must find another way to optimize the game. It's a tough trade-off, but you cannot have both dynamic batching and normal mapped shaders with >180 vertex objects. You must either choose between your shader or batching, or you must optimize elsewhere to regain what the lack of batching cost you.