This is the first in a series of tutorials looking at the various materials available in Away3D. First off the block is EnviroBitmapMaterial.
This tutorial builds of code that is explained in the first tutorial of this set, so if you haven’t read it then I suggest you do so now.
Environment mapping is a process that aims to fake the look of the external world reflected on an object. I say “fake” because even the fastest home PCs don’t have the processing to ray trace the actual world reflection in real time (at least not in any scene that has any sort of detail). However you can achieve a similar effect by supplying a second texture that represents the view of the world.
At its heart creating a EnviroBitmapMaterial involves supplying just two BitmapData textures: one as the base texture, and one as the environment texture. In the demo the ResourceManager takes care of creating the EnviroBitmapMaterial. You can also change the reflectiveness of the texture. The reflectiveness value is a Number between 0 and 1. At 0 there is no reflection, and you can only see the base texture. At 1 you can only see the environment map with no base texture.
While the EnviroBitmapMaterial gives you a quick and easy way to achieve a shiny look, it does highlight one of the limitations of this style of shading. Take a look at the torus model. You notice how it looks almost transparent? This is because the EnviroBitmapMaterial works by rendering a “shader triangle” (in this case the environment texture) over the “texture triangle” (the base material) with one of the built in Flash blend modes. The shader triangle uses BlendMode.ADD, which means the colour of the environment texture is added cumulatively to the scene. On concave models like the torus, where you can have two triangles rendered on top of each other, this blending leads to a situation where the textures of both visible faces (in this case the opposite side of the inside ring, and the outside surface of the ring) are combined, leading to a transparent look.
You can even run into trouble on convex models like the rounded cube. The rounded cube does not have the same transparency issues that the torus has, but the process of rendering two triangles does lead to some depth issues (you’ll see the environment effect popping in and out on some of the cubes sides).
These issues should all be dealt with as Away3D moves over to the Flash Plater 10 platform and makes use of the new Pixel Blender functionality, but for now it’s useful to know that the current shading system has issues with complex or concave models.
The demo allows you to play with some of the properties of the EnviroBitmapMaterial, and you can apply it to a selection of Away3D’s built in primitives (see this tutorial for more explanation on the built in primitives).
Find more Flash tutorials here.