# How to go about rotating an Axis in GLSL

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What would be the correct way to rotate an axis in GLSL? All I can come up with is
vec4 pos = gl_Vertex;
pos.y = sin();


Something to that effect? I am trying to rotate a earth sphere in a circle or I should say spinning around on a point... Thanks

##### Share on other sites
bump, I am trying to do a glRotatef() but in a vertex shader...

##### Share on other sites
You _can_ construct the rotation matrix in a vertex shader. Look at the specific math in the Matrix and Quaternion FAQ for example. However, that would be a pointless waste of shader cycles, because you'd do that once for each vertex (assuming you want all of earth to have the same rotation, of course :-)

Instead, you could calculate the appropriate matrix on the CPU and send it to the program as a matrix constant. That'd be a lot more efficient.

##### Share on other sites
Quote:
 Original post by hplus0603You _can_ construct the rotation matrix in a vertex shader. Look at the specific math in the Matrix and Quaternion FAQ for example. However, that would be a pointless waste of shader cycles, because you'd do that once for each vertex (assuming you want all of earth to have the same rotation, of course :-)Instead, you could calculate the appropriate matrix on the CPU and send it to the program as a matrix constant. That'd be a lot more efficient.

Ok, thanks. I will just use glRotatef(), as of now I am using render monkey to model the shader. Would have been nice to watch it rotate to see how it looks. :)

1. 1
Rutin
48
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011717
• ### Who's Online (See full list)

There are no registered users currently online

×