Multiple light sources and repair the indentation fuckup caused by the transition to normalized integer types.

git-svn-id: https://svn.eduke32.com/eduke32@1212 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-01-16 05:03:12 +00:00
parent d1b9aa4c5c
commit 91c6cf8f7a
2 changed files with 109 additions and 121 deletions

View file

@ -192,37 +192,24 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
{ {
1 << PR_BIT_POINT_LIGHT, 1 << PR_BIT_POINT_LIGHT,
// vert_def // vert_def
"#define MAX_LIGHTS 2\n"
"uniform int lightCount;\n"
"uniform vec3 pointLightPosition[MAX_LIGHTS];\n"
"uniform vec2 pointLightRange[MAX_LIGHTS];\n"
"varying vec3 vertexNormal;\n" "varying vec3 vertexNormal;\n"
"varying vec3 vertexPos;\n" "varying vec3 vertexPos;\n"
"varying vec3 lightVector[MAX_LIGHTS];\n"
"\n", "\n",
// vert_prog // vert_prog
" vec3 lightPos;\n"
"\n"
" vertexNormal = normalize(gl_NormalMatrix * gl_Normal);\n" " vertexNormal = normalize(gl_NormalMatrix * gl_Normal);\n"
" vertexPos = vec3(gl_ModelViewMatrix * gl_Vertex);\n" " vertexPos = vec3(gl_ModelViewMatrix * gl_Vertex);\n"
"\n"
" while (l < lightCount) {\n"
" lightPos = pointLightPosition[l];\n"
" lightVector[l] = lightPos - vertexPos;\n"
"\n"
" l++;\n"
" }\n"
"\n", "\n",
// frag_def // frag_def
"#define MAX_LIGHTS 2\n" "#define MAX_LIGHTS 32\n"
"uniform int lightCount;\n" "uniform int lightCount;\n"
"uniform vec3 pointLightPosition[MAX_LIGHTS];\n"
"uniform vec3 pointLightColor[MAX_LIGHTS];\n" "uniform vec3 pointLightColor[MAX_LIGHTS];\n"
"uniform vec2 pointLightRange[MAX_LIGHTS];\n" "uniform vec2 pointLightRange[MAX_LIGHTS];\n"
"varying vec3 vertexNormal;\n" "varying vec3 vertexNormal;\n"
"varying vec3 vertexPos;\n" "varying vec3 vertexPos;\n"
"varying vec3 lightVector[MAX_LIGHTS];\n"
"\n", "\n",
// frag_prog // frag_prog
" vec3 lightVector;\n"
" vec3 fragmentNormal;\n" " vec3 fragmentNormal;\n"
" float dotNormalLightDir;\n" " float dotNormalLightDir;\n"
" float lightAttenuation;\n" " float lightAttenuation;\n"
@ -231,8 +218,9 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" fragmentNormal = normalize(vertexNormal);\n" " fragmentNormal = normalize(vertexNormal);\n"
"\n" "\n"
" while (l < lightCount) {\n" " while (l < lightCount) {\n"
" pointLightDistance = length(lightVector[l]);\n" " lightVector = pointLightPosition[l] - vertexPos;\n"
" dotNormalLightDir = max(dot(fragmentNormal, normalize(lightVector[l])), 0.0);\n" " pointLightDistance = length(lightVector);\n"
" dotNormalLightDir = max(dot(fragmentNormal, normalize(lightVector)), 0.0);\n"
" if (pointLightDistance < pointLightRange[l].y)\n" " if (pointLightDistance < pointLightRange[l].y)\n"
" {\n" " {\n"
" if (pointLightDistance < pointLightRange[l].x)\n" " if (pointLightDistance < pointLightRange[l].x)\n"
@ -242,7 +230,7 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" (pointLightRange[l].y - pointLightRange[l].x);\n" " (pointLightRange[l].y - pointLightRange[l].x);\n"
" }\n" " }\n"
" result += vec4(lightAttenuation * dotNormalLightDir * pointLightColor[l], 0.0);\n" " result += vec4(lightAttenuation * dotNormalLightDir * pointLightColor[l], 0.0);\n"
" float specular = pow( max(dot(reflect(-normalize(lightVector[l]), fragmentNormal), normalize(-vertexPos)), 0.0), 60.0);\n" " float specular = pow( max(dot(reflect(-normalize(lightVector), fragmentNormal), normalize(-vertexPos)), 0.0), 60.0);\n"
" result += vec4(lightAttenuation * specular * vec3(1.0, 0.5, 0.5), 0.0);\n" " result += vec4(lightAttenuation * specular * vec3(1.0, 0.5, 0.5), 0.0);\n"
" }\n" " }\n"
"\n" "\n"
@ -2762,11 +2750,11 @@ static int32_t polymer_bindmaterial(_prmaterial material)
pos[5] * rootmodelviewmatrix[10] + pos[5] * rootmodelviewmatrix[10] +
+ rootmodelviewmatrix[14]; + rootmodelviewmatrix[14];
color[3] = 0.1f; color[3] = 0.5f;
color[4] = 0.5f; color[4] = 0.5f;
color[5] = 0.1f; color[5] = 0.5f;
range[2] = 0.0f / 1000.0; range[2] = 5000.0f / 1000.0;
range[3] = 10000.0f / 1000.0; range[3] = 10000.0f / 1000.0;
/* bglUniform3fARB(prprograms[programbits].uniform_pointLightPosition, 62208, 42000 / 16.0, -6919); /* bglUniform3fARB(prprograms[programbits].uniform_pointLightPosition, 62208, 42000 / 16.0, -6919);