4

I am trying to make wireframe transparent in one of examples of Qt3D, but fails. I set alpha to 0.5 in robustwireframe.frag, but it does not work.

void main(){
// Calculate the color from the phong model
     vec4 color = vec4( adsModel( fs_in.position, normalize( fs_in.normal ) ), 0.5);
     fragColor = shadeLine( color );

How to make wireframe transparent in Qt3D?

  • 1
    Maybe you can have a look at the QPhongAlphaMaterial https://github.com/qt/qt3d/blob/5.11/src/extras/defaults/qphongalphamaterial.cpp and adapt the shader so that it works for your wireframe. – Florian Blume Apr 28 '18 at 09:34

1 Answers1

1

Adding a BlendEquation to the the renderStates will enable the Alpha blending so add the following code to the RenderPass in the WireframeEffect.qml:

RenderPass {
    renderStates: [
           BlendEquation {blendFunction: BlendEquation.Min}
     ]
     shaderProgram: ShaderProgram {
                        vertexShaderCode:loadSource("qrc:/shaders/robustwireframe.vert")
                        geometryShaderCode: loadSource("qrc:/shaders/robustwireframe.geom")
                        fragmentShaderCode: loadSource("qrc:/shaders/robustwireframe.frag")
   }
}
Rui Sebastião
  • 855
  • 1
  • 18
  • 36