Sign in to follow this  
BroderickCalpe

Make spheres look smoother with GLSL

Recommended Posts

BroderickCalpe    231
[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
TheUnnamable    1129

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
mhagain    13430

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this