In these days some of our projects require the use of 3D, and dealing with 3D objects in Flash can be a very painfull situation if you need to show many poligons and apply dinamic material to those poligons. In order to explore some of the “new” features of Flash, we decided to skip the mainstream 3d libraries (Away and Papervision) and try to create a simple renderer for our projects and our needs.
The renderer is intended to “bring to life” any kind of parametric surface, these kind of surface would give us a domain space were the surface tessellation is defined. Working with the parametric space and the domain space gives us the oportunity to calculate texture maps on the domain space that could be applied to the parametric space. The domain space and tessellation also gives us the chance to simplify the calculations (this can be done because every step of the domain space is formed by two triangles for tessellation purposes), so every texel in the texture is a step in the domain space which can be interpreted as a interpolation of the information of the two triangles that are part of the step.
Working the texture for every texel (product of the mix of two triangles allows us to calculate the lighting for every surface taking into account the distance of every triangle from the light, it also allows us to use multiple lights on the scene and recreate phong materials with specular values defined through the material definition.
In some future posts we will try to clean up the code for this simple renderer if you would like to play with it.