git-svn-id: svn://db.shs.com.ru/libs@54 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -11,12 +11,12 @@ uniform float z_near, z_far;
|
||||
uniform bool firstPass;
|
||||
uniform vec2 dt;
|
||||
uniform vec4 back_color;
|
||||
uniform mat4 mat_proji;
|
||||
uniform mat4 mat_proji, mat_viewi, mat_viewproji;
|
||||
|
||||
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;
|
||||
vec4 pos, lpos, shp;
|
||||
vec3 li, si, ldir, halfV;
|
||||
float sh_pow, sh_mul, dist, NdotL, NdotH, spot, ldist, diff;
|
||||
|
||||
@@ -36,6 +36,25 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
||||
//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));
|
||||
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.;
|
||||
///spot *= textureProj(qgl_Light[index].shadow, shp);
|
||||
}
|
||||
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);
|
||||
@@ -86,16 +105,16 @@ void main(void) {
|
||||
|
||||
sh_pow = 1. / max((1. - v1.w), 0.0001);
|
||||
sh_mul = max(1. - v1.w, 0.0001);
|
||||
for (int i = 0; i < 1; ++i)
|
||||
calcLight(i, n, v, v2);
|
||||
//for (int i = 0; i < 8; ++i)
|
||||
// calcLight(i, n, v, v2);
|
||||
calcLight(4, n, v, v2);
|
||||
|
||||
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texture(t_pp, tc).rgb;
|
||||
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb;
|
||||
//qgl_FragData[0].rgb = vec3(abs(lpos.xyz - pos.xyz)/10);
|
||||
//qgl_FragData[0].rgb = vec3(ldist/1000);
|
||||
vec2 shp = (vec4(qgl_FragTexture.xy, 1, 1) *transpose(qgl_Light[0].shadowMatrix)).xy;
|
||||
float shd = 1./texture(qgl_Light[0].shadow, shp).r;
|
||||
shd = shd*shd;// - ldist;
|
||||
qgl_FragData[0].rgb = vec3(abs(shd)/1000000);
|
||||
//qgl_FragData[0].rgb = vec3(*1000);
|
||||
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
||||
//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].a = 0.;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user