Open3D (C++ API)
Shader.h
Go to the documentation of this file.
1 // Automatically generated header file for shader.
2 // See LICENSE.txt for full license statement.
3 
4 #pragma once
5 
6 // clang-format off
7 namespace open3d {
8 
9 namespace visualization {
10 
11 namespace glsl {
12 
13 const char * const ImageFragmentShader =
14 "#version 330\n"
15 "\n"
16 "in vec2 UV;\n"
17 "uniform sampler2D image_texture;\n"
18 "\n"
19 "out vec4 FragColor;\n"
20 "\n"
21 "void main()\n"
22 "{\n"
23 " FragColor = texture(image_texture, UV);\n"
24 "}\n"
25 ;
26 
27 } // namespace open3d::glsl
28 
29 } // namespace open3d::visualization
30 
31 } // namespace open3d
32 
33 // clang-format on
34 // clang-format off
35 namespace open3d {
36 
37 namespace visualization {
38 
39 namespace glsl {
40 
41 const char * const ImageMaskFragmentShader =
42 "#version 330\n"
43 "\n"
44 "in vec2 UV;\n"
45 "uniform sampler2D image_texture;\n"
46 "\n"
47 "uniform vec3 mask_color;\n"
48 "uniform float mask_alpha;\n"
49 "\n"
50 "out vec4 FragColor;\n"
51 "\n"
52 "void main()\n"
53 "{\n"
54 " FragColor = vec4(mask_color, texture(image_texture, UV).r * mask_alpha);\n"
55 "}\n"
56 ;
57 
58 } // namespace open3d::glsl
59 
60 } // namespace open3d::visualization
61 
62 } // namespace open3d
63 
64 // clang-format on
65 // clang-format off
66 namespace open3d {
67 
68 namespace visualization {
69 
70 namespace glsl {
71 
72 const char * const ImageMaskVertexShader =
73 "#version 330\n"
74 "\n"
75 "in vec3 vertex_position;\n"
76 "in vec2 vertex_UV;\n"
77 "\n"
78 "out vec2 UV;\n"
79 "\n"
80 "void main()\n"
81 "{\n"
82 " gl_Position = vec4(vertex_position, 1);\n"
83 " UV = vertex_UV;\n"
84 "}\n"
85 ;
86 
87 } // namespace open3d::glsl
88 
89 } // namespace open3d::visualization
90 
91 } // namespace open3d
92 
93 // clang-format on
94 // clang-format off
95 namespace open3d {
96 
97 namespace visualization {
98 
99 namespace glsl {
100 
101 const char * const ImageVertexShader =
102 "#version 330\n"
103 "\n"
104 "in vec3 vertex_position;\n"
105 "in vec2 vertex_UV;\n"
106 "\n"
107 "out vec2 UV;\n"
108 "\n"
109 "uniform vec3 vertex_scale;\n"
110 "\n"
111 "void main()\n"
112 "{\n"
113 " gl_Position = vec4(vertex_position * vertex_scale, 1);\n"
114 " UV = vertex_UV;\n"
115 "}\n"
116 ;
117 
118 } // namespace open3d::glsl
119 
120 } // namespace open3d::visualization
121 
122 } // namespace open3d
123 
124 // clang-format on
125 // clang-format off
126 namespace open3d {
127 
128 namespace visualization {
129 
130 namespace glsl {
131 
132 const char * const NormalFragmentShader =
133 "#version 330\n"
134 "\n"
135 "in vec3 vertex_normal_camera;\n"
136 "out vec4 FragColor;\n"
137 "\n"
138 "void main()\n"
139 "{\n"
140 " FragColor = vec4(vertex_normal_camera * 0.5 + 0.5, 1);\n"
141 "}\n"
142 ;
143 
144 } // namespace open3d::glsl
145 
146 } // namespace open3d::visualization
147 
148 } // namespace open3d
149 
150 // clang-format on
151 // clang-format off
152 namespace open3d {
153 
154 namespace visualization {
155 
156 namespace glsl {
157 
158 const char * const NormalVertexShader =
159 "#version 330\n"
160 "\n"
161 "in vec3 vertex_position;\n"
162 "in vec3 vertex_normal;\n"
163 "\n"
164 "out vec3 vertex_normal_camera;\n"
165 "\n"
166 "uniform mat4 MVP;\n"
167 "uniform mat4 V;\n"
168 "uniform mat4 M;\n"
169 "\n"
170 "void main()\n"
171 "{\n"
172 " gl_Position = MVP * vec4(vertex_position, 1);\n"
173 " vertex_normal_camera = (V * M * vec4(vertex_normal, 0)).xyz;\n"
174 "}\n"
175 ;
176 
177 } // namespace open3d::glsl
178 
179 } // namespace open3d::visualization
180 
181 } // namespace open3d
182 
183 // clang-format on
184 // clang-format off
185 namespace open3d {
186 
187 namespace visualization {
188 
189 namespace glsl {
190 
191 const char * const PhongFragmentShader =
192 "#version 330\n"
193 "\n"
194 "in vec3 vertex_position_world;\n"
195 "in vec3 vertex_normal_camera;\n"
196 "in vec3 eye_dir_camera;\n"
197 "in mat4 light_dir_camera_4;\n"
198 "in vec3 fragment_color;\n"
199 "\n"
200 "uniform mat4 light_color_4;\n"
201 "uniform vec4 light_diffuse_power_4;\n"
202 "uniform vec4 light_specular_power_4;\n"
203 "uniform vec4 light_specular_shininess_4;\n"
204 "uniform vec4 light_ambient;\n"
205 "\n"
206 "out vec4 FragColor;\n"
207 "\n"
208 "void main()\n"
209 "{\n"
210 " vec3 diffuse_color = fragment_color;\n"
211 " vec3 ambient_color = light_ambient.xyz * diffuse_color;\n"
212 " vec3 specular_color = vec3(1.0, 1.0, 1.0);\n"
213 " vec4 cos_theta;\n"
214 " vec4 cos_alpha;\n"
215 " vec3 n, e, l, r;\n"
216 "\n"
217 " n = normalize(vertex_normal_camera);\n"
218 " e = normalize(eye_dir_camera);\n"
219 " l = normalize(light_dir_camera_4[0].xyz);\n"
220 " r = reflect(-l, n);\n"
221 " cos_theta[0] = clamp(dot(n, l), 0, 1);\n"
222 " cos_alpha[0] = clamp(dot(e, r), 0, 1);\n"
223 "\n"
224 " l= normalize(light_dir_camera_4[1].xyz);\n"
225 " r = reflect(-l, n);\n"
226 " cos_theta[1] = clamp(dot(n, l), 0, 1);\n"
227 " cos_alpha[1] = clamp(dot(e, r), 0, 1);\n"
228 "\n"
229 " l= normalize(light_dir_camera_4[2].xyz);\n"
230 " r = reflect(-l, n);\n"
231 " cos_theta[2] = clamp(dot(n, l), 0, 1);\n"
232 " cos_alpha[2] = clamp(dot(e, r), 0, 1);\n"
233 "\n"
234 " l= normalize(light_dir_camera_4[3].xyz);\n"
235 " r = reflect(-l, n);\n"
236 " cos_theta[3] = clamp(dot(n, l), 0, 1);\n"
237 " cos_alpha[3] = clamp(dot(e, r), 0, 1);\n"
238 "\n"
239 " FragColor = vec4(ambient_color + \n"
240 " diffuse_color * light_color_4[0].xyz * light_diffuse_power_4[0] * cos_theta[0] +\n"
241 " specular_color * light_color_4[0].xyz * light_specular_power_4[0] * pow(cos_alpha[0], light_specular_shininess_4[0]) +\n"
242 " diffuse_color * light_color_4[1].xyz * light_diffuse_power_4[1] * cos_theta[1] +\n"
243 " specular_color * light_color_4[1].xyz * light_specular_power_4[1] * pow(cos_alpha[1], light_specular_shininess_4[1]) +\n"
244 " diffuse_color * light_color_4[2].xyz * light_diffuse_power_4[2] * cos_theta[2] +\n"
245 " specular_color * light_color_4[2].xyz * light_specular_power_4[2] * pow(cos_alpha[2], light_specular_shininess_4[2]) +\n"
246 " diffuse_color * light_color_4[3].xyz * light_diffuse_power_4[3] * cos_theta[3] +\n"
247 " specular_color * light_color_4[3].xyz * light_specular_power_4[3] * pow(cos_alpha[3], light_specular_shininess_4[3]), 1);\n"
248 "}\n"
249 ;
250 
251 } // namespace open3d::glsl
252 
253 } // namespace open3d::visualization
254 
255 } // namespace open3d
256 
257 // clang-format on
258 // clang-format off
259 namespace open3d {
260 
261 namespace visualization {
262 
263 namespace glsl {
264 
265 const char * const PhongVertexShader =
266 "#version 330\n"
267 "\n"
268 "in vec3 vertex_position;\n"
269 "in vec3 vertex_normal;\n"
270 "in vec3 vertex_color;\n"
271 "\n"
272 "out vec3 vertex_position_world;\n"
273 "out vec3 vertex_normal_camera;\n"
274 "out vec3 eye_dir_camera;\n"
275 "out mat4 light_dir_camera_4;\n"
276 "out vec3 fragment_color;\n"
277 "\n"
278 "uniform mat4 MVP;\n"
279 "uniform mat4 V;\n"
280 "uniform mat4 M;\n"
281 "uniform mat4 light_position_world_4;\n"
282 "\n"
283 "void main()\n"
284 "{\n"
285 " gl_Position = MVP * vec4(vertex_position, 1);\n"
286 " vertex_position_world = (M * vec4(vertex_position, 1)).xyz;\n"
287 "\n"
288 " vec3 vertex_position_camera = (V * M * vec4(vertex_position, 1)).xyz;\n"
289 " eye_dir_camera = vec3(0, 0, 0) - vertex_position_camera;\n"
290 "\n"
291 " vec4 v = vec4(vertex_position_camera, 1);\n"
292 " light_dir_camera_4 = V * light_position_world_4 - mat4(v, v, v, v);\n"
293 "\n"
294 " vertex_normal_camera = (V * M * vec4(vertex_normal, 0)).xyz;\n"
295 " if (dot(eye_dir_camera, vertex_normal_camera) < 0.0)\n"
296 " vertex_normal_camera = vertex_normal_camera * -1.0;\n"
297 "\n"
298 " fragment_color = vertex_color;\n"
299 "}\n"
300 ;
301 
302 } // namespace open3d::glsl
303 
304 } // namespace open3d::visualization
305 
306 } // namespace open3d
307 
308 // clang-format on
309 // clang-format off
310 namespace open3d {
311 
312 namespace visualization {
313 
314 namespace glsl {
315 
316 const char * const PickingFragmentShader =
317 "#version 330\n"
318 "\n"
319 "in vec4 fragment_color;\n"
320 "out vec4 FragColor;\n"
321 "\n"
322 "void main()\n"
323 "{\n"
324 " FragColor = fragment_color;\n"
325 "}\n"
326 ;
327 
328 } // namespace open3d::glsl
329 
330 } // namespace open3d::visualization
331 
332 } // namespace open3d
333 
334 // clang-format on
335 // clang-format off
336 namespace open3d {
337 
338 namespace visualization {
339 
340 namespace glsl {
341 
342 const char * const PickingVertexShader =
343 "#version 330\n"
344 "\n"
345 "in vec3 vertex_position;\n"
346 "in float vertex_index;\n"
347 "uniform mat4 MVP;\n"
348 "\n"
349 "out vec4 fragment_color;\n"
350 "\n"
351 "void main()\n"
352 "{\n"
353 " float r, g, b, a;\n"
354 " gl_Position = MVP * vec4(vertex_position, 1);\n"
355 " r = floor(vertex_index / 16777216.0) / 255.0;\n"
356 " g = mod(floor(vertex_index / 65536.0), 256.0) / 255.0;\n"
357 " b = mod(floor(vertex_index / 256.0), 256.0) / 255.0;\n"
358 " a = mod(vertex_index, 256.0) / 255.0;\n"
359 " fragment_color = vec4(r, g, b, a);\n"
360 "}\n"
361 ;
362 
363 } // namespace open3d::glsl
364 
365 } // namespace open3d::visualization
366 
367 } // namespace open3d
368 
369 // clang-format on
370 // clang-format off
371 namespace open3d {
372 
373 namespace visualization {
374 
375 namespace glsl {
376 
377 const char * const Simple2DFragmentShader =
378 "#version 330\n"
379 "\n"
380 "in vec3 fragment_color;\n"
381 "out vec4 FragColor;\n"
382 "\n"
383 "void main()\n"
384 "{\n"
385 " FragColor = vec4(fragment_color, 1);\n"
386 "}\n"
387 ;
388 
389 } // namespace open3d::glsl
390 
391 } // namespace open3d::visualization
392 
393 } // namespace open3d
394 
395 // clang-format on
396 // clang-format off
397 namespace open3d {
398 
399 namespace visualization {
400 
401 namespace glsl {
402 
403 const char * const Simple2DVertexShader =
404 "#version 330\n"
405 "\n"
406 "in vec3 vertex_position;\n"
407 "in vec3 vertex_color;\n"
408 "\n"
409 "out vec3 fragment_color;\n"
410 "\n"
411 "void main()\n"
412 "{\n"
413 " gl_Position = vec4(vertex_position, 1);\n"
414 " fragment_color = vertex_color;\n"
415 "}\n"
416 ;
417 
418 } // namespace open3d::glsl
419 
420 } // namespace open3d::visualization
421 
422 } // namespace open3d
423 
424 // clang-format on
425 // clang-format off
426 namespace open3d {
427 
428 namespace visualization {
429 
430 namespace glsl {
431 
432 const char * const SimpleBlackFragmentShader =
433 "#version 330\n"
434 "\n"
435 "out vec4 FragColor;\n"
436 "\n"
437 "void main()\n"
438 "{\n"
439 " FragColor = vec4(0.1, 0.1, 0.1, 1);\n"
440 "}\n"
441 ;
442 
443 } // namespace open3d::glsl
444 
445 } // namespace open3d::visualization
446 
447 } // namespace open3d
448 
449 // clang-format on
450 // clang-format off
451 namespace open3d {
452 
453 namespace visualization {
454 
455 namespace glsl {
456 
457 const char * const SimpleBlackVertexShader =
458 "#version 330\n"
459 "\n"
460 "in vec3 vertex_position;\n"
461 "uniform mat4 MVP;\n"
462 "\n"
463 "void main()\n"
464 "{\n"
465 " gl_Position = MVP * vec4(vertex_position, 1);\n"
466 "}\n"
467 ;
468 
469 } // namespace open3d::glsl
470 
471 } // namespace open3d::visualization
472 
473 } // namespace open3d
474 
475 // clang-format on
476 // clang-format off
477 namespace open3d {
478 
479 namespace visualization {
480 
481 namespace glsl {
482 
483 const char * const SimpleFragmentShader =
484 "#version 330\n"
485 "\n"
486 "in vec3 fragment_color;\n"
487 "out vec4 FragColor;\n"
488 "\n"
489 "void main()\n"
490 "{\n"
491 " FragColor = vec4(fragment_color, 1);\n"
492 "}\n"
493 ;
494 
495 } // namespace open3d::glsl
496 
497 } // namespace open3d::visualization
498 
499 } // namespace open3d
500 
501 // clang-format on
502 // clang-format off
503 namespace open3d {
504 
505 namespace visualization {
506 
507 namespace glsl {
508 
509 const char * const SimpleVertexShader =
510 "#version 330\n"
511 "\n"
512 "in vec3 vertex_position;\n"
513 "in vec3 vertex_color;\n"
514 "uniform mat4 MVP;\n"
515 "\n"
516 "out vec3 fragment_color;\n"
517 "\n"
518 "void main()\n"
519 "{\n"
520 " gl_Position = MVP * vec4(vertex_position, 1);\n"
521 " fragment_color = vertex_color;\n"
522 "}\n"
523 ;
524 
525 } // namespace open3d::glsl
526 
527 } // namespace open3d::visualization
528 
529 } // namespace open3d
530 
531 // clang-format on
const char *const PhongFragmentShader
Definition: Shader.h:191
const char *const PickingVertexShader
Definition: Shader.h:342
const char *const PickingFragmentShader
Definition: Shader.h:316
const char *const ImageFragmentShader
Definition: Shader.h:13
const char *const ImageMaskFragmentShader
Definition: Shader.h:41
const char *const Simple2DVertexShader
Definition: Shader.h:403
const char *const NormalFragmentShader
Definition: Shader.h:132
Definition: PinholeCameraIntrinsic.cpp:33
const char *const PhongVertexShader
Definition: Shader.h:265
const char *const ImageMaskVertexShader
Definition: Shader.h:72
const char *const SimpleBlackFragmentShader
Definition: Shader.h:432
const char *const ImageVertexShader
Definition: Shader.h:101
const char *const SimpleVertexShader
Definition: Shader.h:509
const char *const Simple2DFragmentShader
Definition: Shader.h:377
const char *const SimpleBlackVertexShader
Definition: Shader.h:457
const char *const SimpleFragmentShader
Definition: Shader.h:483
const char *const NormalVertexShader
Definition: Shader.h:158