Skip to content

Commit

Permalink
Merge branch 'Development' into node-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
pragma37 committed Oct 22, 2023
2 parents c79be5d + 85f60c0 commit 5ed963f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Malt/Shaders/Common/Normal.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ vec3 sample_normal_map(sampler2D normal_texture, int uv_index, vec2 uv)
*/
vec3 radial_tangent(vec3 normal, vec3 axis)
{
float d = abs(dot(normal, axis));
float epsilon = 1e-5;
if(d > 1.0 - epsilon)
{
// Avoid singularities when normal == axis.
vec3 alternative_axis = normalize(axis + vec3(0.1, 0.2, 0.3));
axis = mix(axis, alternative_axis, map_range_clamped(d, 1.0 - epsilon, 1.0, 0.0, epsilon));
}
return normalize(cross(axis, normal));
}

Expand Down

0 comments on commit 5ed963f

Please sign in to comment.