Archived

This topic is now archived and is closed to further replies.

Gammastrahler

sucking spotlights!

Recommended Posts

Gammastrahler    150
i have trouble with opengl spotlights. i have read many tutorials about it, i copied code examples, but they don´t work!
    
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

Share this post


Link to post
Share on other sites
Gammastrahler    150
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?

Share this post


Link to post
Share on other sites
chrisflatley    122
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

Share this post


Link to post
Share on other sites
Bad Monkey    145
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??

Share this post


Link to post
Share on other sites
Myopic Rhino    2317
quote:
Original post by Gammastrahler
i actually use simple geometry (quads for walls, etc).

That''s why your spotlight won''t show up. Check out item 2 in this article.
quote:
Original post by Gammastrahler
i´m wondering how lighting is done in unreal (rooms are also build from simple quads).
Lightmapping. That''s really the best way to handle spotlights.

Share this post


Link to post
Share on other sites
iNsAn1tY    476
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!

Share this post


Link to post
Share on other sites
Gammastrahler    150
thanks for the replies! but high tesselation means performance cuts... i think dynamic lightmapping would be the choice for me. does anyone know about good tutorials about this?

thanks gammastrahler

Share this post


Link to post
Share on other sites
Lukerd    122
Theres an example with source here.

And there is a tutorial here.

"To err is human, to really mess up requires a computer"

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. "
- Albert Einstein


Edited by - Lukerd on February 7, 2002 4:54:13 AM

Share this post


Link to post
Share on other sites