Game Development Community

Stencil Shadows - anyone wanna help?

by Brett Fattori · in Torque Game Engine · 02/09/2004 (4:05 pm) · 9 replies

I think I'm finally at a point where I could use some help. I've about stretched myself to the extent of my knowledge. The shadows are in, they are about 90% working, and it's time. It's time for me to put out a call to anyone who's got some experience with this.

The code is pretty clear about what it does, however there's still some "required" knowledge when it comes to this. I started from square one, myself, and worked my way up to this point. I'd like to avoid having to teach someone everything I know, but I'm willing to work with someone who's got some good skills.

I started with an edge connectivity method based off of an article by Eric Lengeyl. I stuck with that for 99% of the time. Recently, I found some pseudo-code by Jason Bestimt that approaches it entirely differently. The total time to generate edge lists is fractionally longer with this other method. The big plus is that the volumes are mostly (read 99.5%) complete. The big minus is that it's including just about all the edges to create the volume. Huge bummer when your models have a bunch of faces. It's considering all of the tris in an object as potential shadow casters and throwing out ones that don't face the lightsource. It should really be working with pairs of faces and only considering a pair that contains one light-facing tri and one not.

Today, I also implemented a simpler method to render the shadows. Volumes are generated into vertex lists, so I thought it might be easier to use the method of drawing a big quad over the screen (a la damage filter) and using the stencil plane to "cut away" where the shadows aren't. All I needed to do was create a shadow renderer that runs after the scene is generated and perform this step. No problem, and a heck of a lot easier/faster than rendering the scene twice (once in shade, a second time with light only where shadows weren't).

So, getting to the point... Send me an email if you're up to this challenge. Again, I'm really looking for someone who's either had some experience with stenciled shadow volumes or can spot problems in my code and help to fix it. I'll fire off a zip file with a patch to the current HEAD, and some new files that encompass the shadow volume code. Additionally, I can provide the Stronghold mission with shadows enabled everywhere I've been able to get them running "semi-decent".

I really want to get this done for the community. I've gotten so much from everything that people have already done that I wanted something big to give back. I doubt this will be for everyone, in the end, as it can really eat up framerate. However, with the included (and planned) options, someone with creativity should be able to use it to really enhance their game project.

- Brett Fattori

#1
02/09/2004 (9:16 pm)
I'll be happy to take a look. I claim no special expertise, but I have been mucking about in the nether regions of Torque a lot lately, so I might be able to see something good. And, I'd really like to see this put back out to the community. :)

E-mail is in my profile.
#2
02/11/2004 (5:31 pm)
Thanks Ben.. I'll send along a patch shortly. I wanna try a couple of things to speed up shadowing and face/edge pairing.

- Brett
#3
02/11/2004 (5:46 pm)
I would be willing to have a trawl through the code and run some profiling test on a few of my machines, and see if i can come up with any ways to speed it up.
#4
02/15/2004 (3:22 pm)
Hmm. after trying both sets of patches (even tried patching manually just in case), i cannot get the stencil shadows to work at all, there are no compile errors, and all the options are in game (even get artifacts on skybox), but not shadows appear from the objects..
#5
02/15/2004 (6:50 pm)
Did you manage to get it working ben?
#6
02/16/2004 (3:51 am)
Khris142@yahoo.com

I'd like to help with this.
#7
03/31/2004 (11:09 am)
Has this gone anywhere? i was thinking of implimenting stencil shadows into torque..i don't wanna re invent the wheel if others are alreading working on this :)
#9
03/31/2004 (2:15 pm)
Thanx