glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
GLfloat spotdir[3] = {0, -1, 0};
GLfloat pos[4] = {0, 100, 0, 1.0};
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotdir);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 45);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 20);
i have tried dozens of different values for the cutoff angle and spot exponent, but nothing changed.
anyone an idea?
Edited by - gammastrahler on February 6, 2002 2:31:33 PM
sucking spotlights!
i have trouble with opengl spotlights. i have read many tutorials about it, i copied code examples, but they don´t work!
I''m not sure that spotdir[3] = {0, -1, 0}; is a good value...
Try that spotdir[3] = {0, -1, -10};
Try that spotdir[3] = {0, -1, -10};
no, the spot dir is a unit vector and needs in the range -1..1
i´m wondering about i tried about 50 different cutoff and exponent values but the light cone never changes....
what the hell is going on?
i´m wondering about i tried about 50 different cutoff and exponent values but the light cone never changes....
what the hell is going on?
You are shining the light cone onto a vertex. Lighting in OpenGl is done at the vertices - so if your spotlight cone doesn''t intersect any vertices they it''ll look like no light is on.
Chris
Chris
really stupid question (not trying to insult you), but is your geometry tesselated enough to show these changes?
it may just be that there aren''t enough vertices to accurately show the different cut-offs... but then, you would expect a big difference between something like 5 degrees and 45 degrees wouldn''t you??
it may just be that there aren''t enough vertices to accurately show the different cut-offs... but then, you would expect a big difference between something like 5 degrees and 45 degrees wouldn''t you??
i actually use simple geometry (quads for walls, etc).
i´m wondering how lighting is done in unreal (rooms are also build from simple quads).
i´m wondering how lighting is done in unreal (rooms are also build from simple quads).
quote:Original post by GammastrahlerThat''s why your spotlight won''t show up. Check out item 2 in this article.
i actually use simple geometry (quads for walls, etc).
quote:Original post by GammastrahlerLightmapping. That''s really the best way to handle spotlights.
i´m wondering how lighting is done in unreal (rooms are also build from simple quads).
In Unreal, they take a huge triangle and tesselate into a load of really small triangles. This way, there are loads of vertices to perform lighting calculations on, and you get a nice spotlighted surface.
Don''t worry. This got me for a while. Try and write some algorithms that tesselate large triangles into smaller ones...
iNsAn1tY - the place where imagination and the real world merge...
Try http://uk.geocities.com/mentalmantle - Now updated!
Don''t worry. This got me for a while. Try and write some algorithms that tesselate large triangles into smaller ones...
iNsAn1tY - the place where imagination and the real world merge...
Try http://uk.geocities.com/mentalmantle - Now updated!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement