stencil terror

ok i guess this is actually pretty simple. i use stencil shadow volumes to simulate shadows. now i want to exclude some geometry from receiving shadows (muzzle flashes, laser beams etc)

my question is: how can i write values to the stencil buffer no matter what values where there before?

i try to render my models which should be excluded from shadows right after i rendered the silhouettes of the shadow casters into the stencil buffer, but there are always artifacts :stuck_out_tongue:

Draw all that stuff last after everything, whether you draw shadow passes or light passes, once you’re done draw the muzzle flashes, explosions, lasers, etc. with no stencil tests. You should still enable depth testing of course.

that’s what i’ve done so far. the problem is: i’m rendering multiple passes, one for every light source, and then blend them all together. so the lighting isn’t correct for geometry which is drawn after.

EDIT: argh i’m an idiot… instead of rendering all the shadows and then all the models to the stencil buffer, i rendered a group’s shadow, then the group, etc… -.- sometimes i really think i should get another hobby.