TGA and OBJ transparency problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Phxx
Posts: 13
Joined: Wed May 10, 2006 7:55 pm

TGA and OBJ transparency problem

Post by Phxx »

Hi all!

I'm having an issue with a transparent tga textures on a table:
Please look at the following. The table should be glass, but only half of the table legs are visible (see left image) , but if you go beneath it, all are visible. (see right image)


Image

Any ideas?

Thanks in advance.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Does this effect change if you use more or less transparency? Maybe try 0.75, 0.25 and 0.0 opacity.
Phxx
Posts: 13
Joined: Wed May 10, 2006 7:55 pm

Post by Phxx »

hybrid wrote:Does this effect change if you use more or less transparency? Maybe try 0.75, 0.25 and 0.0 opacity.
I tried setting SMaterial::MaterialTypeParam to 0, 0.5, 0.75, etc.
The effect is still the same. Once i go over 0.52 the transparent material is completely gone! And below that value it just looks like it does now.

Other things i've tried:
- Changing the resolution of the texture (it is now 256*256 mapped onto it using UWV mapping)
- Changing the legs of the table
- flipping the normals

Nothing helps.
Does anyone have any other ideas?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, OBJ loader has no support for alpha channel transparency which is the type of transparency I would have expected here. So first of all I'd need to know which type of transprency you chose for your mesh in the modeller.
There are several types available in Irrlicht, this has to be adapted to the obj format. Currently supported are ADD_COLOR and VERTEX_ALPHA (which both don't use the ref parameter, though).
So in addition to the type you've set I'd also need the .obj file to see which format flag is used.
Phxx
Posts: 13
Joined: Wed May 10, 2006 7:55 pm

Post by Phxx »

hybrid wrote:Ok, OBJ loader has no support for alpha channel transparency which is the type of transparency I would have expected here. So first of all I'd need to know which type of transprency you chose for your mesh in the modeller.
There are several types available in Irrlicht, this has to be adapted to the obj format. Currently supported are ADD_COLOR and VERTEX_ALPHA (which both don't use the ref parameter, though).
So in addition to the type you've set I'd also need the .obj file to see which format flag is used.
http://www.nimation.nl/yoran/table.zip
Here you'll find the texture and the OBJ.
I switched from 3DS to OBJ because of bugs, and now OBJ seems to be lacking some things as well :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You don't use mtl file, how do you apply the texture? You won't get special materials with this.
Phxx
Posts: 13
Joined: Wed May 10, 2006 7:55 pm

Post by Phxx »

The material file is not needed.
I apply all material settings in irrlicht.
Because my material has to be dynamic and it can be altered by the user.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, then please provide the code (material settings etc) that you use. How do you get some parts to be colored, while others are textured? You just have one meshbuffer (because you only have one group in your mesh).
Phxx
Posts: 13
Joined: Wed May 10, 2006 7:55 pm

Post by Phxx »

First note: I tried loading this model in other 3d modellers and they have the same problem the irrlicht engine has, so it is probably an error in the model itself and nothing to do with irrlicht.

Anyway I have 1 mesh.
The mesh is UWV mapped using 3D Studio Max. The TGA contains an alpha channel. So certain parts, the top of the table will become translucent.

Here is a code snippet:

Code: Select all

driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
driver->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY,true);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);


scene::IAnimatedMesh* mesh = smgr->getMesh(THE_TABLE_MODEL);
scene::ISceneNode* n = smgr->addOctTreeSceneNode(mesh,rootNode,FURNITURE_NODE, 1024);


n->setMaterialFlag(video::EMF_GOURAUD_SHADING, true);		
n->setMaterialFlag(video::EMF_ANISOTROPIC_FILTER, true);

n->getMaterial(0).Shininess = 50.0f;
n->getMaterial(0).EmissiveColor.set(0,200,200,200);
n->getMaterial(0).DiffuseColor.set(0,200,200,200);
n->getMaterial(0).AmbientColor.set(0,200,200,200);


n->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);

n->setMaterialTexture(0, 0);
n->setMaterialTexture(0, driver->getTexture( THE_TEXTURE_CONTAINING_THE_ALPHA_CHANNEL );
Post Reply