return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
light->SpotExponent = params[0];
- _mesa_invalidate_spot_exp_table(light);
break;
case GL_SPOT_CUTOFF:
ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0));
-/*
- * Whenever the spotlight exponent for a light changes we must call
- * this function to recompute the exponent lookup table.
- */
-void
-_mesa_invalidate_spot_exp_table( struct gl_light *l )
-{
- l->_SpotExpTable[0][0] = -1;
-}
-
-
-static void
-validate_spot_exp_table( struct gl_light *l )
-{
- GLint i;
- GLdouble exponent = l->SpotExponent;
- GLdouble tmp = 0;
- GLint clamp = 0;
-
- l->_SpotExpTable[0][0] = 0.0;
-
- for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) {
- if (clamp == 0) {
- tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent);
- if (tmp < FLT_MIN * 100.0) {
- tmp = 0.0;
- clamp = 1;
- }
- }
- l->_SpotExpTable[i][0] = (GLfloat) tmp;
- }
- for (i = 0; i < EXP_TABLE_SIZE - 1; i++) {
- l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] -
- l->_SpotExpTable[i][0]);
- }
- l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0;
-}
-
-
-
/* Calculate a new shine table. Doing this here saves a branch in
* lighting, and the cost of doing it early may be partially offset
* by keeping a MRU cache of shine tables for various shine values.
void
_mesa_validate_all_lighting_tables( struct gl_context *ctx )
{
- GLuint i;
GLfloat shininess;
shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0];
shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0];
if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess)
validate_shine_table( ctx, 1, shininess );
-
- for (i = 0; i < ctx->Const.MaxLights; i++)
- if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1)
- validate_spot_exp_table( &ctx->Light.Light[i] );
}
light->_NormSpotDirection);
if (PV_dot_dir > light->_CosCutoff) {
- double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- int k = (int) x;
light->_VP_inf_spot_attenuation =
- (GLfloat) (light->_SpotExpTable[k][0] +
- (x-k)*light->_SpotExpTable[k][1]);
+ powf(PV_dot_dir, light->SpotExponent);
}
else {
light->_VP_inf_spot_attenuation = 0;
ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 );
ASSIGN_3V( l->SpotDirection, 0.0, 0.0, -1.0 );
l->SpotExponent = 0.0;
- _mesa_invalidate_spot_exp_table( l );
l->SpotCutoff = 180.0;
l->_CosCutoffNeg = -1.0f;
l->_CosCutoff = 0.0; /* KW: -ve values not admitted */
GLuint legal,
const char * );
-extern void _mesa_invalidate_spot_exp_table( struct gl_light *l );
-
extern void _mesa_invalidate_shine_table( struct gl_context *ctx, GLuint i );
extern void _mesa_validate_all_lighting_tables( struct gl_context *ctx );
#else
#define _mesa_update_color_material( c, r ) ((void)0)
#define _mesa_validate_all_lighting_tables( c ) ((void)0)
-#define _mesa_invalidate_spot_exp_table( l ) ((void)0)
#define _mesa_material_bitmask( c, f, p, l, s ) 0
#define _mesa_init_lighting( c ) ((void)0)
#define _mesa_free_lighting_data( c ) ((void)0)
continue; /* this light makes no contribution */
}
else {
- GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- GLint k = (GLint) x;
- GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
- + (x-k)*light->_SpotExpTable[k][1]);
+ GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
attenuation *= spot;
}
}
continue; /* this light makes no contribution */
}
else {
- GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- GLint k = (GLint) x;
- GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
- + (x-k)*light->_SpotExpTable[k][1]);
+ GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
attenuation *= spot;
}
}
OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormSpotDirection );
OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation );
printf( "\n" );
- OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable );
OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient );
OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse );
OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular );