It’s no secret that I like graphics. It’s the main reason why I play video games and it’s the main reason I got into programming. So obviously I was delighted to be invited and to join to the Away3D team last month. Inspired by my earlier Stok3d project (now on the backburner for a bit), I set off to create similar normal mapped pixel shaders, this time in full 3D. After some rough first patches (Stok3d was pretty simple since it only used DisplayObjects, flat planes), things have luckily shaped up, leading up to the first release!
The current state is a dot-release (3.4.2), so the exact implementation might still change while we’re working towards a shiny new 3.5.
So what is the difference with the previous shaders? Using Pixel Bender, the shading is calculated for every pixel in the texture, resulting in much more detailed and realistic lighting or reflections. Each shader requires an object-space normal map, which you can use to add detailed shading information without increasing the polycount of the mesh.
The shaders come in three flavors: environment map shaders, and single- and multi-pass shaders. Single-pass shaders take one PointLight3D and any AmbientLight3D on the scene to calculate the lighting, whereas multi-pass takes any number of lights of any type (AmbientLight3D, DirectionalLight3D, and AmbientLight3D). Important to note, tho, is that every light adds another pass and will be slower. Of course, if you’re only using 1 light, always use single pass.
Check out the following classes in Google Code:
- SphericEnvMapPBMaterial: spheric environment mapping
- Cubic EnvMapPBMaterial: cubic environment mapping
- DiffusePBMaterial: Single-pass, adds diffuse lighting to the texture
- PhongPBMaterial: Single-pass, adds diffuse lighting and specular highlights, with support for specular maps
- SpecularPBMaterial: Single-pass, adds only highlights – can be used in combination with Prefab3D’s prebaked lighting to create view-dependent specular highlights
- DiffuseMultiPassMaterial: Diffuse shading with multiple light sources
- PhongMultiPassMaterial: Phong shading with multiple light sources
Enough explanations, time for some demos! Right-click to view source:
- Cubic environment mapping
- Single pass shading: showing how a detailed normal map and specular map can enrich the shading
- Multi pass shading: using 3 lights (directional moonlight, firefly, and a flickering flame) and ambient
That’s it, enjoy! Feel free to drop by the mailing list for questions or read the official announcement! For now, I need to get some sleep before Flash on the Beach kicks off













Away3D Flash Engine » Away3D 3.4.2: Pixel Bender to the max!
on Sep 19th, 2009
@ 1:49 am:
[...] Written by recent new recruit and pixel-maestro David Lenaerts, the shaders offer a vast array of new options and shading techniques, all at the pixel level. For more detailed information on the various shader types, you can read David’s post over at http://www.derschmale.com. [...]
Piergiorgio Niero
on Sep 19th, 2009
@ 11:23 am:
oh god!
that’s what’s called an AWESOME job!
congrats david, looking forward to meet you at fotb
again, AWESOOOME!!
Allen Chou
on Sep 19th, 2009
@ 5:26 pm:
Wow…you’ve taken my breath away!
Frank Pepermans
on Sep 19th, 2009
@ 5:47 pm:
Most impressive David, Bob sure is disgustingly good looking
Looking forward to having a chat sometime soon, unfortunately won’t be able to make it to FOTB
David
on Sep 20th, 2009
@ 11:31 am:
Thanks all
@Piergiorgio: Well, I’m leaving to FOTB in a few, so see you there!
@Frank: Hehe, I’m surprised you remembered his name! Forgot to mention it in the post
Maybe next AUG meeting we can have a longer chat than the 10 seconds last time
dVyper
on Sep 22nd, 2009
@ 11:00 am:
Truly brilliant examples!!!
One thing: the href for the hyperlink for the second example is missing the ‘http’ prefix and so it is broken.
» Day Two Marc Hibbins
on Sep 24th, 2009
@ 1:24 pm:
[...] example with a human face that renders sweat, scars and frowns all with the tool. The examples are here on David’s blog and here on the Away3D [...]
David
on Sep 24th, 2009
@ 5:36 pm:
dVyper: ah thanks mate
Fixed it!
Fukhaos
on Oct 22nd, 2009
@ 2:20 pm:
ahuahuau
I know the sky in first project:
http://www.fukhaos.com
but is an AWESOME job !!
David
on Oct 22nd, 2009
@ 4:24 pm:
Thanks! Hehe, got the skybox from http://www.fpsbanana.com