Opacity value<1.0 become invisible

Hello Everyone,
I am trying this example (Opacity) on Ubuntu 18.04 and VTK 8.2.0.
The object is disappeared when I set the opacity value<1.0.

When both of the opacity values are less than 1.0,

cubeActor->GetProperty()->SetOpacity(0.5);
sphereActor->GetProperty()->SetOpacity(0.7);

<1.0


When I adjust the opacity values,

cubeActor->GetProperty()->SetOpacity(0.5);
sphereActor->GetProperty()->SetOpacity(1.0);

=1.0

I have no idea how to fix it. :cry:
Please give me some help. :bowing_woman:

Hi @Panda12197

Could you share the output of glxinfo ?

Best,

Hello @mwestphal

Thanks for your reply.
Here is my glxinfo.

glxinfo

Hello,

Please, check your program whether you’re not setting a discard-containing shader code like this one:

void main()
{             
    vec4 texColor = texture(texture1, TexCoords);
    if(texColor.a < 1.0)
        discard;
    FragColor = texColor;
}

Also, make sure the program is not redefining the default behavior of alpha blending via a call to glBlendFunc(), glBlendFuncSeparate() and/or glBlendEquation().

take care,

Paulo

1 Like

Hello @Paulo_Carvalho

I’m sorry for my late reply. :bowing_woman:

As I am a beginner, I did not know much about in OpenGL.
In my program, there is no shader code that I created. I took time to search this:

but I did not find anything.
I got the following error everytime when opacity value is less than 1.0.

ERROR: In /home/VTK-8.2.0/Rendering/OpenGL2/vtkShaderProgram.cxx, line 446
vtkShaderProgram (0x55d9fb9540): 1:#version 320 es
2: #ifndef GL_ES
3: #define highp
4: #define mediump
5: #define lowp
6: #endif // GL_ES
7: #define attribute in
8: #define varying out
9:
10:
11: /=========================================================================
12:
13: Program: Visualization Toolkit
14: Module: vtkPolyDataVS.glsl
15:
16: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
17: All rights reserved.
18: See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
19:
20: This software is distributed WITHOUT ANY WARRANTY; without even
21: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22: PURPOSE. See the above copyright notice for more information.
23:
24: ========================================================================= /
25:
26: in vec4 vertexMC;
27:
28: // frag position in VC
29: out vec4 vertexVCVSOutput;
30:
31: // optional normal declaration
32: //VTK::Normal::Dec
33:
34: // extra lighting parameters
35: //VTK::Light::Dec
36:
37: // Texture coordinates
38: //VTK::TCoord::Dec
39:
40: // material property values
41: //VTK::Color::Dec
42:
43: // clipping plane vars
44: //VTK::Clip::Dec
45:
46: // camera and actor matrix values
47: uniform mat4 MCDCMatrix;
48: uniform mat4 MCVCMatrix;
49:
50: // Apple Bug
51: //VTK::PrimID::Dec
52:
53: // Value raster
54: //VTK::ValuePass::Dec
55:
56: // picking support
57: //VTK::Picking::Dec
58:
59: void main()
60: {
61: //VTK::Color::Impl
62:
63: //VTK::Normal::Impl
64:
65: //VTK::TCoord::Impl
66:
67: //VTK::Clip::Impl
68:
69: //VTK::PrimID::Impl
70:
71: vertexVCVSOutput = MCVCMatrix * vertexMC;
72: gl_Position = MCDCMatrix * vertexMC;
73:
74:
75: //VTK::ValuePass::Impl
76:
77: //VTK::Light::Impl
78:
79: //VTK::Picking::Impl
80: }
ERROR: In /home/VTK-8.2.0/Rendering/OpenGL2/vtkShaderProgram.cxx, line 447
vtkShaderProgram (0x55d9fb9540):

regards,

Aye Moh

Hello,

It seems to me that your graphics driver is not up-to-date and/or that your graphics card is old. Lines 446 and 447 in vtkShaderProgram.cxx are in a part of the VTK code where it calls the graphics back-end to compile a vertex shader program (the source code you see in the error message) and fails.

I recommend trying your program in hardware known to run modern 3D programs (e.g. ParaView) and see whether it works there.

regards,

Paulo

Hello @Paulo_Carvalho

Now, I am using Jetson nano with JetPack 4.6.

Still, your OpenGL backend is not compiling the shader code VTK is sending to compile. Have you considered upgrading to VTK 9.2? Its more recent shader code may compile sans issues there. If you still experience shader code failing to compile on that platform, I recommend you to report the issue in here: https://gitlab.kitware.com/vtk/vtk/-/issues

1 Like

Hello @Paulo_Carvalho ,

I am sorry for my late reply.

I upgrade VTK version to 9.2 according to your advice. Now, opacity works correctly.
Thanks you for your suggestion.

opacity_test_1

But I have another problem. :sweat_smile:
Actually, I am trying to visualize the point cloud using PCL, VTK and Qt.
When I using VTK8.2, opacity did not work not only testing of opacity example but also using QVTKOpenGLWidget for point cloud visualization.Now, I upgrade to VTK9.2 and opacity example of vtk is working correctly but I got the following error when I use QVTKOpenGLNativeWidget to visualize.

ERR| 8BA34010]vtkOpenGLRenderWindow.c:512 ERR| vtkGenericOpenGLRenderWindow (0x55beaecc80): GLEW could not be initialized: Missing GL version

regards,

Aye Moh

Hi,

Can you, please, start a new question for that? Solving multiple problems in a single thread will confuse other people with the same problem as you.

thanks,

Paulo

2 Likes

Hello @Paulo_Carvalho,

I will start a new question for this problem.
Thanks you very much for all of your suggestion.

Best regards,
Aye Moh

1 Like