OpenGL lighting fixes
Michael Goffioul
michael.goffioul at gmail.com
Mon Feb 2 16:37:33 CST 2009
On Mon, Feb 2, 2009 at 2:33 PM, Kai Habel <kai.habel at gmx.de> wrote:
> I am currently working on enabling light (at least for the OpenGL
> renderer). I noticed the following problems with the current code.
>
> 1.) To set the material properties (ambient and diffuse reflection) we
> have some instances in gl_render.cc with:
>
> for (int i = 0; i < 3; i++)
> cb[i] = (as * fcolor(i));
> glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
>
> for (int i = 0; i < 3; i++)
> cb[i] *= (ds / as);
> glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
>
> As you can see, the calculation of the diffuse reflection fails if as==0.
Agreed. Your fix looks fine.
> 2.) The surface normals should be calculated when facelighting is set to
> 'flat' too.
That's not my understanding of Matlab documentation. When facelighting
is flat, the ligthening should be uniform across the each quad and equal
to the lightening of the first vertex. That's why I don't update the normal on
the usbsequent vertices.
> In addition we need to normalize here, since we don't do
> this in graphics.cc --> surface::properties::update_normals (void) anymore.
Agreed.
Michael.
More information about the Octave-maintainers
mailing list