[comp.sys.sgi] Alpha blending ...

gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) (09/05/90)

Is there any way I can use the alpha blending hardware to display 
a possibly intersecting set of polygons ??  Since the polygons 
can intersect, I have no way of properly ordering them in z ...


thanks,
gautam

e-mail : gautamm@ncsa.uiuc.edu

gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) (09/05/90)

In article <1990Sep5.151623.12906@ux1.cso.uiuc.edu> gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) writes:
>Is there any way I can use the alpha blending hardware to display 
>a possibly intersecting set of polygons ??  Since the polygons 
>can intersect, I have no way of properly ordering them in z ...
>
	Apologies for not including this in the earlier message .. I
am trying to run this on a GT ( using gl ).

>
>thanks,
>gautam
>
>e-mail : gautamm@ncsa.uiuc.edu
>

thanks,
gautam

e-mail : gautamm@ncsa.uiuc.edu

robert@texas.esd.sgi.com (Robert Skinner) (09/06/90)

In article <1990Sep5.151623.12906@ux1.cso.uiuc.edu>,
gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) writes:
|> Is there any way I can use the alpha blending hardware to display 
|> a possibly intersecting set of polygons ??  Since the polygons 
|> can intersect, I have no way of properly ordering them in z ...
|> 
|> 
|> thanks,
|> gautam

I can only assume from the phrase "no way of properly ordering them in z", 
that you are doing hidden surface elimination with the painter's algorithm,
where you paint every polygon from the farthest to the nearest.  

You should use Z-buffering instead.  The Z buffer does hidden surface
elimination at each individual pixel, so intersecting primitives are
no problem.  Its a snap to use, just do this 

	zbuffer( TRUE );
	gconfig();

after you open the window, and call zclear() after clear().
The GT does z-buffering as fast as regular polygons, and there is no 
need to sort your primitives by depth, so your program should run
faster.

Hope this helps,
Robert Skinner
robert@sgi.com

	They are your parent's worst nightmare --
	because they ARE your parents.

				- Radio add about the Jefferson Airplane
				  reunion concert, Berkeley, Sept '89

" ratcliffe) (09/06/90)

In article <1990Sep5.171056.23011@odin.corp.sgi.com> robert@sgi.com writes:
>
>In article <1990Sep5.151623.12906@ux1.cso.uiuc.edu>,
>gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) writes:
>|> Is there any way I can use the alpha blending hardware to display 
>       .............
>You should use Z-buffering instead.  The Z buffer does hidden surface
>elimination at each individual pixel, so intersecting primitives are
>no problem.  Its a snap to use, just do this 
>
>	zbuffer( TRUE );
>	gconfig();

  correction:  it is not necessary to include a call to "gconfig();"
  after calling "zbuffer(TRUE);".  jury, strike the above reference to 
  gconfig(); from your collective minds.
--
                                             daveus rattus   

                                   yer friendly neighborhood ratman

                              KOYAANISQATSI

   ko.yan.nis.qatsi (from the Hopi Language)  n.  1. crazy life.  2. life
     in turmoil.  3. life out of balance.  4. life disintegrating.  
     5. a state of life that calls for another way of living.

gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) (09/06/90)

In article <1990Sep5.171056.23011@odin.corp.sgi.com> robert@sgi.com writes:
>
>In article <1990Sep5.151623.12906@ux1.cso.uiuc.edu>,
>gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) writes:
>|> Is there any way I can use the alpha blending hardware to display 
>|> a possibly intersecting set of polygons ??  Since the polygons 
>|> can intersect, I have no way of properly ordering them in z ...
>|> 
>I can only assume from the phrase "no way of properly ordering them in z", 
>that you are doing hidden surface elimination with the painter's algorithm,
>where you paint every polygon from the farthest to the nearest.  

        I am sorry I didn't make myself very clear -- I am trying to
do transparent( translucent ) surfaces -- therefore the alpha
blending.  The problem is that if I use the z-buffer ( which I am
using), parts of intersecting polygons are not rendered at all ( the
part which lies behind values in the z-buffer). I can get this 
portion if I re-render the polygon with the zfunction changed to
test for values of z GREATER than the values in the z-buffer.
However, I  haven't been able to get the alpha values right. Does
anyone have any experience with this ?

Thanks once again !
gautam


>Hope this helps,
>Robert Skinner
>robert@sgi.com
>

thanks,
gautam

thant@horus.esd.sgi.com (Thant Tessman) (09/06/90)

In article <1990Sep5.190659.14015@ux1.cso.uiuc.edu>,
gautamm@kandinsky.ncsa.uiuc.edu (Gautam Mehrotra) writes:
> 
>         I am sorry I didn't make myself very clear -- I am trying to
> do transparent( translucent ) surfaces -- therefore the alpha
> blending.  The problem is that if I use the z-buffer ( which I am
> using), parts of intersecting polygons are not rendered at all ( the
> part which lies behind values in the z-buffer). I can get this 
> portion if I re-render the polygon with the zfunction changed to
> test for values of z GREATER than the values in the z-buffer.
> However, I  haven't been able to get the alpha values right. Does
> anyone have any experience with this ?

The 'hack' that the SGI demos use is to draw all of the solid
stuff normally, and then turn on the z-buffer write mask (using
zwritemask) and draw all the alpha-blended stuff.  It will
z-buffer correctly against the solid stuff without putting
anything in the z-buffer to mess up subsequent alpha-blended
stuff.

This isn't correct, but it looks okay for highly transparent
stuff and where the colors of the transparent polygons don't 
vary too much.

The 'correct' way is to turn off the z-buffer and depth-sort
the transparent stuff (painter's algorithm (maybe via BSPTree)).

This is a hard problem.  There are some other tricks
that give good approximations, but I don't know enough about
them to comment.

> 
> thanks,
> gautam

thant