Remove _BaseAlpha, fix reflect lighting bug.

This commit is contained in:
Keith Whitwell 2001-07-28 19:28:49 +00:00
parent 616f470629
commit 46af1f87c8
6 changed files with 40 additions and 34 deletions

View file

@ -1,4 +1,4 @@
/* $Id: light.c,v 1.44 2001/05/09 12:24:51 keithw Exp $ */
/* $Id: light.c,v 1.45 2001/07/28 19:28:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -664,7 +664,6 @@ void _mesa_update_material( GLcontext *ctx,
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse );
}
ctx->Light._BaseAlpha[0] = CLAMP( mat->Diffuse[3], 0.0, 1.0 );
}
if (bitmask & BACK_DIFFUSE_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
@ -672,7 +671,6 @@ void _mesa_update_material( GLcontext *ctx,
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse );
}
ctx->Light._BaseAlpha[1] = CLAMP( mat->Diffuse[3], 0.0, 1.0 );
}
/* update material specular values */
@ -801,7 +799,6 @@ void _mesa_update_color_material( GLcontext *ctx,
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse );
}
ctx->Light._BaseAlpha[0] = CLAMP( mat->Diffuse[3], 0.0, 1.0 );
}
if (bitmask & BACK_DIFFUSE_BIT) {
@ -810,7 +807,6 @@ void _mesa_update_color_material( GLcontext *ctx,
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse );
}
ctx->Light._BaseAlpha[1] = CLAMP( mat->Diffuse[3], 0.0, 1.0 );
}
/* update light->_MatSpecular = light's specular * material's specular */
@ -1216,9 +1212,6 @@ _mesa_update_lighting( GLcontext *ctx )
ACC_SCALE_3V(ctx->Light._BaseColor[side],
ctx->Light.Model.Ambient,
mat->Ambient);
ctx->Light._BaseAlpha[side] =
CLAMP( ctx->Light.Material[side].Diffuse[3], 0.0, 1.0 );
}
foreach (light, &ctx->Light.EnabledList) {

View file

@ -1,4 +1,4 @@
/* $Id: mtypes.h,v 1.49 2001/07/13 20:07:37 brianp Exp $ */
/* $Id: mtypes.h,v 1.50 2001/07/28 19:28:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -496,7 +496,6 @@ struct gl_light_attrib {
GLboolean _NeedVertices; /* Use fast shader? */
GLuint _Flags; /* LIGHT_* flags, see below */
GLfloat _BaseColor[2][3];
GLfloat _BaseAlpha[2];
};

View file

@ -1,4 +1,4 @@
/* $Id: rastpos.c,v 1.29 2001/07/05 15:31:21 brianp Exp $ */
/* $Id: rastpos.c,v 1.30 2001/07/28 19:28:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -126,7 +126,6 @@ shade_rastpos(GLcontext *ctx,
GLuint *Rindex)
{
GLfloat (*base)[3] = ctx->Light._BaseColor;
const GLfloat *sumA = ctx->Light._BaseAlpha;
struct gl_light *light;
GLfloat diffuseColor[4], specularColor[4];
GLfloat diffuse = 0, specular = 0;
@ -135,7 +134,7 @@ shade_rastpos(GLcontext *ctx,
_mesa_validate_all_lighting_tables( ctx );
COPY_3V(diffuseColor, base[0]);
diffuseColor[3] = sumA[0];
diffuseColor[3] = CLAMP( ctx->Light.Material[0].Diffuse[3], 0.0, 1.0 );
ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0);
foreach (light, &ctx->Light.EnabledList) {

View file

@ -1,4 +1,4 @@
/* $Id: s_context.c,v 1.24 2001/07/17 19:39:32 keithw Exp $ */
/* $Id: s_context.c,v 1.25 2001/07/28 19:28:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -541,9 +541,10 @@ _swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
v->win[0], v->win[1], v->win[2], v->win[3]);
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
fprintf(stderr, "texcoord[%d] %f %f %f %f\n", i,
v->texcoord[i][0], v->texcoord[i][1],
v->texcoord[i][2], v->texcoord[i][3]);
if (ctx->Texture.Unit[i]._ReallyEnabled)
fprintf(stderr, "texcoord[%d] %f %f %f %f\n", i,
v->texcoord[i][0], v->texcoord[i][1],
v->texcoord[i][2], v->texcoord[i][3]);
#if CHAN_TYPE == GL_FLOAT
fprintf(stderr, "color %f %f %f %f\n",

View file

@ -1,4 +1,4 @@
/* $Id: t_vb_lighttmp.h,v 1.13 2001/07/17 19:39:32 keithw Exp $ */
/* $Id: t_vb_lighttmp.h,v 1.14 2001/07/28 19:28:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -116,8 +116,6 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
(void) vstride;
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light._BaseAlpha[0]);
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light._BaseAlpha[1]);
/* fprintf(stderr, "%s\n", __FUNCTION__ ); */
@ -134,10 +132,12 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
VB->ColorPtr[0] = &store->LitColor[0];
VB->SecondaryColorPtr[0] = &store->LitSecondary[0];
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
if (IDX & LIGHT_TWOSIDE) {
VB->ColorPtr[1] = &store->LitColor[1];
VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
}
/* Side-effects done, can we finish now?
@ -158,8 +158,12 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
if ( CHECK_MATERIAL(j) )
_mesa_update_material( ctx, new_material[j], new_material_mask[j] );
if ( CHECK_VALIDATE(j) )
if ( CHECK_VALIDATE(j) ) {
_mesa_validate_all_lighting_tables( ctx );
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
if (IDX & LIGHT_TWOSIDE)
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
}
COPY_3V(sum[0], base[0]);
ZERO_3V(spec[0]);
@ -331,9 +335,6 @@ static void TAG(light_rgba)( GLcontext *ctx,
color[0] = Fcolor;
color[1] = Bcolor;
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light._BaseAlpha[0]);
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light._BaseAlpha[1]);
if (IDX & LIGHT_COLORMATERIAL) {
if (VB->ColorPtr[0]->Type != GL_FLOAT)
import_color_material( ctx, stage );
@ -343,8 +344,12 @@ static void TAG(light_rgba)( GLcontext *ctx,
}
VB->ColorPtr[0] = &store->LitColor[0];
if (IDX & LIGHT_TWOSIDE)
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
if (IDX & LIGHT_TWOSIDE) {
VB->ColorPtr[1] = &store->LitColor[1];
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
}
if (stage->changed_inputs == 0)
return;
@ -362,8 +367,12 @@ static void TAG(light_rgba)( GLcontext *ctx,
if ( CHECK_MATERIAL(j) )
_mesa_update_material( ctx, new_material[j], new_material_mask[j] );
if ( CHECK_VALIDATE(j) )
if ( CHECK_VALIDATE(j) ) {
_mesa_validate_all_lighting_tables( ctx );
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
if (IDX & LIGHT_TWOSIDE)
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
}
COPY_3V(sum[0], base[0]);
@ -565,13 +574,15 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
COPY_3V(base[0], light->_MatAmbient[0]);
ACC_3V(base[0], ctx->Light._BaseColor[0] );
UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[0], base[0] );
UNCLAMPED_FLOAT_TO_CHAN(basechan[0][3], ctx->Light._BaseAlpha[0]);
UNCLAMPED_FLOAT_TO_CHAN(basechan[0][3],
ctx->Light.Material[0].Diffuse[3]);
if (IDX & LIGHT_TWOSIDE) {
COPY_3V(base[1], light->_MatAmbient[1]);
ACC_3V(base[1], ctx->Light._BaseColor[1]);
UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[1], base[1]);
UNCLAMPED_FLOAT_TO_CHAN(basechan[1][3], ctx->Light._BaseAlpha[1]);
UNCLAMPED_FLOAT_TO_CHAN(basechan[1][3],
ctx->Light.Material[1].Diffuse[3]);
}
do {
@ -652,8 +663,8 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
(void) nr;
(void) nstride;
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light._BaseAlpha[0]);
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light._BaseAlpha[1]);
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]);
if (IDX & LIGHT_COLORMATERIAL) {
if (VB->ColorPtr[0]->Type != GL_FLOAT)
@ -680,9 +691,13 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
if ( CHECK_MATERIAL(j) )
_mesa_update_material( ctx, new_material[j], new_material_mask[j] );
if ( CHECK_VALIDATE(j) )
if ( CHECK_VALIDATE(j) ) {
_mesa_validate_all_lighting_tables( ctx );
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]);
if (IDX & LIGHT_TWOSIDE)
UNCLAMPED_FLOAT_TO_CHAN(sumA[1],
ctx->Light.Material[1].Diffuse[3]);
}
COPY_3V(sum[0], ctx->Light._BaseColor[0]);
if (IDX & LIGHT_TWOSIDE)

View file

@ -1,4 +1,4 @@
/* $Id: gen_matypes.c,v 1.2 2001/03/29 03:41:40 gareth Exp $ */
/* $Id: gen_matypes.c,v 1.3 2001/07/28 19:28:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -106,7 +106,6 @@ int main( int argc, char **argv )
OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext, Light._NeedVertices );
OFFSET( "CTX_LIGHT_FLAGS ", GLcontext, Light._Flags );
OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext, Light._BaseColor );
OFFSET( "CTX_LIGHT_BASE_ALPHA ", GLcontext, Light._BaseAlpha );
/* struct vertex_buffer offsets: