Game Development Community

Partally Transparent Materials

by Eric McQuiggan · in Torque X 3D · 09/14/2009 (6:27 pm) · 10 replies

Hey Crew,
I'm trying to put these awesome trees into my game:
Sharp Trees

The leaves do not show up in game but they do in the show tool, My trees are tree coloured spires! I think this might have to do with material settings, but I'm not sure how to set this up.

This would also help me with my older problem about refraction, because I could use a semitransparent object for that.

Thanks!

#1
09/14/2009 (8:34 pm)
They may be really old. Try opening up the max files, and re-exporting them.

Best Regards,
T.
#2
09/15/2009 (4:12 am)
Eric, which tree are you having trouble with? I downloaded and picked the first one (Banana) and saw no issues.

www.envygames.com/share/banana.jpg

I added a material definition to the leveldata.txscene file that looks like this:
<TreeMaterial type="GarageGames.Torque.Materials.SimpleMaterial" name="TreeMaterial">
      <NameMapping>data\shapes\Banana_Main</NameMapping>
      <TextureFilename>data\shapes\Banana_Main</TextureFilename>
      <IsTranslucent>false</IsTranslucent>
      <IsAdditive>true</IsAdditive>
    </TreeMaterial>

And the code to add it to the scene looks like this:
public void CreateTree()
{
    TorqueObject objTree = new TorqueObject();
    objTree.Name = "Tree";

    T3DSceneComponent componentScene = new T3DSceneComponent();
    componentScene.SceneGroup = "TreeGroup";
    componentScene.Position = new Vector3(1020, 1020, 300);
    objTree.Components.AddComponent(componentScene);

    T3DTSRenderComponent componentRender = new T3DTSRenderComponent();
    componentRender.ShapeName = @"data\shapes\Sharp_Ban01.dts";
    componentRender.SceneGroupName = "TreeGroup";
    objTree.Components.AddComponent( componentRender);

    TorqueObjectDatabase.Instance.Register(objTree);
}

If there's a different tree causing you trouble, let me know and I'll try it out too.

John K.
www.envygames.com
#3
09/15/2009 (1:09 pm)
Awesome, thanks alot!
I got the Banana to work, so I'm going to try others. I don't really understand how that material works though, as it seems like you never actually assign it to the object.

#4
09/15/2009 (4:46 pm)
Hey John,
Unfortunately, it looks like the material doesn't do anything. I disabled it from the leveldata.txscene, the leaves still show up. I didn't know before, but I figured out that the Banana Tree's leaves are not transparent, so they are dictated by the same material as the trunk, this is not the case for other trees!

But the Banana tree does have a transparent section:

ShowTool:
ericmcquiggan.com/pics/Screens/BananaShow.PNG
And same tree in game:
ericmcquiggan.com/pics/Screens/BananaGame.PNG
I remember you had talked about partially transparent sections on a fighter jet model, but I couldn't find that thread.

Thanks for you help.
#5
09/16/2009 (6:58 pm)
Hi Eric, of course I had to pick the one model that had no problems :) I remember writing about and F16 flame effect, but that was with a customized bloom shader. I'll check out the rendering code again to see if anything looks wrong. I'll also try another tree model with transparent leaves textures.

John K.
www.envygames.com
#6
09/16/2009 (7:28 pm)
Eric, since you did not call out a specific tree, I picked another one - poplar (since it sounds like popular). The files in the project are: Poplar_Main.jpg and Sharp_Poplar01.dts. I did the same exact thin, Here's the XML code.

<TreeMaterial type="GarageGames.Torque.Materials.SimpleMaterial" name="TreeMaterial">
      <NameMapping>data\shapes\Poplar_Main</NameMapping>
      <TextureFilename>data\shapes\Poplar_Main</TextureFilename>
      <IsTranslucent>true</IsTranslucent>
      <IsAdditive>false</IsAdditive>
    </TreeMaterial>

And the picture... If I'm missing something, let me know. I did not preview in ShowTool.
www.envygames.com/share/poplar.jpg

John K.
www.envygames.com
#7
09/16/2009 (7:40 pm)
With respect to your earlier post... The isn't necessarily a direct mapping between the texture and the model. Instead, the mapping is between a texture and a material. In the material definition above, the connection between material and the texture is done by path-matching the "TextureFilename" property. The mapping between the model's internal reference to a texture and the material definition is done via the NameMapping property. So, if a model has multiple textures, then there should be multiple materials defined as above. If they use transparency, then the IsTranslucent property must be set to true.

John K.
www.envygames.com
#8
09/18/2009 (3:55 pm)
Ah, so when I define a Material, and later load a DTS, Torque will check the DTS to see if it contains texture files already defined as materials? Cool.

Here is a Locust:
www.ericmcquiggan.com/pics/Screens/GreatSuccess.PNG
I guess the isTranslucent and isAdditive were switched around, and now it all works.

Thanks a lot!
Eric.
#9
09/18/2009 (4:03 pm)
Excellent, looks good Eric.

John K.
www.envgames.com
#10
09/18/2009 (7:19 pm)
Sorry Tilan, I didn't get back to you, but I don't currently have the source max files, just the DTS, which, in my understanding, are designed to prevent reverse engineering.