Archived

This topic is now archived and is closed to further replies.

inrecovery

How to enable smooth/flat shading.Tutorial Numbers 1/3

Recommended Posts

inrecovery    122
Hi All, I dont quite understand what exactly is meant by smooth shading. Quoting from NeHe''s tutorial #1:
quote:
The next line enables smooth shading. Smooth shading blends colors nicely across a polygon, and smoothes out lighting. I will explain smooth shading in more detail in another tutorial. glShadeModel(GL_SMOOTH); // Enables Smooth Shading
==>Use glShadeModel to enable smooth shading.Right? Quoting from NeHe''s tutorial #3:
quote:
In this tutorial I will teach you how to add 2 different types of coloring to the triangle and quad. Flat coloring will make the quad one solid color. Smooth coloring will blend the 3 colors specified at each point (vertex) of the triangle together, creating a nice blend of colors.
But, a) nowhere in the tutorial has he done anything to enable Flat Shading? b) Even if the code glShadeModel is comemnted out, the result is the same. This makes me wonder what exactly have I overlooked because I don''t quite understand the difference between smooth shading and flat shading and of how to enable them. "Recovering Thinker" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "He conquers who endures." -Persius !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Share this post


Link to post
Share on other sites
janharal    138

Flat shading is enabled by a call to.
glShadeModel(GL_FLAT);

The default shading model is GL_SMOOTH, so that is probably why
commenting out the glShadeModel(GL_SMOOTH) line does not change anything.

Shading and colouring isn''t quite the same thing, though - keep reading those tutorials and you''ll get to it.

Share this post


Link to post
Share on other sites
inrecovery    122
I take your word! But must say that NeHe probably was writing Tutorial No. 3 when he was sleeping,else I am sure taht there would have been more explanation that given there!

Hey wait: how would you explain *flat shading* for the quadilateral when in fact the default is smooth shading?

NeHe says that the quad has flat shading and the triangle has smooth shading!

Waiting for your comments!

Share this post


Link to post
Share on other sites
janharal    138

Hi again - sorry about the delay..

As I said there is a difference between colouring and shading:

The only difference between the two objects in lesson 2 is that
the triangle is assign one colour for each vertex, while all vertices in the quad are given the same colour. This is just
colouring.

In order to use shading you have to set up at least one lightsource and define normals for all vertices - so it is a bit more complicated than colouring. I think shading is first discussed in lesson 7.

Share this post


Link to post
Share on other sites