diff --git a/Effects/surface-lights.eff b/Effects/surface-lights.eff index b9bb489e4..2e7cf46dd 100644 --- a/Effects/surface-lights.eff +++ b/Effects/surface-lights.eff @@ -12,6 +12,7 @@ /environment/visibility-m /environment/ground-haze-thickness-m /sim/rendering/eye-altitude-m + /environment/terminator-relative-position-m @@ -28,7 +29,7 @@ GL_ARB_point_sprite GL_ARB_point_parameters - GL_ARB_shader_objects + GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_vertex_shader GL_ARB_fragment_shader @@ -36,22 +37,25 @@ - - - 8 - DepthSortedBin - - false - - src-alpha - one-minus-src-alpha - - - gequal - 0.1 - - directional - + + + 8 + DepthSortedBin + + false + + src-alpha + one-minus-src-alpha + + + false + + + gequal + 0.03 + + directional + point point @@ -73,8 +77,8 @@ Shaders/surface-light-lightfield.frag - size - float + size + float size @@ -102,9 +106,17 @@ sampler-2d 0 - true - + + terminator + float + terminator + + true + + + + diff --git a/Shaders/surface-light-lightfield.frag b/Shaders/surface-light-lightfield.frag index 5db78a578..a581b715e 100644 --- a/Shaders/surface-light-lightfield.frag +++ b/Shaders/surface-light-lightfield.frag @@ -6,6 +6,7 @@ uniform float visibility; uniform float avisibility; uniform float hazeLayerAltitude; uniform float eye_alt; +uniform float terminator; varying vec3 relPos; varying float pixelSize; @@ -40,6 +41,28 @@ else } +float light_sprite (in vec2 coord, in float transmission) +{ + +coord.s = coord.s - 0.5; +coord.t = coord.t - 0.5; + +float r = length(coord); + +if (pixelSize<1.3) {return vec4 (1.0,1.0,1.0,1.0) * 0.08;} + +float sinphi = dot(vec2 (1.0,0.0), normalize(coord)); + +float ray = clamp(pow(sin((sinphi-3.0) * (sinphi-3.0)),10.0),0.0,1.0); + +float fogEffect = (1.0-smoothstep(0.4,0.8,transmission)); + +float intensity = clamp(ray * exp(-40.0 * r * r) + exp(-80.0*r*r),0.0,1.0) + 0.1 * fogEffect * (1.0-smoothstep(0.3, 0.6,r)); + +return vec4 (1.0,1.0,1.0,1.0) * intensity; + +} + void main() { @@ -111,9 +134,12 @@ void main() transmission = fog_func(transmission_arg); - float dist_att = exp(-0.3/pixelSize); + float lightArg = terminator/100000.0; + float attenuationScale = 1.0 + 3.0 * (1.0 -smoothstep(-15.0, 0.0, lightArg)); + float dist_att = exp(-0.3/attenuationScale/pixelSize); - vec4 texel = texture2D(texture,gl_TexCoord[0].st); + //vec4 texel = texture2D(texture,gl_TexCoord[0].st); + vec4 texel = light_sprite(gl_TexCoord[0].st,transmission); gl_FragColor = vec4 (gl_Color.rgb, texel.a * transmission * dist_att); diff --git a/Shaders/surface-light-lightfield.vert b/Shaders/surface-light-lightfield.vert index 7762ab9a5..a8804f2de 100644 --- a/Shaders/surface-light-lightfield.vert +++ b/Shaders/surface-light-lightfield.vert @@ -20,5 +20,5 @@ void main() float dist = length(relPos); float lightScale = size * size * size * size * size / 1000.0; pixelSize = min(size * size/25.0,lightScale/dist); - gl_PointSize = pixelSize; + gl_PointSize = 2.0 * pixelSize; }