_Object2World and dynamic batching

I was tweaking a shader for a volumetric fog effect, and I ran into an issue with the _Object2World matrix and dynamic batching.

At first, the shader was using a Material property for the position of the object, which did not allow for dynamic batching. I corrected this by deriving the object origin from the _Object2World matrix in the vertex shader instead, but once dynamic batching kicks in, (verified by monitoring draw calls in Statistics) the _Object2World matrix seems to be constant across different objects.

Is this an expected side-effect of dynamic batching? I’ve reviewed the following documentation and found nothing related to this issue:

http://docs.unity3d.com/Documentation/Components/SL-BuiltinValues.html

It’s the identity matrix when batching occurs. Not allowing us to use our own vertex transform for batching is a serious problem.

1 Like

Thanks Jessy. Such a fundamental limitation should be documented somewhere. Any word from Unity folks if this will be corrected anytime soon?

I don’t think many people are affected by the limitation, but I agree.

I’ve never heard mention of it. I bet that scripting this would kill a lot of the performance gained from batching, however.

You can work around it.

Glad I spotted this thread. Good info!