Talk:GLSL Programming/GLUT/Diffuse Reflection

Some comments about this tutorial.


 * Use vec3 for colors in the material, since the alpha component does not make sense here, and it saves some casts to vec3 later on.


 * As a physicist, I really don't like the contents of struct lightSource. Physically, light has just one color, which is neither "diffuse" or "specular" or whatever. And even then using the word "intensity" instead of "color" is more accurate. Physical point light sources always have quadratic attenuation. Of course, for a far away point source, you can simplify things using a constant attenuation. Linear attenuation only happens if you have a line source instead of a point source (think fluorescent tubes in an office), but then you need more than just a position vector to specify the direction of the line. It is also unrealistic for a light source to have a combination of constant, linear and quadratic attenuation. So I suggest:
 * Dropping linear attenuation from this tutorial.
 * Changing vec4 lightSource.diffuse to vec3 lightSource.intensity.
 * Using values bigger than 1 for some intensity components to make it clear this is not something that needs to be in the [0, 1] range.
 * Drop the attenuation variables completely. Use only fully constant or fully quadratic attenuation based on position.w.


 * I would not make light0.spotCutoff < 90.0 a special case. If you set spotCutoff to 180 anyway for non-spot lights then the code still works as expected. I would not worry too much about performance, an if statement itself is pretty costly.


 * Thanks for your comments!
 * Much of this tutorial decisions (naming and light model) are based on the Blender and Unity versions, which themselves are based on the OpenGL 1.x fixed Phong (non-realistic) lighting. Actually the serials of tutorials reimplements the OpenGL 1.x classic lighting.  Later tutorials goes beyond that model.
 * Using a value bigger than 1 is a good idea :) Beuc (discuss • contribs) 21:30, 14 September 2011 (UTC)

What does the "mesh.object2world" represent? What is the purpose of the m_3x3_inv_transp?
 * m_3x3_inv_transp in particular confuses me, as it is not explained at all. How am I supposed to compute it?

Should "One Directional" light source be changed to "Unidirectional" or "Omnidirectional"? It's confusing because a spot light has a direction. What's the difference between this "one directional" source and a "point" light source?