This demo nicely illustrates the huge visual enhancement that normalmapping brings to Away3D. You can click on the bust to swap between the new Dot3BimapMaterial and the old WhiteShadingBitmapMaterial to compare. New materials that take advantage of normal maps will be included in the next release of Away3D.
The normal map in this example was created from a high-poly mesh using a technique decribed here. The resulting model has significantly fewer triangles, but retains a high degree of detail in the displayed object. This is hugely beneficial to scenes where high render speeds require low poly-models.
Rob
First ever implementation of dot3 normal mapping in Flash
There is a lot of possibility with importing normal maps into away3d. However, normal maps themselves can be complex to get right, so this demo combines the advantages of a normal map render pipe with the simplicity of a bumpmapped texture, allowing the model to have extra detail without all that fiddly high-poly/low-poly nonsense. Much easier to get right, plus you have the advantage of using a normal map if you would prefer. People with faster machines can set the default quality to high for a fantastic smoothed shading experience... - looks great but it's also heavy on the old processor.
I cannot tell you how soon i want to try this with a proper normal map...
Rob
While working on the next demo for the new improved PhongMaterial, i wanted to add some animated texture on a model... but the MovieMaterial was just eating my cpu resources! So I've reused a concept I had in my bitmapdata engine.
I think that the animators among us will love this one: the new Away3d AnimatedBitmap class...
it's using no expensive draw(), no expensive copyPixels(), and it renders at the speed of regular texture like the BitmapMaterial!
It supports also loops, and will support much more play options since it seams to be fast, but right now i've more than enough to play with, so I will first finish that PhongShading demo!
After 3 weeks vacation with nothing but a pencil and a notebook, i had wrote down some idea's for this class i wanted to test. Since you guys seem to like my blog, (my stats are growing very fast lately), i thought it was time to post some new demos. These are dev workfiles, this means: no fancy models, no nice textures and there are still many things to be done in the code, from improving perf to new features. These demos are just outputs while writing.
What's new in these ones?
The class has been updated to the composite idea - if you are familiar with Away3D
or PV this means that in your code you would usually make a material like this:
var material = new BitmapMaterial(mybitmapdata);
Now you can pass some graphical fx to it.
for the first demo you would do something like this:
var bump = new Bump(mybump);
var material = new BitmapMaterial(mybitmapdata, {}, [bump]);
The third param is an array, meaning when this code is released there will be more than just a bump to push in that array...
So what happens? When the material generates the faces the bitmapData is updated, and the next fx in the array will then use the resulting bitmapData from the previous. This is very nice because a different order in the array can create some completely different results. And believe me, you will soon want to save every swf outputted like i do, because they are nice to look at! The class has 3 other features -
1) it can use its own lightmap, like previous demos.
2) it can use an environment lightmap (this one is in development since some serious changes must be made into the core of the engine).
3) it can use an option that enables you to mask a part of the fx, allowing you to create some interesting materials, like rust on chrome etc..
This one demonstrates the bump applied with the texture mode set to overlay (forgot to mention, you also can set blendmodes on a texture)...
var bump = new Bump(mybump, mylightmap, "overlay");
This one illustrate the mask being set, creating some very interesting fx.
var bump = new Bump(mybump, mylightmap, "overlay", mymask);
I have more ideas to test/write from my notebook.
Fabrice
While busy cleaning the code from yesterday, i've added one more thing: a mask for the whole texture.
It sounds overkill at first sight since you can use a png with alpha, but do you remember how heavy those little friends can be?
Anyway, for those interested, it will now be possible to create a mask from a very sharp movieclip or an external image.
Because you can choose how to apply the mask (see my last post for more on applying masks) an extra parameter is required: true or false.
This will mask the entire result - used in the above demo
new Bump(mybumpsource, mylightmap, mymode, mymask, true);
This will mask only the bitmap result - used in the previous demos
new Bump(mybumpsource, mylightmap, mymode, mymask, false);
Here's another quick demo, just to demonstrate the flexibility of this class:
4 planes, 4 exact same bitmapdata's, 4 different results with this class, and i'm not counting the environment normal mapping coming up. Notice the way 2 planes are rendered where a mask is being defined. The boolean parameter is set to true on one of them.
Fabrice
It's been a while since my last post on materials. I thought it might be good to let see we are VERY busy right now with Away3D.
One of the latest feature, like this demo shows, is the normal mapping. Now natively implemented in the engine.
Any mesh using this new Material will reflect the environement or a given reflection map.
This is the first of this kind of materials and i have already a few more in the making.
How would you find being able to add phong shading coming from a given light source to your model?
Check this blog to see soon more of that shiny stuff!
Away3D rocks people!
k, Back to code now... too much fun!
Fabrice
PS: Rob is actually busy merging our codes for the next release.
PS2: Right click on model, open the Flashplayer menu, and select Away stats if you want some fps details...
Update
Made some tests last nite.
Code seams stabile and perform pretty well no matter model geometry being loaded...
Tried a 4206 faces overkill head model. FPS dropped down to 2fps and on init of the mesh the head.obj needed arround 2 seconds to intialize due to enormous amount of precalculations. The hummingbird model however with a respectable 974 faces count was running at a steady 25 fps very smootly.
I will try to improve the code on this...
I've turned 40 this weekend, so i thought it would be nice to celebrate...
First idea was: i do a cake! Nah... doesn't shine...
Since Away3D is now able to create anything looking expensive like gold or silver, i thought, what's the most expensive material on earth? Diamonds of course!
Everyone who has played with transparent objects knows you need alpha info, and then... well here it comes, what comes next? You need something to move light! So most go for double geometry, above each other. Did that too, but then you get a z-sorting artifact, all faces are swapping on and off. Useless.
So i've updated the enviroMaterial again to render faces another way...
Enjoy the Away3D diamond! The right amount of shinyness and face count!
Fabrice
I just couldn't accept having phong shading only facing you, this would simply be useless in most cases and you would probably choose to have textures with 'pre-baked' shading in order to get light coming from another direction just to better translate the scenery you want to build.
The model displayed in this demo has around 650 faces, all being runtime shaded by the code.
The code generates random color, camera position and light position. So some camera angles might look pretty weird but I think it adds some pretty cool drama on screen!
Keep in mind that sometimes the light will quickly turn when it is very near the target center of the model...it's because the light is being calculated at object level, just to save thousands of calculations per sec.
Fabrice
After days working on the code, it's finally there. A smooth shiny reflecting surface!
I let you judge of the quality and the performance... i'am very happy with this result, that's all i can say!
To get there and be able to make this demo, i got help from my friends Rob Bateman and Peter Kapelyan. Without them, i could have spend days on the code trying to find the bug i was looking for. And it was a nasty one... Peter shown us the way with his sharp eye and Rob killed the beast!
I'm very proud of the Away3D team, thank you guys, real teamwork!
Fabrice