31 namespace visualization {
39 "uniform sampler2D image_texture;\n"
41 "out vec4 FragColor;\n"
45 " FragColor = texture(image_texture, UV);\n"
53 "uniform sampler2D image_texture;\n"
55 "uniform vec3 mask_color;\n"
56 "uniform float mask_alpha;\n"
58 "out vec4 FragColor;\n"
62 " FragColor = vec4(mask_color, texture(image_texture, UV).r * mask_alpha);\n"
69 "in vec3 vertex_position;\n"
70 "in vec2 vertex_UV;\n"
76 " gl_Position = vec4(vertex_position, 1);\n"
84 "in vec3 vertex_position;\n"
85 "in vec2 vertex_UV;\n"
89 "uniform vec3 vertex_scale;\n"
93 " gl_Position = vec4(vertex_position * vertex_scale, 1);\n"
101 "in vec3 vertex_normal_camera;\n"
102 "out vec4 FragColor;\n"
106 " FragColor = vec4(vertex_normal_camera * 0.5 + 0.5, 1);\n"
113 "in vec3 vertex_position;\n"
114 "in vec3 vertex_normal;\n"
116 "out vec3 vertex_normal_camera;\n"
118 "uniform mat4 MVP;\n"
124 " gl_Position = MVP * vec4(vertex_position, 1);\n"
125 " vertex_normal_camera = (V * M * vec4(vertex_normal, 0)).xyz;\n"
132 "in vec3 vertex_position_world;\n"
133 "in vec3 vertex_normal_camera;\n"
134 "in vec3 eye_dir_camera;\n"
135 "in mat4 light_dir_camera_4;\n"
136 "in vec3 fragment_color;\n"
138 "uniform mat4 light_color_4;\n"
139 "uniform vec4 light_diffuse_power_4;\n"
140 "uniform vec4 light_specular_power_4;\n"
141 "uniform vec4 light_specular_shininess_4;\n"
142 "uniform vec4 light_ambient;\n"
144 "out vec4 FragColor;\n"
148 " vec3 diffuse_color = fragment_color;\n"
149 " vec3 ambient_color = light_ambient.xyz * diffuse_color;\n"
150 " vec3 specular_color = vec3(1.0, 1.0, 1.0);\n"
153 " vec3 n, e, l, r;\n"
155 " n = normalize(vertex_normal_camera);\n"
156 " e = normalize(eye_dir_camera);\n"
157 " l = normalize(light_dir_camera_4[0].xyz);\n"
158 " r = reflect(-l, n);\n"
159 " cos_theta[0] = clamp(dot(n, l), 0, 1);\n"
160 " cos_alpha[0] = clamp(dot(e, r), 0, 1);\n"
162 " l= normalize(light_dir_camera_4[1].xyz);\n"
163 " r = reflect(-l, n);\n"
164 " cos_theta[1] = clamp(dot(n, l), 0, 1);\n"
165 " cos_alpha[1] = clamp(dot(e, r), 0, 1);\n"
167 " l= normalize(light_dir_camera_4[2].xyz);\n"
168 " r = reflect(-l, n);\n"
169 " cos_theta[2] = clamp(dot(n, l), 0, 1);\n"
170 " cos_alpha[2] = clamp(dot(e, r), 0, 1);\n"
172 " l= normalize(light_dir_camera_4[3].xyz);\n"
173 " r = reflect(-l, n);\n"
174 " cos_theta[3] = clamp(dot(n, l), 0, 1);\n"
175 " cos_alpha[3] = clamp(dot(e, r), 0, 1);\n"
177 " FragColor = vec4(ambient_color + \n"
178 " diffuse_color * light_color_4[0].xyz * light_diffuse_power_4[0] * cos_theta[0] +\n"
179 " specular_color * light_color_4[0].xyz * light_specular_power_4[0] * pow(cos_alpha[0], light_specular_shininess_4[0]) +\n"
180 " diffuse_color * light_color_4[1].xyz * light_diffuse_power_4[1] * cos_theta[1] +\n"
181 " specular_color * light_color_4[1].xyz * light_specular_power_4[1] * pow(cos_alpha[1], light_specular_shininess_4[1]) +\n"
182 " diffuse_color * light_color_4[2].xyz * light_diffuse_power_4[2] * cos_theta[2] +\n"
183 " specular_color * light_color_4[2].xyz * light_specular_power_4[2] * pow(cos_alpha[2], light_specular_shininess_4[2]) +\n"
184 " diffuse_color * light_color_4[3].xyz * light_diffuse_power_4[3] * cos_theta[3] +\n"
185 " specular_color * light_color_4[3].xyz * light_specular_power_4[3] * pow(cos_alpha[3], light_specular_shininess_4[3]), 1);\n"
192 "in vec3 vertex_position;\n"
193 "in vec3 vertex_normal;\n"
194 "in vec3 vertex_color;\n"
196 "out vec3 vertex_position_world;\n"
197 "out vec3 vertex_normal_camera;\n"
198 "out vec3 eye_dir_camera;\n"
199 "out mat4 light_dir_camera_4;\n"
200 "out vec3 fragment_color;\n"
202 "uniform mat4 MVP;\n"
205 "uniform mat4 light_position_world_4;\n"
209 " gl_Position = MVP * vec4(vertex_position, 1);\n"
210 " vertex_position_world = (M * vec4(vertex_position, 1)).xyz;\n"
212 " vec3 vertex_position_camera = (V * M * vec4(vertex_position, 1)).xyz;\n"
213 " eye_dir_camera = vec3(0, 0, 0) - vertex_position_camera;\n"
215 " vec4 v = vec4(vertex_position_camera, 1);\n"
216 " light_dir_camera_4 = V * light_position_world_4 - mat4(v, v, v, v);\n"
218 " vertex_normal_camera = (V * M * vec4(vertex_normal, 0)).xyz;\n"
219 " if (dot(eye_dir_camera, vertex_normal_camera) < 0.0)\n"
220 " vertex_normal_camera = vertex_normal_camera * -1.0;\n"
222 " fragment_color = vertex_color;\n"
229 "in vec4 fragment_color;\n"
230 "out vec4 FragColor;\n"
234 " FragColor = fragment_color;\n"
241 "in vec3 vertex_position;\n"
242 "in float vertex_index;\n"
243 "uniform mat4 MVP;\n"
245 "out vec4 fragment_color;\n"
249 " float r, g, b, a;\n"
250 " gl_Position = MVP * vec4(vertex_position, 1);\n"
251 " r = floor(vertex_index / 16777216.0) / 255.0;\n"
252 " g = mod(floor(vertex_index / 65536.0), 256.0) / 255.0;\n"
253 " b = mod(floor(vertex_index / 256.0), 256.0) / 255.0;\n"
254 " a = mod(vertex_index, 256.0) / 255.0;\n"
255 " fragment_color = vec4(r, g, b, a);\n"
263 "uniform sampler2D image_texture;\n"
266 "/* built-in option to ensure RGB and D are handled in the same shader,\n"
267 " which can be used in 2 passes */\n"
268 "#define DEPTH_TEXTURE_MODE 0\n"
269 "#define RGB_TEXTURE_MODE 1\n"
270 "#define GRAYSCALE_TEXTURE_MODE 2\n"
271 "uniform int texture_mode;\n"
273 "/* Decides the colormap of the depth image */\n"
274 "uniform float depth_max;\n"
275 "out vec4 FragColor;\n"
277 "float Interpolate(float value, float y0, float x0, float y1, float x1) {\n"
278 " if (value < x0) return y0;\n"
279 " if (value > x1) return y1;\n"
280 " return (value - x0) * (y1 - y0) / (x1 - x0) + y0;\n"
283 "float Jet(float value /* already clamped in [0, 1] */) {\n"
284 " if (value <= -0.75) {\n"
286 " } else if (value <= -0.25) {\n"
287 " return Interpolate(value, 0.0, -0.75, 1.0, -0.25);\n"
288 " } else if (value <= 0.25) {\n"
290 " } else if (value <= 0.75) {\n"
291 " return Interpolate(value, 1.0, 0.25, 0.0, 0.75);\n"
298 " if (texture_mode == DEPTH_TEXTURE_MODE) {\n"
299 " float depth = texture(image_texture, UV).r;\n"
300 " depth = clamp(depth, 0, depth_max);\n"
301 " depth = depth / depth_max;\n"
302 " depth = 2 * depth - 1;\n"
303 " FragColor = vec4(Jet(depth - 0.5), Jet(depth), Jet(depth + 0.5), 1);\n"
304 " } else if (texture_mode == RGB_TEXTURE_MODE) {\n"
305 " FragColor = texture(image_texture, UV);\n"
306 " } else if (texture_mode == GRAYSCALE_TEXTURE_MODE) {\n"
307 " float scalar = texture(image_texture, UV).r;\n"
308 " FragColor = vec4(vec3(scalar), 1);\n"
316 "in vec3 fragment_color;\n"
317 "out vec4 FragColor;\n"
321 " FragColor = vec4(fragment_color, 1);\n"
328 "in vec3 vertex_position;\n"
329 "in vec3 vertex_color;\n"
331 "out vec3 fragment_color;\n"
335 " gl_Position = vec4(vertex_position, 1);\n"
336 " fragment_color = vertex_color;\n"
343 "out vec4 FragColor;\n"
347 " FragColor = vec4(0.1, 0.1, 0.1, 1);\n"
354 "in vec3 vertex_position;\n"
355 "uniform mat4 MVP;\n"
359 " gl_Position = MVP * vec4(vertex_position, 1);\n"
366 "in vec3 fragment_color;\n"
367 "out vec4 FragColor;\n"
371 " FragColor = vec4(fragment_color, 1);\n"
378 "in vec3 vertex_position;\n"
379 "in vec3 vertex_color;\n"
380 "uniform mat4 MVP;\n"
382 "out vec3 fragment_color;\n"
386 " gl_Position = MVP * vec4(vertex_position, 1);\n"
387 " fragment_color = vertex_color;\n"
394 "in vec3 vertex_position_world;\n"
395 "in vec3 vertex_normal_camera;\n"
396 "in vec3 eye_dir_camera;\n"
397 "in mat4 light_dir_camera_4;\n"
398 "in vec2 fragment_uv;\n"
400 "uniform mat4 light_color_4;\n"
401 "uniform vec4 light_diffuse_power_4;\n"
402 "uniform vec4 light_specular_power_4;\n"
403 "uniform vec4 light_specular_shininess_4;\n"
404 "uniform vec4 light_ambient;\n"
405 "uniform sampler2D diffuse_texture;\n"
407 "out vec4 FragColor;\n"
411 " vec3 diffuse_color = texture(diffuse_texture, fragment_uv).rgb;\n"
412 " vec3 ambient_color = light_ambient.xyz * diffuse_color;\n"
413 " vec3 specular_color = vec3(1.0, 1.0, 1.0);\n"
416 " vec3 n, e, l, r;\n"
418 " n = normalize(vertex_normal_camera);\n"
419 " e = normalize(eye_dir_camera);\n"
420 " l = normalize(light_dir_camera_4[0].xyz);\n"
421 " r = reflect(-l, n);\n"
422 " cos_theta[0] = clamp(dot(n, l), 0, 1);\n"
423 " cos_alpha[0] = clamp(dot(e, r), 0, 1);\n"
425 " l= normalize(light_dir_camera_4[1].xyz);\n"
426 " r = reflect(-l, n);\n"
427 " cos_theta[1] = clamp(dot(n, l), 0, 1);\n"
428 " cos_alpha[1] = clamp(dot(e, r), 0, 1);\n"
430 " l= normalize(light_dir_camera_4[2].xyz);\n"
431 " r = reflect(-l, n);\n"
432 " cos_theta[2] = clamp(dot(n, l), 0, 1);\n"
433 " cos_alpha[2] = clamp(dot(e, r), 0, 1);\n"
435 " l= normalize(light_dir_camera_4[3].xyz);\n"
436 " r = reflect(-l, n);\n"
437 " cos_theta[3] = clamp(dot(n, l), 0, 1);\n"
438 " cos_alpha[3] = clamp(dot(e, r), 0, 1);\n"
440 " FragColor = vec4(ambient_color + \n"
441 " diffuse_color * light_color_4[0].xyz * light_diffuse_power_4[0] * cos_theta[0] +\n"
442 " specular_color * light_color_4[0].xyz * light_specular_power_4[0] * pow(cos_alpha[0], light_specular_shininess_4[0]) +\n"
443 " diffuse_color * light_color_4[1].xyz * light_diffuse_power_4[1] * cos_theta[1] +\n"
444 " specular_color * light_color_4[1].xyz * light_specular_power_4[1] * pow(cos_alpha[1], light_specular_shininess_4[1]) +\n"
445 " diffuse_color * light_color_4[2].xyz * light_diffuse_power_4[2] * cos_theta[2] +\n"
446 " specular_color * light_color_4[2].xyz * light_specular_power_4[2] * pow(cos_alpha[2], light_specular_shininess_4[2]) +\n"
447 " diffuse_color * light_color_4[3].xyz * light_diffuse_power_4[3] * cos_theta[3] +\n"
448 " specular_color * light_color_4[3].xyz * light_specular_power_4[3] * pow(cos_alpha[3], light_specular_shininess_4[3]), 1);\n"
455 "in vec3 vertex_position;\n"
456 "in vec3 vertex_normal;\n"
457 "in vec2 vertex_uv;\n"
459 "out vec3 vertex_position_world;\n"
460 "out vec3 vertex_normal_camera;\n"
461 "out vec3 eye_dir_camera;\n"
462 "out mat4 light_dir_camera_4;\n"
463 "out vec2 fragment_uv;\n"
465 "uniform mat4 MVP;\n"
468 "uniform mat4 light_position_world_4;\n"
472 " gl_Position = MVP * vec4(vertex_position, 1);\n"
473 " vertex_position_world = (M * vec4(vertex_position, 1)).xyz;\n"
475 " vec3 vertex_position_camera = (V * M * vec4(vertex_position, 1)).xyz;\n"
476 " eye_dir_camera = vec3(0, 0, 0) - vertex_position_camera;\n"
478 " vec4 v = vec4(vertex_position_camera, 1);\n"
479 " light_dir_camera_4 = V * light_position_world_4 - mat4(v, v, v, v);\n"
481 " vertex_normal_camera = (V * M * vec4(vertex_normal, 0)).xyz;\n"
482 " if (dot(eye_dir_camera, vertex_normal_camera) < 0.0)\n"
483 " vertex_normal_camera = vertex_normal_camera * -1.0;\n"
485 " fragment_uv = vertex_uv;\n"
493 "in vec2 fragment_uv;\n"
494 "out vec4 FragColor;\n"
496 "uniform sampler2D diffuse_texture;\n"
500 " FragColor = texture(diffuse_texture, fragment_uv);\n"
507 "in vec3 vertex_position;\n"
508 "in vec2 vertex_uv;\n"
509 "uniform mat4 MVP;\n"
511 "out vec2 fragment_uv;\n"
515 " gl_Position = MVP * vec4(vertex_position, 1);\n"
516 " fragment_uv = vertex_uv;\n"
const char *const NormalVertexShader
Definition: Shader.h:110
const char *const ImageVertexShader
Definition: Shader.h:81
const char *const SimpleVertexShader
Definition: Shader.h:375
const char *const TexturePhongFragmentShader
Definition: Shader.h:391
const char *const PickingFragmentShader
Definition: Shader.h:226
const char *const NormalFragmentShader
Definition: Shader.h:98
const char *const ImageMaskFragmentShader
Definition: Shader.h:49
const char *const Simple2DFragmentShader
Definition: Shader.h:313
const char *const TextureSimpleVertexShader
Definition: Shader.h:504
const char *const TextureSimpleFragmentShader
Definition: Shader.h:490
const char *const Simple2DVertexShader
Definition: Shader.h:325
const char *const TexturePhongVertexShader
Definition: Shader.h:452
const char *const SimpleFragmentShader
Definition: Shader.h:363
const char *const ImageFragmentShader
Definition: Shader.h:35
const char *const ImageMaskVertexShader
Definition: Shader.h:66
const char *const RGBDImageFragmentShader
Definition: Shader.h:259
const char *const PhongFragmentShader
Definition: Shader.h:129
const char *const SimpleBlackVertexShader
Definition: Shader.h:351
const char *const PhongVertexShader
Definition: Shader.h:189
const char *const PickingVertexShader
Definition: Shader.h:238
const char *const SimpleBlackFragmentShader
Definition: Shader.h:340
Definition: PinholeCameraIntrinsic.cpp:16