This is a continuation of a recent post that @DamianJ helped me with.
This geo-node cuboid works with a shader. It let’s you choose (per X, Y, Z faces) the tile (from a texture) by a row and column number.
The problem is that the uv rotation of the faces is different when the cuboid has differing sizes. See the tile with a ‘3’ on it being all over the place.
Anyone know what could go in the red frame area to compensate? Or is this a problem to fix in the shader?
The file is here (no python): https://codeberg.org/dbat/level-design-tools/media/branch/main/uv_rotation_mystery.blend
Thank you!
The 1st face-corner’s UV subtracted by the face’s UV gives your your quadrant… you can use the sign and arctan2 functions to extract the quadrant angle (which will be -135° ,-45° ,45° or 135°), to which you add some multiple of π/4 to correct for your UV’s tilt. It was +π/4 for me, could be -π/4 for you.
You can only evaluate this angle after the UV unwrapping has happened already.
I think you’re very brave to use the UV Unwrap node. I generally make my own UVs and if I need to, Pack UV Islands instead.
Good luck.
Thanks for your reply. I’m not quite sure how to make use of that graph. Is it a geo-nodes or a shader graph?
If geo nodes, the left side takes a UVMap, which in my case I don’t yet have. My uv_unwrapper node group is where the UV Unwrap node is, do I substitute that for the Named Attribute in your screenshot?
Sorry! I can be a bit dense 
Its a GN Node-Group.
As stipulated in my 1st post, this has to come after UV Unwrap. This is why I think you’re brave. There appears to be no rhyme or reason to how UV Unwrap rotates faces… hence why the correction can only happen AFTER the UV Unwrap node. You can have groups inside groups.
I used it something like this:
Good luck.
Thanks again. I got it going. Yeah, it’s soooo close, but as you said, there are weird cases where I have to do a different pi division.
I don’t pretend to understand your nodes, to me they’re sheer magic. Thanks for your help!