Quake3World.com
https://www.quake3world.com/forum/

Dirty hack:: depth pass shadow volumes
https://www.quake3world.com/forum/viewtopic.php?f=10&t=1146
Page 1 of 2

Author:  $NulL [ 02-24-2005 09:15 AM ]
Post subject:  Dirty hack:: depth pass shadow volumes

Stop me if this has been done before, but I've never seen it.

Test Map [240Kb]

Sample video [xvid 800Kb]

Screenshots
Image

Image

Now the interesting bit, how it works:

The outward facing polygons of the shadow volume darken whats already in the framebuffer.
The inward facing ones brighten it up again.

So when you can see both inward and outward facing polys they cancel each other out, but when only the outward facing poly is visiable the area is shadowed.
(You should never directly see an inward facing polygon)

There are some major limitations though. Being depth pass shadows you dont ever want a player's view to pass into a shadow volume.
There will be a maximum number of shadow polys rendered on top of each other before it fails and the shadow volumes become visable.

That'll do me for now
-- $NulL

Author:  Lukin [ 02-24-2005 09:41 AM ]
Post subject: 

Wow, moving shadows in Quake 3.
Great idea.

Author:  bork[e] [ 02-24-2005 10:40 AM ]
Post subject: 

Awsome, I'll check it out later.

Author:  Fjoggs [ 02-24-2005 10:40 AM ]
Post subject: 

Dizzy.. :p
Does it hit bad on performance it it works smoothly, like light-styles?

Author:  rgoer [ 02-24-2005 12:20 PM ]
Post subject: 

very cool!

Author:  Meridanox [ 02-24-2005 01:03 PM ]
Post subject: 

Great work! Looks almost like D3 stencil shadows.

I suppose you could reverse the effect and make fake light as well - like a swinging lantern.

Author:  $NulL [ 02-24-2005 01:54 PM ]
Post subject: 

Fjoggs wrote:
Does it hit bad on performance it it works smoothly, like light-styles?


It shouldnt, its only two simple single pass shaders.

Author:  ydnar [ 02-24-2005 02:17 PM ]
Post subject: 

This gets my vote for coolest Q3 hack in years.

Author:  ydnar [ 02-24-2005 02:20 PM ]
Post subject: 

Okay, I thought up an extension of your idea. Use q3map_alphaMod volume brushes on the shadow volume's vertexes to fade the shadow out. You could fake "soft" shadows this way too.

Make the lighten/darken shadows use alphaGen vertex and a blendFunc that uses the alpha channel and voila...smooth/fading "stencil" shadows.

Author:  Kat [ 02-24-2005 02:26 PM ]
Post subject: 

I might have this totally wrong here but are we looking at 'projected shadow volumes' a la what Doom 3 does? What happens with multiple light sources?

Author:  $NulL [ 02-24-2005 02:56 PM ]
Post subject: 

Kat wrote:
I might have this totally wrong here but are we looking at 'projected shadow volumes' a la what Doom 3 does? What happens with multiple light sources?


The shadow volumes are brushes placed behind the shadow caster's brushes. There could be a 2nd set of shadow brushes for a second light source that go off in a different direction. I included the .map with the test map, it might help explain.

Ydnar :: I'll give it a shot, but im not sure it'll work out. Because when you look through a shadow volume thats been alpha moded the brightness of the light/shadow textures wont be the correct values to cancel each other out, so the volumes will beome visiable.

Author:  rgoer [ 02-24-2005 03:30 PM ]
Post subject: 

you can make sure you get the correct values to cancel each other out still if you give the out-facing shader alphaGen vertex and the in-facing shader alphaGen inverseVertex. They should still add up to 1.

Author:  blood.angel [ 02-24-2005 04:01 PM ]
Post subject: 

Exactly how was this done without access to the full code? The SDK doesnt allow access to the rendering code.

Author:  Timbo [ 02-24-2005 04:21 PM ]
Post subject: 

blood.angel wrote:
Exactly how was this done without access to the full code? The SDK doesnt allow access to the rendering code.


Sorcery. Alternatively.. read the post? :icon23:

Author:  $NulL [ 02-24-2005 04:25 PM ]
Post subject: 

rgoer wrote:
you can make sure you get the correct values to cancel each other out still if you give the out-facing shader alphaGen vertex and the in-facing shader alphaGen inverseVertex. They should still add up to 1.


That would only be true if your facing strait through the volume, any other angle would give different alpha values on front and back faces.

Author:  ydnar [ 02-24-2005 05:02 PM ]
Post subject: 

I will test at home later... :)

Author:  rgoer [ 02-24-2005 05:20 PM ]
Post subject: 

good call $NulL I wasn't thinking fully

Author:  Lenard [ 02-24-2005 06:07 PM ]
Post subject: 

Cool but all the tex's in your map seem to be missing. Also, on low quality the shadows have purple trails. The polygons become barely visible I suppose, I'm still not 100% on how it works.

It must be that there pyramid like poly's jutting out from the object that draw a shadow on the wall wherever the object intersects it... if this is the case then the polys are becomming visible and turning purple on low quality settings.

Would this work with models?

Author:  Meridanox [ 02-24-2005 08:35 PM ]
Post subject: 

Lenard wrote:
Would this work with models?


Should... they're just shaders assigned to a surface.

Good seeing all the old faces around again... ydnar, rgoer, kat, etc.

Hey, kat... maybe we should start a Quake3 Can Do It Too project! Hahaha!

Author:  rep [ 02-24-2005 11:13 PM ]
Post subject: 

This would work well with a moving spotlight.

Edit: The only problem would be matching the proper shadow scale in a scene. The closer an object is to the surface it casts a shadow on, the closer the size of the shadow to 1:1 scale it shall be. The problem here of course is in a room lit with multiple sources, one must painstakingly measure the proper trajectory of each object's shadow.

Working in radiant, this would probably be impossible... However, you can convert your map to ASE, load it in 3D Studio Max and give the whole thing a generic texture, and then use render to texture to create the lightmaps.

Once this is achieved, you can use the lightmaps as a source to trace onto, and then model the shadow volumes into the proper scale.

Soft shadows can be achieved using this same method. Simply duplicate the shadow volume twice and enlarge each ever so slightly, and apply a lighter shader onto each as you move out. The levels of shadow fidelity are endless, only limited by the capabilities of our video cards. For an object such as the cross in the example scene it wouldn't be too taxing to duplicate the shadow volume in this manner to produce said effect.

edit: True gradient shadows can be achieved as well by segmenting the shadow volume model into partitions corresponding with the direction of the light. For example, if you have a flashlight on a plane projecting on a shape, you can do one of two things for an accurate shadow; Create a simple shadow texture on a plane that includes the degradation of the shadow after distance, which would be slapped on a single plane close to the surface like a decal, or for a dynamic shadow you would slice it into pieces and animate each accordingly.

Image

The distance of a light source dictates the character of the shadow. The closer the light is to the object, the smaller and more solid the shadow will appear. As the light source moves away from the object, the shadow not only enlarges opposite the direction of the light, but it diffuses due to the loss of intensity. This effect can be achieved with these methods, using a stepped procedural model/shader combination. The more steps, the more realistic it will look. The less steps, the more banded it will appear.

Author:  Vexar [ 02-24-2005 11:57 PM ]
Post subject:  Sweeet stuff man..

I am with Big Y, Zaaaazome!

Author:  Pext [ 02-25-2005 02:06 AM ]
Post subject: 

is it possible to automate this via q3map2 and a boolean, saved at the brushes you want to cast the shadow?

Author:  $NulL [ 02-25-2005 05:44 AM ]
Post subject: 

Right, I got a fading one kinda working. I used a gradiant texture instead of alpha blending it. But I carnt get around the values not being able to cancel each other out, so it looks ok from the side or top but from anywhere else the volumes become too visible.

Image

Author:  Myth [ 02-25-2005 08:53 AM ]
Post subject: 

Wow, nice progress!

Author:  dAde [ 02-26-2005 03:35 AM ]
Post subject: 

Sounds great :). Will check it at home...

Author:  Jemcdv [ 05-25-2007 01:32 PM ]
Post subject: 

Sorry, but what happened to this?

Author:  Foo [ 05-25-2007 01:34 PM ]
Post subject: 

What do you mean?

Author:  dzjepp [ 05-25-2007 01:37 PM ]
Post subject: 

lol rep, what a self-centered cunt

Author:  Jemcdv [ 05-25-2007 01:43 PM ]
Post subject: 

Foo wrote:
What do you mean?


It just seems like it ended there. Wasn't there more to explore? Like that graduated shadow effect.

P.S. I can download the video but not the .pk3.

Author:  rgoer [ 05-25-2007 03:02 PM ]
Post subject: 

P.S. this was two and a half years ago

Author:  Jemcdv [ 05-25-2007 03:05 PM ]
Post subject: 

rgoer wrote:
P.S. this was two and a half years ago


I know, I was hoping this wasn't the only related thread to be found on this topic. I haven't been around for about that long so it's big news to me.

Author:  obsidian [ 05-26-2007 05:25 PM ]
Post subject: 

Well, unfortunately... this was the only thread about this technique.

Author:  Silicone_Milk [ 06-10-2007 04:21 PM ]
Post subject: 

Whatever happened to Rep anyways?

Author:  obsidian [ 06-10-2007 04:55 PM ]
Post subject: 

Banned, I think.

Author:  Scourge [ 06-10-2007 04:59 PM ]
Post subject: 

Yep.

Page 1 of 2 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/