For my game, I am aiming for a relatively consistent texture pixel density, which means a 1 meter high slab of stone should have 64 pixels along its side and a 4 meter high stone 256 pixels.
I can adjust this by making a new copy of the rock material for every individual object that uses it, figure out how big it is and what the right scale is, and then enter the UV scale manually.
That time and work adds up over time with a larger game.
Is there a way to automate this in some way, so I just have one material that I can plug into each object without having to do the UV scale adjustment manually and instead have it all conform to one standard value that I set?
StandardMaterial3D has a “world triplanar” option under UV1 that may be helpful, then you can use the same material for objects using the same texture.
I’d be surprised to hear it’s resource intensive, using world coordinates should be less calculations but at worst it’s up to three more mat4 multiplication per-vertex. Still only sampling the albedo, normal etc once, other triplanar techniques may sample up to three textures for each axis but not Godot’s.
World triplanar is very good for a “fixed-size” texture, non-world triplanar might help too. These triplanar techniques are sometimes call auto-uv since they don’t depend on UV mapping to texture objects, I bring them up since UV maps are what create such pixel/size distortions. If you aren’t going for a funky style then UV mapping is perfectly fine, some textures simply will be more stretched than others, it’s hard to notice in game.
Sorry yes, you probably will want to change the uv scale when using triplanar. The benefit of triplanar over UV maps would be that one side of your model will have the same pixel density as any other side, while a UV map could blow up just one face. Of course carefully crafted UV maps should be better than most triplanars.
I ran into this problem quite recently when making scalable tiles for a golf course. I wanted the texture to repeat when I made the tiles bigger, instead of stretching.
In the end, since I was only scaling the meshes at edit-time, I wrote some helper classes that could adjust the vertices and the corresponding UVs. Now, instead of scaling along a particular axis, I’m moving all the vertices on one edge of the tile, and reconstructing the mesh programmatically (via ArrayMesh and MeshDataTool).
Yes, it’s painful. Even more so when the tiles consist of multiple materials.
Triplanar is in games since forever. It’s not resource intensive. If it fits your needs - use it.
If projective mapping doesn’t suit your use cases and you want to use model’s UVs, you can model all your assets in some normalized size, scale the nodes to wanted size, deduce scaling from within the shader and let the shader scale UVs accordingly.