git-svn-id: svn://db.shs.com.ru/libs@68 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user