git-svn-id: svn://db.shs.com.ru/libs@636 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -17,8 +17,8 @@ in vec3 view_dir;
|
||||
uniform vec2 dt;
|
||||
uniform float z_near;
|
||||
uniform sampler2D tex_0, tex_1, tex_2, tex_3, tex_4;
|
||||
uniform sampler2D tex_d;
|
||||
uniform int lights_count;
|
||||
uniform sampler2D tex_d, tex_sum;
|
||||
uniform int lights_start, lights_count;
|
||||
|
||||
const vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
const float _pe = 2.4e-7;
|
||||
@@ -36,45 +36,45 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
|
||||
halfV = normalize(ldir + v);
|
||||
NdotL = max(dot(n, ldir), 1E-6);
|
||||
NdotH = max(dot(n, halfV), 1E-6);
|
||||
spot = step(1.01E-6, NdotL) * qgl_light_parameter[index].intensity;
|
||||
/*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 *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
|
||||
//lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
|
||||
//bn = normalize(cross(lwdir, vec3(1, 0, 0)));
|
||||
//bn2 = normalize(cross(lwdir, bn));
|
||||
float ds = ldist/200.;//max(abs(sdist) / 5000, 0.02);
|
||||
//spot *= clamp(1. - sdist, 0, 1);
|
||||
vds = ds * bn.xyz;
|
||||
vds2 = ds * bn2.xyz;
|
||||
float shadow = getShadow(index, pos.xyz, vec3(0)) * 3.;
|
||||
shadow += getShadow(index, pos.xyz, vds ) * 2.;
|
||||
shadow += getShadow(index, pos.xyz, - vds ) * 2.;
|
||||
shadow += getShadow(index, pos.xyz, - vds2 ) * 2.;
|
||||
shadow += getShadow(index, pos.xyz, + vds2 ) * 2.;
|
||||
//shadow += getShadow(index, pos.xyz, vds - vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, - vds + vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds );
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds );
|
||||
//shadow += getShadow(index, pos.xyz, - vds2 - vds2);
|
||||
//shadow += getShadow(index, pos.xyz, + vds2 + vds2);
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds - vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds - vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds + vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds + vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, vds - vds2 - vds2);
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds2 + vds2);
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds2 - vds2);
|
||||
//shadow += getShadow(index, pos.xyz, - vds + vds2 + vds2);
|
||||
//shadow += shadow += getShadow(index, pos.xyz, vds+vds2)*10;
|
||||
spot *= mix(1., shadow / 11., shadow_on);
|
||||
}*/
|
||||
//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);
|
||||
//si += spot * qgl_Light[index].color.rgb * shm_diff * light_specular(0, ldir, n, halfV, v, sh_pow);
|
||||
spot = step(1.001E-6, NdotL) * qgl_light_parameter[index].intensity;
|
||||
#ifdef SPOT
|
||||
float scos = max(dot(-ldir, qgl_light_position[index].direction.xyz), 0.);
|
||||
spot *= scos * step(qgl_light_parameter[index].endAngleCos, scos);
|
||||
spot *= smoothstep(qgl_light_parameter[index].endAngleCos, qgl_light_parameter[index].startAngleCos, scos);
|
||||
/*//lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
|
||||
//bn = normalize(cross(lwdir, vec3(1, 0, 0)));
|
||||
//bn2 = normalize(cross(lwdir, bn));
|
||||
float ds = ldist/200.;//max(abs(sdist) / 5000, 0.02);
|
||||
//spot *= clamp(1. - sdist, 0, 1);
|
||||
vds = ds * bn.xyz;
|
||||
vds2 = ds * bn2.xyz;
|
||||
float shadow = getShadow(index, pos.xyz, vec3(0)) * 3.;
|
||||
shadow += getShadow(index, pos.xyz, vds ) * 2.;
|
||||
shadow += getShadow(index, pos.xyz, - vds ) * 2.;
|
||||
shadow += getShadow(index, pos.xyz, - vds2 ) * 2.;
|
||||
shadow += getShadow(index, pos.xyz, + vds2 ) * 2.;
|
||||
//shadow += getShadow(index, pos.xyz, vds - vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, - vds + vds2 ) * 1.5;
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds );
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds );
|
||||
//shadow += getShadow(index, pos.xyz, - vds2 - vds2);
|
||||
//shadow += getShadow(index, pos.xyz, + vds2 + vds2);
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds - vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds - vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds + vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds + vds2 );
|
||||
//shadow += getShadow(index, pos.xyz, vds - vds2 - vds2);
|
||||
//shadow += getShadow(index, pos.xyz, vds + vds2 + vds2);
|
||||
//shadow += getShadow(index, pos.xyz, - vds - vds2 - vds2);
|
||||
//shadow += getShadow(index, pos.xyz, - vds + vds2 + vds2);
|
||||
//shadow += shadow += getShadow(index, pos.xyz, vds+vds2)*10;
|
||||
spot *= mix(1., shadow / 11., shadow_on);*/
|
||||
#endif
|
||||
spot /= (qgl_light_parameter[index].constantAttenuation +
|
||||
ldist * (qgl_light_parameter[index].linearAttenuation +
|
||||
ldist * qgl_light_parameter[index].quadraticAttenuation));
|
||||
float NdotLs = NdotL*NdotL;
|
||||
float NdotHs = NdotH*NdotH;
|
||||
|
||||
@@ -106,7 +106,6 @@ void main(void) {
|
||||
|
||||
pos.w = 1;
|
||||
pos.xyz = view_dir * z;
|
||||
//pos.z = -pos.z;
|
||||
vec3 v = normalize(-pos.xyz);
|
||||
|
||||
//vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
|
||||
@@ -127,14 +126,14 @@ void main(void) {
|
||||
li = vec3(0.);//qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
|
||||
si = vec3(0.);
|
||||
for (int i = 0; i < lights_count; ++i)
|
||||
calcLight(i, normal, v);
|
||||
// calcLight(0, n, v, v2);
|
||||
|
||||
//calcLight(0, normal, v);
|
||||
calcLight(lights_start + i, normal, v);
|
||||
|
||||
qgl_FragColor.rgb = max(vec3(0), li * diffuse + si * specular + emission);
|
||||
vec4 result = vec4(max(vec3(0), li * diffuse + si * specular + emission), 1);
|
||||
#ifndef FIRST_PASS
|
||||
result += texelFetch(tex_sum, tc, 0);
|
||||
#endif
|
||||
qgl_FragColor = result;
|
||||
//qgl_FragColor.rgb = vec3(1);
|
||||
qgl_FragColor.a = 1;
|
||||
|
||||
|
||||
//qgl_FragData[4] = vec4(speed.xy, bn.yz);
|
||||
|
||||
Reference in New Issue
Block a user