2014-02-25 08:49:37 +00:00
|
|
|
|
|
|
|
// -*-C++-*-
|
|
|
|
|
|
|
|
// Shader that uses OpenGL state values to do per-pixel lighting
|
|
|
|
|
|
|
|
uniform float size;
|
|
|
|
|
|
|
|
varying vec3 relPos;
|
2014-04-24 06:43:28 +00:00
|
|
|
varying vec2 rawPos;
|
2014-02-25 08:49:37 +00:00
|
|
|
varying float pixelSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_FrontColor= gl_Color;
|
|
|
|
gl_Position = ftransform();
|
|
|
|
|
|
|
|
vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
|
|
|
|
relPos = gl_Vertex.xyz - ep.xyz;
|
2014-04-24 06:43:28 +00:00
|
|
|
rawPos = gl_Vertex.xy;
|
2014-02-25 08:49:37 +00:00
|
|
|
float dist = length(relPos);
|
2014-08-13 07:52:59 +00:00
|
|
|
float angular_fade = 0.0;
|
|
|
|
if (length(gl_Normal)> 0.0)
|
|
|
|
{
|
|
|
|
angular_fade = 2.0 * max(0.0,-dot(normalize(gl_Normal), normalize(relPos)));
|
|
|
|
}
|
|
|
|
float lightScale = size * size * size * size * size/ 500.0 *angular_fade;
|
|
|
|
pixelSize = min(size * size/25.0,lightScale/dist) ;
|
2014-02-28 07:15:41 +00:00
|
|
|
gl_PointSize = 2.0 * pixelSize;
|
2014-02-25 08:49:37 +00:00
|
|
|
}
|