# Opacity issue in QVTKOpenGLWidget and PCL Visualizer

**URL:** https://discourse.vtk.org/t/opacity-issue-in-qvtkopenglwidget-and-pcl-visualizer/9646
**Category:** Support
**Created:** [October 19, 2022, 6:45am UTC](https://discourse.vtk.org/t/opacity-issue-in-qvtkopenglwidget-and-pcl-visualizer/9646 "2022-10-19T06:45:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Panda12197](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/e480ec/32.png) [@Panda12197](https://discourse.vtk.org/u/Panda12197)
#### Post date: [October 19, 2022, 6:45am UTC](https://discourse.vtk.org/t/opacity-issue-in-qvtkopenglwidget-and-pcl-visualizer/9646/1 "2022-10-19T06:45:13Z")

</div>

I am trying to set the opacity for Cube in pclviewer with surface. It is successed but I can not set the opacity value.

**It is OK when the opacity value is 1.0 but any values less than 1.0 make it invisible**.

The program is as following:

> viewer-\>addCube(Eigen::Vector3f(c\_x,c\_y,c\_z),Eigen::Quaternionf(rotation),w,d,h,“cube”);  
> viewer-\>setShapeRenderingProperties (pcl::visualization::PCL\_VISUALIZER\_COLOR, 0.0, 1.0, 0.0, “cube”);  
> viewer-\>setShapeRenderingProperties (pcl::visualization::PCL\_VISUALIZER\_REPRESENTATION  
> ,pcl::visualization::PCL\_VISUALIZER\_REPRESENTATION\_SURFACE,“cube”);  
> viewer-\>setShapeRenderingProperties(PCL\_VISUALIZER\_OPACITY,0.5,“cube”);

When I run the program, I got the following error:

> ERROR: In /home/VTK-8.2.0/Rendering/OpenGL2/vtkShaderProgram.cxx, line 446  
> vtkShaderProgram (0x55d9fb9540): 1:#version 300 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](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):

I am using PCL-1.12.1, VTK-8.2 and Qt5.

---

<div class="post-metadata">

### Author: ![nnw](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nnw/32/5507_2.png) [@nnw](https://discourse.vtk.org/u/nnw)
#### Post date: [October 21, 2022, 2:53am UTC](https://discourse.vtk.org/t/opacity-issue-in-qvtkopenglwidget-and-pcl-visualizer/9646/2 "2022-10-21T02:53:23Z")

</div>

I also get the same error while using either “#version 320 es” or “#version 150”.  
Is there any way to find compatible version for glsl?  
It works fine with vtk6.3 but not in vtk8.2.0.  
Here is my opengl version.  
 ![Screenshot from 2022-10-21 11-49-50](https://discourse.vtk.org/uploads/default/original/2X/f/f2caa3cff1d54754105e2a571e9f04d5ffe1c0be.png)
