Geogram Version 1.9.9
A programming library of geometric algorithms
Loading...
Searching...
No Matches
points_vertex_shader.h
1//import <GLUP/current_profile/vertex_shader_preamble.h>
2//import <GLUPES/vertex_shader_state.h>
3//import <GLUP/stdglup.h>
4//import <GLUP/current_profile/toggles.h>
5//import <GLUP/current_profile/primitive.h>
6
7glup_in vec4 vertex_in;
8glup_in vec4 color_in;
9glup_in vec4 tex_coord_in;
10glup_in highp float vertex_id_in;
11
12glup_flat glup_out vec4 color;
13glup_flat glup_out vec4 tex_coord;
14glup_flat glup_out vec3 center_world_space;
15glup_flat glup_out float radius;
16glup_flat glup_out glup_id primitive_id;
17
18
19void main(void) {
20
21 if(glupIsEnabled(GLUP_PICKING)) {
22#ifdef GLUP_ES_100
23 primitive_id = float(int(vertex_id_in + 0.5)) + 0.5;
24#else
25 primitive_id = int(vertex_id_in + 0.5);
26#endif
27 }
28
29 if(glupIsEnabled(GLUP_VERTEX_COLORS)) {
30 color = color_in;
31 }
32
33 if(glupIsEnabled(GLUP_TEXTURING)) {
34 if(glupIsEnabled(GLUP_INDIRECT_TEXTURING)) {
35 tex_coord = tex_coord_in;
36 } else {
37 tex_coord = GLUP_VS.texture_matrix * tex_coord_in;
38 }
39 }
40
41 // note: WebGL does not have glPointSize() API function
42 // so the only way to set it is from the VS.
43 gl_PointSize = GLUP_VS.point_size;
44 gl_Position = GLUP_VS.modelviewprojection_matrix*vertex_in;
45
46 center_world_space = vertex_in.xyz / vertex_in.w;
47
48 vec4 P1 = GLUP_VS.inverse_modelviewprojection_matrix*vec4(
49 0.0, 0.0, 0.0, 1.0
50 );
51 vec4 P2 = GLUP_VS.inverse_modelviewprojection_matrix*vec4(
52 GLUP_VS.point_size/GLUP_VS.viewport[2],0.0,0.0,1.0
53 );
54 radius = length(P1.xyz/P1.w-P2.xyz/P2.w);
55}
double length(vec3 v)
Computes the length of a vector.
vecng< 3, Numeric::float64 > vec3
Represents points and vectors in 3d.
Definition geometry.h:65
vecng< 4, Numeric::float64 > vec4
Represents points and vectors in 4d.
Definition geometry.h:71