Away3D Normalmaps Generation (3)

Flash Add 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.

18 Responses to “Away3D Normalmaps Generation (3)”

  1. Flashbookmarks Says:

    Wow that’s looking great, good job.

  2. ian stokes Says:

    Fabrice..your the shizzle..the man…and btw..Pv3d is for kids! Away3d is a “mans” way to do 3d! this is where things get crazy!

  3. Peter Says:

    Awesome Work Fabrice!

    Rush Hour Part four?

    http://i184.photobucket.com/albums/x25/DD900/RushHour3-1.jpg

    :P

  4. saul Says:

    You are Amazing!

    I think its time to look into this awesome 3D engine and go beyond pv3d myosis (i just invented a new word, lol).

  5. Max Says:

    Nice work there, when will we be seeing a tutorial? That would be fantastic.

    Cheers,
    Max

  6. Fabrice Says:

    Max, yes that’s on my to do list. But almost all you need to know is already typed in the 3 posts. Its that easy !

  7. Martin Says:

    great work, i w8t for the tutorial - how long we must wait! how do you make the mimic animation from the eyes and the mouth - can say anything about the algorithmn or a source example? thx man!

  8. Fabrice Says:

    The mimic is builded in 2 parts.
    1/ I have the same head model exported as as3 using the AS3Exporter, each one having just little changes, like eyes closed/open, to make the model look a bit alive.
    At init I pass the 3 meshes to the Animator class, I add a SequenceDone listener. OnSequence done, I generate randomly a new Sequence where each animation gets a new speed and order.
    2/the textures, For the demo I’ve used 2 technics, one for each head, just to see how it goes.
    The first head uses a copypixel. basically you have the texture with eye balls, no iris. The iris is a simple image. The way it works is super simple: you need one extra bitmapdata, the is a clone of the texture with eye balls only.
    that’s how it goes: iteration 1, you define a rect, the rect represents the region of the texture where both eyes iris will be drawn. You copypixel that info on source and add one eye, the second one is just same copypixel but with offset x equal to distance between 2 eyes. iteration 2, you just overwrite that rect with a copypixel of your clone bmd, and repeat the copypixel. These iterations are done on setTimout, like every random 1500 ms.
    The second approach is similar except it uses movieclip. I move the yes, take a snapshot and update the moviematerial. Note that a cliprect is set to the moviematerial to avoid redraw whole image.

    for the dot3material, its like super easy. just new Dot3Material(sourcebmd, normalmap);
    The rest is automatic.

    Note that we just released a player 10 version of the engine, where the normalmaping renderer is faster, using pixelbender.

  9. Martin Says:

    thx for the fast answer. i will try it what u say, but i am not so affin in away3d. i come from pv3d, but away3d facial animation can be easier, so i must now learn away3d now :) question will follow ;-)

  10. Martin Says:

    sry for double post. do you know any ressources were i can learn this normalmapping and facial animations technics in away3d. thx.

  11. Derek Says:

    Hello. My comment isn’t directly related to this post, but I’ve been searching everywhere for an example on how to set up video controls and video listeners for the videoMaterial. I’ve sifted through the documentation and can’t seem to figure out how to reference the netstream object from the video Material. I would appreciate any help. Thanks.

  12. Fabrice Says:

    Martin and Derek,
    May be stupid question but why don’t you join our dev group?
    http://groups.google.com/group/away3d-dev

  13. Derek Says:

    Hello Fabrice -my membership to the dev group is pending. Sorry to be impatient, but I have a proof of concept I need to have completed soon and am wondering if you know the quick answer of how to add complete listeners or netstreamStatus events to individual videoMaterials? Thanks for any help.
    Derek

  14. Fabrice Says:

    You should have access by now… Due to spam attacks we need give access by hand. Rob and me are moderating the group, so if you have registered while we are sleeping, takes a few hours :)

  15. dom Says:

    please please please give source of this

  16. Fabrice Says:

    @dom
    The generators are in the svn/zip in materials.utils package. I still have to find some time to write a few tuts…

  17. mariodesign Says:

    TRABAJO PROGRAMADOR AS3 AWAY3D

    URGENTE: Busco persona experta en el manejo de codigo AS3 y Away3D. (propuesta vigente para mayo de 2010)

    Yo soy Diseñador industrial y manejo a la perfeccion el tema del modelado, texturizado y diseño 3D.

    El asunto es que estoy desarrollando una aplicacion para un cliente y tengo dificultades para la programacion.

    URGENTE, FAVOR ESCRIBIR AL CORREO mariodesign@gmail.com PARA HABRAR DEL PAGO POR EL TRABAJO.

    El trabajo es para buen tiempo, inclusive me están solicitando cotizar una aplicacion mucho mas compleja, con personajes de la farandula que interactuan entre ellos y necesito URGENTEMENTE una mano derecha para desarrollar estos proyectos!!!

    mariodesign@gmail.com

  18. Promethe Says:

    Hi there! I’m working on normal maps generation myself and I was hoping you could share the code snippet Mario gave you to “grow” the pixels to the canvas color. Or at least a hint on how to do it :P

    Thank you very much.

    Regards,

Leave a Reply

Entries RSS Comments RSS Log in