Problem with transparent objects

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
JunkerKun
Posts: 97
Joined: Mon Jan 28, 2013 12:52 am

Problem with transparent objects

Post by JunkerKun »

I realise it is impossible to tell what exactly is the problem without having a look at the source but I can't really publish it right now - it would be quite big since it's tied to some external resources. But I think just some suggestions is better than nothing.

So, when I draw my objects with per-pixel lighting on them, I use this code:

Code: Select all

core::array<scene::ISceneNode*> nodes;
        GetSceneManager()->getSceneNodesFromType(scene::ESNT_ANY, nodes);
        //Update nodes
        for (u32 i=0; i<nodes.size(); i++) {
            if (nodes[i]->getType()==scene::ESNT_MESH || 
                nodes[i]->getType()==scene::ESNT_ANIMATED_MESH ||
                nodes[i]->getType()==scene::ESNT_BILLBOARD) {
                if (nodes[i]->isVisible()) {
                    GetLightsManager()->UpdateLights(nodes[i]);
                    nodes[i]->OnAnimate(GetElapsedTime());
                };
                continue;
            };
            if (nodes[i]->getType()==scene::ESNT_CAMERA) {
                nodes[i]->OnAnimate(GetElapsedTime());
                continue;
            };
        };
        //Update welders
        GetWeldersManager()->Update();
        //Update lights
        for (u32 i=0; i<nodes.size(); i++) {
            if (nodes[i]->getType()==scene::ESNT_LIGHT) {
                nodes[i]->OnRegisterSceneNode();
            };
        };
 
        //Render everything
        objectsManager->GetCameraManager()->GetCameraNode()->render();
        lightsManager->OnRenderPassPreRender(scene::ESNRP_SOLID);
        for (u32 i=0; i<nodes.size(); i++) {
            if (nodes[i]->getType()==scene::ESNT_MESH || 
                nodes[i]->getType()==scene::ESNT_ANIMATED_MESH ||
                nodes[i]->getType()==scene::ESNT_BILLBOARD) {
                if (nodes[i]->isVisible()) {
                    nodes[i]->render();
                };
                continue;
            };
        };
        GetWeldersManager()->Render();
        std::vector<scene::ISceneNode*>* noLights = GetShadowsManager()->GetNoLights();
        for (u32 i=0; i<noLights->size(); i++) {
            noLights->at(i)->setVisible(true);
            noLights->at(i)->OnAnimate(GetElapsedTime());
            noLights->at(i)->render();
            noLights->at(i)->setVisible(false);
        };
        
        return true;
And when I draw them without shaders at all I use this:

Code: Select all

sceneManager->drawAll();
        weldersManager->Update();
        weldersManager->Render();
        return true;
But when I change node's material type to EMT_TRANSPARENT_ALPHA_CHANNEL it's not being drawn. The material is not changed to per-pixel lighting, I checked. Also, when I use the code for non-shader rendering it works fine, translucency is there (but I can't use it because of delay in bones update). EMT_TRANSPARENT_ALPHA_CHANNEL_REF works fine in both modes. It also works with cubes and billboards, but not meshes or particles. Any ideas?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Problem with transparent objects

Post by hendu »

The meshes check the draw pass matches with their transparency. Ie a transparent mesh only render()s in the transparent pass. You can set the pass in current irr with a smgr func.
JunkerKun
Posts: 97
Joined: Mon Jan 28, 2013 12:52 am

Re: Problem with transparent objects

Post by JunkerKun »

Oh? How do I do that exactly?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Problem with transparent objects

Post by hendu »

grep the scene manager header for ESNRP. I don't have trunk sources at hand.
Post Reply