discard overlapping transparent pixels?

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!

discard overlapping transparent pixels?

Postby andrea_i » Thu Mar 08, 2018 5:07 pm

Hi! I'm pretty new to irrlicht and loving it so far, I'm making a brush sketching tool and I got stuck on this issue:

I'd like for each of my strokes to never show overlapping alpha with itself, thus avoid the artifacts visible in this image:

What I'd like to achieve instead, is having each stroke to overlap only with subsequent or previous strokes, based on Z depth, because it's a 3d paint app.
Also, in this app there's no shading or lights, all flat. Not sure if it helps solving the issue or not.

I've read it might be necessary to use the stencil buffer, but to be honest I'm no openGL expert, I can pretty much work my way around a GLSL shader but I can't write one of my own, especially with advanced techniques, so I'm hoping someone will be able to help here!

Posts: 2
Joined: Thu Mar 08, 2018 4:56 pm

Re: discard overlapping transparent pixels?

Postby CuteAlien » Fri Mar 09, 2018 12:44 pm

Maybe https://en.wikipedia.org/wiki/Alpha_compositing can help a little bit. It's a tricky problem.
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
Posts: 8465
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: discard overlapping transparent pixels?

Postby andrea_i » Fri Mar 09, 2018 12:51 pm

It looks like someone figured it out in Unity using a vertex+fragment shader and stencil buffers, here's the post:

What I desperately need from this community is guidelines to do the following (because I really can't find my way around this):
1) add a CG shader that uses the stencil buffer
2) set the blend function to this: SrcAlpha OneMinusSrcAlpha

Eventually I guess I'll figure it out, looking at the shadows implementation in irrlicht, but it might take me a while...please help : )
Posts: 2
Joined: Thu Mar 08, 2018 4:56 pm

Return to Advanced Help

Who is online

Users browsing this forum: No registered users and 1 guest