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

Submitted by Tim C. Schröder, posted on May 29, 2001

Image Description, by Tim C. Schröder

This is a picture of a research project I have done in my spare time here at Crytek. I got interested in doing some Direct3D stuff, and inspired by Doom3 my work had to be about lights and shadows. This demo uses per-pixel attenuation for the lighting, thanks to Ron Frazier for is awesome tutorial. Unlike him, I do the setup for the PPA inside a vertex shader, only 9 instructions. The shadows are implemented with shadow volumes. Take a look at nVidias developer site and head for the whitepaper of Mark J. Kilgard if you want to learn more about this. The shots were taken on my slower home system, GeForce 256 DDR + Athlon 700. Still runs pretty fast with 75 - 125FPS. I hope you like it, maybe you have some suggestions for a better lighting / shadow implementation, I would love to try them out...


Image of the Day Gallery


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.

May 30, 2001, 01:04 PM

You have to see it from my point of view ;-) I have my GeForce since Nov 99, and for me it's already pretty outdated, not a future target ;-)

Well, the framerate does not drop much when the polygoncount increases. Also, texturing is implemented and no problem. I just disabled it because you can see the lighting much much better and the test scene was trown together by myself without any special pretty artwork ;-)

The main bottleneck of the algorithm is the fillrate impact that drawing of the shadow volumes cause. And this impact will not increase much with the complexity of the geometrie, because the volume size / area won't increase much.



May 30, 2001, 01:11 PM

Well, if you say so. But if you look at the Bottom Right or Top Left images, you can see that they do not "look" correct, even if they are physically correct for you models. The sphere should have a shadow that shapes to the sphere, not looking like a jagged edge. It's probably just the shad of the "sphere" since it's not really round, it gets shadowed correctly, just doesn't look quite right. I dunno, but it's still a really nice IOTD, and in a game or rolling demo, it wouldn't be noticeable, a matter of fact, that would look really nice. Are you going to give out a demo, or add texture mapping to this? Would love to see a rolling demo though.

Frans Bouma

May 30, 2001, 01:17 PM

For complex objects it's indeed a bit slow perhaps, especially the edge projection. THis idea is in my mind for a long time now but never had the time to code it out completely, so it might be too slow to do in real time, but you never know. TOday games already use projected edgemaps to add shadows to the scene, but these are all hard edged. Doing the same projections 4 times adds already softshadows WITH depthrange to the scene using htis technique. if hard edged shadows can be done in real time (lots of games proof that), soft shadows using 4 times the projections could perhaps also be done in real time, but again... only a real implementation proofs it :) (I hope to find some time this summer to implement it, but tcs can perhaps add it to his code without too much effort, dunno :))


May 30, 2001, 01:31 PM

lol, what spehere ? There is no sphere in the picture, it's just a bunch of triangles that approximate the shape of a sphere. The shadowing object is not round, so why should it cast the shadow of a round object ? Make a round object, and you'll get a round shadow ;-)

It has texture mapping, but I know that most people here are more interested in the lighting algorithm than in seeing textures polys ;-) So I disabled decal textures. Actually this is a self made room and just some Q3 textures are attached. So it does not really look cool ;-)

I'm not giving out any source / demo now, maybe I later get the chance. I'm working for Crytek, and throwing out source while working on a commercial project could raise an interest conflict...



May 30, 2001, 01:33 PM

At the moment I just draw one quad, so I don't see how I could use goroud interpolation. The point is that I don't do edge projection, I use shadow volumes and I don't have any geometrical information about my shadows...



May 30, 2001, 01:47 PM

The shitty thing with these kind of object-precision algorithms is that 1. They require CPU intervenence (which you really want to try to prevent these days). 2. The scale with complexity of shadow blockers (and with increased polygoncount, this means even more calculations on the CPU, even if you'd dynamically scale down the mesh).

I believe that image-precision methods are the way to go. Memory's getting cheaper and cheaper and soon we will be seeing multiple temporary buffers on the card which can do stuff like that. ie, let the card render shadow blockers into a 1Kx1K shadow map then do depth-shadow mapping on the card. This puts much burden off of the CPU (ie, it doesn't have to touch the vertex-buffers at all. It just fires the command to the GPU).


May 30, 2001, 01:52 PM

Not to mention the fact that soon enough we will be seeing displacement mapping, and there's no sane way of doing object-precision shadow generation on the CPU with that. Not to mention that image-precision schemes are so much more convenient to generate shadows for higher-order surfaces, or subdiv. surfaces.


May 30, 2001, 02:22 PM

I can understand source code, obviously working for a Game Progarmming company and releasing source code to anything that you are working on (even if it's not for any specific game) is not looked upon very nicely. I misspelled shaped, and wrote shad instead, opps. I meant to say that the shape of the "shpere" was getting shadowed correctly, but it didn't quite look like a real sphere. The object looks like a sphere (enough triangles), but when it gets shadowed, you can see where it isn't. Maybe it'd be best to avoid rounded objects, or if you even get soft shadowing integrated it would look better with them. I really like everything else in the pictures though, looks pretty realistic. If you can't give out a demo, would you be able to take a few more snap shots of it running with texture-mapping, and whatever else you have in it, and send it to me?

R. van Wijnen

May 30, 2001, 02:38 PM

What's this?
Are my eyes deceiving me?
Is it really you Tim?
You're alive?

Just kidding.
I know you're really busy at Crytek. It's good to see you're still doing great stuff. I like the pic.

Keep up the good work.



May 30, 2001, 02:51 PM

Don't worry, I guess everybody understood your point, even with the typo.

You are speaking about a VERY hevay subject. Take curved surfaces for example. Q3 increses the detail when you get closer. But maybe you are far away from a curved surface, but the shadow is right in your face. So you see a really low poly version of the surface, ugly !

ANother thing. Ever though of visibility calculations ? You can "easily" precalculate if an object is visible from a given point, but what about it's shadow ? Try to calculate which object's shadow can visble from which point of view.

Shadows take scene management problems to an entire new level.



May 30, 2001, 02:52 PM

Nope, don't think so. I think the shader is faster because you don't need the full matrix. My shader has only nine instructions, and NV says up to nine instructions is for free on the NV20...


Hannu K.

May 30, 2001, 02:56 PM

Have you played BoD or just seen some screenshots? When I first time took a torch in my hand, I almost crapped in my pants :D.


May 30, 2001, 03:05 PM

I saw somebody playing it. I just found that those shadows don't have such a great impact, maybe because the lighting has no real good attenuation or is not DOT3 based.

Maybe it's just because I see stuff like realtime shadows 8h a day, and I know the NV20 + tech demos loooooooooong before it was released ;-)

Well, it's an improvement ;-)


Garett Bass

May 30, 2001, 03:16 PM

Cool, thanks for the info, that makes this technique much more appealing! :D

Marco Al

May 30, 2001, 03:53 PM

If we could use non uniformly sampled framebuffers then I could see how you could get shadow maps at image precision (from the camera's viewpoint, which is the only one which counts), but without that getting good precision out of shadow maps (let alone image precision) seems to me to be more an art than a science. Am I missing something?


May 30, 2001, 04:01 PM

Ok, thanks for all the great feedback guys ! A LOT of replies, I also received a ton of mails from old (and new) friends about this subject.


Jaap Suter

May 30, 2001, 05:54 PM

Thank you Willem,

I was about to say the same :). To elaborate...

Realtime dynamic beamtree stuff is not possible on current hardware. Unless you optimize :). After weeks of work it was pretty fast. However, the biggest optimization was in using silhouettes instead of all polygons. This introduces a new problem. Realtime silhouette generation is a pain in the ass. It's possible but I didn't feel like implementing it (it requires some VIPM like stuff, where you cache a silhouette and only update edges depending on the camera location).

I implemented a silhouette generator for convex objects. And tested my realtime dynamic beamtree shadow casting algo with it. I could use 1000 polygon tube's (primite in Max) without a problem. Casting it on a staircase for example. Pretty neat.

I could make a demo if you're interested. The code however, is something I cannot release :(.



p.s. WILLEM, we miss you!! :)


May 31, 2001, 12:00 AM

The method you are using DOES have fall down cases though. It is possible to get an edge set that isn't entirely interconnected and does overlap - meaning you get a definate problem with your in out counts.

To get the proper silhouette, you have to clip all those edges to each other in a beamtree and work with occlusion/partial occlusion etc.

Sure, your problem doesn't have a problem with a CUBE, or a SPHERE, or SIMPLE shapes, but there is indeed a problem :)


May 31, 2001, 12:09 AM

Actually, they've changed to shadow-maps and I know that for a fact. Also, if you look at the shadows projected onto various different objects, you can see soft edges.

There are two examples :)


May 31, 2001, 07:42 AM

With image-precision I was referring to algorithms that work on a per-pixel level (like depth shadow maps), rather than at a per-object level (object-precision, eg, shadow volume generation [NOT testing, which is done at image-precision if you use a stencil-buffer]). I didn't mean the actual accuracy or precision of a particular scheme.


May 31, 2001, 08:24 AM

Nope, there is NO problem. Every complex shape just works fine ;-) You can fix all this without clipping. Works with every closed body...



May 31, 2001, 09:36 AM

So, you are talking about Potential Visibility Sets on objects shadows... interesting, can be done with static lighting, but that defeats the purpose of not useing light maps :). Oh well, that's why I am staying away from shadows at the moment and working on my Terrain engine. I beleive I found a really good way to get rid of most polyons that aren't visible with barely any CPU or Video card time. Objects are another story , and forget about their shadows ;).


May 31, 2001, 10:22 AM

You must be using a different method to the one I was thinking of then.


May 31, 2001, 05:36 PM



May 31, 2001, 05:38 PM



May 31, 2001, 05:55 PM

2 years before a GeForce _1_ is a target!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!!?!?!?!?!?!?!?

What the heck!?!?!?!

GeForce 1's have been around for a LONG time, man! For the sake of pete, you can buy them for $47!!!!!! And you can get a GeForce2 MX for only a dollar more! Even if I concede that perhaps you can't expect EVERYONE to have a GeForce 1 in their system, 2 years!?!?!?!? You've got to be kidding! The GeForce, IMO, is already obsolete. In fact it's so obsolete that I wouldn't even consider buying one. IMO, once a product has reached that point, I can't see how you can say it'll be 2 years before it becomes a viable target platform. That's rediculous! Considering it's been out since '99, if we apply the same reasoning then we should only now be expecting consumers to be using cards from '97! So we should only just now be writing games expecting users to have a Voodoo1?! Oh, okay, a Voodoo2 then? Come on! I think a GeForce 1 (or something on that level) is a perfectly acceptable piece of hardware to expect users to have. Especially considering if a game project is only now undergoing development it'll probably be atleast a year before it hits the shelves. So I think writing code today to support the GeForce 1 is actually shooting a little low. You have to anticipate what the mainstay will be when your game is released, not while it's in development. And even then it might be good to target your game to what might be the mainstay just a bit after it's released. Especially considering most games don't make their original release dates.

This thread contains 86 messages.
First Previous ( To view more messages, select a page: 0 1 2 ... out of 2) Next Last
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.