Flicker of Wavefront OBJ with transparent vertex alpha (d < 1)

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
slater
Posts: 3
Joined: Mon May 23, 2016 6:06 pm
Location: USA
Contact:

Flicker of Wavefront OBJ with transparent vertex alpha (d < 1)

Post by slater »

Greetings.

I'm looking how to eliminate transparency flicker in my irrlicht scene.

The scene has a handful of transparent wavefront OBJ files loaded. The blue scene nodes in the image below represent a robot arm. The arm is behind several transparent grey walls, also OBJ. The MTL files have d = 0.3, therefore the resulting scene nodes have EMT_TRANSPARENT_VERTEX_ALPHA. There are no other materials/textures.

Image

When I pan the camera, the parts of the robot (each a different OBJ file) flicker independently as the scene tries to figure out which one is in front.

Image

I would like the flicker to be gone, i.e. the appearance the objects to remain more or less constant as I pan.

I've tried changing the Z-buffer, modifying driver features (EVDF_BLEND_OPERATIONS, EVDF_BLEND_SEPARATE) as well as changing the blend operation on the scene node material, e.g. EBO_MAX. Nothing produced the desired effect.

Image

Does this need to be done with a shader? Can someone point out an example?

Thanks so much!
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Flicker of Wavefront OBJ with transparent vertex alpha (d < 1)

Post by CuteAlien »

Seems the forum has some problems with google drive images :-( edit: Seems to work now

The problem is likely sorting. Transparency works by drawing stuff further from the camera first and that nearer to the camera later.

But Irrlicht sorts transparent objects only per node. Then nodes are drawn from back to front. Which is pretty quick and works... until you have cases with a transparent object surrounding another one (and a few more cases where it's hard to decide which is in front like comparing really large and small objects where the center can flip depending on the camera angle).

Possible workaround - split the outer node into several independent nodes. Then Irrlicht can probably handle it.

If this is a single node I suppose you would have to sort your polygons before each draw call (so furthest from camera is in front in the index-buffer).

If there are several transparent meshbuffers in the node it might be even more complicated. As the order of meshbuffers is not easy to sort unless you create your own node-types and handle the drawing yourself. Easiest there is probably splitting the meshbuffers into nodes.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
slater
Posts: 3
Joined: Mon May 23, 2016 6:06 pm
Location: USA
Contact:

Re: Flicker of Wavefront OBJ with transparent vertex alpha (d < 1)

Post by slater »

Thanks Michael for the quick reply and helpful ideas.

I tried both suggestions - sorting vertices and splitting the nodes. Sorting resolved it but requires the robot to be a single node - not feasible since the robot joints move with respect to each other. Sorting anyhow is of course way too slow to do frame-by-frame. Splitting the walls into multiple nodes helped with the flicker but it it still happens, and it's not practical to split the walls (by hand) into many small nodes.

Workaround I'm going with is to remove the faces of the walls and keep the border. No flicker with this solution:

Image

Thanks again, and thanks for maintaining irrlicht - still a very useful graphics engine.
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Flicker of Wavefront OBJ with transparent vertex alpha (d < 1)

Post by CuteAlien »

Ah, seeing now you tried EBO_MAX for BlendOperation. You should try EBO_ADD. Sorry, I missed that and if you are lucky that may even work (and lot simpler than sorting, damn...). Reason I think it could work is that ADD should be order independent. Maybe even something the .obj loader should set.

And googling a bit - there also seem to be some algorithms for order-independent transparency. Guess I'll have to read about that some time.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Flicker of Wavefront OBJ with transparent vertex alpha (d < 1)

Post by CuteAlien »

Irrlicht svn has now IMeshSceneNode::setNodeRegistration which can be called with irr::scene::ENR_PER_MESH_BUFFER to allow sorting per meshbuffer. It can help with such cases.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply