[Mesa-users] lighting problem with mesa software rendering

Brian Paul brianp at vmware.com
Tue Jul 24 08:41:06 PDT 2012


On 07/24/2012 07:56 AM, Wendt, Lars Henning wrote:
> Hi all,
>
> I'm using mesa as software renderer and I get some strange lighting effects.
> In some cases it looks like the source of light is relative to the model while it should be relative to the camera.
> Attached you'll find some apitraces to reproduce the error.
>
> The problem was reproduced with the following versions of mesa:
> 6.5.1 linux
> 7.8.2 windows/linux
> 8.0   windows
>
> It seems to me that it could be a numeric problem.
> As you will see the modelview matrix contains rather small numbers.
> Nonetheless other implementation doesn't have this problem or can cope with it.
>
> Does anybody have an idea what is wrong? Is it a bug? Is there any chance the behavior will be improved in future mesa versions? Or did I get something wrong?

I think I see the problem.

In src/mesa/math/m_matrix.c near line 518 we have:

  if (det*det < 1e-25)
     return GL_FALSE;

  det = 1.0F / det;


The det (determinant) value is very small here and by returning false 
we're giving up on computing the inverse of the combined modelview * 
projection matrix.

That check code dates back to 2000 or earlier.  I'd guess it was a 
check to avoid floating point divide by zero.  But I'm not sure why 
the square of det is used.

I changed the check to read "if (det < 1e-25)" and it seems to fix the 
problem.  Can you try that too and see what happens?

-Brian


More information about the mesa-users mailing list