Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
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.


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. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!