Game Development Community

Mip mapping and alpha testing

by Justin Tolchin · in Torque Game Engine Advanced · 04/28/2005 (9:28 am) · 9 replies

There are just a couple of features I've seen in the Gamebryo graphics engine and I was wondering if they are available in Torque.

Mipmapping, specifically how to turn it off for a paticular texture, shader and/or custom material.

Alpha testing, which lets you write to the z buffer only when the alpha value of an object is above a certain number.

The paticular problem I'm having is with renduring steel girders represented by alpha values in the texture. The only provision I see in torque is the translucentZWrite flag which writes z values of the opaque and transparent parts of the texture the same.

#1
04/28/2005 (1:13 pm)
TSE doesn't currently support those features through the Materials system, but they sound like good additions to me. I'll put them on the list for MS3.

Until then you shouldn't need the alpha test feature to get the look you want, it will just boost the efficiency of your translucent textures. If you want a fully transparent pixel, make the alpha value black.
#2
04/28/2005 (1:28 pm)
Thanks for the info, but the alpha value is fully zero now and I'm still having trouble. I think my problem is that mipmapping is blending some of my alpha values so there is a little halo around the front girders where the back girders and other buildings are being cut out.

www.tolchin.net/gg/alphaissues.jpg
#3
04/29/2005 (10:31 am)
I don't think the engine is properly aware that's a translucent material... Is that a DIF?
#4
04/29/2005 (3:04 pm)
Nope, just a nice normal .dts file. :-)
#5
04/29/2005 (7:51 pm)
Honestly that looks more like an artifact of your PNG exporter than something the engine is doing.
#6
04/30/2005 (1:38 pm)
Nah, it's draw order. See how the terrain is showing on the edges? You might try breaking the girder up into 4 submeshes.
#7
04/30/2005 (10:44 pm)
@Brain - This thread reminds me that the translucentZWrite patch i submitted is only obeyed by interiors at the moment. It has no effect on DTS shapes when it probably should.
#8
05/02/2005 (4:54 pm)
There's a few problems with that screenshot.

The"halo" is there because you need to be more aggressive in adding blackness to the alpha of those textures.

The other problem is the draw order, which is always a problem in drawing these types of translucent objects. Come to think of it, alpha testing might solve this problem if the discarded pixels are not written to the zbuffer. Otherwise a more complex scenegraph sorting is necessary to get this taken care of. Similar to what you did for the interiors Tom, but all translucent objects of this type need to be batched and drawn at once.
#9
05/03/2005 (10:56 am)
Thank you all for the suggestions.

I used this data block to define the material so the engine should definitely be aware that the material is translucent.

datablock Material(BCTower)
{
baseTex[0] = "~/data/shapes/buildings/bctower/broadcasttower";

translucent[0] = true;
blendOp[0] = LerpAlpha;
translucentZWrite = true;
};

The texture has completely black/white alpha values in the texture. I think that mippmapping is blending the alpha values across the surface. (Notice how much more it's spread out on the side surface than the front surface).

I'm not quite sure what you mean by "breaking the girder up into 4 submeshes" Ben, but I am thinking about redoing the geometry so that there just isn't any geometry between the girders. It just seems like a terrible waste of triangles.

P.S.
I expilictely translucent[0] = false; (I thought that was the default) on the building behind. That cleared up the draw order problem but the tower in front still looks terrible.