hi all, I am experiencing different shader behaviors depending on the number of objects on the screen. I suspect the reason is related to the rendering batch.
The shader is a simple debug shader that shows the object space position as the RGB color. The test objects are rigged objects using the 2D animation package. Each individual body part is a separate game object with the same material/shader.
This is the expected behavior, each individual body part has its own object space.
TBH, I was hoping for a regular shader lol. It’s difficult to debug those shader graphs (generated code for this simple shader is 6500 lines). It looks fine, though.
Maybe you can see what’s going on in the frame debugger or in RenderDoc. Sorry, wish I had a better answer.
Thanks for replying. The shader itself is really simple. I don’t think the problem is caused by the shader. In fact, I’ve tested regular objects such as quad/cube. They are fine. I think the problem is related to the 2D animation rigging pipeline.
2D animation pack is an extension of sprites - batching for sure and easily can repro. Sprites constructor is capable of batching them from same material… and it can also break one off just as oddly
Is there a way to control the batching? In my example, sometimes one character’s arm can be in the same batch as the other character’s leg while all other body parts are not batched at all. The outcome is so random, that a slight movement of the object completely changes the batching.
[quote=“c0d3_m0nk3y, post:8, topic: 893661, username:c0d3_m0nk3y”]
Maybe this is dynamic batching. You can turn it off in the options. https://docs.unity3d.com/Manual/dynamic-batching.html#dynamic-batching-meshes
[/quote]
yes it is dynamics - I also went hunting for all that last night in “Player settings” and the SRP->URP asset >
advanced
im in 2021.2 and nothing showed up
the only thing I could think to hack it is set everything to like -1 X (mirror); maybe that will break everything?
They’ve probably hid it because it’s kind of deprecated AFAIK. It really only helps performance on some mobile platforms.
It seems to be off by default, which makes me wonder if your problem is caused by something else.
I have tried the dynamics batching thingy before, does not seems to make any difference. The only solution I have found so far is to dynamically create new material instances at runtime, but this is kinda expensive.