2019-10-25 23:42:48 +00:00
|
|
|
// -*-C++-*-
|
|
|
|
#version 120
|
|
|
|
|
|
|
|
// Shader that uses OpenGL state values to do per-pixel lighting
|
|
|
|
|
|
|
|
uniform float size;
|
|
|
|
uniform float max_size;
|
|
|
|
|
|
|
|
|
|
|
|
uniform bool is_directional;
|
|
|
|
|
|
|
|
varying vec3 relPos;
|
|
|
|
varying vec2 rawPos;
|
|
|
|
varying float pixelSize;
|
|
|
|
|
2020-04-04 15:57:33 +00:00
|
|
|
varying float flogz;
|
|
|
|
|
2019-10-25 23:42:48 +00:00
|
|
|
bool light_directional = true;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_FrontColor= gl_Color;
|
|
|
|
gl_Position = ftransform();
|
2020-04-04 15:57:33 +00:00
|
|
|
// logarithmic depth
|
|
|
|
flogz = 1.0 + gl_Position.w;
|
2019-10-25 23:42:48 +00:00
|
|
|
|
|
|
|
vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
|
|
|
|
relPos = gl_Vertex.xyz - ep.xyz;
|
|
|
|
rawPos = gl_Vertex.xy;
|
|
|
|
float dist = length(relPos);
|
|
|
|
float angular_fade = 1.0;
|
|
|
|
|
|
|
|
if (is_directional)
|
|
|
|
{
|
|
|
|
angular_fade = 2.0 * max(0.0,-dot(normalize(gl_Normal), normalize(relPos)));
|
|
|
|
}
|
|
|
|
|
|
|
|
float size_use = size;
|
|
|
|
if (size_use < 10.0) {size_use = 20.0;}
|
|
|
|
|
|
|
|
float lightScale = size_use * size_use * size_use * size_use * size_use/ 500.0 *angular_fade;
|
|
|
|
pixelSize = min(size_use * size_use/25.0,lightScale/dist) ;
|
|
|
|
pixelSize = min(pixelSize, max_size);
|
|
|
|
gl_PointSize = 2.0 * pixelSize;
|
|
|
|
}
|