The Add_pixel_to_viewport_accumulator(X, Y, Z, row_coord, column_coord) Webpage

As we said near the end of the previous webpage, it is very likely that when we project all the hyperspace tunnel pixels down into the viewport, many of the pixels will project into the same viewport pixel. If we don't do anything about this, then each time another tunnel pixel projects down into a viewport pixel, it will overwrite the previous pixel color with another color. A better solution would be to keep track of all, or at least some selected number, of the tunnel pixels and their associated colors that project down into each viewport pixel. Then when all tunnel pixels have been projected into the viewport, we just go through all the tunnel pixels that projected into each particular viewport pixel, and we average all these pixel colors together to form the resulting average color for each viewport pixel. This is exactly what the Viewport Accumulator Array, i.e. VAA, does for us.

The VAA is a 3D array of integers. The width of the array is the number of pixels in the viewport, namely 800. The height of the array is 340 and this is also the height of the viewport in pixels. The depth of the VAA is 200. A depth of 200 means that we will keep track of a maximum of 200 tunnel pixels that project into each of the viewport pixels. If more than 200 tunnel pixels project into any viewport pixel, then we just ignore them. Within each integer cell of the 3D array, we will keep track of two pieces of information, those being the texture map row and column of each tunnel pixel that projected into this viewport pixel. We can put these two pieces of information into a single integer value by using bit fields. See the below diagram.

(Diagram)


Now, there is nothing that says that each viewport pixel will have the same number of tunnel pixels projecting down into it. Indeed, when you think about it, the parts of the tunnel that are physically closer to the viewport, i.e. the tunnel pixels out towards the edges of the viewport, will project fewer pixels into these viewport pixels. The parts of the tunnel that are farther away from the viewport will project many more pixels into the pixels that are in towards the center of the viewport. We also need to keep a running total of the number of tunnel pixels that project into each viewport pixel. To service this need, I created another 2D array of integers that are just used to keep this running total. This array is called the Viewport Counter array, i.e. the VCA, and it is the same size as the viewport, i.e. 800x340, but it is only one cell deep.

So the procedure to create the hyperspace tunnel is to first determine where each tunnel pixel is in 3D virtual space. Then re-orient each tunnel pixel using 3D transformations. Project each tunnel pixel down to the viewport and figure out which viewport pixel it projects into. Increment the VCA in the correct cell to say that we have another pixel projecting down into this viewport pixel. Finally, record the texture map row and column of this tunnel pixel in the VAA at the correct cell.

At this point we have all the information we need to actually display the hypersapce tunnel to the user. The image we would be able to generate at this point would not yet have any motion blur applied to it though. And, in my opinion at least, adding motion blur is what really makes the tunnel look like it spinning as we move though it.


Last Updated: May 3, 2002
HTML URL: http://geocities.datacellar.net/~special_effect/ht_add_to_accum.html
E-Mail: special_effect.geo@yahoo.com or click here
1