git-svn-id: svn://db.shs.com.ru/libs@58 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -24,7 +24,7 @@ float sh_pow, sh_mul, dist, NdotL, NdotH, spot, ldist, diff, sdist, shadow;
|
||||
float getShadow(int light, vec3 view_pos, vec3 dpos) {
|
||||
shp = mat_viewi * vec4(view_pos, 1);
|
||||
shp += vec4(dpos, 0);
|
||||
shp = qgl_Light[light].shadowMatrix * shp;
|
||||
//shp = qgl_Light[light].shadowMatrix * shp;
|
||||
//shp.xyz /= shp.w;
|
||||
shp.z -= 0.1;
|
||||
return textureProj(qgl_Light[light].shadow, shp);
|
||||
@@ -43,10 +43,7 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
||||
if (qgl_Light[index].endAngle <= 90.) {
|
||||
float scos = max(dot(-ldir, qgl_Light[index].direction.xyz), 0.);
|
||||
spot *= scos * step(qgl_Light[index].endAngleCos, scos);
|
||||
//spot = clamp(scos / (-qgl_Light[index].endAngleCos + qgl_Light[index].startAngleCos + 0.0001),0,1);
|
||||
spot *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
|
||||
//spot = pow(spot, (qgl_Light[index].spotExponent + 0.001));
|
||||
|
||||
lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
|
||||
bn = normalize(cross(lwdir, vec3(1, 0, 0)));
|
||||
bn2 = normalize(cross(lwdir, bn));
|
||||
@@ -54,7 +51,7 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
||||
//spot *= clamp(1. - sdist, 0, 1);
|
||||
vds = ds * bn.xyz;
|
||||
vds2 = ds * bn2.xyz;
|
||||
float shadow = getShadow(index, pos.xyz, vec3(0)) * 3. +
|
||||
float shadow = 1;/* getShadow(index, pos.xyz, vec3(0))/* * 3. +
|
||||
getShadow(index, pos.xyz, vds ) * 2. +
|
||||
getShadow(index, pos.xyz, - vds ) * 2. +
|
||||
getShadow(index, pos.xyz, - vds2 ) * 2. +
|
||||
@@ -74,47 +71,8 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
||||
getShadow(index, pos.xyz, vds - vds2 - vds2) +
|
||||
getShadow(index, pos.xyz, vds + vds2 + vds2) +
|
||||
getShadow(index, pos.xyz, - vds - vds2 - vds2) +
|
||||
getShadow(index, pos.xyz, - vds + vds2 + vds2);
|
||||
//spot *= shadow / 29.;
|
||||
/*shp = qgl_Light[index].shadowMatrix*vec4(pos.xyz,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.) {
|
||||
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);
|
||||
getShadow(index, pos.xyz, - vds + vds2 + vds2)*/;
|
||||
spot *= shadow;// / 29.;
|
||||
}
|
||||
spot /= (qgl_Light[index].constantAttenuation + ldist * (qgl_Light[index].linearAttenuation + ldist * qgl_Light[index].quadraticAttenuation));
|
||||
///li += spot * gl_LightSource[index].diffuse.rgb * light_diffuse(0, ldir, n);
|
||||
@@ -175,7 +133,17 @@ void main(void) {
|
||||
//qgl_FragData[0].rgb = vec3(abs(lpos.xyz - pos.xyz)/10);
|
||||
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
||||
//shd = shd - shp.w;
|
||||
vec3 fp = pos.xyz * lpos.w;
|
||||
vec3 _dlp = fp - qgl_Light[0].position.xyz;
|
||||
vec3 _ld = qgl_Light[0].direction.xyz;
|
||||
float lz = dot(_ld, _dlp);
|
||||
vec3 _lt = normalize(cross(_ld, _dlp));
|
||||
vec3 _lt2 = normalize(cross(_lt, _dlp));
|
||||
float ly = dot(qgl_Light[0].shadowDir0.xyz, normalize(_dlp));
|
||||
float lx = dot(qgl_Light[0].shadowDir1.xyz, normalize(_dlp));
|
||||
vec3 dd = mat3(mat_viewi)*(normalize(_dlp) - _ld);
|
||||
//qgl_FragData[0].rgb = vec3(abs(shp.xy/shp.w)/1,0);
|
||||
qgl_FragData[0].rgb = vec3(lx*qgl_Light[0].endAngleCos/1);
|
||||
//qgl_FragData[0].rgb = vec3(abs(mat3(mat_viewi)* qgl_Light[0].direction.xyz));
|
||||
//qgl_FragData[0].rgb = vec3(texture(qgl_Light[0].shadow,shp.xyz/shp.w)/2);
|
||||
//qgl_FragData[0].a = 0.;
|
||||
|
||||
Reference in New Issue
Block a user