cogl-material: Don't map the shininess value to [0,1]
In OpenGL the 'shininess' lighting parameter is floating point value limited to the range 0.0→128.0. This number is used to affect the size of the specular highlight. Cogl materials used to only accept a number between 0.0 and 1.0 which then gets multiplied by 128.0 before sending to GL. I think the assumption was that this is just a weird GL quirk so we don't expose it. However the value is used as an exponent to raise the attenuation to a power so there is no conceptual limit to the value. This removes the mapping and changes some of the documentation. http://bugzilla.clutter-project.org/show_bug.cgi?id=2222
This commit is contained in:
parent
89286f6a47
commit
0ab6dc9db1
@ -507,14 +507,12 @@ _cogl_material_flush_color_blend_alpha_depth_state (
|
||||
CoglMaterialLightingState *lighting_state =
|
||||
&authority->big_state->lighting_state;
|
||||
|
||||
/* FIXME - we only need to set these if lighting is enabled... */
|
||||
GLfloat shininess = lighting_state->shininess * 128.0f;
|
||||
|
||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, lighting_state->ambient));
|
||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, lighting_state->diffuse));
|
||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, lighting_state->specular));
|
||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION, lighting_state->emission));
|
||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, &shininess));
|
||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS,
|
||||
&lighting_state->shininess));
|
||||
}
|
||||
|
||||
if (materials_difference & COGL_MATERIAL_STATE_BLEND)
|
||||
|
@ -239,6 +239,8 @@ _cogl_material_init_default_material (void)
|
||||
lighting_state->emission[2] = 0;
|
||||
lighting_state->emission[3] = 1.0;
|
||||
|
||||
lighting_state->shininess = 0.0f;
|
||||
|
||||
/* Use the same defaults as the GL spec... */
|
||||
alpha_state->alpha_func = COGL_MATERIAL_ALPHA_FUNC_ALWAYS;
|
||||
alpha_state->alpha_func_reference = 0.0;
|
||||
@ -3620,7 +3622,7 @@ cogl_material_set_shininess (CoglMaterial *material,
|
||||
|
||||
g_return_if_fail (cogl_is_material (material));
|
||||
|
||||
if (shininess < 0.0 || shininess > 1.0)
|
||||
if (shininess < 0.0)
|
||||
{
|
||||
g_warning ("Out of range shininess %f supplied for material\n",
|
||||
shininess);
|
||||
|
@ -387,11 +387,12 @@ cogl_material_get_specular (CoglMaterial *material,
|
||||
/**
|
||||
* cogl_material_set_shininess:
|
||||
* @material: A #CoglMaterial object
|
||||
* @shininess: The desired shininess; range: [0.0, 1.0]
|
||||
* @shininess: The desired shininess; must be >= 0.0
|
||||
*
|
||||
* Sets the materials shininess, in the standard OpenGL lighting model,
|
||||
* which determines how specular highlights are calculated. A higher
|
||||
* @shininess will produce smaller brigher highlights.
|
||||
* Sets the shininess of the material, in the standard OpenGL lighting
|
||||
* model, which determines the size of the specular highlights. A
|
||||
* higher @shininess will produce smaller highlights which makes the
|
||||
* object appear more shiny.
|
||||
*
|
||||
* The default value is 0.0
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user