Game Development Community

DIFs and DTSs not rendered behind transparency

by Amanda Thompson · in Artist Corner · 09/19/2005 (12:25 pm) · 8 replies

Hi. We're trying to get transparent textures to work in TGE with our CS generated DIFs. They kind of work. :) But, most of the time the other DIF and DTS objects are not drawn behind the transparency. The terrain is rendered behind the alpha, but like I said, the DIFs and DTSs are not. The DTS objects are not rendered at all, and the DIFs just look like a shadow. At certain angles the other DIFs render behind the transparency, but it's jumpy and happens rarely.

Is there something I need to do to Cartography shop file before I export? I've read through several forums on GG and sickhead games, and we haven't found a successful solution. I'm using TGAs in CS and PNGs in Torque. We tried this resource: http://www.garagegames.com/index.phpsec=mg&mod=resource&page=view&qid=4648

I'm an artist. A programmer and I are trying to sort this out. Any information would be very much appreciated. We'd really like to be able to use transparent textures for railing and fences for aesthetics and collisions. Too bad we can't get TSE :)

We might try using MaptoDif, but I'd really rather not since we have the CS Torque Pipeline. It's close to working so I'm hopeful. -Sorry if I missed something in other forums.

Thanks

#1
09/19/2005 (11:05 pm)
Hi Amanda. The issue is not one in CartShop or Pipeline, but in the Torque engine itself. You would have the same issue with map2dif.

The drawing order in the engine has to change for it to work as you want it. In the Torque Shader Engine it skips rendering transparent DIF surfaces until after all other DIFs and DTS shapes are rendered. TGE renders the entire DIF at once... so stuff that should be behind transparent surfaces are not.

The technical details... you have to add another InteriorRenderImage to the SceneState in InteriorInstance::prepRenderImage which uses the EndSort type. You then have to modify the rendering code to not render transparent DIF surfaces until the transparent InteriorRenderImage pass occurs. Also note you need a way to tell if a surface is transparent or not. In TSE it's easy because it has "materials" which include lots of shader stuff including if a surface is to be rendered transparent or not. There is no material system in TGE, so you'll have to invent a method.

Hope this helps.
#2
09/20/2005 (8:41 am)
Hi Tom,

Thanks a lot for the reply! I am the programmer working together with Amanda on this. We are basically just struggling to get transparencies to work. I appreciate your help, and by the way, on a side note, thanks so much for the awesome script debugger and IDE, I use it all the time and it is really useful.

I just posted on the lighting pack public forum another description about what we've been doing here: www.garagegames.com/mg/forums/result.thread.php?qt=34740#271181

The resource we incorporated does do this sorting you described (I *think*), now perhaps it's just a matter of getting it to work right? The resource implements a transparent brush, that can be created in Quark and Worldcraft with some special instructions. This is the resource we are using that John Kabus from the Lighting Pack recommended: Alpha Transparency Support for Interiors

In the resource at the bottom, it describes how to make a new brush entity for Quark and WorldCraft so the resource will work. Is there a way to create new entities in CartographyShop? From what I can tell, the values added to Quark and Worldcraft are:

alpha = 100
alphaSrc = "GL_SRC_ALPHA"
alphaDst = "GL_ONE_MINUS_SRC_ALPHA"

They are creating a new brush type I believe to do this. We'll keep cranking away at it and post any findings we have. We'd really like to keep it in CS as well like that program a lot and the art flow would be easier, but if we have to fall back on DTS shapes for transparency we are also willing to do that.

Thanks again!
#3
09/20/2005 (9:25 am)
Ok... i see your problem. The issue is that this resource requires modification to the map2dif code to support a change to the DIF format itself. Any resource that requires changes to the DIF format will not work with the Pipeline DIF exporter.

You have two options here to get past this:

First and maybe simplest for you guys is to do the modifications to map2dif and use the Pipeline MAP exporter. The Pipeline MAP exporter will export these special transparent detail brush entities. You just need to add these properties to a brush...

classname = trans
alpha = 100
alphaSrc = GL_SRC_ALPHA
alphaDst = GL_ONE_MINUS_SRC_ALPHA

These brushes then will show up in the map file and can be processed by the modified map2dif code.

Another option is to decouple these material settings from the DIF all together. This is how trasparency in TSE works. Possibly the easiest way to add this to this resource is to have a my_dif_name.cs TorqueScript file that you execute within the interior loading code. This script adds a mapping of texture names to transparency settings... off the top of my head:

$my_dif_name::my_texture_name = "100 GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA";
$my_dif_name::other_texture_name = "50 GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA";
etc...

You then do a pass thru the surfaces before it is added to the scene. You query the transparency settings using the texture and dif name from the script state and then apply it to the new surface variables. Once you're done you can tell the script system to delete all $my_dif_name::* vars.

This is just one idea of how you could add this... i'm sure there are many other options.
#4
09/20/2005 (11:07 am)
Tom,

Wow, that is great info! We will try it out right away. We are going to start with the 1st technique you suggested, as that is the direction we were already heading. It looks like the .map file is exporting but map2dif is crashing. We are going to try stepping through it with the debugger to see what the deal is.

We really appreciate the help, thanks.

- Drew
#5
09/20/2005 (2:25 pm)
Well, we got it working! Those fields work great, we didn't have to do anything else. The reason we were having a crash is because we were accidentally running our maps through a new map2dif with an older build of TGE. What can I say, it is always the little things...

It is nice to finally have this working. Pretty much all the steps we needed to take to get this going are in this thread and the one in the lighting pack forum www.garagegames.com/mg/forums/result.thread.php?qt=34740#271181. If anyone else has any questions about getting this working or needs more clarity, post here and we can give more details.

We'll update this thread if we find anything else that needs changing.

Yeah! Transparencies in our mapping program that work right - at last!

Thanks for all your help Tom,
- Drew
#6
10/12/2005 (11:27 am)
Hi. I have run into a problem. My transparent brushes worked great for a while, but yesterday, something happened. I'm not sure what happened, :) but now every time I try to export files with transparent textures and the brush preferences that Tom mentioned above, I get this error message:

Fatal-ISV: (.\entityTypes.cpp @ 2159) Brushes cannot be associated with GameEntities!

The MAPtoDIF exporter was crashing so I tried exporting straight to DIF, and that's when I got the above error message. I don't get an error message when MaptoDif crashes. When I delete brushes with the added preferences, the exporters work. I tried remaking the brushes and even making a new file with a new brush, but the exporters still crash. Files that worked friday don't work now.

I must have done something, but I have no idea what that could have been. I would really appreciate some clarification on the error message, and/or any suggestions or ideas.

Thank you,
Amanda
#7
10/12/2005 (2:12 pm)
A solution I use, is to create the difs seperately, but with the same coordinates. I'm not sure how this would be handled in CartShop, as I use QuArK. In that tool, you can mark groups as 'do not export', yet the non-exported brushes still add their offsets to the final result. So... I take a house map, dupe it. In the first map, I group all the glass as non exports, and dif out the walls. In the second map, I group the walls as non exports, and dif out just the glass. Since the coordinates remained the same, I can then load house.dif and glass.dif with the exact same position in the mission file, and they will be perfectly aligned. TSE will then render them properly.
#8
10/12/2005 (2:48 pm)
@Amanda - I seem to remember seeing this when you add a classname to a brush that map2dif doesn't understand. You sure you using the modified version of map2dif that supports the 'trans' entity?