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?
Jump to content
GameDev.net Posting Guidelines (please read before posting)
For Beginners Forum FAQs (please read before posting)
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 06 April 2013 - 07:40 PM
Use the fragment shader to calculate per pixel shading.
If this post or signature was helpful and/or constructive please give rep.
// C++ Video tutorials
// Easy to learn 2D Game Library c++
SFML2.2 Download http://www.sfml-dev.org/download.php
SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/
// Excellent 2d physics library Box2D
// SFML 2 book
Posted 06 April 2013 - 07:51 PM
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 )
Posted 07 April 2013 - 08:48 AM
Posted 07 April 2013 - 09:48 AM
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.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.