Away3d normal map – second attempt

It seems as though I’m trying to work out the odds of all the dice throws. I’ve been going through all the variations in making a normal map to suit my dice in the away3d scene. I’ve eventually succeeded in getting a version that works out of 3dsMax. Harder than I thought it would be, but maybe I should have thought through the maths rather than just guess at the right checkboxes.

This is my resulting test, with a correct version of the dice and the old version for comparison. It shows the effect of getting it slightly out. The die on the right has the wrong shading at certain angles. Use the arrow keys to rotate them.

[Edit: Feb 2011 – link not working here, I’ll have a look at it]

dice-example-21

The problem with my attempt at getting a normal map for the dice was that I asumed that I just needed to create the object space version of the map. Sounded simple, but then I found that the render in away3d didn’t quite work with any of the variations. The effect was that a face of the cube, when rotated around its perpendicular, would change the lighting that it had. It should stay constant. Because of the normal map being wrong, the rendering system thinks that the face is pointing in a different direction and so should change lighting as the object rotates around. I needed to investigate further.

Being a dice, the easiest way was to use Photoshop to cut and paste the different sides until we got the correct result. Then all (?) I had to do was to get the same rendering out of 3dsMax. It took a route through all the variations of LocalXYZ which should give an object space normals map. None of those variations fitted. World space is just the same, because my object is sat around the origin; X, Y and Z axes are the same for both. So I then tried Screen modes. After several combinations I discovered that turning the front view around by 180 degress gave the result that I was looking for. I finally had a normals map that worked with away3d. The following pics show the colours required by faces whose normals point along the 3 axes. Faces at other angles would be on a graduaton between them. The first image is the LocalXYZ normal map that I first tried; the second image is the correct version.

So a few points to note,

  • Lights aren’t needed for the render as we are not baking a real texture
  • The colours (colors!) need to match the directions that away3d is expecting, as in the diagram.
  • Because Screen mode is used, be careful of rotating object or axes as this will give a different set of colours.
  • Not sure if the object has to be at the centre; I don’t think so. It just needs to be centred with the high resolution version.
  • There needs to be a directional light active in the away3D scene.
  • The polygons in the model viewed in the picture are from the high res version. The simple cube is within this andthe rays are projected outwards.
  • If it’s of any use to anyone, the last picture is an image of the cube within 3dsMax as I created the normals map. It’s front facing but rotated around 180 degrees. Is that because of the Z-up in Max, compared to the Y-up in away3d or Papervision. I don’t want to take the time to think about the maths too much at this time of night.

    [Edit – If you’re into normal maps in away3d, do look at Fabrice’s blog. He’s the one doing the clever stuff underneath.]

    Advertisements

    3 thoughts on “Away3d normal map – second attempt

    1. Pingback: Away3d dice with normal map « Changing colours along the way

    2. sushantyalgudkar

      Hello Ian,
      I am an AS3 developer working on Away3d. Me too have strange problem working with Away3d. You can see the demo of project I am working on at:

      http://www.dnyandeep.com/demos/3d/away-test/clothes/clothes.html

      It uses Away3d 3.5. The light rotates as the clothes model rotates. I read your article above, however I could not get what I should do for my problem. I just understood that I have the same problem as you did.

      Any guidance will highly appreciated.


      Sushant

    3. Hi Sushant

      Your model was quite large and performance was not good on my machine. I would suggest getting right with a low poly model first; it will make it quicker to test with.

      Your light seemed to rotate as the model did, which means the lighting will remain the same on the model. This is the effect that I see. Can you create a scene where you can have the light in a visible position so that we can see where it is?

    Leave a Reply

    Please log in using one of these methods to post your comment:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s