Re: lighting problem with mesa software rendering

"Wendt, Lars Henning" <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <4F6FD2DBA5E2134E8B6F4EA5AED42D251B55513D@EXMBS1.ad.igd.fraunhofer.de>
Hi Brian,

Thank you for your fast solution.

It seems to work in our complex configuration too.	

best
Lars

-----Original Message-----
From: Brian Paul [mailto:[email protected]] 
Sent: Dienstag, 24. Juli 2012 17:41
To: Wendt, Lars Henning
Cc: [email protected]
Subject: Re: [Mesa-users] lighting problem with mesa software rendering

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.