JoeyDeVries / Cell

OpenGL C++ Graphics Engine
Other
915 stars 124 forks source link

Ephemeral black rectangle on Screen #17

Open IngInx747 opened 4 years ago

IngInx747 commented 4 years ago

Hi Joey,

I noticed random black rectangles jumping off on the screen when I tested the app on my Quadro 2000 GPU. Did you find the effect on your device when running the app? If yes but hard to pin a black rectangle, you can move camera into any of 4 point light volumes.

If so, you can change only 'brdf.glsl' to avoid it. First add a epsilon to the denominator of DistributionGGX, the only one function of 3 GGXs where both the nominator and denominator can possibly equal to 0. Secondly, change expression 'pow(1.0 - cosTheta, 5.0)' to 'pow(max(1.0 - cosTheta, 0.0), 5.0)'. Here the cosTheta = dot(N, V) can be a little bigger than 1.0. The behavior of pow can be found here: [https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow](pow function in HLSL).

Specifically the black rectangle was caused by blur shader expanding NAN in our color buffer. If there is any NAN in the input color attachment the blur process will enlarge it and the pixels neighboring NAN one will become NAN too after this pass. After final pass all NAN pixels form the black rectangle on the screen. The NAN pixel is generally caused by undefined behaviors in shader, like 0/0 or pow(-1, 5).

These are potential glitches I found, not all of them. Wish it helps anyone confused by annoying black area :).

jquiver commented 3 years ago

Thanks this really worked

z657446063 commented 3 years ago

Really helpful,thank you so much, it is really hard to solve with。。。