[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OpenGL Transparency
Dennis Payne wrote:
>
> I've been working with an OpenGL program recently. None of the windows
> users have any problems but under Linux there is a minor drawing
> problem. A crumbling wall texture has a transparent area near the top.
> Except instead of being entirely transparent, you can notice it
> especially another transparent area of a crumbling wall.
>
> Since I'm not familiar with OpenGL I'm unsure where to look for the
> problem. Any suggestions?
I *think* I understand what you are talking about - although a clearer
description would help - and it's absolutely NOT a Windoze versus Linux
issue...although it might well depend on your software and which graphics
card you are using on these two setups.
Question:
Does this "not entirely transparent" effect get worse as the wall gets
further away? Does it also get worse as the wall gets more edge-on to
the camera?
If that's what you are talking about then I suspect that what you are
seeing is the MIPmapping of the texture as a function of range and/or
slope.
As you probably know, MIPmapping blends adjacent texels together to
make half resolution, quarter resolution, etc maps...all the way down
to 1x1's.
With a texture that's a mixture of 100% opaque and 100% transparent
texels, that blending tends to cause the opaque texels from gradually
polluting the transparent ones (and the transparent ones gradually
affecting the opaque ones). If your wall was (say) a 16x16 map - with
just the top two rows of texels being transparent.
In the 8x8 map, things may well be OK - you have 7 opaque texels and one
transparent one...but in the 4x4 map, the top row of texels will be 50%
transparent...neither fully opaque nor fully transparent. So, when your
wall is square on to the camera and fairly close, it'll be in it's highest
one or two levels of detail - but when the range gets longer - or when it
goes more edge-on (or both), the MIPmapper will drop down to that 4x4
map and the top of your wall polygon will start to fade into view.
If this *is* your problem then the solution is to NOT use the default
gluBuildMIPMap2D function - but instead to EITHER write your own
MIPmap generator that ensures that any MIPmap texels that are derived
from a transparent texel *remain* transparent...or better still (and
what I do) is to run the default MIPmapper offline - running the
result back out into a new image file which is twice as high and the
same width as the original map and has all the MIPmaps stacked up
vertically on top of each other.
You can then pull that map into GIMP (or the paint program of your
choice) and manually tweak the lower level maps until they fit your
needs.
Yet another way to attack it is to set the glAlphaFunc to crop off
partially transparent texels - but that's rather a blunt instrument
for solving *this* issue....IMHO.
If this *DOESN'T* fit your problem - then give us a better description
of what you see (or better still post a screenshot on a web site
somewhere and email the URL).
I've written a *TON* of OpenGL under Linux and I can absolutely assure
you that this isn't a Linux-specific problem.
--
Steve Baker HomeEmail: <sjbaker1@airmail.net>
WorkEmail: <sjbaker@link.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sourceforge.net
http://tuxaqfh.sourceforge.net
http://tuxkart.sourceforge.net
http://prettypoly.sourceforge.net
http://freeglut.sourceforge.net
---------------------------------------------------------------------
To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.dk
For additional commands, e-mail: linuxgames-help@sunsite.dk