diff --git a/Effects/surface-lights.eff b/Effects/surface-lights.eff index ef6e27c61..ea17f3b5c 100644 --- a/Effects/surface-lights.eff +++ b/Effects/surface-lights.eff @@ -102,6 +102,16 @@ float eye_alt + + max_size + float + max-size + + + is_directional + bool + light-directional + texture sampler-2d diff --git a/Shaders/surface-light-ALS.frag b/Shaders/surface-light-ALS.frag index 2680b35cc..4dbda9abf 100644 --- a/Shaders/surface-light-ALS.frag +++ b/Shaders/surface-light-ALS.frag @@ -9,6 +9,7 @@ uniform float eye_alt; uniform float terminator; uniform float size; + varying vec3 relPos; varying vec2 rawPos; varying float pixelSize; @@ -55,9 +56,14 @@ float r = length(coord); if (pixelSize<1.3) {return vec4 (1.0,1.0,1.0,1.0) * 0.08;} float angle = noise * 6.2832; + float sinphi = dot(vec2 (sin(angle),cos(angle)), normalize(coord)); - -float ray = clamp(pow(sin(mod((sinphi-3.0) * (sinphi-3.0),6.2832)),10.0),0.0,1.0); +float sinterm = sin(mod((sinphi-3.0) * (sinphi-3.0),6.2832)); +float ray = 0.0; +if (sinterm == 0.0) + {ray = 0.0;} +else + {ray = clamp(pow(sinterm,10.0),0.0,1.0);} float fogEffect = (1.0-smoothstep(0.4,0.8,transmission)); @@ -147,7 +153,7 @@ void main() //vec4 texel = texture2D(texture,gl_TexCoord[0].st); vec4 texel = light_sprite(gl_TexCoord[0].st,transmission, noise); - gl_FragColor = vec4 (gl_Color.rgb, texel.a * transmission * dist_att); + gl_FragColor = vec4 (clamp(gl_Color.rgb,0.0,1.0), texel.a * transmission * dist_att); } diff --git a/Shaders/surface-light-ALS.vert b/Shaders/surface-light-ALS.vert index 6940b7280..0d119bd18 100644 --- a/Shaders/surface-light-ALS.vert +++ b/Shaders/surface-light-ALS.vert @@ -1,15 +1,18 @@ - // -*-C++-*- // 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; - +bool light_directional = true; void main() { @@ -20,12 +23,14 @@ void main() relPos = gl_Vertex.xyz - ep.xyz; rawPos = gl_Vertex.xy; float dist = length(relPos); - float angular_fade = 0.0; - if (length(gl_Normal)> 0.0) + float angular_fade = 1.0; + //if (length(gl_Normal)> 0.0) + if (is_directional) { 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) ; + pixelSize = min(pixelSize, max_size); gl_PointSize = 2.0 * pixelSize; }