Jump to content

  • Log In with Google      Sign In   
  • Create Account

Make spheres look smoother with GLSL


Old topic!
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.

  • You cannot reply to this topic
5 replies to this topic

#1 Hachaso77   Members   -  Reputation: 231

Like
1Likes
Like

Posted 06 April 2013 - 07:03 PM

spheres

 

 

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



Sponsor:

#2 EddieV223   Members   -  Reputation: 1406

Like
0Likes
Like

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

http://www.youtube.com/watch?v=Wo60USYV9Ik

 

// Easy to learn 2D Game Library c++

SFML2.1 Download http://www.sfml-dev.org/download.php

SFML2.1 Tutorials http://www.sfml-dev.org/tutorials/2.1/

 

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

 


#3 TheUnnamable   Members   -  Reputation: 803

Like
0Likes
Like

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 )



#4 NightCreature83   Crossbones+   -  Reputation: 2823

Like
1Likes
Like

Posted 07 April 2013 - 08:48 AM

Any vector you pass from a vertex to a fragment shader needs to be renormalised if it was before, the interpolation hardware doesn't guarantee that it stays normalised.
Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#5 mhagain   Crossbones+   -  Reputation: 7959

Like
0Likes
Like

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.


#6 wintertime   Members   -  Reputation: 1708

Like
0Likes
Like

Posted 07 April 2013 - 10:06 AM

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.






Old topic!
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.



PARTNERS