- Home /
Is it possible to mirror a gameobject in shader ?
Hi,
I am currently working on a game where there are right-handed and left-handed characters. For the time being, I scale the character parent (-1;1;1) but it breaks the dynamic batching. So I was wondering if it was possible to do that in the shader to keep the benefits of the dynamic batching, and if it's possible, how ?
Thanks in advance
Answer by StupidlySimple · Aug 07, 2016 at 01:12 AM
Yes you can, but all GameObject using that shader will have their texture be mirrored. Shader is not selected. I think you can retain dynamic batching if you flipped the UV coordinate instead.
Say this is your UV coordinate for a quad corresponding to your vertices.
2|3
0|1
If you flip the coordinate.
3 | 2
1 | 0
You get mirrored image on the horizontal axis.
Well, actually my problem is not about just mirroring the textures.
The thing is that I wanted to mirror the whole gameobject to mirror the animations at the same time (as I said in my first post, this is about right-handed and left-handed characters). For the time being, I was using a scale of (-1;1;1) and reversed UV to keep the textures not reverted (it's a sport game, with logos on the jerseys).But this solution breaks the dynamic batching.
That's why I wanted to scale the gameobject in the shader ins$$anonymous$$d, along with a $$anonymous$$aterialPropertyBlock to pass the scaling matrix to the shader. But I didn't manage to make it work (I don't which exact matrices multiplications I should do to make it work), or if it's even possible.