如何在Qt3D中使线框透明?

时间:2018-04-28 05:25:13

标签: qt qml qt5 qt3d

我试图在one of examples of Qt3D中使线框透明,但失败了。 我在robustwireframe.frag中将alpha设置为0.5,但它不起作用。

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 );

如何在Qt3D中使线框透明?

1 个答案:

答案 0 :(得分:0)

在renderStates中添加BlendEquation将启用Alpha混合,因此将以下代码添加到WireframeEffect.qml中的RenderPass中:

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")
   }
}