Topic was automatically imported from the old Question2Answer platform.
Asked By
pox
Im trying to make a “simple” shader that tiles and rotates a texture atlas ramdomly to avoid visual repetition, it works fine when used in a normal material, but when I try to implement it on a world triplanar I can’t get the uv’s to rotate on their own position instead of the world origin so the overall texture gets a little skewed.
(the rest of the shader is just a normal converted spatial material)
normal texture
randomly rotated by 90 (some lines are bigger or misaligned)
randomly rotated by 95 (the crosses aren’t centered)
rotated normally by 100
This is what I want:
I googled and tried all similar questions on here (I think I should use this somehow) and even on the unity forums but I just distort the texture beyond recognition. Any help?
While we usually use the ones stored in the mesh UV channels it can
also be useful to use the World space Position of the fragment/pixel
instead, especially if there aren’t any UV coordinates available.
You have mesh UVs use it.
With 99.9% probability your shader will not be portable between GLES2, GLES3, Vulcan backend if you use this method.
No, I already have triplanar working, I used the one that godot already has (see my last picture), but I want the rotation to not be triplanar, only the position and scale. I want each “tile” of the texture to rotate individualy. I think I have to find the current “tile” position and offset the world origin to it, but I don’t know how.
It’s hard to show on pictures but if you use the rotateUV function you can see that everything rotates around a single point in the world
I don’t think I can use the mesh uv’s, you use the world as uv in triplanar
Let’s hope they are right I’m not doing 3d in godot.
yrtv | 2021-02-05 21:48
Already tried that one a bunch of times, doesn’t work
pox | 2021-02-05 22:33
Let’s take one step back. Why do you want to use World tri-planar (one shared UV for all meshes using same shader material. UV coordinates is just world x,y,z coordinates) instead of local tri-planar (just generates UV for mesh without UV information. You may need to normalize UVs in some engines. I do not know about godot.). You will not need to search for individual tiles in generated global UV with local tri-planar.
yrtv | 2021-02-06 13:53
Cause it’s for a random tile shader, I want to use it on large terrains (heightmaps) or meshes (CGS) that wont have proper UV to break repetition