Order-independent transparency + custom shader + needAlphaBlending = broken shader

Hi All,
First of all: Congratulations for the new 7.0 release! It looks awesome! Can’t wait to play with Gaussian Splatting.

I’m back with a question / bug report about the combination of

  • order-independent transparency
  • using a custom shader
  • which uses needAlphaBlending.

This breaks the shader (GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs.) I looked into the OIT fragment shader files and was able to fix the GL_INVALID_OPERATION error by setting the missing outputs (depth, frontColor, backColor), but since I don’t fully understand the details if this OIT implementation, I could not get it to render correctly.

Here’s a PG to play with.

In the top two lines you can turn OIT and needAlphaBlending on and off. Turning on both breaks the shader.

Possible workaround: Maybe needAlphaBlending is not necessary as I want to set a constant alpha value for the entire plane and not per fragment.

Thanks a lot in advance for looking into this issue!
Tom

@sebavan or @Evgeni_Popov maybe can help?

1 Like

It’s a bit complicated because you will have to implement the necessary code in your custom shader to support OIT. You should take example on the standard material and look for the ORDER_INDEPENDENT_TRANSPARENCY define. You will also have to add #include<oitDeclaration> and #include<oitFragment> in your shader. Again, look how it is done in the default material (shaders/default.vertex.fx and shaders/default.fragment.fx).

1 Like

Thanks for the pointers, @Evgeni_Popov. I’ll give it a try in the next few days and report back.

Should or must I use the precompiler directives (e.g. #ifdef ORDER_INDEPENDENT_TRANSPARENCY) in my custom shader?

Yes, except if you’re sure you will never use your shader without OIT enabled.