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 <GLUPGLSL/state.h>
3//import <GLUP/stdglup.h>
4//import <GLUP/current_profile/toggles.h>
5//import <GLUP/current_profile/primitive.h>
6
7in vec4 vertex_in;
8in vec4 color_in;
9in vec4 tex_coord_in;
10
11out VertexData {
12 vec4 color;
13 vec4 tex_coord;
14 vec3 center_world_space;
15 float radius;
16} VertexOut;
17
18void main(void) {
19
20 if(glupIsEnabled(GLUP_VERTEX_COLORS)) {
21 VertexOut.color = color_in;
22 }
23
24 if(glupIsEnabled(GLUP_TEXTURING)) {
25 if(glupIsEnabled(GLUP_INDIRECT_TEXTURING)) {
26 VertexOut.tex_coord = tex_coord_in;
27 } else {
28 VertexOut.tex_coord = GLUP.texture_matrix * tex_coord_in;
29 }
30 }
31
32 // note: WebGL does not have glPointSize() API function
33 // so the only way to set it is from the VS.
34 gl_PointSize = GLUP.point_size;
35 gl_Position = GLUP.modelviewprojection_matrix*vertex_in;
36
37 VertexOut.center_world_space = vertex_in.xyz / vertex_in.w;
38 vec4 P1 = GLUP.inverse_modelviewprojection_matrix*vec4(0.0, 0.0, 0.0, 1.0);
39 vec4 P2 = GLUP.inverse_modelviewprojection_matrix*vec4(
40 GLUP.point_size/GLUP.viewport[2],0.0,0.0,1.0
41 );
42 VertexOut.radius = length(P1.xyz/P1.w-P2.xyz/P2.w);
43}
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