post processing light

This commit is contained in:
j3d1 2016-10-05 23:26:55 +02:00
parent f15213db1b
commit 70b0fee526
7 changed files with 169 additions and 58 deletions

View file

@ -0,0 +1,20 @@
#version 120
uniform sampler2D tex0;
uniform sampler2D tex1;
varying vec3 vertex;
varying vec2 uv;
void main()
{
vec3 color = texture2D(tex0, uv).rgb;
vec3 current = texture2D(tex1, uv).rgb;
float a = length(color) - length(current);
if (a > 0.3) {
color = mix(vec3(a/3.0), current, color);
} else {
color = current;
}
gl_FragColor = vec4(texture2D(tex0, uv).xyz + texture2D(tex1, uv).xyz, 1.0);
}

View file

@ -0,0 +1,13 @@
#version 120
uniform vec2 uvScale;
varying vec3 vertex;
varying vec2 uv;
void main()
{
gl_Position = gl_Vertex;
vertex = gl_Position.xyz;
uv = uvScale * (0.5 + vertex.xy / 2.0);
}

View file

@ -42,8 +42,8 @@ void main()
//v /= 1.0 + max(0.0, min(35.0*(decay-0.2), 1.0)) + 10.0 * explCenterDist;
v /= 1.0 + 10.0 * explCenterDist;
gl_FragColor = vec4(hsv2rgb(vec3(h, s, v)), 1.0);
gl_FragColor = vec4(hsv2rgb(vec3(h, s, v)), v*0.2);
//gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
//gl_FragColor.rgb = vec3(0.5+0.5*(a/pi));
}
}

View file

@ -1,7 +1,6 @@
#version 120
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex;
varying vec3 vertex;
varying vec2 uv;
@ -18,9 +17,9 @@ void main()
vec2 texCoord = uv.xy - float(int(gaussRadius/2)) * scale;
vec3 color = vec3(0.0, 0.0, 0.0);
for (int i=0; i<gaussRadius; ++i) {
color += gaussFilter[i] * texture2D(tex0, texCoord).xyz;
color += gaussFilter[i] * texture2D(tex, texCoord).xyz;
texCoord += scale;
}
gl_FragColor = vec4(color, 1.0);
}
}