Game Development Community

Semi-transparent object won't render

by Justin Tolchin · in Torque Game Engine Advanced · 06/09/2005 (9:49 am) · 6 replies

Hi all,

Having yet another transparency issue with TSE. Maybe someone has figured out how to make this stuff work? What we have is a "farm" .dts object which has a field of crops. The "field" and the "crops" are actually two separate meshes within the same .dts, and each has its own texture. What we're seeing is that if we add transparency to the "crop" texture it won't draw against the "field". At first we thought the texture alpha layer might be messed up (we're using SuperPNG for all our textures) but then we noticed that if you pan down to view the farm at an angle, you can see the crops draw against the terrain. They just won't draw against the field.

(Note: the field is also supposed to have transparency, but I turned that off to help isolate the problem with the crops.)

The material we're using for the crops is pretty simple:
datablock Material(FarmCrops)
{
	baseTex[0] = "~/data/shapes/buildings/farm/farm_crops";
	translucent = true;
	translucentBlendOp = LerpAlpha;
};

Here's a picture of the farm with the material transparency off:

www.tolchin.net/GG/farm_notrans.jpg
Here's the same farm with the material transparency on:

www.tolchin.net/GG/farm_trans.jpg
Notice that you can see the "tips" of the crops draw against the terrain ok.

Is there any way to solve this kind of problem? It seems like TSE just doesn't handle draw order properly with transparent objects. Is there a way to force it to adjust the draw order? Or maybe this is some sort of z-buffer issue?

Would appreciate any suggestions on this! Thanks!

#1
06/09/2005 (12:12 pm)
Ben's looking at this Justin.. should be fixed soon enough.
#2
06/09/2005 (12:20 pm)
Excellent! Thanks, Phil. Looking forward to it as we've been having a lot of problems with transparency draw-order issues with TSE.
#3
06/10/2005 (3:38 am)
I've fixed slightly broken sorting for ShapeBase derived classes. Fix is in CVS. Help you out?
#4
06/10/2005 (10:15 am)
@Ben: thanks, but I'm still having the same problems. Was the only change in shapeBase.cpp around line 2244? That's the only thing I ported over to my code.

I still see the exact same behavior, but I did want to double-check something: the new code checks for mShapeInstance->hasTranslucency(). Is this controlled purely by whether or not a material mapping has translucency set to true? Or by checking the "opacity" flag for a texture in 3DS Max? Both? The reason I ask is because when we started porting over from RTS to TSE we noticed that a lot of objects with transparency that were rendering fine in RTS simply didn't render at all in TSE. After some experimentation we noticed that if we turned off the "opacity" flag in Max and created a Material with "translucent = true", the textures would draw more-or-less correctly (with the occasional sorting issue like this one). So I assumed that the Material translucency system was supposed to replace the "opacity" setting in Max so I had the artists turn that flag off on all our textures. Just wondering if this is what we're supposed to do. I had them turn the opacity flag back on for the crop textures this morning just to see the effect, but once again the crops wouldn't render at all (even against the terrain).
#5
06/10/2005 (10:28 am)
Just to be sure, I went ahead and downloaded the latest version of TSE to a separate directory, did a build, updated the material mapping scripts and loaded the model into the demo in the mission editor. I still see the same thing: the crops render fine against the mountains/terrain/orc base (or whatever it's called). But when viewed from above the crops won't render against the farm field. :-(
#6
06/10/2005 (11:51 am)
Ok, sorry, I was wrong! It is working. Yea!!!

It was just a really bad coincidence that when I asked the artist to turn the texture opacity flag back on in Max, he also gave me a completely new version of the .dts where the crops were initially positioned underneath the farm. I needed to run the "grow crops" animation to get them to show up. Since I didn't know this, I just assumed they weren't drawing at all, when in fact they were there they were just hidden underneath the ground. :-(

However, there is still *some* weirdness going on. Since I ended up with a new .dts model with the crop texture opacity turned back on in Max and it was working, I figured I'd have the artist turn the opacity back off and see if it still worked, but it doesn't. So, it seems that at least in this case I *must* have the opacity checkbox checked in Max, even if I have the material mapping using translucency as well. Is that the way it's supposed to work? We have other models with transparent textures where I don't need the opacity checkbox on.

Secondly, I also had him turn on the opacity in Max for the "field" texture as well. Unfortunately, that once again prevents the crops from showing up! Doh! :-( I *can* get the field transparency to work with the crop transparency by using Material translucency for the field texture (but the opacity flag has to be turned back off). It's all very confusing, but at least I have a combination of solutions that works. :-)

Lastly, I just wanted to say "thank you Ben!" for fixing this. My apologies for the earlier confusion. If you have any opinions about the remaining issues described above please let me know.