Rotate the UV coordinates in the shader?
Asked Answered
S

2

0

These are my coordinates in object space:

These are my coordinates of the top face in UV space:

The coordinates map from UV space to object space like this:

I would like to rotate the UV mapping clockwise like this:

At first I thought I could simply rotate the texture, but of course that doesn't work, and I'm pretty sure rotating UVs in the fragment shader is the same as rotating the texture.

Can manipulating UVs in the vertex shader achieve what I want?

Thanks!

Snubnosed answered 4/3, 2022 at 2:35 Comment(0)
A
0

Yes, using cos(ine) and sin(e), something along the lines of this:

https://godotengine.org/qa/41400/simple-texture-rotation-shader

Avidin answered 4/3, 2022 at 4:12 Comment(0)
S
0

@Megalomaniak Thanks, but I'm not sure this will work. Consider this example: Here is a texture projected onto a cube in blender using UV Project From View: Notice how the pixels are perfect squares. Now when I rotate my camera 90 degrees you can see that the pixels are distorted from the perspective changing: Even though the shape of the top face doesn't change, the pixels become distorted I believe the perspective information is encoded in the location of the UV vertices? I'd like to actually change those vertices (the perspective information)--not the actual texture. In other words I'd like to be able to get rid of the pixel distortion in the second image from the shader

Snubnosed answered 4/3, 2022 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.