Shadows with Papervision – it has always been a dream of mine (since last week). I took a stab at it over the past few nights, and this is what I came up with:
Now that you’ve seen it, heres the gist of how its done:
- I created a new material which is very close to the ColorMaterial. This ShadowMaterial has two extra variables - light and casts. light tells the material where the light source is. casts is an array of all the objects which will cast a shadow onto the material.
- When the material is drawn, it simply checks to see if the ray extending from the light to each face on the cast objects hits the face on the material. If the ray does hit a face on the materials object, that face is rendered with a shadow.
Let me know how it runs, and what could make it better! I am probably going to create a “fast” shadow material – which simply checks the object bounding sphere for intersection. It would be good for animated objects and constantly changing scenes – but all the shadows would be circles, and scenes like this wouldn’t be as impressive.

21 Comments, Comment or Ping
Too Cool… Love the secondary shadowing of the blocks and the super fast refresh speed.
August 19th, 2007
Great one. Works great.
August 20th, 2007
simply amazing! i cant wait to see what becomes of this…
August 20th, 2007
computer rock star, yes you are.
August 24th, 2007
Very cool. You could also try using a render of the scene from the viewpoint of the light as an alpha layer on the shadowed maerial.
August 31st, 2007
[Justin] – I’ve done about 20 variations of this method, including various types of lighting. The best results i have gotten are with colored spot lighting and quick shadows (using the bounding sphere rather than every face) with this method. I’ll put some more samples up soon.
August 31st, 2007
Very impressive example, but I’m having a lot of difficulty with the source. Assuming that the Face3D.as file replaces the original pv3d file, I’m getting a series of errors referring to the clone method used in that file. Any help would be appreciated. Thanks.
September 24th, 2007
[@todd] – It probably has to do with the revision you are using. I’m not sure if the clone function exists in 1.5 or not. You could try writing one yourself (should be very easy – just copy the vertices x,y,z properties to a new one) or get the latest rev from the SVN. If you have the newest, I’m not sure whats wrong. Sorry!
September 24th, 2007
Hi! It looks good.
I did dynamic shadows on ours engine. You can see it here: http://blog.alternativagame.com/en/2007/09/22/dynamic-shadows/
October 2nd, 2007
i’d love to implement your shadow-material in my new project but ive got massive problems to get it in. it seems not to work with the new revision of PV3D altought i did all the changes in der Face3D-Class. Youve got some ideas how to get it workin´??
October 22nd, 2007
I have also problems get this working. This is the message I get:
1119: Access of possibly undefined property material through a reference with static type org.papervision3d.core.geom:Face3D.
November 24th, 2007
I think most of the problems come with the revision changes – I don’t really remember what revision I used to generate this, so it might be tricky to find out (i should have just used 1.5!). Right now I’m swamped with stuff but will start on a 2.0 revision for everyone when i get some spare time. Then everyone can be on the same page when trying to implement it. This technique uses raycasting, so its a little slower than some other options I might look into implementing as well. Either way, with shaders in 2.0 it is now much easier to implement shadows!
November 24th, 2007
I hope you get some spare time very soon.
This would be exactly what i need for a GW project i’m working on.
May 15th, 2008
I’m not getting this to work in GW. Anyone know if there is a tutorial or something to create this effect?
please respond at konlnedra [ at ] gmail . com
June 27th, 2008
I mean kolnedra [ at ] gmail . com
June 27th, 2008
Did the 2.0 compatible version ever materialize?
February 7th, 2009
LOL – Found it!
February 7th, 2009
Very cool! I was just looking how to create a sun… this helps
May 25th, 2009
Reply to “Papervision Shadow Casting”