git-svn-id: svn://db.shs.com.ru/libs@70 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2015-12-13 21:45:21 +00:00
parent 0ba2de4741
commit cf8bb76a80
4 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
#version 150
uniform sampler2D t0, ts, tg1;
uniform float radius = 2;
uniform vec2 dt;
vec4 getTexel(vec2 tc, vec4 fp, vec4 fps) {
vec4 ct = max(texture(t0, tc), vec4(0)), st = max(texture(ts, tc), vec4(0));
ct = mix(ct, fp, step(1, abs(fps.w - ct.w)));
return ct;
}
void main(void) {
ivec2 itc = ivec2(gl_FragCoord.xy);
vec4 vg1 = texelFetch(tg1, itc, 0);
vec2 tc = qgl_FragTexture.xy;
float o = radius, o2 = radius * 2;
vec4 fps = max(texture(ts, tc), vec4(0));
vec4 fp = max(texture(t0, tc), vec4(0));
vec4 scol = (fp * 3. +
getTexel(tc + dt * vec2( o, 0 ), fp, fps) * 2. +
getTexel(tc + dt * vec2( 0, o ), fp, fps) * 2. +
getTexel(tc + dt * vec2( -o, 0 ), fp, fps) * 2. +
getTexel(tc + dt * vec2( 0, -o), fp, fps) * 2. +
getTexel(tc + dt * vec2( o, o ), fp, fps) * 1.5 +
getTexel(tc + dt * vec2( o, -o), fp, fps) * 1.5 +
getTexel(tc + dt * vec2( -o, -o ), fp, fps) * 1.5 +
getTexel(tc + dt * vec2( -o, o ), fp, fps) * 1.5 +
getTexel(tc + dt * vec2( o2, 0 ), fp, fps) +
getTexel(tc + dt * vec2( 0, o2), fp, fps) +
getTexel(tc + dt * vec2(-o2, 0 ), fp, fps) +
getTexel(tc + dt * vec2( 0, -o2), fp, fps)) / 21.;
/*vec4 scol = fp;
scol = min(scol, getTexel(tc + dt * vec2( o, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( -o, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, -o), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( o, o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( o, -o), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( -o, -o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( -o, o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( o2, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, o2), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2(-o2, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, -o2), fp, fps));*/
qgl_FragData[0].rgba = vec4(vg1.z);
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,32 @@
#version 150
uniform sampler2D t0, ts, tg1;
uniform float z_near, z_far;
uniform mat4 mat_proj;
in vec3 view_dir;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(t0, tc, 0), vs = texelFetch(ts, tc, 0), vg1 = texelFetch(tg1, tc, 0);
vec3 n = vec3(-vg1.xy, vg1.z);
vec3 bn = cross(n, vec3(0, 0, 1));
vec3 bn2 = cross(n, bn);
vec4 pos;
pos.w = 1;
pos.xyz = view_dir * vs.w;
vec4 spos = pos, tpos, tv0;
vec2 tsp;
float l = 20 * 0.5;
pos.xyz += bn2 * l;
for (int i = 0; i < 16; ++i) {
tpos = mat_proj * pos;
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
tv0 = texture(ts, tsp);
l *= 0.5;
pos.xyz += bn2 * (step(pos.z, tv0.w) * 2. - 1.) * l;
}
qgl_FragData[0].rgb = vec3(1.-(vs.w - v0.w));
qgl_FragData[0].rgb = vec3(length(pos.z - spos.z)/15);
//qgl_FragData[0].rgb = vec3(abs(v0.w/1));
}

View File

@@ -0,0 +1,10 @@
#version 150
in vec3 view_corner;
out vec3 view_dir;
void main(void) {
view_dir = view_corner / view_corner.z;
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}