Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Jon Hasselgren, posted on March 23, 2001




Image Description, by Jon Hasselgren



Some sceenshots of a dynamic light and shadows system I've been working on for some days now. The shadows are dynamic stencil buffered shadows and the system trys as much as possible to cut down the amount of shadow volume polygons generated in order to minimize fillrate dependency.

The pictures are:
Upper left - One dynamic lightsource with shadows.
Upper right - Its the same shot, but shadowing edges are outlined.
Lower left - 3 lightsources scene (R,G,B). It might be hard to see but there are really alot of faint shadows in the picture.
Lower right - The scene with lightmapping only.

It's still quite fillrate intense since the shadowing force me to do a n+2 pass rendering where n is the amount of lights. First I need to render lightmaps (This also initializes the depth buffer so you can do blending), then for every light I must render shadow volumes to the stencil buffer and then render lighting with additive blending and stencil testing. When done with all lights I render the textures with modulative blending. There are still some problems/bugs to overcome, for instance the entrance/exit of shadow volumes are bugging me. Since I actually render the shadow volumes they are also clipped to the near plane, but as you can imagine this creates somewhat weird results. It can be solved by setting the near plane to 0.01, but that breaks the Z-Buffer.

The performance is pretty ok (I think). Since my hardware sucks i sent a copy to a friend with a better computer and the one light scene run at 50-70 FPS on his machine in 800x600 resolution. The 3 lightsource scene runs at ~25 FPS on my computer in 320x240 (but my Viper550's fillrate is ~28 MPixels/s).

Well,I guess I could keep talking forever, so I better stop.


[prev]
Image of the Day Gallery
www.flipcode.com

[next]

 
Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Cromoly

March 23, 2001, 04:34 PM

Wow, very impressive! Can I try this out?

 
Saad Faisal

March 23, 2001, 05:01 PM

This is very beautiful. Do you have any plans for a demo [ with source perhaps]

 
Nexus

March 23, 2001, 05:02 PM

I hate to point this out on an otherwise very nice IOTD, but isn't the shadow of the column on the right hand side facing the wrong direction (ie towards the dynamic light), with a distinct lack of one on the other side to suggest that there's a static light somewhere behind it to explain the effect?

Gratz n a very nice shot though.

 
Brainiac

March 23, 2001, 05:11 PM

Right. I wouldn't have noticed that, but it really looks wrong. Anyway, a nice IOTD.

 
Lucid

March 23, 2001, 05:15 PM

good eye... it might just be the ground texture though... notice how if you look hard enough can make out a '?' of darkness in the floor.... obviously a ? would not be the result of an error in his calculations(hopefully not), but more likely just the fact that the texture is darker in that area... so, hopefully that is what it is...

dunno, i could be talking crap though...

 
eulogy

March 23, 2001, 05:33 PM

Nice work!
A little comment though: aren't the shadows of the columns in the lower left corner supposed to be just darker than the rest of the texture, and not colored?

 
Nexus

March 23, 2001, 06:00 PM

Question mark?? I've gone crosseyed looking at it, but I can't spot one. (I can see one when I'm looking at it crosseyed, but that's about as good as suggesting that the cloud that went by my window was really a camel). Seriously though, I think you're just seeing a darker patch in the texture.

With the coloured shadow in the bottom left picture, it may be that a blue light is in a different position, closer than the the pillars so that there's still a shadow, but it's slightly blue tinted. If you look at the blue light on the front of the steps and on the pillars themselves, I'd strongly suspect that this is the case - especially because if you look VERY carefully, you can see parts of the picture where the pillars are cutting out a tiny bit of blue light onto the green and red light. I don't see anything to suggest there's anything really wierd going on there, but there's definately something odd in those top two screens.

 
Fabian Giesen

March 23, 2001, 06:44 PM

if you look at the lower right image (the lightmapping only one),
you see that the shadow seems to be there too, i.e. it comes from the lightmap, not from a light.

an interesting visual artifact nonetheless :)

 
EGreg

March 23, 2001, 09:42 PM

I don't knwo about the direction of the shadows, but I think there's a shadow of Sherlock Holmes in the far right / top picture. See if you can find it. It's the one that looks like an &.

Happy hunting,
Greg

 
Timothy Barnes

March 23, 2001, 09:47 PM

Finally something excellent that isn't a landscape :)


Good work...I'm pretty damn impressed, and after watching pure FF9 video's my standards got high. :)

 
Lion V

March 24, 2001, 01:13 AM

Beatiful.
Soo....will it be the next quake, or what ? :-)
~V'lion

 
Timothy Barnes

March 24, 2001, 01:47 AM

Well I gotta say, it looks more eyecandish than Doom3 :)

 
STZ

March 24, 2001, 03:32 AM

Well... what an interesting thing I noticed in the picture. I see $ sign of the floor. It's partially hidden in the shadows so you need to look at the pic extremely carefully and extremely long time to clearly see it.

 
Lucid

March 24, 2001, 06:06 AM

Here's where I thought I saw a ? mark....
Look at the top right image....

 
Jon Hasselgren

March 24, 2001, 09:18 AM

Well, first thanks for all the nice feedback. I might aswell answer some posts

Nexus: As fabian said, the shadow comes from the static lightmaps. The radius of the light isn't very large so the shadow isn't fully illuminated. Generally to see wich shadows are dynamic look for sharp edges. And yes, the colored image has one green light behind the left column, one red light behind the right and one blue placed more or less between them.

Lucid: Never saw that myself :). I think the questionmark simply comes from rescaleing the image in photoshop, original resolution was 1280x960

Can't say anything certain about a demo. I'll see what i can do

 
STZ

March 24, 2001, 09:37 AM

Now I really see it..
I can assure you that nobody wanted to encrypt ? mark this way. I can see also P letter which partially consists from ? There are guite enough darker spots(maybe shadows) which can be grouped together in many ways.
And I see that those shadows aren't fully correct, as one of them facing into opposite direction than it should. SO I simply can't believe in correctness of whole picture.

 
morgan

March 24, 2001, 11:46 PM

Hi Jon,

I've been working on similar problems with stencil buffer shadows. I have a paper coming (maybe to flipcode) on the topic, but here are some notes about my experiences:

Yes, you need the near clipping plane *really* close (the alternatives are too horrible to mention). If you also move in the far clipping plane (mine is at 50 meters), this doesn't trash the z0-buffer too badly.

It is possible to determine shadow volumes very fast, especially for static geometry, since you only have to look at object edges, not triangle edges. Using clever silhouette finding algorithms, I got exact shadow volume determination down to one dot product per face and one compare per (object) edge.

When trying to determine if the camera is in a shadow volume, plucker coordinates and bounding volumes are your friends.

For one light, you can save a whole rendering pass by subtracting light from shadowed areas with a black polygon instead of adding light with subsequent passes. I think you can do the same for multiple, colored lights by alpha blending against the inverse of the light color (the order of light sources will affect the result, however, so this is questionable). If you know how to get a subtractive alpha blending, that's really what you want.

-m

 
Amythius

March 25, 2001, 08:55 PM

Magnificant! I am wondering if there is Source Code for this?

 
This thread contains 18 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.