Archived

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

Gammastrahler

sucking spotlights!

Recommended Posts

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
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
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
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
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