[gameprogrammer] Re: OpenGL Colours and Alpha

On Tuesday 31 October 2006 20:01, Alan Wolfe wrote:
> instead of drawing alpha enabled objects back to front there is also
> some kind of trick disabling the zbuffer but its really fuzzy in my
> memory... :P

Yes drawing alpha blended with zbuffer writes disabled and reads enabled 
should be enough. But if one has partly opaque objects these will need 
two passes. One for opaque parts and one for translucent parts.

For GL2.0+ (fragment shaders that support fragment depth writing).
Better aproach is to make the fragment shader modify the depth of  
the translucent fragments. This way one can have window with frames etc 
as a single quad, without the need for the second pass.
This will also reduce artifacts produced by the two pass system.

The only downside for this compared to the z-ordered rendering is that 
in some cases the colors produced by multiple translucent surfaces will 
be different due to the intermediate precisions.

> On 10/31/06, Matthew Weigel <unique@xxxxxxxxxxx> wrote:
> > Alan Wolfe wrote:
> > > Heya Steve,
> > >
> > > Yep you got it, you have to enable blending
> > >
> > > glEnable(GL_BLEND); is the way to do it i think (dont have any gl
> > > code right here at the moment!)
> > >
> > > you also can change the type of blending you want with the
> > > glBlendFunc command, so you can do alpha blending, additive
> > > blending, multiplicative blending, difference blending etc. (:
> >
> > You also *have* to order the drawing of objects with an alpha value
> > less than 1 - draw objects that are further away first.  This way,
> > as closer objects are drawn, they can take into account the colors
> > of things behind them.
> >
> > For brightness, you may also want to switch to lights and materials
> > instead of colors.

This is very true. And don't forget that there is no law that says that 
one can't use higher values than 1.0 as color component. Although all 
the color components are clamped in the end to be between 0.0 and 1.0 
one can use say 5.0 in laser color. This way it will need only 20% of 
the light from 1.0 intensity light source to be fully light.

> > --
> > Matthew Weigel
> >
> > ---------------------
> > To unsubscribe go to http://gameprogrammer.com/mailinglist.html

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: