Skip to content

Commit

Permalink
limit bump2normal map
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmc committed May 25, 2024
1 parent ffb9ad1 commit 519e093
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/textures/bump2normal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ class Bump2NormalTextureInstance final : public Texture::Instance {
_bump->evaluate(Interaction{it.uv() - make_float2(step, 0.f)}, time).x;
auto dy = _bump->evaluate(Interaction{it.uv() + make_float2(0.f, step)}, time).x -
_bump->evaluate(Interaction{it.uv() - make_float2(0.f, step)}, time).x;
n = normalize(make_float3(
clamp(dx / (2.f * step), -1.f, 1.f),
clamp(-dy / (2.f * step), -1.f, 1.f),
1.f));
auto dxy = make_float2(dx / (2.f * step), -dy / (2.f * step));
n = normalize(make_float3(dxy, max(1.f, length(dxy))));
};
return make_float4(n * 0.5f + 0.5f, 1.f);
}
Expand Down

0 comments on commit 519e093

Please sign in to comment.