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

This commit is contained in:
2015-12-10 14:42:56 +00:00
parent 30ea938f38
commit 8f0c371a96
15 changed files with 221 additions and 26 deletions

View File

@@ -1,17 +1,50 @@
#version 150
uniform sampler2D t0, t1, ts;
uniform sampler2D t0, t1, ts, tbs;
uniform float z_near, z_far;
uniform mat4 mat_proj;
uniform vec3 cam_aim, cam_pos;
in vec3 view_dir;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec2 sp = qgl_FragTexture.xy;
vec4 v0 = texelFetch(t0, tc, 0), v1 = texelFetch(t1, tc, 0), vs = texelFetch(ts, tc, 0);
vec3 sp = vec3(qgl_FragTexture.xy, v0.w);
vec2 tsp;
vec4 pos;
pos.w = 1;
pos.xyz = view_dir * v0.w;
vec4 spos = pos;
vec4 tpos;
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
vec3 vd = vec3(0, 0, 1);
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
vec3 rn = reflect(vd, n);
float coeff = clamp(dot(vd, rn), 0, 1);
vec3 rvs = texture(ts, sp - rn.xy/v0.w).rgb;
qgl_FragData[0].rgb = mix(vs.rgb, rvs, coeff);
//qgl_FragData[0].rgb = vec3(v0.w/10);
//rn.z += 1.;
float coeff = clamp(1.-(dot(vec3(0,0,1), n)), 0, 1), cz = v0.w;
coeff = coeff*coeff;
coeff = coeff*coeff;
rn.z = -rn.z;
int i = 0;
vec4 tv0;
float l = z_far * 0.5;
pos.xyz += rn * l;
for (i = 0; i < 16; ++i) {
tpos = mat_proj * pos;
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
tv0 = texture(t0, tsp);
l *= 0.5;
pos.xyz += rn * (step(pos.z, tv0.w) * 2. - 1.) * l;
}
vec2 ess = abs(tsp - vec2(0.5, 0.5)) - vec2(0.3, 0.3);
ess = clamp(ess, vec2(0, 0), vec2(0.2, 0.2));
ess = smoothstep(vec2(0.2, 0.2), vec2(0, 0), ess);
coeff *= min(ess.x, ess.y);
float blur = step(0., coeff) * length(pos.xyz - spos.xyz);
vec3 rvs = texture(ts, tsp).rgb;
qgl_FragData[0] = vec4(rvs.rgb, coeff + clamp(round(blur * 10), 0, 1000));
}

View File

@@ -1,6 +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();
}

View File

@@ -0,0 +1,37 @@
#version 150
uniform sampler2D t0;
uniform float radius = 2;
uniform vec2 dt;
void main(void) {
vec2 tc = qgl_FragTexture.xy;
float r = float(radius);
vec4 v0 = texture(t0, tc);
float rad;
float coeff = modf(v0.a, rad);
rad /= 10.;
float o = radius * rad, o2 = radius * rad * 2;
vec3 scol = (v0.rgb * 3. +
max(texture(t0, tc + dt * vec2( o, 0 )).rgb, vec3(0)) * 2. +
max(texture(t0, tc + dt * vec2( 0, o )).rgb, vec3(0)) * 2. +
max(texture(t0, tc + dt * vec2( -o, 0 )).rgb, vec3(0)) * 2. +
max(texture(t0, tc + dt * vec2( 0, -o)).rgb, vec3(0)) * 2. +
max(texture(t0, tc + dt * vec2( o, o )).rgb, vec3(0)) * 1.5 +
max(texture(t0, tc + dt * vec2( o, -o)).rgb, vec3(0)) * 1.5 +
max(texture(t0, tc + dt * vec2( -o, -o )).rgb, vec3(0)) * 1.5 +
max(texture(t0, tc + dt * vec2( -o, o )).rgb, vec3(0)) * 1.5 +
max(texture(t0, tc + dt * vec2( o2, 0 )).rgb, vec3(0)) +
max(texture(t0, tc + dt * vec2( 0, o2)).rgb, vec3(0)) +
max(texture(t0, tc + dt * vec2(-o2, 0 )).rgb, vec3(0)) +
max(texture(t0, tc + dt * vec2( 0, -o2)).rgb, vec3(0))/* +
texture(t0, tc + dt * vec2( o2, o )).rgb +
texture(t0, tc + dt * vec2( o2, -o)).rgb +
texture(t0, tc + dt * vec2(-o2, -o )).rgb +
texture(t0, tc + dt * vec2(-o2, o )).rgb +
texture(t0, tc + dt * vec2( o, o2)).rgb +
texture(t0, tc + dt * vec2( o, -o2)).rgb +
texture(t0, tc + dt * vec2( -o, -o2)).rgb +
texture(t0, tc + dt * vec2( -o, o2)).rgb*/) / 21.;
qgl_FragData[0] = vec4(scol, v0.w);
}

View File

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

View File

@@ -0,0 +1,12 @@
#version 150
uniform sampler2D t0, ts;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(t0, tc, 0), vs = texelFetch(ts, tc, 0);
float rad;
float coeff = modf(v0.a, rad);
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff);
//qgl_FragData[0].rgb = vec3(v0.rgb);
}

View File

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