• Advertisement
Sign in to follow this  

Make spheres look smoother with GLSL

This topic is 1750 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

[sharedmedia=gallery:images:3557]

 

 

Please have a look at the attached image.  How can I make sure that my spheres look smooth using GLSL shaders?

Any tutorials, examples maybe?

 

Thanks

Share this post


Link to post
Share on other sites
Advertisement

Or simply use smooth normals. For every vertex, gather all the faces the vertex is part of and average their normals. There, you have your vertex normal.

Also, when going for a fragmet shader, I advise reading up on Phong shading. It interpolates the normals over the surface, normalizes them and uses that for other calculations. This gives smooth and pleasant shading. For comparison: http://diccan.com/Images/gouraud_phong_flat.jpg ( from left to right: flat, goaroud mentioned above, phong )

Share this post


Link to post
Share on other sites

The interpolation hardware actually guarantees that it will not stay normalized, because normalization involves a sqrt and the plot of sqrt is a curve, not a straight line.  Of course, you can use such a fine level of tesselation that the error is to all intents and purposes invisible, but that involves it's own set of tradeoffs (particularly the risk of becoming vertex-bound) so yes, renormalization and calculation of lighting in the fragment shader is the way to go.

Share this post


Link to post
Share on other sites

For a sphere you dont need fancy calculations, just take the vector from the center of the sphere to the current surface point and normalize it to get the most correct value.

Share this post


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

  • Advertisement