Away3D Normalmaps Generation (3)

Flash 18 Comments »

normalmaps1

Several code improvements were made on the generator since my last post. Next to some speed, line correction where colors were out of range and many other fixes. The class allows now to generate much smaller files (so you generate them also faster) while displaying good looking surface. Now the minimum size is defined as the minimum surface area defined by the uv's that will be drawn at minimum of one pixel, if smaller, it still will be printed as one pixel causing probably overlapping per faces. I will not extend on this, just try it and you'll see for yourself.

The default of the map size generated by the class has been set to 512x512. But a 256x256 would do just fine in many cases. The smaller the size, the fastest it's generated.

In this example you can see an experiment with highlights, coupled with a bump map. Both are using the Away3d Dot3MovieMaterial and vertexes animation are done using the Animator/AS3Exporter class. Note that the material allows you to set a cliprect, basically it's only updating the information within that rect, in this case, just the eyes region. As a result, it runs much faster than redrawing whole map.

The only challenge for this demo was the mapping. For objectspace normalmaps you must define unic regions on the model. So after remapping twice the first head and fail. I've made a spherical projection in order to get per face a unic area of the map. In just a matter of seconds, the mapping was perfect but not my textures were totally useless..
The only change to the mapping was to move the faces behind the ears into a nonused area of the map. I understand now why most face textures are builded this way. The code on itself is quite simple, Away handles everything for you. Most work was to compose the maps in Photoshop from a few shots (thx for your skin Joseph!) and play a lot with the clone tool. To know where to place the elements becomes a breeze when you have the normalmap, you just need to use it as underlayer, and every important elements such as eyes, mouth, nose are pasted and set to transparent 50%, this way you see where they overlap and if you need to rescale. When they fit set back to 100% and clear the gaps with the clone tool.

This technic allows designers to reach a new level of realism into their Flash sceneries. Even with killer settings like now, it's still running smoothly on my mac. For older machines, less detailed maps and models would be required. Same old story....

Here are the maps used on one of the models. The demo uses bigger versions of these bitmaps.


The normalmap, rendered dynamically in Away, exported and reimported back to Flash.


The bump map, just to enhance some details of the skin and hair borders.


and finally the color map.

Another improvement done to the class is the way the map "reads" the mesh while writing the map.

normalmaps2

The code was not suitable for shapes with sharp edges or when angles were great between faces like with a cube for instance. Because the code takes an average of the neighbourg faces normals, it was allways giving some curvy result. The new version compares the angle and decides to add the neighbourg face normal or just ignores it.

In the first example using the previous version of the class, you can see that the sides of the pack were not been detected as flat surfaces. Causing some wierd volumes. If the map was generated from a more detailed model it would not be that obvious.
This demo uses the previous version of the code and this one uses the new version. You can see that the map top left representing the pack with the lastest version as now more flat area's than with the previous one. If you look at the pack in this version, there are no more irregular light influences on the surface. The sphere however remains unchanged. Both maps are dynamically traced at 512x512 and are displayed half size.

Finally Mario Klingemann gave me a hand for one more issue. Mario provided me a wonderfull code that "grows" the pixels to the canvas color. This was needed for the areas next to the map default background. Having them growing just a bit was enough to ban the artefacts sometimes caused by the aliasing of the trace at the edges of the background color.

I will soon post a tutorial on this class.

Entries RSS Comments RSS Log in

127.0.0.1
192.168.1.1