» Shadow maps using depthbuffer
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

Shadow maps using depthbuffer

demo shadow shader vvvv28 sample
Credits: elliotwoods


This patch and shader demonstrate how you can use a depth buffer as a shadow map to cast shadows from a light source.

Note that this is meant more as a learning tool than for your final projects, as there's many aesthetic improvements that should be made before deploying as a virtual scene lighting tool.

I've uploaded it here mostly to demonstrate the principle of how to perform this type of shadow mapping.


shadow map 0.1.zip
31.07.12 [15:23 UTC] by elliotwoods | 1150 downloads

kimiki 31/07/2012 - 15:52


thx elliot

nissidis 31/07/2012 - 15:54

perfect !

nissidis 31/07/2012 - 15:58

but doesnt work for me, plus I cant find this INTZ format texture..

elliotwoods 31/07/2012 - 17:02

@nissidis : you need the latest vvvv alpha release (alpha28 not beta27)

nissidis 31/07/2012 - 17:16

Yes, just noticed it in the tags section above.. :) thx !
(NITZ isn't it only for ATI's hardware ? :S)

elliotwoods 31/07/2012 - 18:01


INTZ is for recent (DX10+) hardware. With recent drivers, all three major IHVs expose this. According to ATI [1], it also allows using stencil buffer while rendering. Also allows reading from depth texture while it’s still being used for depth testing (but not depth writing). Looks like this applies to NV & Intel parts as well.

It should work on NVidia, ATI and Intel

nissidis 31/07/2012 - 19:36

thanks a lot Eliot!

nissidis 31/07/2012 - 20:01

Another question : these shadows' artifacts (these that you mentioned before) are they because of Sampler, File Format or smoothstep() ?

PS: Is fast and accurate, I love it!

elliotwoods 01/08/2012 - 13:48

this is the 'de-facto' way of treating the shadows:

but an even better way is to defocus them with a soft shadow:

both are fairly easy additions to the above

Psykeview 11/10/2012 - 15:16

very nice elliot, i like it very much and the performance is very good,
just would like to know how to remove artifacts from the shadows,,, any tip to achieve this?

nissidis 11/10/2012 - 20:11

if you increase the FOV of perspective node and pull the light source further than the initial position (for example in Y axis) you will get a much better result eliminating almost all these artifacts. I still have the soft shadowing problem since I am totaly noob in hlsl programming and concepts

nissidis 11/10/2012 - 20:28

@Psykeview --> a 'hint' would be the device(EX.9) wich is rendering the INTZ texture (right side). Check there until you start seeing the teapots getting white/grey, this was the only practical way for me to understand what I was doing...

anonymous user login


~20h ago

domj: Stuck in your patching or eager to share what you made or came across? Join Midweek Patch Therapy at 17:30 https://therapy.domj.net/

~1d ago

david: vvvv meetup 3. new stream link. again youtube made us nuts.. please send everybody to https://youtu.be/pa3HRQ7kj6w

~2d ago

joreg: Reminder: Join us this evening, 8pm CET for the 3rd worldwide #vvvv meetup: 3.-worldwide-vvvv-meetup

~2d ago

sinus: @evvvvil: very impressive stuff! keep on marching the rays!You´ll never walk alone!

~2d ago

evvvvil: @mediadog, thankx for pointing it out broski. Wicked.

~4d ago

domj: Catching up with the Midweek Patch Therapy excerpts, expect more videos over the week. https://youtu.be/36r8LnHaS7g

~4d ago

mediadog: @evvvvil hey you made the webgl-dev-list cool stuff list: http://gfxprose.blogspot.com/2020/05/cool-webgl-stuff-2020-05-21.html

~5d ago

evvvvil: Yo I'm live doing a VJ set made in vvvv for OUTLINE demoparty with OddJohn DJing! Come see us play here: https://www.twitch.tv/outlinedemoparty/

~7d ago

domj: A blast to read with great references. Thoughts on how to make programming more learnable and understandable. http://worrydream.com/LearnableProgramming/

~7d ago

gegenlicht: @evvvvil damn. - missed it. Such unique styles, others would create 1000 twitter loops from one of ur sessions. :3 #bobrossmarch