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

@@ -20,30 +20,23 @@ void main(void) {
vec4 dc = qgl_FragColor;
vec2 tc = qgl_FragTexture.xy;
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
//if (acc_fog) dc.xyz = mix(dc.rgb, gl_Fog.color.rgb, fogCoord);
vec3 n, dn, bn;
dn = (texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.)) * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
//float tx = dn.x;
dn.y = -dn.y;
//dn.y = tx;
dn = TBN * dn;
//dn = dn * mat3(qgl_ModelViewMatrix)*10;//*(mat3(qgl_NormalMatrix));
n = normalize(qgl_NormalMatrix * (normal + dn));//normalize(qgl_NormalMatrix * (normal - dn));
bn = normalize(qgl_NormalMatrix * binormal);//normalize(qgl_NormalMatrix * (normal - dn));
n = normalize(qgl_NormalMatrix * (normal + dn));
bn = normalize(qgl_NormalMatrix * binormal);
//n = dn;
/*vec2 dpm = normalize(gl_FragCoord.xy * dt * 2. - vec2(1., 1.)), ntc;
ntc = gl_FragCoord.xy * dt * 2. - vec2(1., 1.) + dpm * hei;
dpm = gl_ModelViewProjectionMatrixInverse
dpm = dpm * gl_ModelViewProjectionMatrixInverse;
dpm += */
//tc += 1+et.xy * hei/10;// / et.z;
dc *= texture(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
vec4 spec = texture(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
spec *= qgl_Material.color_specular;
vec4 specularity = texture(qgl_Material.map_specularity.map, tc) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
float specularity = dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
specularity = clamp(specularity, 0.05, 0.99);
float reflectivity = qgl_Material.reflectivity;//dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
reflectivity = clamp(reflectivity, 0., 1.);
vec4 self = texture(qgl_Material.map_self_illumination.map, tc) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
self *= qgl_Material.color_self_illumination;
@@ -52,7 +45,7 @@ void main(void) {
//gl_FragDepth = logz;
qgl_FragData[0] = vec4(dc.rgb, pos.w);
qgl_FragData[1] = vec4(n.xyz / 2. + vec3(0.5), specularity);
qgl_FragData[1] = vec4(n.xyz, specularity + round(reflectivity * 100));
qgl_FragData[2] = vec4(spec.rgb, hei);
qgl_FragData[3] = vec4(self.rgb, bn.x);
qgl_FragData[4] = vec4(speed.xy, bn.yz);

View File

@@ -100,7 +100,7 @@ void main(void) {
v3 = texelFetch(t3, tc, 0),
v4 = texelFetch(t4, tc, 0);
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
vec3 dc = v0.rgb, n = v1.xyz;
bn = normalize(vec3(v3.w, v4.zw));
bn2 = normalize(cross(n, bn));
float height = v2.w;
@@ -127,13 +127,15 @@ void main(void) {
//pos.z = v0.w;
vec3 v = normalize(-pos.xyz);
sh_pow = 1. / max((1. - v1.w), 0.0001);
sh_mul = max(1. - v1.w, 0.0001);
float reflectivity = 0.;
float specularity = modf(v1.w, reflectivity);
sh_pow = 1. / max((1. - specularity), 0.0001);
sh_mul = max(1. - specularity, 0.0001);
for (int i = 0; i < 8; ++i)
calcLight(i, n, v, v2);
calcLight(0, n, v, v2);
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb;
qgl_FragData[0] = vec4(li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb, v0.w);
//qgl_FragData[0].rgb = vec3(abs((v0.w)/50));
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
//shd = shd - shp.w;

View File

@@ -16,7 +16,7 @@ void main(void) {
for (int i = 0; i < steps; ++i) {
ct += speed.xy * cdt;
float mul = 1. - abs(i - hsteps) * 2. / steps;
scol += texture(t0, ct).rgb * mul;
scol += max(texture(t0, ct).rgb, vec3(0)) * mul;
sum += mul;
}
scol /= sum;

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));
}

View File

@@ -9,10 +9,11 @@ void main(void) {
float r = float(radius);
vec4 v0 = texture(t0, tc);
float rad;
float coeff = modf(v0.a, rad);
float coeff = modf(v0.a, rad) * 1.1;
rad /= 10.;
rad *= 2;
float o = radius * rad, o2 = radius * rad * 2;
vec3 scol = (v0.rgb * 3. +
vec3 scol = (max(v0.rgb, vec3(0)) * 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. +

View File

@@ -1,12 +1,15 @@
#version 150
uniform sampler2D t0, ts;
uniform sampler2D t0, tg1, ts;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(t0, tc, 0), vs = texelFetch(ts, tc, 0);
vec4 v0 = texelFetch(t0, tc, 0), vg1 = texelFetch(tg1, 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);
float coeff = clamp(modf(v0.a, rad) * 1.1, 0., 1.);
float reflectivity = 0.;
float specularity = modf(vg1.w, reflectivity);
reflectivity = clamp(reflectivity / 100., 0., 1.);
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff * reflectivity);
//qgl_FragData[0].rgb = vec3(vs.rgb*coeff * reflectivity);
}