[Shader Graph] [URP] [Quest2] Scaling UVs by object's size doesn't work on the Quest 2/Android

Hey everyone!

Ran into a problem here and maybe someone more knowledgeable knows what could be happenning.

I created a simple shader function to scale an object UVs according to the object size. This is so I can have some materials behave as “BSP” brushes. Everything works well in the editor, however, when I compile and run the game on the Quest 2, the UVs are not scaling at all. It is as if the object size information is not being passed through or something.

I understood from reading other threads that you need to set the precision to float for such cases, but on my Shadergraph I only have Inherit, single and half.

Does anyone have any idea why it’s not working in the Quest 2?

Here’s a gif demonstrating the behavior:

Here’s how it would look in the Meta 2:

Here’s how it looks in editor:

And my shader graph function:

And then the result of that function gets applied as UV coordinates for each texture map:

Thanks in advance!

PS: Seems like I posted this in the wrong forum, can someone move it to the Shader Graph forum please? :slight_smile:

7953217--1018507--uvscaling-min.gif

Are the game objects set to be static? If so, they’re being statically batched, meaning those meshes are getting baked into a larger single mesh with any scale, rotation, and position pre-applied so that on the device they do not have any scaling.

This should also show this behavior if you press play in the editor and look at it in the game view.

1 Like

Aw shucks… that makes sense… I didn’t know that that’s how static batching works in Unity. I did the exact same shader in Unreal, and batching doesn’t break it there.

Do you have an idea how else to accomplish something like this? Since this is for Oculus, I’m not sure I can afford to turn off static batching :confused:

Thanks for the reply!

The solution is … don’t use a shader to do this for static geometry. Build the geometry bespoke, either with an external modeling tool, or using ProBuilder.

Alternatively you could use a world space UV shader.

Each of those methods have their drawbacks. World space UVs won’t work for what I’m seeking. I might have to bite the bullet and just go with ProBuilder.

Edit:
I did some perf tests with different combinations of static batching, srp batching, instancing etc… and to my surprise, the lowest drawcall count I got on my scene was with static batching turned off and GPU instancing enabled on materials. Turns out that in this case turning off Static Batching is not a deal-breaker at all :slight_smile:

Thanks.