Add in some ambient light for iqm models.

Though the bsp loader doesn't yet support colored lighting, the ambient
light will be colored when it does. With this, I guess iqm model support is
done for glsl until I figure out how I want to do dual quaternion support.
This commit is contained in:
Bill Currie 2012-05-15 19:15:51 +09:00
parent 111377f1be
commit 31772afd13
2 changed files with 9 additions and 1 deletions

View file

@ -83,6 +83,7 @@ static struct {
shaderparam_t vtangent;
shaderparam_t vnormal;
shaderparam_t vposition;
shaderparam_t ambient;
lightpar_t lights[MAX_IQM_LIGHTS];
shaderparam_t texture;
shaderparam_t normalmap;
@ -99,6 +100,7 @@ static struct {
{"vtangent", 0},
{"vnormal", 0},
{"vposition", 0},
{"ambient", 1},
{
{{"lights[0].position", 1}, {"lights[0].color", 1}},
{{"lights[1].position", 1}, {"lights[1].color", 1}},
@ -151,6 +153,7 @@ glsl_R_InitIQM (void)
GLSL_ResolveShaderParam (iqm_shader.program, &iqm_shader.vtangent);
GLSL_ResolveShaderParam (iqm_shader.program, &iqm_shader.vnormal);
GLSL_ResolveShaderParam (iqm_shader.program, &iqm_shader.vposition);
GLSL_ResolveShaderParam (iqm_shader.program, &iqm_shader.ambient);
for (i = 0; i < MAX_IQM_LIGHTS; i++) {
GLSL_ResolveShaderParam (iqm_shader.program,
&iqm_shader.lights[i].position);
@ -203,6 +206,8 @@ glsl_R_DrawIQM (void)
float blend;
iqmframe_t *frame;
R_LightPoint (ent->origin); //FIXME min_light?
VectorScale (ambientcolor, 1/255.0, ambientcolor);
R_FindNearLights (ent->origin, MAX_IQM_LIGHTS, lights);
// we need only the rotation for normals.
@ -233,6 +238,7 @@ glsl_R_DrawIQM (void)
}
#endif
qfeglUniform3fv (iqm_shader.ambient.location, 1, ambientcolor);
for (i = 0; i < MAX_IQM_LIGHTS; i++) {
quat_t val;
lightpar_t *l = &iqm_shader.lights[i];

View file

@ -4,6 +4,7 @@ struct light {
};
uniform sampler2D texture;
uniform sampler2D normalmap;
uniform vec3 ambient;
uniform light lights[8];
uniform vec4 fog;
@ -52,7 +53,8 @@ main (void)
norm = (texture2D (normalmap, st).xyz - vec3(0.5)) * 2.0;
norm = tbn * norm;
l = calc_light (norm, 0);
l = ambient;
l += calc_light (norm, 0);
l += calc_light (norm, 1);
l += calc_light (norm, 2);
l += calc_light (norm, 3);