ruba / cortex-vfx

Automatically exported from code.google.com/p/cortex-vfx
Other
2 stars 1 forks source link

Marschner NaN SL error #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

I have been testing the Marscher renderman shader in PRman, it works very well 
thank you.

One issue I had was the occasional NaN black square type artifacts. A bit of 
investigation traced them to a divide by zero in Marscher.inl line 159,

        l = 2*cos(gammaT)/cosTheta;

so I replaced with,

        l = 2*cos(gammaT)/max(1e-5,cosTheta);

and the artifacts went away. I checked for malformed inputs to the shader but 
couldn't find any issues. Any ideas why I would be seeing this?

Cheers, Jeremy

Original issue reported on code.google.com by jeremypr...@gmail.com on 29 Jun 2010 at 12:32

GoogleCodeExporter commented 8 years ago
Hi Jeremy,
I think I know what's going on. At Marschner.h line 72 there's a coefficient 
(finalScale) that is multiplied to the output values and it contains cosTheta 
too. As far as I remember 3delight returns 0 if you multiply NaN by 0. And 
that's what happens when cosTheta is zero at line 159. So 3delight ends up 
eliminating those values anyways. Your fix is right but it looks like we could 
have other spots where division is not being verified and you would get the 
same issues in PRman. If you find other spots, let us know!
I will patch the file here as well. 
thank you!

Original comment by lucio.im...@gmail.com on 29 Jun 2010 at 5:23

GoogleCodeExporter commented 8 years ago

Original comment by lucio.im...@gmail.com on 20 Sep 2010 at 4:47