Saving Z buffer

swenson at NUSC-WPN.ARPA swenson at NUSC-WPN.ARPA
Thu May 4 23:51:00 AEST 1989


Chuck writes:

> ...
>      This is my question: can I prerender the Earth and save the resulting
> image and Z buffer, so that when I need to draw new satellite positions, I
> can just load the frame buffer with the bitmap, and the Z buffer with the
> Z values?  This way, I only have to render the satellites each iteration, 
> but still will get proper clipping.
>

I have a couple of suggestions:

	1)  If the "eye" is in geo-synchronous orbit about the earth, you
	can probably render a copy of this wonderful planet in both
	the front and back planes in doublebuffer mode.  You then need
	to protect the image of the earth by using a call to WRITEMASK (mask).
	This all, of course, means that you have to do your rendering in
	12 bit color map mode, c'est la vie.  When the screen is cleared and
	buffers are swapped, the earth doesn't go anywhere (making its 
	inhabitants very happy).  The one thing that you must keep in mind
	when employing this, is that if a purple satellite is over the
	the green ocean you want the display hardware to display the 
	satellite as purple...I demonstrate:

		...
		mapcolor (6, 0, 255, 0);	/* Color of the ocean. */
		writemask (0x000f);		/* Enable writing to the
						 * earth bit planes.
						 */
		draw_earth (over_there);
		writemask (0xfff0);		/* Disable writing to earth
						 * bit planes.
						 */

		/* Notice I need two color map declarations!!! */
		mapcolor (1 << 4, 255, 0, 255);	/* Color of satellite over
						 * nothin'.
						 */
		mapcolor ((1 << 4) + 6, 255, 0, 255);
						/* Color of satellite over
						 * green ocean.
						 */
		draw_sat (over_here);
		...

	This will cause the "bit-plane" interpreter to draw a purple satellite
	over the green ocean.  Also, the program has to be smart enough to
	know NOT to draw the satellite as it passes behind the earth.  I have
	had excellent results using this technique.


	2)  If the eye is not in geo-synchronous orbit, you could employ the 
	same technique but only draw the half of the globe that you need...
	this cuts the number of pollywogs in half and negates the need to 
	use the Z-buffer (I think that z-buffering slows rendering down by
	50% or more).

			Hope I've helped,
			Steve Swenson
			Naval Underwater Systems Center
			SWENSON at NUSC-WPN.ARPA
------



More information about the Comp.sys.sgi mailing list