octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OpenGL lighting fixes


From: Michael Goffioul
Subject: Re: OpenGL lighting fixes
Date: Mon, 2 Feb 2009 22:37:33 +0000

On Mon, Feb 2, 2009 at 2:33 PM, Kai Habel <address@hidden> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]