0 Replies Latest reply on May 16, 2006 10:26 AM by heilong

    3d and REAL shading (Gouraud shading a triangle)

    heilong Level 1

      I'll ask it quite simple:
      There is a triangle movie clip with vertices A (0, 0); B (256, 0); C (0, 256)
      Each vertex has some color (e.g., A - red, B - green, C - blue).
      I need to shade the entire area of this triangle by interpolating between these 3 colors.
      Something like a gradient, but it has 3 vertices, not 2 like a linear one.

      I tried two ways:
      1) create a 256x256 BitmapData, attach it to my clip and shade the triangle in bitmap,
      manually (just like people were programming 3d graphics before opengl&direct3d).
      this works, but is very slow (of course).
      2) create a 2x2 or 3x3 or some other lilttle square bitmap, shade it then scale it to 256x256
      with smoothing option (attachBitmap's argument) enabled. this works quite fast and looks almost
      right but not quite right.

      I also thought on how to accomplish this with a gradient (maybe several gradients), but no ideas...
      You can check out my code at: http://heilong.oceanography.ru/flash/lab/