- Home /
Manually configure light bounds? / Optimising lighting for dynamic batching
Here's the quick background, my project has:
- Lots of dynamic objects
- 4 dynamic lights
- Mobile/VertexLit shader
- Targetting Android
All the dynamic objects are sharing a single material, so I'm relying on Unity's dynamic batching to bring the draw calls down to a sensible amount on Android. And in theory, Mobile/VertexLit can do 4 lights simultaneously (via vector ops) so this can all be done via a single draw call.
Problem: Since the lights all cover different areas, some objects fall under light 1, some under 1+2, some under 3, some under 3+4, etc. etc.
Unity (in it's infinite wisdom) is trying to make dynamic batches for each combination of lights, which means in my test scene, 6 objects each fall under a different lighting permutation and end up as 6 batches (bad!). Really, I want to (somehow) force Unity to only consider one lighting permutation (all 4 lights) and then create one dynamic batch for this, so all 6 objects become one dynamic batch.
Ways I can think of doing this:
1. Somehow force the light bounds to be huge, so that Unity thinks all objects are lit by all lights.
2. Disable light culling for dynamic batch generation somehow
3. Mess with my object's bounds so that they appear to be intersecting all of the lights (but will this then mess up frustum culling?)
4. Ditch Unity lighting and write my own shaders (ugh. super time sink).
5. Something else.
Unfortunately, I do not know how to actually do any of these in Unity, as it appears I can't dig deep enough into the renderer. Anyone any suggestions? Thanks.
Dude, your 2D dynamic lighting article clearly shows, that you are the best candidate, to make a good asset that accomplishes believable 2D dynamic lighting. None of the assets out there do it right. I'd gladly pay €30-40 for an asset like that. $$anonymous$$aybe more. Is there no way to take advantage of your methods, by drawing to a texture, and then overlay the camera with that texture?
Though I did find this beautiful per-pixel solution: https://www.assetstore.unity3d.com/en/#!/content/38682
Your answer
Follow this Question
Related Questions
Mobile Build Spotlight Problem 1 Answer
Shadows problem on mobile 0 Answers
How to fix spotLight problom in android ? 0 Answers
Lighting won't extend far on Android,Lighting won't extend far on mobile? 0 Answers
lighting heavy mobile game optimization 0 Answers