Quake3World.com Forums
     Level Editing & Modeling
        Dirty hack:: depth pass shadow volumes


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Dirty hack:: depth pass shadow volumes

The Afflicted
The Afflicted
Joined: 27 Mar 2002
Posts: 792
PostPosted: 02-24-2005 09:15 AM           Profile Send private message  E-mail  Edit post Reply with quote


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

Test Map [240Kb]

Sample video [xvid 800Kb]

Screenshots
[url=http://www.asei73.dsl.pipex.com/images/shadow/shot0000.jpg]
Image
[/url][url=http://www.asei73.dsl.pipex.com/images/shadow/shot0001.jpg]
Image
[/url]

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 07-24-2009 11:58 PM, edited 2 times in total.

Top
                 

blaze a blaze
blaze a blaze
Joined: 29 Jan 2000
Posts: 344
PostPosted: 02-24-2005 09:41 AM           Profile Send private message  E-mail  Edit post Reply with quote


Wow, moving shadows in Quake 3.
Great idea.




Top
                 

The Borked One
The Borked One
Joined: 23 Mar 2004
Posts: 4707
PostPosted: 02-24-2005 10:40 AM           Profile Send private message  E-mail  Edit post Reply with quote


Awsome, I'll check it out later.




Top
                 

Old Skool'
Old Skool'
Joined: 02 May 2002
Posts: 5215
PostPosted: 02-24-2005 10:40 AM           Profile Send private message  E-mail  Edit post Reply with quote


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




Top
                 

btw cocks
btw cocks
Joined: 16 Aug 2003
Posts: 3216
PostPosted: 02-24-2005 12:20 PM           Profile Send private message  E-mail  Edit post Reply with quote


very cool!



_________________
Image


Top
                 

Trainee
Trainee
Joined: 17 Feb 2005
Posts: 41
PostPosted: 02-24-2005 01:03 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
Q3Map2 | Shader Manual | Wiki Manual


Top
                 

The Afflicted
The Afflicted
Joined: 27 Mar 2002
Posts: 792
PostPosted: 02-24-2005 01:54 PM           Profile Send private message  E-mail  Edit post Reply with quote


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


It shouldnt, its only two simple single pass shaders.




Top
                 

Immortal
Immortal
Joined: 15 Dec 2000
Posts: 2297
PostPosted: 02-24-2005 02:17 PM           Profile Send private message  E-mail  Edit post Reply with quote


This gets my vote for coolest Q3 hack in years.




Top
                 

Immortal
Immortal
Joined: 15 Dec 2000
Posts: 2297
PostPosted: 02-24-2005 02:20 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

True Nightmare
True Nightmare
Joined: 14 Nov 2000
Posts: 4216
PostPosted: 02-24-2005 02:26 PM           Profile Send private message  E-mail  Edit post Reply with quote


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?




Top
                 

The Afflicted
The Afflicted
Joined: 27 Mar 2002
Posts: 792
PostPosted: 02-24-2005 02:56 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

btw cocks
btw cocks
Joined: 16 Aug 2003
Posts: 3216
PostPosted: 02-24-2005 03:30 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
Image


Top
                 

Elite
Elite
Joined: 09 Jun 2000
Posts: 21781
PostPosted: 02-24-2005 04:01 PM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
Image


Top
                 

Timbo
Timbo
Joined: 09 Jun 2000
Posts: 1099
PostPosted: 02-24-2005 04:21 PM           Profile Send private message  E-mail  Edit post Reply with quote


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:




Top
                 

The Afflicted
The Afflicted
Joined: 27 Mar 2002
Posts: 792
PostPosted: 02-24-2005 04:25 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Immortal
Immortal
Joined: 15 Dec 2000
Posts: 2297
PostPosted: 02-24-2005 05:02 PM           Profile Send private message  E-mail  Edit post Reply with quote


I will test at home later... :)




Top
                 

btw cocks
btw cocks
Joined: 16 Aug 2003
Posts: 3216
PostPosted: 02-24-2005 05:20 PM           Profile Send private message  E-mail  Edit post Reply with quote


good call $NulL I wasn't thinking fully



_________________
Image


Top
                 

NOT OK
NOT OK
Joined: 03 Aug 2003
Posts: 1017
PostPosted: 02-24-2005 06:07 PM           Profile Send private message  E-mail  Edit post Reply with quote


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?



_________________
Image


Top
                 

Trainee
Trainee
Joined: 17 Feb 2005
Posts: 41
PostPosted: 02-24-2005 08:35 PM           Profile Send private message  E-mail  Edit post Reply with quote


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!



_________________
Q3Map2 | Shader Manual | Wiki Manual


Top
                 

rep
rep
Joined: 29 Aug 2002
Posts: 6771
PostPosted: 02-24-2005 11:13 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
Image


Last edited by rep on 02-25-2005 12:02 AM, edited 1 time in total.

Top
                 

Insane Quaker
Insane Quaker
Joined: 04 Aug 2000
Posts: 255
PostPosted: 02-24-2005 11:57 PM           Profile Send private message  E-mail  Edit post Reply with quote


I am with Big Y, Zaaaazome!




Top
                 

Who's that man, Mommy?
Who's that man, Mommy?
Joined: 27 Aug 2003
Posts: 5149
PostPosted: 02-25-2005 02:06 AM           Profile Send private message  E-mail  Edit post Reply with quote


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




Top
                 

The Afflicted
The Afflicted
Joined: 27 Mar 2002
Posts: 792
PostPosted: 02-25-2005 05:44 AM           Profile Send private message  E-mail  Edit post Reply with quote


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




Top
                 

The Afflicted
The Afflicted
Joined: 12 Jan 2000
Posts: 526
PostPosted: 02-25-2005 08:53 AM           Profile Send private message  E-mail  Edit post Reply with quote


Wow, nice progress!




Top
                 

Trainee
Trainee
Joined: 08 Feb 2005
Posts: 36
PostPosted: 02-26-2005 03:35 AM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
dade.pl | maposfera.org


Top
                 

Insane Quaker
Insane Quaker
Joined: 07 Sep 2004
Posts: 286
PostPosted: 05-25-2007 01:32 PM           Profile Send private message  E-mail  Edit post Reply with quote


Sorry, but what happened to this?




Top
                 

Timed Out
Timed Out
Joined: 02 Aug 2000
Posts: 37903
PostPosted: 05-25-2007 01:34 PM           Profile   Send private message  E-mail  Edit post Reply with quote


What do you mean?




Top
                 

It felt good...
It felt good...
Joined: 28 Mar 2001
Posts: 9558
PostPosted: 05-25-2007 01:37 PM           Profile   Send private message  E-mail  Edit post Reply with quote


lol rep, what a self-centered cunt




Top
                 

Insane Quaker
Insane Quaker
Joined: 07 Sep 2004
Posts: 286
PostPosted: 05-25-2007 01:43 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

btw cocks
btw cocks
Joined: 16 Aug 2003
Posts: 3216
PostPosted: 05-25-2007 03:02 PM           Profile Send private message  E-mail  Edit post Reply with quote


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




Top
                 

Insane Quaker
Insane Quaker
Joined: 07 Sep 2004
Posts: 286
PostPosted: 05-25-2007 03:05 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12254
PostPosted: 05-26-2007 05:25 PM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

Immortal
Immortal
Joined: 12 Mar 2005
Posts: 2155
PostPosted: 06-10-2007 04:21 PM           Profile   Send private message  E-mail  Edit post Reply with quote


Whatever happened to Rep anyways?




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12254
PostPosted: 06-10-2007 04:55 PM           Profile Send private message  E-mail  Edit post Reply with quote


Banned, I think.




Top
                 

Pestilence
Pestilence
Joined: 25 Mar 2002
Posts: 15681
PostPosted: 06-10-2007 04:59 PM           Profile Send private message  E-mail  Edit post Reply with quote


Yep.




Top
                 
Quake3World.com | Forum Index | Level Editing & Modeling


Post new topic Reply to topic


cron
Quake3World.com
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group