comparison Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp @ 771:ed783cbc92d7

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 24 May 2019 11:04:41 +0200
parents e6850c866469
children 4d1f57773b5b
comparison
equal deleted inserted replaced
770:e6850c866469 771:ed783cbc92d7
27 #include <Core/Images/ImageProcessing.h> 27 #include <Core/Images/ImageProcessing.h>
28 28
29 29
30 static const char* FRAGMENT_SHADER = 30 static const char* FRAGMENT_SHADER =
31 ORTHANC_STONE_OPENGL_SHADER_VERSION_DIRECTIVE 31 ORTHANC_STONE_OPENGL_SHADER_VERSION_DIRECTIVE
32 "uniform float u_offset; \n" 32 "uniform float u_offset; \n"
33 "uniform float u_slope; \n" 33 "uniform float u_slope; \n"
34 "uniform float u_windowCenter; \n" 34 "uniform float u_windowCenter; \n"
35 "uniform float u_windowWidth; \n" 35 "uniform float u_windowWidth; \n"
36 "uniform sampler2D u_texture; \n" 36 "uniform sampler2D u_texture; \n"
37 "varying vec2 v_texcoord; \n" 37 "varying vec2 v_texcoord; \n"
38 "void main() \n" 38 "void main() \n"
39 "{ \n" 39 "{ \n"
40 " vec4 t = texture2D(u_texture, v_texcoord); \n" 40 " vec4 t = texture2D(u_texture, v_texcoord); \n"
41 " float v = (t.r * 256.0 + t.g) * 256.0; \n" 41 " float v = (t.r * 256.0 + t.g) * 256.0; \n"
42 " v = v * u_slope + u_offset; \n" // (*) 42 " v = v * u_slope + u_offset; \n" // (*)
43 " float a = u_windowCenter - u_windowWidth; \n" 43 " float a = u_windowCenter - u_windowWidth / 2.0; \n"
44 " float dy = 1.0 / u_windowWidth; \n" 44 " float dy = 1.0 / u_windowWidth; \n"
45 " if (v <= a) \n" 45 " if (v <= a) \n"
46 " v = 0.0; \n" 46 " v = 0.0; \n"
47 " else \n" 47 " else \n"
48 " { \n" 48 " { \n"
49 " v = (v - a) * dy; \n" 49 " v = (v - a) * dy; \n"
50 " if (v >= 1.0) \n" 50 " if (v >= 1.0) \n"
51 " v = 1.0; \n" 51 " v = 1.0; \n"
52 " } \n" 52 " } \n"
53 " gl_FragColor = vec4(v, v, v, 1); \n" 53 " gl_FragColor = vec4(v, v, v, 1); \n"
54 "}"; 54 "}";
55 55
56 56
57 namespace OrthancStone 57 namespace OrthancStone
58 { 58 {