1
0
Fork 0

Towards consistent surface light rendering for ALS, some changes suggested by Emilian Huminiuc

This commit is contained in:
Thorsten Renk 2014-10-24 09:36:03 +03:00
parent 4e144a16bb
commit bd6d46a63c
3 changed files with 28 additions and 7 deletions

View file

@ -102,6 +102,16 @@
<type>float</type>
<value><use>eye_alt</use></value>
</uniform>
<uniform>
<name>max_size</name>
<type>float</type>
<value><use>max-size</use></value>
</uniform>
<uniform>
<name>is_directional</name>
<type>bool</type>
<value><use>light-directional</use></value>
</uniform>
<uniform>
<name>texture</name>
<type>sampler-2d</type>

View file

@ -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 sinphi = dot(vec2 (sin(angle),cos(angle)), normalize(coord));
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);
}

View file

@ -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;
}