Skip to content

Commit

Permalink
Merge pull request #478 from KhronosGroup/fix/tangent_threshold
Browse files Browse the repository at this point in the history
Fix black artifacts caused by invalid tangents [465]
  • Loading branch information
UX3D-haertl committed Jul 19, 2023
2 parents c33d91e + 169e380 commit 768bb64
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/Renderer/shaders/material_info.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ NormalInfo getNormalInfo(vec3 v)
vec2 uv_dx = dFdx(UV);
vec2 uv_dy = dFdy(UV);

if (length(uv_dx) + length(uv_dy) <= 1e-6) {
uv_dx = vec2(1.0, 0.0);
uv_dy = vec2(0.0, 1.0);
if (length(uv_dx) <= 1e-2) {
uv_dx = vec2(1.0, 0.0);
}

if (length(uv_dy) <= 1e-2) {
uv_dy = vec2(0.0, 1.0);
}

vec3 t_ = (uv_dy.t * dFdx(v_Position) - uv_dx.t * dFdy(v_Position)) /
Expand Down

0 comments on commit 768bb64

Please sign in to comment.