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);
|
|
|
|
float lightScale = size * size * size * size * size / 1000.0;
|
|
|
|
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
|
|
|
}
|