Lighting the insie of a cube
Im trying to make a lit room.
The camera is inside ans there should be comming 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.
oim very sure the light posision is correct..
i hope you can help me
(btw with a sphere this works fine!)
thx
-xill
I believe you're looking for light attenuation, which makes the light fade with distance. Place the light source closer to the ceiling.
Maybe it "works" with a sphere because the many polygons show off how the light hits at varying angles? Just a guess.
[edited by - Waverider on April 30, 2002 11:59:27 AM]
Maybe it "works" with a sphere because the many polygons show off how the light hits at varying angles? Just a guess.
[edited by - Waverider on April 30, 2002 11:59:27 AM]
It's not what you're taught, it's what you learn.
isnt that normal in a light??
i mean, if light doesnt fade in distance what does the position matter??? then it can be everywhere in the room...
how can i turn attenuation on?
like..
glLightfv(GL_LIGHT0, GL_*_ATTENUATION, x); ???
and what should be best for * and x??
-xill
i mean, if light doesnt fade in distance what does the position matter??? then it can be everywhere in the room...
how can i turn attenuation on?
like..
glLightfv(GL_LIGHT0, GL_*_ATTENUATION, x); ???
and what should be best for * and x??
-xill
nothing is normal for a light in computergrafics, cause simulating correct lighting is _FAR_ from beeing in realtime..
what gl does is:
ambient + diffuse + specular
where you can set colors for those..
diffuse is what you''re using and is calculated with the cosine of the angle to the light and the surfacenormal, as well as the distance-attentuation. the distance-attentuation-function is att = 1/(a+bx+cx^2) where you have to set the parameters..
and, most important: remember its only calculated per vertex.. in your geometrical case you will get the worst artefacts if you don''t tesselate your cube to some higher res.
guess you should read some docs about how lighting is done in gl, and play around for a while, it should clarify a lot..
don''t ask too much from the gl-lights, they are old and crap, but they work on every implementations, wich is the "power" of them.. (they look damn cool for highres-meshes like on sgi-workstations btw..
have seen it one time.. wow...)
"take a look around" - limp bizkit
www.google.com
what gl does is:
ambient + diffuse + specular
where you can set colors for those..
diffuse is what you''re using and is calculated with the cosine of the angle to the light and the surfacenormal, as well as the distance-attentuation. the distance-attentuation-function is att = 1/(a+bx+cx^2) where you have to set the parameters..
and, most important: remember its only calculated per vertex.. in your geometrical case you will get the worst artefacts if you don''t tesselate your cube to some higher res.
guess you should read some docs about how lighting is done in gl, and play around for a while, it should clarify a lot..
don''t ask too much from the gl-lights, they are old and crap, but they work on every implementations, wich is the "power" of them.. (they look damn cool for highres-meshes like on sgi-workstations btw..

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
so youre saying that all pixels must have the same color in 1 polygon? i dont believe that..
btw.. i didnt see any difference when i made my cube of 6*16 polygons :/
btw.. i didnt see any difference when i made my cube of 6*16 polygons :/
So what do i have to do to make the light realistic in that cube? thats the most simple light i can think of, shouldnt be too hard right?
In the game engines of today it looks pretty cool and i still have alot FPS
In the game engines of today it looks pretty cool and i still have alot FPS
THIS is what i had in mind
http://developer.nvidia.com/view.asp?IO=pp_attenuation_ogl
only then, a stationary ligth source
\o/

http://developer.nvidia.com/view.asp?IO=pp_attenuation_ogl
only then, a stationary ligth source

\o/
for gl, nothing is stationary as gl does not know any scene..
but this is perpixellighting you look at (more precious, pertexel lighting) and like that independend of vertice-count
if you simply enable GL_LIGHTING you get the standart lighting of opengl, wich is pervertexlighting, wich only calculates one lighting-value per vertex (means 3 per triangle and then linear interpolated like colors)
"take a look around" - limp bizkit
www.google.com
but this is perpixellighting you look at (more precious, pertexel lighting) and like that independend of vertice-count
if you simply enable GL_LIGHTING you get the standart lighting of opengl, wich is pervertexlighting, wich only calculates one lighting-value per vertex (means 3 per triangle and then linear interpolated like colors)
"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
yeah i know all that, i read te theory 100x now....
but i DONT see any difference between ANY vertex in my quads..
EVERY pixel in my quad has the same color.
I dont really want per pixel lightning but i want it to look like when you assign 3 different colors to the verices but then with different light values...
what ever i do with GL_*_ATTENUATION, i dont see anything happening...
i saw what i want just done with the standard opengl light
hel me
but i DONT see any difference between ANY vertex in my quads..
EVERY pixel in my quad has the same color.
I dont really want per pixel lightning but i want it to look like when you assign 3 different colors to the verices but then with different light values...
what ever i do with GL_*_ATTENUATION, i dont see anything happening...
i saw what i want just done with the standard opengl light
hel me

Okay, a stupid question first: Did you enable GL_POLYGON_SMOOTH?
probabely since it all goes well with a sphere.
I think the problem is that the light position is in such a way that values from the normals calculated by the light are somehow all the same. Try placing the light in one of the corners instead of the center of the roof (is it in the center now)? Are all your normals correct? (eg normalized and all?) Is your diffuse light set too high (this can cause every polygon to be full bright)? Do you use one normal per poly or one normal per veretx? (try one normal per vertex if possible).
If you have some spare time, look through the OpelGL docs and find out exactly how OGL calculates light based on the normals. Calculate them by hand to find a light position that *must* result in different colors on each vertex. Insert it and try to experiment with all the other settings.
My two (euro) cents
- An eye for an eye will make the world go blind -
probabely since it all goes well with a sphere.
I think the problem is that the light position is in such a way that values from the normals calculated by the light are somehow all the same. Try placing the light in one of the corners instead of the center of the roof (is it in the center now)? Are all your normals correct? (eg normalized and all?) Is your diffuse light set too high (this can cause every polygon to be full bright)? Do you use one normal per poly or one normal per veretx? (try one normal per vertex if possible).
If you have some spare time, look through the OpelGL docs and find out exactly how OGL calculates light based on the normals. Calculate them by hand to find a light position that *must* result in different colors on each vertex. Insert it and try to experiment with all the other settings.
My two (euro) cents
- An eye for an eye will make the world go blind -
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement