Specular Power = 0
Crossbones+ - Reputation: 1116
Posted 28 June 2012 - 11:53 AM
Today I found a new bug in my engine, after some debugging I found that it happened because I added a new material that had a specular power = 0, so when the HdV = 0 it caused an exception 0^0, and the luminance calculated at those pixels was a NaN and the average luminance of the scene was also NaN so the tonemapped scene resulted in black screen.
I fixed it by adding a small value (0.0001) to the specular power stored in the gbuffer before doing HdV^power, but I was wondering if this is usual or I'm doing something else wrong...
Aqua Engine - my DirectX 11 game "engine" - In development
Members - Reputation: 1391
Moderators - Reputation: 5643
Posted 28 June 2012 - 12:19 PM
Members - Reputation: 292
Posted 29 June 2012 - 08:22 AM
Members - Reputation: 228
Posted 12 July 2012 - 06:51 PM
float pow(float base, float exponent)
return exp2(log2(v), exponent);
The fix is to either call max(v, very_small_number ) or something like
float mypow(float base, float exponent)
return base > very_small_number ? exp2(log2(v), exponent) : 0;
And you get to sit down and tune your own very_small_number for whatever you are working on.