LuxCore icon indicating copy to clipboard operation
LuxCore copied to clipboard

Glossy reflections on GPU

Open JonSargent opened this issue 4 years ago • 1 comments

I'm having trouble validating the specular behavior of glossy* materials using the PATHOCL engine on GPUs.

This zip file contains two stripped down test scenes:

  • Simple example: Just an ortho camera pointing at a glossy2 surface, with a light behind the camera view. Pixel rays leave the camera, bounce off the test surface at normal incidence, and then hit the light (which has a luminous intensity of 1). As far as specular reflection tests go, this is as simple as it gets. A surface with kd=0 and ks=0.5 should have a luminance of 0.5 in the rendering. This is exactly what the PATHCPU engine reports. The PATHOCL engine, on the other hand, reports a value that's 12% too low -- at least on my GPU (NVIDIA GeForce RTX 2080 Ti, see log for details). The simulation has converged nicely, so noise is not the issue. spec reflection

  • Incidence angle study: Similar logic, but using 90 surfaces angled away from the camera plane in 1-degree increments (from 0 to 89 degrees). Just a cheap hack for turning one ortho rendering into a discrete plot of specular reflection vs. incidence-angle. Here's what it shows for glossy2 surfaces with ks=0.25, 0.5, and 0.75. The PATHCPU results are spot on. Ks values fit exactly, and the fresnel effect pushes the reflectance toward 1 at grazing angles, as expected: image The PATHOCL results, though, are again systematically low: image Plotting the relative error looks like this: image Three different ks values, every possible incidence angle, same result: a systematic error of about -12%. I haven't been brave enough to wade into the CL engine code, but hopefully the pattern points to a simple cause? Let me know if I can be of use with troubleshooting. I should have access to a few other GPUs over the course of the next week, so I can at least see if the pattern repeats.

Originally posted by @JonSargent in https://github.com/LuxCoreRender/LuxCore/issues/470#issuecomment-730796543


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

JonSargent avatar Nov 22 '20 16:11 JonSargent

Repeating the "simple_example" test on other devices revealed the following relative errors for PATHOCL glossy2 specular reflectance:

  • NVIDIA RTX 2080 Ti (as above): -12%
  • Radeon Pro 560: -21%
  • Radeon RX 5600 XT: -72%
  • Intel Core i5-5287U CPU: 0%

It's clear that the magnitude of the error is GPU specific -- and non existent when building the same CL kernels on a CPU (at least on the one compatible device I have). It's also clear that scope of the error is limited. The diffuse component calculates just fine, as does the specular component for non-glossy materials (e.g. glass). Not sure what about the SchlickBSDF_Coating* cl funcs (?) could be device sensitive, but maybe that's a place to start looking.

JonSargent avatar Nov 22 '20 16:11 JonSargent