git-svn-id: svn://db.shs.com.ru/libs@47 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2015-11-26 11:53:29 +00:00
parent 2ace72ff47
commit 4cbcbb5174
26 changed files with 346 additions and 105 deletions

View File

@@ -30,11 +30,13 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
NdotH = max(dot(n, halfV), 0.);
spot = step(0., NdotL) * qgl_Light[index].intensity;
if (NdotL > 0.) {
/*if (gl_LightSource[index].spotCutoff < 180.) {
spot = max(dot(-ldir, gl_LightSource[index].spotDirection.xyz), 0.);
spot *= step(gl_LightSource[index].spotCosCutoff, spot);
spot = pow(spot, (gl_LightSource[index].spotExponent + 0.001));
}*/
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));
}
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 * sh_mul * light_specular(0, ldir, n, halfV, v, sh_pow);
@@ -72,6 +74,7 @@ void main(void) {
pos.xy *= v3.w;
pos.z = posz;
pos.xyz += n * height;
//pos.xyz = v3.xyz;
//pos = v3;
//pos = vec4(sp, 0, 1.) * mat_proji;
//pos *= v0.w;
@@ -79,37 +82,15 @@ void main(void) {
//pos.xy *= 10.;
//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);
//for (int i = 0; i < 16; ++i)
calcLight(7, n, v, v2);
/*if (lightsCount > 0) {
calcLight(0, n, v, v2);
if (lightsCount > 1) {
calcLight(1, n, v, v2);
if (lightsCount > 2) {
calcLight(2, n, v, v2);
if (lightsCount > 3) {
calcLight(3, n, v, v2);
if (lightsCount > 4) {
calcLight(4, n, v, v2);
if (lightsCount > 5) {
calcLight(5, n, v, v2);
if (lightsCount > 6) {
calcLight(6, n, v, v2);
if (lightsCount > 7) {
calcLight(7, n, v, v2);
}
}
}
}
}
}
}
}*/
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texture2D(t_pp, tc).rgb;
for (int i = 0; i < 16; ++i)
calcLight(i, n, v, v2);
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texture(t_pp, tc).rgb;
//qgl_FragData[0].rgb = vec3(abs(lpos.xyz - pos.xyz)/10);
//qgl_FragData[0].rgb = texture2D(t_pp, tc).rgb;
//qgl_FragData[0].rgb = vec3(pow(NdotH,100)*2);
//qgl_FragData[0].rgb = si.rgb;
//qgl_FragData[0].rgb = (v0.rgb)/2;
//qgl_FragData[0].a = 0.;
}