Advertisement

what kind of shadowing and lighting???

Started by July 10, 2003 08:23 PM
5 comments, last by yodaman 21 years, 7 months ago
Hiya I was wanting to know a few things about shadowing and lighting. For one thing, can you use shadow volumes for EVERY object in a world or should you use shadowmaps for say static objects and volumetric for dynamic? vertex lighting... I want to use vertex lighting for dynamic objects, would any one recommend me using OpenGL''s lighting for that? and if so, how can you make GL''s lighting view independent? projectors: what are they? I think there used for volumes around lights...? And also, whats the best method (real time) for lighting static objects (that are probably not very high in poly count)??? (perpixel, lightmapping etc?) Thanks a TON to anyone who replys, im stuck ~yodaman
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
quote:

I was wanting to know a few things about shadowing and lighting.
For one thing, can you use shadow volumes for EVERY object in a world or should you use shadowmaps for say static objects and volumetric for dynamic?



You could do that, it would be a big waste of resources though.You could use shadowvolums for dynamic objects and static objects close to these (since they might cast shadows unto dynamic ones), and use shadowmaps for everything else for performance reasons. This could be a good tradeoff between realism and speed. Also, you might want to switch of shadowvolumes for dynamic objects the player can''t see, or that are far enough away so that the shadow will not be noticed.

quote:

vertex lighting... I want to use vertex lighting for dynamic objects, would any one recommend me using OpenGL''s lighting for that? and if so, how can you make GL''s lighting view independent?


I don''t quite understand your question. Lighting depends on the position of the light relative to the object, and not on the position of the spectator. Vertex lighting ain''t bad, if your objects are tesselated enough, otherwise you might be seeing some artifacts.

quote:

projectors: what are they? I think there used for volumes around lights...?


I think (don''t quote me on that), that projectors are some kind of texture projections used in compination with lights. If you turn these one in UT2k3 you get to see ''animated shadows'' on the floors etc. Those are not shadowvolumes, but animated textures superimposed over the geometry.

quote:

And also, whats the best method (real time) for lighting static objects (that are probably not very high in poly count)???
(perpixel, lightmapping etc?)


Usually lightmapping should be best for static geometry (fastet at least). The lighting won''t change, so you can very well use precalculated textures. In compination with the shadowvolumes this should look pretty good. If the lighting does change lightly (lights going on and off) you could use animated textures. In combination with the shadowvolumes it should be looking pretty nifty.
How do I set my laser printer on stun?
Advertisement
Thanks alot for your reply!

I dont know how todo shadow mapping, can''t seem to find a good tut on it, do you know any?

What I ment by GL''s lighting being view dependent was that when you move the camera, the lights position seems to move with you.
How can I stop that? I already tried push/pop matrix, didnt work.

thanks again and cheers!

~yodaman
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
quote:

I dont know how todo shadow mapping, can't seem to find a good tut on it, do you know any?


'Google: shadow mapping'. First few links are to the nVidia developer pages + a few more to other sites. Don't know if the links are any good though.

quote:

What I ment by GL's lighting being view dependent was that when you move the camera, the lights position seems to move with you.
How can I stop that? I already tried push/pop matrix, didnt work.


Aye, that problem does seem familiar. Here's how I basically do it:
Scene::mainloop{  glClear(...);               // clear the screen (if needed)  glLoadIdentity();           // reset transformation matrix  camera.insert();            // gluLookAt or similar.  while(light.next())         // for all lights    light.object().insert();  // insert lights into scene  glEnable(GL_LIGHTING);  while(mesh.next())          // for all objects    mesh.object().insert();   // insert object into scene  glDisable(GL_LIGHTING);}Light::insert{  glPushMatrix();  {    // Translate the transformation matrix (glTranslate should to too    glMultMatrixf((light.center()+light.offset()).matrix());    // Set the light at position 0,0,0,1 of the new matrix    //light.position := float position[4]={0,0,0,1}    glLightfv(GL_LIGHTx,GL_POSITION,light.position);   }  glPopMatrix();}Mesh::insert{  glPushMatrix();  {    // Translate/Rotate the transformation matrix (glTranslate should to too    glMultMatrixf((entity.center+offset()).matrix());    glMultMatrixf(entity.rotation);    glCallList(meshlist);  }  glPopMatrix();}


This should do the trick. I hope it's not too confusing, I've tried to leave out all the complicated stuff.

If you wonder about the light.position: (OpenGL works in 4D!)
0,0,0,1 is for positional lights
0,0,0,0 is for directional lights

[edited by - Wildfire on July 11, 2003 2:35:23 PM]
How do I set my laser printer on stun?
Sweet thanks alot wildfire!!!
you not only answered my question but sparked an idea as well

Do any commerical games or Have any commercial games ever used OpenGL''s lighting?

Oh, have you ever read the book Design Patterns? I was thinking of buying it, this guy that works at a small local game development place told me about it...

g2g thanks alot!

-yodaman
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
So....when are we going to see some screenshots, Yoda??
Advertisement
Im not sure yet. Im still working on a lot of the base code still, well including physics routines, but I actually plan on making the Rasterizer last (just to not follow the crowd )

Im going to make a web sight in a few weeks or so, so any sreen shots/demos/code etc, Ill post on it.

I got something in mind that ill post though (well, after I code it again, lol). I made a demo (but deleted it) of my terrain shadowing/lighting method, look pretty cool! Emboss bump mapped terrain

Cheers
~yodaman
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org

This topic is closed to new replies.

Advertisement