PDA

View Full Version : How to shade a flat surface? Very Noobie



UnderWear
11-20-2002, 09:49 PM
If I have a room and a light in the center...how do I shade the walls correctly?

Do I have to compose the walls as many pieces so that there are lots of vertices? (like square jigsaw pieces)

If so, how do I easily draw a wall like this?

mikael_aronsson
11-21-2002, 01:29 AM
Hi !

You just create youir walls and define the material it should have, OpenGL will calculate the color at each pixel using a simple local lighting algorithm.

You will not get any shadows though, you have do some extra work to get that.

Also if you have large "walls" you might want to tesselate it into a higher number of triangles because that would improve lighting a bit.

So a wall could be done like:
glBegin( GL_QUADS)
glVertex...
glVertex...
glVertex...
glVertex...
glEnd()

Make sure you enable GL_LIGHTING and GL_LIGHT0 first and set the materials attributes to what you want.

Mikael