[SOLVED] 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
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

[SOLVED] Obj transparency problem

Post by zielin »

Hello,

I have problem during model loading from obj. I'm using Irrlicht 1.8.
I have tree model, which has leaves created on polygons with textures (TGA). Problem is that around leaves i have white or black 'halo'.

Here is my code:

Code: Select all

 
            scene::IMesh *mesh = m_device->getSceneManager()->getMesh( (m_repoDir + "/" + object.getDirectory() + object.getFileName()).toStdString().c_str());
 
            if (mesh != NULL)
            {
                m_node = m_device->getSceneManager()->addOctreeSceneNode(mesh);
 
                if (m_node != NULL)
                {
                    m_node->setPosition(core::vector3df(m_projectElement->getX(), m_projectElement->getY(), m_projectElement->getZ()));
                    m_node->setMaterialFlag(video::EMF_GOURAUD_SHADING, true);
                    m_node->setMaterialFlag(video::EMF_ANISOTROPIC_FILTER, true);
                    m_node->setMaterialFlag(video::EMF_LIGHTING, false);
                    m_node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
 
                    m_node->getMaterial(0).Shininess = 50.0f;
                    m_node->getMaterial(0).EmissiveColor.set(0,200,200,200);
                    m_node->getMaterial(0).DiffuseColor.set(0,200,200,200);
                    m_node->getMaterial(0).AmbientColor.set(0,200,200,200);
                    m_node->setScale(core::vector3df(100, 100, 100));
                }
           }
 
Device and driver initialisation:

Code: Select all

 
            SIrrlichtCreationParameters params;
            params.Fullscreen = false;
            params.WindowSize = core::dimension2d<u32>(1024, 768);
            params.Stencilbuffer = true;
            params.AntiAlias = true;
            params.LoggingLevel = ELL_INFORMATION;
            params.WithAlphaChannel = true;
            params.Doublebuffer = true;
            params.DriverType = video::EDT_DIRECT3D9;
            params.Stereobuffer = false;
            params.WindowId = widget->winId();
 
And here are texture options after initialization

Code: Select all

 
    getDriver()->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
    getDriver()->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY,true);
    getDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
 
The output rendering looks like this:
Image

I don't know what's going wrong. Please help me find error or suggest where I should search for errors.
Thanks.
Last edited by zielin on Tue Dec 03, 2013 9:57 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Obj transparency problem

Post by hybrid »

Try the same without the octree node, make sure that there is really only one material, and check out the ADD_COLOR material. Also check the material file of your obj mesh, maybe there's some strange and/or unsupported setting included.
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: [SOLVED] Obj transparency problem

Post by zielin »

As hybrid said, problem was in material but not in model but code. Somewhere deep in function responsible for replacement of models, i've been overwriting material type in something default without information about alpha.
Now I'm using EMT_TRANSPARENT_ALPHA_CHANNEL on loaded model and everything is fine.

Thanks.
Post Reply