i dont post on forums, but i got quite a bit of help from here just by reading past mails... to cut it short, i implemented shadow mapping combined with optional projective textures like spotlight circle or other image for projector effect, also i combined light depth texture with fog rendered light view...
[just quick tip: you dont need depth texture to achieve shadow mapping, if you render image with linear glFog u get the same values(distance from light) in your image]
... anyway, here is demo featuring 4 dynamic lights+flashlight, they have nice fade-out in distance effect..
no pixel or vertex shader!
uses:
ARB multitextures
FBO for off-screen rendering
VBO(vertex arrays) to hold scene mesh, actually in this version it is compiled in display list for +10fps boost
its not optimised, it doesnt cool scene for any light
by the way scene contains 32x32 quads + 1 to 4 quads for sides where there is en elevation like steps or those other boxes(walls)
so scene is rendered 10 times each frame with flashlight on,
5 times from each lights view and 5 times to add/blend light to scene
shadow textures are 1024x1024, flashlight with short frustum can be as small as 128x128
PCF is OFF as it produces white anomalies when transiting to black in combination with fog texture, i dont really care if my blocky shadow is made out of round blocks instead of square ones, i want to keep resolution high so there are no blocks...
every frame:
//collect lights views
bind FBO
for all lights:
bind lightN.depth texture to FBO
bind lightN.rgb texture to FBO (rendered black/white with glFog to fade out distance later)
-render scene
bind FBO, 0
//blend lights to scene
for all lights:
set 3 multitexture stages
0-depth/compare_to_r
1-fog/blend
2-circle/blend
-render scene
end frame
here is a download link with source code:
http://one.xthost.in...lko/opengl.html

if your configuration cant push 60fps some bugs will happen with flash light depending if your vsync is on or off, flashlight in this demo is just a quick hack and is the same as other lights, for proper flashlight effects there needs to be added some illumination around from reflected light not just where beam is... that stuff will come later
on my 1GHz AMD + GeForce7300GT i get from 70-140FPS
however executables in download might be locked to 60fps, so you can change source code or if anyone is interested at all i can clean up source code or add option to better measure performance.....
the whole idea is to implement FLEXIBLE shadow class that can dynamically fit into any scene, also it should be easy to use, here is how it looks in my demo:
collect light views...
FRUSTUM::beginGetShadowPass();
for(counter=0;counter<lightsNum;counter++){
light[counter].getShadow();
drawStatic();
drawDynamic(false);
}
FRUSTUM::endGetShadowPass();
and blend light views with scene...
FRUSTUM::beginBlendShadowPass();
for(int counter=0;counter<lightsNum;counter++){
light[counter].blendShadow();
drawStatic();
drawDynamic(false);
}
FRUSTUM::endBlendShadowPass();
so, to finish my thought from the beginning, to return something back for all the wisdom i got from internet.... heres this little demo and if you like it and wanna implement some of the stuff, feel free to ask... zelco@xtra.co.nz
or if it can be done better, please advise
cheers











