mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Fix rare graphical error showing a black box
This may happen at certain hard to replicate viewing angles. Theoretically clamp 0,1 should also be faster since SAT (saturate) is a free operation on output however since saturate only exists on HLSL we are at the mercy of the GLSL compiler to replace clamp 0,1 with SAT. Source: http://www.humus.name/Articles/Persson_LowLevelThinking.pdf#page=22
This commit is contained in:
@@ -82,7 +82,7 @@ void main()
|
|||||||
// Cook-Torrance BRDF
|
// Cook-Torrance BRDF
|
||||||
float NDF = DistributionGGX(N, H, roughness);
|
float NDF = DistributionGGX(N, H, roughness);
|
||||||
float G = GeometrySmith(N, V, L, roughness);
|
float G = GeometrySmith(N, V, L, roughness);
|
||||||
vec3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
|
vec3 F = fresnelSchlick(clamp(dot(H, V), 0.0, 1.0), F0);
|
||||||
|
|
||||||
vec3 nominator = NDF * G * F;
|
vec3 nominator = NDF * G * F;
|
||||||
float denominator = 4 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.001; // 0.001 to prevent divide by zero.
|
float denominator = 4 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.001; // 0.001 to prevent divide by zero.
|
||||||
|
|||||||
Reference in New Issue
Block a user