3D Normal Mapping with Pixel Bender

// August 3rd, 2009 // Experiments, Flash 3D, Pixel Bender, Source code & tutorials

In my previous normal mapping experiment I used just flat images, now it was time to do it in 3d, with Pixel Bender.

But to do that, I needed a “world” normal map of the 3d object. The problem was that standard 3d normal mapping is done with local maps (img 3). I’m sure someone familiar with 3D modeling programs can create world normal maps, but I don’t, I tried for hours ;)

normal map pixelbender

So I had to create the world map in Flash and unwrap the hole thing to the local map’s UV cords. Then I used Pixel Bender to create one map by adding the local and the world map together. So I ended up with 2 maps, the diffuse map (img 2) and the world normal map (with the details of the local map). All that was left to do was render the two on top of each other and apply a Pixel Bender blendmode to create the shading effect (something like this, but with Pixel Bender)

» View normal mapping experiment

Ok, all nice and stuff, but there is actually something very interesting going on (correct me if I’m wrong).
Lets say you want an object with a bitmap material and phong shading. In the classic way you have to project every normal of every vertex every frame and recalculate the the uv mapping to draw the phong layer, After that, you blend the phong and the diffuse layer.
But with the normal map, you just have to (pixel)blend 2 bitmap material renders…. I didn’t tested it yet, but it sounds a lot faster to me? + there is no extra cost for adding local normal maps.

I joined the Away3D team and this is part of the experiments for a new FP10 branch. So no source code for now. If its still is interesting after optimalization and further testing, it will be in Away3D sooner or later.
But if you have questions, your free to ask.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

3 Responses to “3D Normal Mapping with Pixel Bender”

  1. Tom says:

    Very nice. Interesting site as well.

  2. Very cool! As are all your experiments. Are you using Away for the geometry in this example?
    I’ve been playing with something similar, and am trying to add depth calculations to the mix.
    http://videometry.blogspot.com/2009/08/depthmap-filter-new-example.html

    If you’re ever in need of a full “world” normal map for a model, I’ll gladly help make you one :O)

  3. Kris says:

    Hi Peter,
    No, its not Away3D in this sample, its just something i hacked together. Your tests also are looking very cool. :)
    Cheers, Kris

Leave a Reply