Im trying to make a lit room.
The camera is inside ans there should be coming a light from the ceiling.
im doing the following:
enable lighting
enable light0
position the light
set diffuse light to 1, 1, 1
set light model to local point light
draw the cube with normals pointing to the inside and draw the verteces clockwise so that the front faces will be inside
Ok, the cube is lit from the inside now, but the onlything i see is a white screen now, all 6 polygons have the same color!
I want the floor to look darker than the ceiling, becuz the light comes from the ceiling.
glEnable(GL_COLOR_MATERIAL);// Without everything will be white.
Originally posted by xillie:
[b]Im trying to make a lit room.
The camera is inside ans there should be coming a light from the ceiling.
im doing the following:
enable lighting
enable light0
position the light
set diffuse light to 1, 1, 1
set light model to local point light
draw the cube with normals pointing to the inside and draw the verteces clockwise so that the front faces will be inside
Ok, the cube is lit from the inside now, but the onlything i see is a white screen now, all 6 polygons have the same color!
I want the floor to look darker than the ceiling, becuz the light comes from the ceiling.
For your ceiling you could make a sphere your light source by using the material option of GL_EMISSION.
As for the other lighting issue’s, there is a trick to doing what you ask. Opengl lights everything the same even if the light is block by another object. You have to create you own shadows using the stencil buffer. go to nehe.gamedev.net and look at the shadow tutor.
Originally posted by xill:
[b]yes i did, but i dont think it has anything to do with it…
what i want is see a nice circle of light on teh ceiling which grows darker…
there are no objects in the way )
all i want is that the further a pixel is the darker it is, you can see that nicely in a sphere but i cant do it on a cube, even if i devide it into 6*16 polygons theyre all lit the same
Even with attenuation set correctly you probably won’t get the effect you’re looking for. OpenGL only calculates lighting at each vertex and then interpolates per pixel. With a cube, any higlights that don’t fall on a vertex will be lost since OpenGL only samples at vertices. To solve this, tesselate the cube into more triangles or use a different lighting technique, e.g. lightmaps or per pixel lighting. Check out pifall #2here . Lightmapping is explained in the FAQ.
Its not per pixel lighting that i want, all i ask is that each vertex is calculated…
but now, the color from one vertex of the floor is not the same as the same point of the wall… all pixels in the polygons are the same color, and i DID enable GL_POLYGON_SMOOTH
Originally posted by xillie: Ok, the cube is lit from the inside now, but the onlything i see is a white screen now, all 6 polygons have the same color!
I want the floor to look darker than the ceiling, becuz the light comes from the ceiling.
Remember to make your normals unit length (i.e. Normalised). Otherwise your light might be oversaturated. Or your light might be too bright for your scene. Try cutting your light intensity and see if it makes a difference.
Also, though unlikely, check if you had entered any state that treats lighting differently, like texture mapping.
[This message has been edited by Furrage (edited 05-02-2002).]
i know now, i was wrong on the vertex normals! i thought all vertices of the quad had the same normals so i used the same normals for each of them, but i have to calculate the normals out of 3 other normals