changeset 771:ed783cbc92d7

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 24 May 2019 11:04:41 +0200
parents e6850c866469
children b8dfd966b5f4
files Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp
diffstat 2 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp	Fri May 24 11:02:20 2019 +0200
+++ b/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp	Fri May 24 11:04:41 2019 +0200
@@ -38,7 +38,7 @@
       float windowCenter, windowWidth;
       l.GetWindowing(windowCenter, windowWidth);
 
-      const float a = windowCenter - windowWidth;
+      const float a = windowCenter - windowWidth / 2.0f;
       const float slope = 256.0f / windowWidth;
 
       const Orthanc::ImageAccessor& source = l.GetTexture();
--- a/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp	Fri May 24 11:02:20 2019 +0200
+++ b/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp	Fri May 24 11:04:41 2019 +0200
@@ -29,28 +29,28 @@
 
 static const char* FRAGMENT_SHADER = 
   ORTHANC_STONE_OPENGL_SHADER_VERSION_DIRECTIVE
-  "uniform float u_offset;                       \n"
-  "uniform float u_slope;                        \n"
-  "uniform float u_windowCenter;                 \n"
-  "uniform float u_windowWidth;                  \n"
-  "uniform sampler2D u_texture;                  \n"
-  "varying vec2 v_texcoord;                      \n"
-  "void main()                                   \n"
-  "{                                             \n"
-  "  vec4 t = texture2D(u_texture, v_texcoord);  \n"
-  "  float v = (t.r * 256.0 + t.g) * 256.0;      \n"
-  "  v = v * u_slope + u_offset;                 \n"  // (*)
-  "  float a = u_windowCenter - u_windowWidth;   \n"
-  "  float dy = 1.0 / u_windowWidth;             \n"
-  "  if (v <= a)                                 \n"
-  "    v = 0.0;                                  \n"
-  "  else                                        \n"
-  "  {                                           \n"
-  "    v = (v - a) * dy;                         \n"
-  "    if (v >= 1.0)                             \n"
-  "      v = 1.0;                                \n"
-  "  }                                           \n"
-  "  gl_FragColor = vec4(v, v, v, 1);            \n"
+  "uniform float u_offset;                           \n"
+  "uniform float u_slope;                            \n"
+  "uniform float u_windowCenter;                     \n"
+  "uniform float u_windowWidth;                      \n"
+  "uniform sampler2D u_texture;                      \n"
+  "varying vec2 v_texcoord;                          \n"
+  "void main()                                       \n"
+  "{                                                 \n"
+  "  vec4 t = texture2D(u_texture, v_texcoord);      \n"
+  "  float v = (t.r * 256.0 + t.g) * 256.0;          \n"
+  "  v = v * u_slope + u_offset;                     \n"  // (*)
+  "  float a = u_windowCenter - u_windowWidth / 2.0; \n"
+  "  float dy = 1.0 / u_windowWidth;                 \n"
+  "  if (v <= a)                                     \n"
+  "    v = 0.0;                                      \n"
+  "  else                                            \n"
+  "  {                                               \n"
+  "    v = (v - a) * dy;                             \n"
+  "    if (v >= 1.0)                                 \n"
+  "      v = 1.0;                                    \n"
+  "  }                                               \n"
+  "  gl_FragColor = vec4(v, v, v, 1);                \n"
   "}";