ricardocabellov5.0balter-egos
trace mr.doob r08028
blogdemoscenefeaturedextrascontact
 *blog... kind of... *rss

« PV3D 2.0: How to rende...Loop a FLV in AS3 (and... »

PV3D 2.0: How to do simple realtime shadows
06.12.2007
Some people have mailed asking about how the shadows were done and where was the function in the API to create them.

Well, first of all PV3D 2.0 doesn't do the shadows automatically, but the new features let you do it (an many more other things). As soon as I knew that with the new version you were able to render the same scene in different sprites I though "shadows!". So, went quickly to give it a try and it worked perfectly. The idea is basically to do 2 renders per frame (this may be slow if you apply it at the end of a project). First render from the top of the scene, apply that render to the white plane at the bottom, and then second render from the user's camera.

This is the view from the "light camera" that gets rendered into a 512x256 bitmapViewport:



Next thing I wanted was to make the shadow a less dark, so, having already the bitmap, I just need to apply a colorTransform to it and make it a bit more pale.



And finally, apply a BlurFilter to the bitmap so the shadows is a bit diffuse



And that's all, this is the result:



Just as a last note... for the ball example I had to change before rendering the shadow the texture of the ball to black, and then change it back to the backed AO material.

Next thing on this matter will be to try to implement stencil shadows (because at the moment the shadow only works if the light is on the top, or one side...)

Oh! I almost forgot, here is the source file (requires flex2SDK, PV3D 2.0 and Tweener).
posted by mr.doob at 15:17
0 comment written so far

SORRY!
Is not that I don't care about what you have to say, of course I do, but they are speaking louder and I lost my patience :(
 *profile 



traditional id: Ricardo Cabello Miguel
based in: London, UK
serving to: Hi-ReS!
contact me: click here


 *latest posts 

* Some new Flash 10 Shaders for realtime... (01.09.2008)
* Service Pack 3 Setup Error (31.08.2008)
* FDT does work in Linux (19.08.2008)
* Sorry for the delay... (19.08.2008)
* Hi-ReS! Stats (11.08.2008)
* Björk - Hidden Place (Knick & The Ene... (09.08.2008)
* Noisia vs Religion (08.08.2008)
* Inspire08 demo log, day 117 (07.08.2008)
* Inspire08 demo log, day 116 (06.08.2008)
* Thank you for writing to Yahoo! Accou... (01.08.2008)
* Thank you for writing to Yahoo! Accou... (01.08.2008)
* Definition of FAIL (31.07.2008)
* Ronny Pries live @ Alpha Box Jan'08 (23.07.2008)
* WALL·E (23.07.2008)
* Where do we get the time from? (22.07.2008)


 *latest comments 

* C++, SDL Coding? Maybe.. ;) (Preview) (trace)
* C++, SDL Coding? Maybe.. ;) (Preview) (Joey)
* La picaresca (spt)
* Mr. Slip Up (ricardo)
* La picaresca (ricardo)
* La picaresca (spt)
* La picaresca (sole)
* Demoscene @ Cirsa (sml)
* La picaresca (humphr3y)
* La picaresca (alfio)
* fiver2's new baby: debris (Jcl)
* Barcelona = full of shit(s) (Soli)
* Demoscene @ Cirsa (Scener)
* Rar & unrar with Ubuntu (SethPlate)
* Mindcandy 2 (Jcl)


 *advertising