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

This commit is contained in:
2015-12-13 21:43:59 +00:00
parent 8f0c371a96
commit 0ba2de4741
16 changed files with 193 additions and 75 deletions

View File

@@ -18,20 +18,22 @@ void main(void) {
vec4 spos = pos;
vec4 tpos;
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
vec3 dc = v0.rgb, n = v1.xyz;
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
vec3 rn = reflect(vd, n);
//rn.z += 1.;
float coeff = clamp(1.-(dot(vec3(0,0,1), n)), 0, 1), cz = v0.w;
float coeff = clamp(1. - (dot(vec3(0,0,1), n)), 0, 1), cz = v0.w;
coeff = coeff*coeff;
coeff = coeff*coeff;
float reflectivity = 0.;
float specularity = modf(v1.w, reflectivity);
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) {
for (i = 0; i < 20; ++i) {
tpos = mat_proj * pos;
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
tv0 = texture(t0, tsp);
@@ -43,8 +45,11 @@ void main(void) {
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;
vec4 pr_pos = mat_proj * pos, pr_spos = mat_proj * spos;
pr_pos.xyz /= pr_pos.w;
pr_spos.xyz /= pr_spos.w;
float blur = step(0., coeff) * length(pr_pos.xyz - pr_spos.xyz) * (1. - specularity);
vec3 rvs = max(texture(ts, tsp).rgb, vec3(0));
qgl_FragData[0] = vec4(rvs.rgb, coeff + clamp(round(blur * 10), 0, 1000));
qgl_FragData[0] = vec4(rvs.rgb, coeff / 1.1 + clamp(round(blur * 10), 0, 1000));
}