Wintermute Engine Forum

Wintermute Engine => Bug reports => Topic started by: Eshaktaar on March 25, 2008, 07:20:08 PM

Title: Strange Graphic Glitch with Texture Alpha Channel
Post by: Eshaktaar on March 25, 2008, 07:20:08 PM
Here's something rather puzzling: I've got a low-poly character whose hair makes use of the texture's alpha channel. The problem is that the transparency seems to be bugged on one side of the character:

(http://www.hulub.ch/temp/AlphaWeirdness01.jpg)
Looking okay. Don't mind the floating strands of hair, I pulled them out for testing.

(http://www.hulub.ch/temp/AlphaWeirdness02.jpg)
On this side, the transparency only works with fully transparent parts (i.e. black pixels in the alpha channel) of the texture.

(http://www.hulub.ch/temp/AlphaWeirdness03.jpg)
As you can see, the glitch is only on one side.

At first I thought it had something to do with the polygons being mirrored, put by pulling out strands and simply rotating them by 180° I could make the glitch appear/disappear (as you can see with the hair above the character's head), and it didn't matter on what side (left or right of the character's symmetry axis) the polys were (the floating hair in the second image is behind the character, on his right side where all the "good" hair is).

I suspect it's got something to do with the polygons' normals. All the hair polygons on the left side of the character's head have normals which point to the left, and those are the ones affected. I made a small example 3d actor to test this, which you can download here: AlphaTest.zip (http://www.hulub.ch/temp/AlphaTest.zip)
Just copy the zip's content into the actors folder of one of your projects and look at the preview. The actor consists of two pairs of quadratic planes which got a texture with alpha channel on them. One pair faces forwards, the other one backwards. One of the pairs shows the same glitch, at least on my machine:

(http://www.hulub.ch/temp/AlphaWeirdness04.jpg)

I could reproduce the glitch on two computers (one with an ATI and one with a GeForce card), so I guess it's not a problem with my PC. I tried both TGAs and PNGs, with no difference. I'm using 3ds Max with the Panda DX exporter, by the way. Can anybody else reproduce this?
Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Jyujinkai on March 25, 2008, 08:34:48 PM
you should nvr mirror anything in 3D is makes all sorts of problems. Load up your file and make sure the normals is all working as you expect. Then before export to wme reset the tranforms of the mirrored stuff. So you have 0,0,0 on all transforms and all vertexes have no position information .. remember everytig is stored if you mirror something you are in fact gatting a real mirror. as in the vertex order is reversed, normal are flipped.. etc etc.

Most 3D apps now have advanced mirroring functions to avoid thse problems. Like the Symmetry modifier or the mirror modifier in Max. Still even in these cases you will need to collpace everything to a zeroed out mesh.
Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Eshaktaar on March 25, 2008, 08:53:15 PM
I also thought it was the mirroring at first, but just pulling out correct hair polys and turning them by 180° makes the glitch appear. The character is already one editable poly (meaning the hair strands aren't separate objects) in 3ds Max and I reset all transformations via Reset XForm.

In the zip file is an example where I just created two planes, then copied and turned them by 180°.
Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Eshaktaar on March 28, 2008, 08:19:04 PM
So... am I the only one having this problem? Did anyone successfully create/import a character with hair planes without getting these glitches? Does the 3d actor from AlphaTest.zip (http://www.hulub.ch/temp/AlphaTest.zip) look all right on someone's system?

I'm asking because I'm at a point where I have to decide how to model my 3d character's hair, and I'd rather not rely on sculpted polys.
Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Stucki on March 28, 2008, 09:14:32 PM
i have the same problem with my chars.
i am using stencil shadows .. maybe its because of shadow casting.....

Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Eshaktaar on March 28, 2008, 09:37:44 PM
Thanks for the reply! I was getting the feeling I was imagining things. ::slug
The screenshots above were made with stencil shadows disabled. I did notice some additional oddities when they were enabled, though (like shadows appearing on the planes).

I know alpha textures are a fiddly topic, as almost any engine has its own problems with rendering them.
Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Mnemonic on April 05, 2008, 05:07:28 PM
I know alpha textures are a fiddly topic, as almost any engine has its own problems with rendering them.
Yes, because unfortunately this seems to be a generic problem with no good solution... The issue isn't caused by normals, but by z-buffer. Basically the polygons painted first will "win". Now depending on how your actor is rotated, either the right transparent polygons win (are painted earlier) or they don't. Sadly, I can't offer you a workaround other than "don't use layered semi-transparent polygons".
Title: Re: Strange Graphic Glitch with Texture Alpha Channel
Post by: Eshaktaar on April 05, 2008, 10:33:38 PM
Thanks for your reply. To stay on the safe side I made the character without "alpha hair", so it's okay.