Dirty hack:: depth pass shadow volumes

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
$NulL
Posts: 100
Joined: Wed Mar 27, 2002 8:00 am

Dirty hack:: depth pass shadow volumes

Post by $NulL »

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
Last edited by $NulL on Sat Sep 17, 2022 6:17 pm, edited 3 times in total.
Lukin
Posts: 349
Joined: Sat Jan 29, 2000 8:00 am

Post by Lukin »

Wow, moving shadows in Quake 3.
Great idea.
bork[e]
Posts: 4357
Joined: Tue Mar 23, 2004 8:00 am

Post by bork[e] »

Awsome, I'll check it out later.
Fjoggs
Posts: 2555
Joined: Fri May 03, 2002 7:00 am

Post by Fjoggs »

Dizzy.. :p
Does it hit bad on performance it it works smoothly, like light-styles?
rgoer
Posts: 798
Joined: Sun Aug 17, 2003 7:00 am

Post by rgoer »

very cool!
[img]http://www.sloganizer.net/en/style4,btw-spc-cocks.png[/img]
Meridanox
Posts: 41
Joined: Thu Feb 17, 2005 7:12 pm

Post by Meridanox »

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.
[url=http://shaderlab.com/]Q3Map2[/url] | [url=http://shaderlab.com/q3map2/shader_manual/]Shader Manual[/url] | [url=http://en.wikibooks.org/wiki/Q3Map2]Wiki Manual[/url]
$NulL
Posts: 100
Joined: Wed Mar 27, 2002 8:00 am

Post by $NulL »

Fjoggs wrote:Does it hit bad on performance it it works smoothly, like light-styles?
It shouldnt, its only two simple single pass shaders.
ydnar
Posts: 36
Joined: Fri Dec 15, 2000 8:00 am

Post by ydnar »

This gets my vote for coolest Q3 hack in years.
ydnar
Posts: 36
Joined: Fri Dec 15, 2000 8:00 am

Post by ydnar »

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.
Kat
Posts: 952
Joined: Tue Nov 14, 2000 8:00 am

Post by Kat »

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?
$NulL
Posts: 100
Joined: Wed Mar 27, 2002 8:00 am

Post by $NulL »

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.
rgoer
Posts: 798
Joined: Sun Aug 17, 2003 7:00 am

Post by rgoer »

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.
[img]http://www.sloganizer.net/en/style4,btw-spc-cocks.png[/img]
blood.angel
Posts: 871
Joined: Sat Jun 10, 2000 7:00 am

Post by blood.angel »

Exactly how was this done without access to the full code? The SDK doesnt allow access to the rendering code.
[img]http://members.lycos.co.uk/bloodangel1977/sig.jpg[/img]
Timbo
Posts: 171
Joined: Sat Jun 10, 2000 7:00 am

Post by Timbo »

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:
$NulL
Posts: 100
Joined: Wed Mar 27, 2002 8:00 am

Post by $NulL »

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.
ydnar
Posts: 36
Joined: Fri Dec 15, 2000 8:00 am

Post by ydnar »

I will test at home later... :)
rgoer
Posts: 798
Joined: Sun Aug 17, 2003 7:00 am

Post by rgoer »

good call $NulL I wasn't thinking fully
[img]http://www.sloganizer.net/en/style4,btw-spc-cocks.png[/img]
Lenard
Posts: 737
Joined: Mon Aug 04, 2003 7:00 am

Post by Lenard »

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?
[img]http://myspace-001.vo.llnwd.net/00555/10/05/555355001_l.gif[/img]
Meridanox
Posts: 41
Joined: Thu Feb 17, 2005 7:12 pm

Post by Meridanox »

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!
[url=http://shaderlab.com/]Q3Map2[/url] | [url=http://shaderlab.com/q3map2/shader_manual/]Shader Manual[/url] | [url=http://en.wikibooks.org/wiki/Q3Map2]Wiki Manual[/url]
rep
Posts: 2910
Joined: Fri Aug 30, 2002 7:00 am

Post by rep »

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.
Last edited by rep on Fri Feb 25, 2005 8:02 am, edited 1 time in total.
[img]http://members.cox.net/anticsensue/rep_june.gif[/img]
Vexar
Posts: 18
Joined: Sat Aug 05, 2000 7:00 am

Sweeet stuff man..

Post by Vexar »

I am with Big Y, Zaaaazome!
Pext
Posts: 4257
Joined: Thu Aug 28, 2003 7:00 am

Post by Pext »

is it possible to automate this via q3map2 and a boolean, saved at the brushes you want to cast the shadow?
$NulL
Posts: 100
Joined: Wed Mar 27, 2002 8:00 am

Post by $NulL »

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
Myth
Posts: 165
Joined: Wed Jan 12, 2000 8:00 am

Post by Myth »

Wow, nice progress!
dAde
Posts: 36
Joined: Tue Feb 08, 2005 6:27 pm

Post by dAde »

Sounds great :). Will check it at home...
[url=http://dade.pl][b]dade.pl[/b][/url] | [url=http://maposfera.org]maposfera.org[/url]
Post Reply