# Thread: Interpolation (Gouraud)

1. ## Interpolation (Gouraud)

I use the Gouraud system for rendering light to my 3d set and the result is very poor. I think my normals are not correct. I see light on my polygons randomly. If i have a polygon on the (x,z) plane and i specify its normal like this glNormal3d(0.0,1.0,0.0) the reflection is perfect i have no problem so my light is ok but when i use the Gouraud system for more complex polygons i can't get the good effect. Here is an exemple of what i do.

glBegin(GL_POLYGON);
glColor3d(bla,bla,bla);
glNormal3d(x,y,z);
glVertex3d(x,y,z);
glNormal3d(x2,y2,z2);
glVertex3d(x2,y2,z2);
glNormal3d(x3,y3,z3);
glVertex3d(x3,y3,z3);
.
.
.
glEnd();

I would like to know if i have to put negatives attributes to normal ex: (glNormal3d(x1,-y1,z1) depending on the side of the polygon i want to see and know what's wrong with my code. Thanks

2. ## Re: Interpolation (Gouraud)

i don't know what you want to render, but in the example i see you pass polygon vertices as normals... this way your normals won't be of unit length.

use glEnable(GL_NORMALIZE);
this will normalize any normal vector to unit length, so lighting will be good.

ps: if you've enabled lighting, a color directly specified with glColor() will be discarded, unless you've done a glEnable(GL_COLOR_MATERIAL)

Dolo/\/\ightY

3. ## Re: Interpolation (Gouraud)

Yeah i know what you are telling me but i think you don't know th Gouraud interpolation system (and thats better cuz i thinks it suck hehe). I need to know my problem on this topic cause i don't want to calculate all my normal (i missed time).

4. ## Re: Interpolation (Gouraud)

I forgot the glcolor is to be replaced with setmaterial sorry!

5. ## Re: Interpolation (Gouraud)

Maybe i don't understand something, but why do u give the same argument to glNormal and glVertex ? (glNormal3d (x, y, z);
glVertex3d (x, y, z)

If it works, i will se it, but i don't think so ?

Why don't u calculate your owns normals ?

I do like that:
For each face i calculate the face normal (from the 3 points the face have)

then for each points of the 3d object, i calculate the average of the face normals which contains this point

and this is the normals of each point i give to glnormal3d

bye

6. ## Re: Interpolation (Gouraud)

gouraud system works by linear interpolation of intensities across scanlines.
if you wish to use gouraud, wich opengl uses by default, you need to specify a color for every vertex.
if you don't use lighting.

instead, if you use lighting, then you have to specify a normal.
opengl will then apply lighting to the normal, and will find color components that then will be fed to the rasterizer.
loosely speaking.

if you specify a normal equal to the vertex, and you're rendering a triangle, the normal probably won't be perpendicular to the surface.
this way, you'll get wrong lighting.

there are cases where a normal IS equal to the vertex wich it belongs, like with unit spheres.

are you rendering planets or something like that?

however, when developing/debugging, to activate normalization could be helpful.
also is very useful to understand how T&L works, by reading the redbook.

about normal evaluation, you could precalculate them if the geometry is static, and store them into a database.

Dolo/\/\ightY

[This message has been edited by dmy (edited 03-21-2000).]

7. ## Re: Interpolation (Gouraud)

Finaly i left the Gouraud interpolation and i've made my own fonction to calculate normals and my x-wing (because stars wars is the subject of this lab in an infography course) look good now. Some of my friends use Gouraud. 50% works and the other 50% doesn't work. The professor could not explain us very well why it doesnt work for everybody so i use my own method and it's better now. So thanks you all for the reply!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•