Optimize lighting model a bit.

git-svn-id: https://svn.eduke32.com/eduke32@1265 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-03-25 13:23:35 +00:00
parent a4070de923
commit 53bbdc9cd7
3 changed files with 17 additions and 28 deletions

View file

@ -125,7 +125,7 @@ typedef enum {
} prlighttype; } prlighttype;
typedef struct s_prlight { typedef struct s_prlight {
int32_t x, y, z, horiz, faderange, range; int32_t x, y, z, horiz, range;
int16_t angle, sector; int16_t angle, sector;
char color[3]; char color[3];
prlighttype type; prlighttype type;

View file

@ -330,23 +330,15 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" lightRange.x = gl_LightSource[0].constantAttenuation;\n" " lightRange.x = gl_LightSource[0].constantAttenuation;\n"
" lightRange.y = gl_LightSource[0].linearAttenuation;\n" " lightRange.y = gl_LightSource[0].linearAttenuation;\n"
"\n" "\n"
" if (pointLightDistance > lightRange.y)\n" " lightAttenuation = clamp(1.0 - pointLightDistance * lightRange.y, 0.0, 1.0);\n"
" lightAttenuation = 0.0;\n"
" else if (pointLightDistance < lightRange.x)\n"
" lightAttenuation = 1.0;\n"
" else\n"
" lightAttenuation = 1.0 - (pointLightDistance - lightRange.x) /\n"
" (lightRange.y - lightRange.x);\n"
"\n" "\n"
" if (lightAttenuation > 0.0) {\n"
" if (isNormalMapped == 1) {\n" " if (isNormalMapped == 1) {\n"
" N = 2.0 * (normalTexel.rgb - 0.5);\n" " N = 2.0 * (normalTexel.rgb - 0.5);\n"
" N = normalize(TBN * N);\n" " N = normalize(TBN * N);\n"
" } else\n" " } else\n"
" N = normalize(vertexNormal);\n" " N = normalize(vertexNormal);\n"
" NdotL = dot(N, L);\n" " NdotL = max(dot(N, L), 0.0);\n"
"\n" "\n"
" if (NdotL > 0.0) {\n"
" E = normalize(eyeVector);\n" " E = normalize(eyeVector);\n"
" R = reflect(-L, N);\n" " R = reflect(-L, N);\n"
"\n" "\n"
@ -356,8 +348,6 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
"\n" "\n"
" lightSpecular = pow( max(dot(R, E), 0.0), 60.0) * 10.0;\n" " lightSpecular = pow( max(dot(R, E), 0.0), 60.0) * 10.0;\n"
" result += vec4(lightDiffuse * lightSpecular, 0.0);\n" " result += vec4(lightDiffuse * lightSpecular, 0.0);\n"
" }\n"
" } //else { result = vec4(0.0, 1.0, 0.0, 1.0); }\n"
"\n", "\n",
}, },
{ {
@ -3178,8 +3168,8 @@ static int32_t polymer_bindmaterial(_prmaterial material, char* lights, int
polymer_transformpoint(inpos, pos, curmodelviewmatrix); polymer_transformpoint(inpos, pos, curmodelviewmatrix);
range[0] = prlights[lights[curlight]].faderange / 1000.0f; range[0] = prlights[lights[curlight]].range / 1000.0f;
range[1] = prlights[lights[curlight]].range / 1000.0f; range[1] = 1 / range[0];
color[0] = prlights[lights[curlight]].color[0] / 255.0f; color[0] = prlights[lights[curlight]].color[0] / 255.0f;
color[1] = prlights[lights[curlight]].color[1] / 255.0f; color[1] = prlights[lights[curlight]].color[1] / 255.0f;

View file

@ -7379,7 +7379,6 @@ PALONLY:
light.z = t->z; light.z = t->z;
light.range = tilesizx[t->picnum]*tilesizy[t->picnum]; light.range = tilesizx[t->picnum]*tilesizy[t->picnum];
light.faderange = 0;
light.color[0] = 255; light.color[0] = 255;
light.color[1] = 80; light.color[1] = 80;