Game Development Community

[SOLVED] Another Transparency issue thread!

by Ken Beard · in Artist Corner · 12/03/2009 (9:05 pm) · 15 replies

I'm really racking my brain on this, I'll try to explain it as best as I can. It all makes sense in my head but putting it into words tends to be difficult for me sometimes lol. I've searched the forums and I can find people with similar problems but no real solution other then writing a custom shader for TGEA. I'm using Torque 3D so I'm hoping there is an easier solution. So here we go:

In 3ds max I have a model.

www.motorworldonline.net/images/stories/cars/leastair/003.jpg
As you can see it has semi transparent windows and head lights and some other semi transparency that you can't see. This is done via a png texture not geometry in 3ds max. The texture shares other parts of the car like badges, trim, chrome pieces and etc that are not transparent or semi transparent at all. In fact they need to be rendered solid and use a spec map that I already have ready to go.

Here is what my file looks like in Gimp so you can see where my transparency is.

www.motorworldonline.net/images/gimp.jpg
I know for a fact my PNG is exported correctly for other engines. Originally I was using Unity3D and everything imports correctly on the first try. For giggles I exported the same model to Unreal Development Kit and it worked flawless on the first try. I'm assuming for Torque 3D though I am doing something incorrect.

When I import into Torque 3D this is what I am seeing.


www.motorworldonline.net/images/torque3d1.jpg
Everything looks fine. I see the transparency is not automatic like the other engines so I do some looking around in the material editor and find transparency options. This is where I have spent about 6 hours to day tweaking and adjusting these settings and searching the forums and custom editing the materials.cs file for my car model. The result is one of two.

Following many of community member Steve's post and replies to other posts with transparency issues I come up with this:

www.motorworldonline.net/images/torque3d2.jpg
Semi transparency on the windows looks great as does my specular map. But now the model is not rending correctly. Anywhere I have textures that use trim or chrome disappear or look incredibly odd at certain angles. Here is a video for reference:

www.motorworldonline.net/index.php?option=com_content&view=article&id=12...

For the life of me I can not figure this out. Using only the alpha threshold works but I loose my semi transparency all together for the windows like so...

www.motorworldonline.net/images/torque3d3.jpg
Does anyone here have a clue what I am doing wrong? I see the common response is to make my windows a separate file. While this is an option, its an option I'm trying to avoid when it seems like this is such a simple feature. Especially when other engines support it out of the box. Its a waste of video memory and will result in me having to go back over 2 years of work and remodel my cars windows and trim around these limitations. I really hope someone can tell me I'm just over looking a simple setting!

Again anyone who can help me get going in the right direction, I would greatly appreciate it. Thanks everyone!

- Ken

#1
12/03/2009 (10:04 pm)
The way that photoshop creates the alpha in PNG files is not compatible with TGE/TGEA/T3D. Torque expects that the alpha channel in the PNG is actually a seperate channel in the PNG. The previous reccomendation was use use SuperPNG to same the PNG file from PhotoShop however the author of SuperPNG has updated his plugin to use the same method of saving the alpha as photoshop.

See this article on TDN

This article has a link to an archived version of the old SuperPNG photoshop plugin. Which will save the correct PNG version. There are various posts and tutorials on this website about this issue with creating transparent textures for use with torque.

You might also want to consider using .DDS for your textures due to its performance benifits over using PNGs and JPGs.
#2
12/03/2009 (10:14 pm)
Thanks for your reply Matt, the DDS plug in has the same exact results. Works fine in Unreal though. Haven't tried again in Unity3D yet with the DDS. I will try the older SuperPNG plug in and see where that gets me!
#3
12/03/2009 (10:19 pm)
Nope same results, parts of the mesh that share the same texture are still showing up very oddly as seen in the video I posted. :(
#5
12/03/2009 (10:26 pm)
When working with .DDS you have to make sure that you use the right export settings and .dds version for the texture type that you are exporting.
#6
12/03/2009 (11:05 pm)
I greatly appreciate your help. :) From reading the TDN and searching the forums (http://www.torquepowered.com/community/forums/viewthread/78814) I'm understanding that I need to use DXT3/5 for the texture. DXT5 is my choice since I need the alpha channel. In materials.cs I need to set translucent = true; to my linked dds file to tell it what the purpose of the alpha channel is for in my RGBA. My RBG channel is only one layer, my background is locked and solid gray in color.

In Torque 3D I am still presented with the same messed up issues. My chrome and trim still end up looking like they are inverted on the model when transparency is turned on. With it off, the model looks fine but of course I don't have any transparency. Really at a loss here.

No Transparency
www.motorworldonline.net/images/torque3d4.jpg
Transparency On:
www.motorworldonline.net/images/torque3d5.jpg
If you really want to be technical the transparency works great and I am achieving the desired effects on the glass and trim, but the other parts of the mesh that share this same material that do not have any kinda of alpha settings on them are causing the mesh to appear to have some sort of inverted mesh look. As you can see above if you look at the tail lights in both pictures.



#7
12/03/2009 (11:49 pm)
Is there any way that you could send me a DTS/Collada file and your textures so that I could take a better look at what the issue might be?
#8
12/03/2009 (11:50 pm)
Would be very grateful for the help! I'll upload the files to my site, where would you like me to email the link?
#9
12/03/2009 (11:57 pm)
No problem, my email is on my profile page.
#10
12/04/2009 (12:12 am)
Sent, thanks again I really do appreciate you taking the time to try and help me out. I'm sure its some inane detail that I am over looking.
#11
12/04/2009 (12:44 am)
@Ken

The issue is that T3D is a deferred renderer and Unity and Unreal are traditional forward renderers.... the rules for transparency are different.

So first thing... in you will not get shadows or more than 4 lights on anything semi-transparent in T3D 1.0 or 1.1. There is a new published technique for getting up to 4 layers of shadowed and lit transparent surfaces working for deferred renderers, but its gonna be a bit longer till we implement and ship that.

I would suggest putting your opaque and cutout alpha (like the grill) into a seperate material. These elements can render deferred and get full lighting and shadowing.

The semi-transparent glass parts need to be in another material which will be forward rendered after the opaque bits.

There may be some tricks to allow you to keep it all in the same texture, but it will take a little experimenting to work that out.
#12
12/04/2009 (9:05 am)
Hi Tom,

Thanks so much for explaining that, at least now I can rest easy knowing its not in my artwork! LOL. Well yes it is, but you guys know what I mean. Thank you everyone for your help. I hope you guys didn't take offense to me comparing to Unity and Unreal I was only using that as reference to show my PNG settings were in fact correct for the transparency. I love Torque 3D and wont be going anywhere!

It sounds as though splitting those textures up will be the easiest way to go for now unless anyone has any tips to get me going in the right direction to keep my original texture.

Again, Tom and Matt really appreciate your input!
#13
12/04/2009 (11:30 am)
@Ken: yep, just trying to start with the simplest potential issues first and work up from there. Glad to see that Tom was able to chime in with the actual cause.

I will try a few things this weekend and see if I can come up with any other options that might help you out.

Very nice modeling BTW, some clever texture use as well, shouldn't take much to have it looking great in T3D. I am going to go out on a limb and guess that given your focus that you love the T3D road system. :)
#14
12/04/2009 (3:19 pm)
@Ken:
You should be able to use the same texture image file (PNG/DDS) for both the transparent bits and the opaque bits. So no need to redo your texture file work.

What you'll need to do is define two separate materials. One for the transparent parts, and one for the opaque parts. And have these two materials point back to the same texture file.

Within 3DS Max you'll need to break up your model into the transparent and opaque bits, and have them refernece these different material names. Unfortunately I can't help you do that as I don't use Max.

- Dave
#15
12/04/2009 (7:39 pm)
Dave! I could hug you and not even still want a bud light man! I'm not even sure why that option never occurred to me. Now I need to sit in the corner with my dunce hat on for a while!

www.motorworldonline.net/images/torque3d6.jpg
Thank you everyone, can't tell everyone how much I appreciate their time and patience in helping me with this matter! Couldn't be happier to have come back to Garage Games after all these years!

And yes Matt, the Torque guys had my $750 before they even got done completing the sentence of road and river editors!