To be fair, I'm not using Away3D at the moment - I'm using the Flash 10 3D API (graphicsTrianglePath, Graphics.drawGraphicsData, etc). However, the principles are similar to Away3D or Away3D Lite so I thought someone might be able to help me with my question.
I have a mesh of triangles that represent a terrain. I am pre- calculating the projection triangles (isometric projection, FWIW), and then rendering with fills. I have calculated a lightmap for the terrain by simply applying lambert shading to the original heightmap. The only thing I can't figure out is how to get the lighting into the scene with any degree of performance. I can render the terrain with the textures. I can render the terrain with the lightmap. This stuff happens so fast that I could do it a dozen times per frame and still get 60 FPS. But when I try to blend the texture pass with the lighting pass, I can't figure out how to do it without performance dying completely. If I render the texture pass into one Sprite, and the lighting pass into another Sprite, it works fine - I can see the lightmap which hides the texture pass. So now I should be able to set the blendMode of the lighting Sprite to BlendMode.MULTIPLY, right? Well, as soon as I do that, the framerate hits the floor. It looks awesome, but it is so slow that I simply can't use it. I also tried pre-lighting the textures - that way, I could avoid doing the blending on-the-fly. But this involves creating a unique texture for each tile on the mesh, and of course I run out of memory pretty quickly that way (anything more than a 90x90 mesh starts getting memory errors). The next thing I thought of was rendering the passes into a BitmapData buffer. But there's no way to render directly into a buffer; you have to render into a DisplayObject and THEN copy it into a buffer. This turns out to be no faster than just having the DisplayObjects on the screen. I figure that in order to make Away3D or Away3D Lite work with lighting, someone must have solved this problem. So any tips or tricks you could provide would be most welcome! Thanks, Jeremy
