Salome HOME
Return old behavior of point sprites
authorisk <ilya.sevrikov@opencascade.com>
Wed, 17 Aug 2016 13:16:57 +0000 (16:16 +0300)
committerisk <ilya.sevrikov@opencascade.com>
Wed, 17 Aug 2016 13:16:57 +0000 (16:16 +0300)
src/VTKViewer/VTKViewer_PolyDataMapper.cxx
src/VTKViewer/VTKViewer_PolyDataMapper.h
src/VTKViewer/resources/Point.fs.glsl
src/VTKViewer/resources/Point.vs.glsl

index f61d2af2165adb49115956402d39580767249308..3f08ccfbbd793f83ee677e11f5a5f8d2f74a61a5 100644 (file)
@@ -125,6 +125,7 @@ int VTKViewer_PolyDataMapper::InitShader()
   this->OpenGLHelper.vglUseProgramObjectARB( this->PointProgram );
 
   this->myLocations.ModelViewProjection = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uModelViewProjectionMatrix" );
+  this->myLocations.Projection          = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uProjectionMatrix" );
   this->myLocations.GeneralPointSize    = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uGeneralPointSize" );
   this->myLocations.PointSprite         = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uPointSprite" );
 
@@ -883,6 +884,7 @@ void VTKViewer_PolyDataMapper::InternalDraw(vtkRenderer* ren, vtkActor* act ) {
         {
                this->OpenGLHelper.SetUniformMatrix( this->myLocations.ModelViewProjection, wcdc );
         }
+        this->OpenGLHelper.SetUniformMatrix( this->myLocations.Projection, vcdc );
 
         this->OpenGLHelper.vglUniform1iARB( this->myLocations.GeneralPointSize, std::max( aSize[0], aSize[1] ) );
 
index 0413ae6653bffdceae7a2c139a804d4e98f481a1..8fa5725b0dba170f77aeb95185a8df205de84f87 100644 (file)
@@ -141,11 +141,13 @@ private:
     static const GLint INVALID_LOCATION = -1;
 
     GLint ModelViewProjection;
+    GLint Projection;
     GLint GeneralPointSize;
     GLint PointSprite;
 
     Locations()
     : ModelViewProjection (INVALID_LOCATION),
+      Projection          (INVALID_LOCATION),
       GeneralPointSize    (INVALID_LOCATION),
       PointSprite         (INVALID_LOCATION)
     {
index 1c7cbb020c47a4e02bb1e155db6b9506aa40af29..d13a97713889d94707255fc58b3a18603eb63d59 100644 (file)
@@ -13,10 +13,9 @@ uniform sampler2D uPointSprite;
 in vec4 VSColor;
 void main()
 {
-  outColor = VSColor;
-  vec4 testColor = Texture2D(uPointSprite, gl_PointCoord);
-  if (testColor.r > 0.1)
-    outColor = testColor * outColor;
-  else
+  vec4 aColor = Texture2D(uPointSprite, gl_PointCoord) * VSColor;
+  if (aColor.a < 0.5)
     discard;
+
+  outColor = aColor;
 }
index c73f7eb183a528b94c0acf93867587333562ae51..50f109e639d17c4cdbec8d1f8194b326c4d9ba20 100644 (file)
@@ -9,6 +9,7 @@
   attribute float Diameter;
 #endif
 
+uniform mat4 uProjectionMatrix;
 uniform mat4 uModelViewProjectionMatrix;
 uniform int  uGeneralPointSize;
 
@@ -18,7 +19,7 @@ void main()
   gl_Position  = uModelViewProjectionMatrix * vec4 (Vertex.xyz, 1.0);
 
   if (uGeneralPointSize == -1)
-    gl_PointSize = Diameter;
+    gl_PointSize = 1400 * uProjectionMatrix[1].y * Diameter;
   else
     gl_PointSize = uGeneralPointSize;