# How to go about rotating an Axis in GLSL

This topic is 4897 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. :)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634091
• Total Posts
3015435
×