bezier.geom revision 32001f49
1#version 120 2#extension GL_EXT_geometry_shader4: enable 3 4uniform int NumSubdivisions; 5 6void main() 7{ 8 /* num is the number of subdivisions 9 * can be anything between 1 and infinity 10 */ 11 int num = NumSubdivisions; 12 13 float dt = 1. / float(num); 14 float t = 0.; 15 for (int i = 0; i <= num; i++) { 16 float omt = 1. - t; 17 float omt2 = omt * omt; 18 float omt3 = omt * omt2; 19 float t2 = t * t; 20 float t3 = t * t2; 21 vec4 xyzw = 22 omt3 * gl_PositionIn[0].xyzw + 23 3. * t * omt2 * gl_PositionIn[1].xyzw + 24 3. * t2 * omt * gl_PositionIn[2].xyzw + 25 t3 * gl_PositionIn[3].xyzw; 26 gl_Position = xyzw; 27 gl_FrontColor = vec4(1, 1, 1, 1); 28 EmitVertex(); 29 t += dt; 30 } 31} 32