1
0
Fork 0

Randomness for ALS surface lights lense flare

This commit is contained in:
Thorsten Renk 2014-04-24 09:43:28 +03:00
parent 364cc9b087
commit 6fa9d8ac88
3 changed files with 11 additions and 3 deletions

View file

@ -75,6 +75,7 @@
<program>
<vertex-shader>Shaders/surface-light-lightfield.vert</vertex-shader>
<fragment-shader>Shaders/surface-light-lightfield.frag</fragment-shader>
<fragment-shader>Shaders/noise.frag</fragment-shader>
</program>
<uniform>
<name>size</name>

View file

@ -9,10 +9,12 @@ uniform float eye_alt;
uniform float terminator;
varying vec3 relPos;
varying vec2 rawPos;
varying float pixelSize;
float alt;
float Noise2D(in vec2 coord, in float wavelength);
float fog_func (in float targ)
{
@ -41,7 +43,7 @@ else
}
vec4 light_sprite (in vec2 coord, in float transmission)
vec4 light_sprite (in vec2 coord, in float transmission, in float noise)
{
coord.s = coord.s - 0.5;
@ -51,7 +53,8 @@ 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 angle = noise * 6.28;
float sinphi = dot(vec2 (sin(angle),cos(angle)), normalize(coord));
float ray = clamp(pow(sin((sinphi-3.0) * (sinphi-3.0)),10.0),0.0,1.0);
@ -76,6 +79,8 @@ void main()
float distance_in_layer;
float transmission_arg;
float noise = Noise2D(rawPos.xy ,1.0);
// angle with horizon
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
@ -139,7 +144,7 @@ void main()
float dist_att = exp(-0.3/attenuationScale/pixelSize);
//vec4 texel = texture2D(texture,gl_TexCoord[0].st);
vec4 texel = light_sprite(gl_TexCoord[0].st,transmission);
vec4 texel = light_sprite(gl_TexCoord[0].st,transmission, noise);
gl_FragColor = vec4 (gl_Color.rgb, texel.a * transmission * dist_att);

View file

@ -6,6 +6,7 @@
uniform float size;
varying vec3 relPos;
varying vec2 rawPos;
varying float pixelSize;
@ -17,6 +18,7 @@ void main()
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 lightScale = size * size * size * size * size / 1000.0;
pixelSize = min(size * size/25.0,lightScale/dist);