1 /* 2 Copyright (c) 2008 Seneca College 3 Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/) 4 */ 5 6 c3dl.point_vs = 7 8 "attribute vec3 Vertex;" + 9 "attribute vec3 Color;" + 10 11 "uniform vec3 attenuation;" + 12 "uniform mat4 modelViewProjMatrix;" + 13 "uniform mat4 viewMatrix;" + 14 15 "void main(void){" + 16 17 " vec4 v = vec4(Vertex, 1.0);" + 18 19 // place the point in view space so we can calculate the distance from the camera. 20 // get the distance from the camera to the point. 21 " float d = length(vec3(viewMatrix * v));" + 22 23 // the points will attenuate depending on the attenuation factors and 24 // the distance from the camera. 25 " gl_PointSize = 1.0/(attenuation[0] + (attenuation[1] * d) + (attenuation[2] * d * d));" + 26 " gl_FrontColor = vec4(Color, 1.0); " + 27 " gl_Position = modelViewProjMatrix * v;" + 28 29 "}"; 30