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 :)
Pingback: Away3D Flash Engine » Away3D 3.4.2: Pixel Bender to the max!
oh god!
that’s what’s called an AWESOME job!
congrats david, looking forward to meet you at fotb :)
again, AWESOOOME!!
Wow…you’ve taken my breath away!
Most impressive David, Bob sure is disgustingly good looking :P
Looking forward to having a chat sometime soon, unfortunately won’t be able to make it to FOTB :(
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 :D
Truly brilliant examples!!!
One thing: the href for the hyperlink for the second example is missing the ‘http’ prefix and so it is broken.
Pingback: » Day Two Marc Hibbins
dVyper: ah thanks mate :) Fixed it!
ahuahuau
I know the sky in first project:
http://www.fukhaos.com
but is an AWESOME job !!
Thanks! Hehe, got the skybox from http://www.fpsbanana.com :-)