git-svn-id: svn://db.shs.com.ru/libs@55 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -17,8 +17,11 @@ float light_diffuse(int model, vec3 l, vec3 n) {return max(0., dot(l, n));}
|
||||
float light_specular(int model, vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {return max(0., pow(dot(n, h), shininess));}
|
||||
|
||||
vec4 pos, lpos, shp;
|
||||
vec3 li, si, ldir, halfV;
|
||||
float sh_pow, sh_mul, dist, NdotL, NdotH, spot, ldist, diff;
|
||||
vec3 li, si, ldir, halfV, bn, bn2;
|
||||
vec2 vds, vds2;
|
||||
float sh_pow, sh_mul, dist, NdotL, NdotH, spot, ldist, diff, sdist, shadow;
|
||||
|
||||
|
||||
|
||||
void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
||||
lpos = qgl_Light[index].position;
|
||||
@@ -37,23 +40,47 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
||||
spot *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
|
||||
//spot = pow(spot, (qgl_Light[index].spotExponent + 0.001));
|
||||
shp = qgl_Light[index].shadowMatrix*vec4(pos.xyz,1);
|
||||
shp.z -= 0.1;
|
||||
///spot *= textureProj(qgl_Light[index].shadow, shp);
|
||||
float ds = shp.z / 100, dds = ds + ds;
|
||||
float shadow = textureProj(qgl_Light[index].shadow, vec4(shp.xy, shp.zw))/* +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( 0, ds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( 0, -ds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( ds, 0), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( -ds, 0), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( ds, ds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( ds, -ds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( -ds, -ds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( -ds, ds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( dds, 0), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2(-dds, 0), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( 0, dds), shp.zw)) +
|
||||
textureProj(qgl_Light[index].shadow, vec4(shp.xy + vec2( 0, -dds), shp.zw))*/;
|
||||
spot *= shadow / 1.;
|
||||
//shp.z -= 0.1;
|
||||
shp.xyz /= shp.w;
|
||||
float shr = texture(qgl_Light[index].shadowColor, shp.xy).r;
|
||||
sdist = shp.w - shr - 1.;
|
||||
//if (sdist > 0.) {
|
||||
float ds = 0.01;//max(abs(sdist) / 5000, 0.02);
|
||||
//spot *= clamp(1. - sdist, 0, 1);
|
||||
vds = vec2(ds,0);//bn.xy * ds;
|
||||
vds2 = vec2(0,ds);//bn2.xy * ds;
|
||||
shadow = //shr + //texture(qgl_Light[index].shadowColor, shp.xy, shp.zw)) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy + vds ).r - 1, 0, 1)
|
||||
/*clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy + vds - vds2 ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy + vds + vds2 ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy - vds ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy - vds - vds2 ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy - vds + vds2 ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy - vds2 ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy + vds2 ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy + vds + vds ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy - vds - vds ).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy - vds2 - vds2).r - 1, 0, 1) +
|
||||
clamp(shp.w - texture(qgl_Light[index].shadowColor, shp.xy + vds2 + vds2).r - 1, 0, 1)*/;
|
||||
/*texture(qgl_Light[index].shadowColor, shp.xy - vds ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy - vds + vds2 ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds2 ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy - vds ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy - vds2 ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy - vds - vds2 ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy ).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r +
|
||||
texture(qgl_Light[index].shadowColor, shp.xy + vds + vds + vds2 + vds2).r*/;
|
||||
shadow = shadow / 1;// - 0.5;
|
||||
spot *= ds*100;//clamp(1. - shadow, 0, 1);
|
||||
//}
|
||||
///spot *= textureProj(qgl_Light[index].shadow, shp);
|
||||
}
|
||||
spot /= (qgl_Light[index].constantAttenuation + ldist * (qgl_Light[index].linearAttenuation + ldist * qgl_Light[index].quadraticAttenuation));
|
||||
@@ -85,13 +112,15 @@ void main(void) {
|
||||
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.);
|
||||
bn = vec3(v3.w, v4.zw);
|
||||
bn2 = normalize(cross(n, bn));
|
||||
float height = v2.w;
|
||||
li = qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
|
||||
si = vec3(0.);
|
||||
|
||||
float posz = z_near * z_far / (texelFetch(td, tc, 0).r * (z_far - z_near) - z_far);
|
||||
pos = vec4(sp, 0., 1) * mat_proji;
|
||||
pos.xy *= v3.w;
|
||||
pos.xy *= v0.w;
|
||||
pos.z = posz;
|
||||
//pos.xyz += n * height;
|
||||
//pos.xyz = v3.xyz;
|
||||
@@ -115,6 +144,6 @@ void main(void) {
|
||||
//shd = shd - shp.w;
|
||||
//qgl_FragData[0].rgb = vec3(abs(shd)/10000);
|
||||
//qgl_FragData[0].rgb = vec3((shp.z)/1000);
|
||||
//qgl_FragData[0].rgb = vec3(abs(pos.xyz)/1000);
|
||||
qgl_FragData[0].rgb = vec3((shp.w-1 - texture(qgl_Light[4].shadowColor, shp.xy-vec2(0.01,0)).r));
|
||||
//qgl_FragData[0].a = 0.;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user