2014-02-25 08:49:37 +00:00
|
|
|
// -*-C++-*-
|
2016-08-05 11:16:23 +00:00
|
|
|
#version 120
|
2014-02-25 08:49:37 +00:00
|
|
|
|
|
|
|
// Shader that uses OpenGL state values to do per-pixel lighting
|
|
|
|
|
|
|
|
uniform float size;
|
2014-10-24 06:36:03 +00:00
|
|
|
uniform float max_size;
|
|
|
|
|
|
|
|
|
|
|
|
uniform bool is_directional;
|
2014-02-25 08:49:37 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-10-24 06:36:03 +00:00
|
|
|
bool light_directional = true;
|
2014-02-25 08:49:37 +00:00
|
|
|
|
|
|
|
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-10-24 06:36:03 +00:00
|
|
|
float angular_fade = 1.0;
|
2019-10-06 08:26:42 +00:00
|
|
|
|
2014-10-24 06:36:03 +00:00
|
|
|
if (is_directional)
|
2014-08-13 07:52:59 +00:00
|
|
|
{
|
|
|
|
angular_fade = 2.0 * max(0.0,-dot(normalize(gl_Normal), normalize(relPos)));
|
|
|
|
}
|
2019-10-06 08:26:42 +00:00
|
|
|
|
|
|
|
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) ;
|
2014-10-24 06:36:03 +00:00
|
|
|
pixelSize = min(pixelSize, max_size);
|
2014-02-28 07:15:41 +00:00
|
|
|
gl_PointSize = 2.0 * pixelSize;
|
2014-02-25 08:49:37 +00:00
|
|
|
}
|