Skip to content

Commit

Permalink
Fix 2D normals for transposed texture
Browse files Browse the repository at this point in the history
  • Loading branch information
kleonc committed Jan 15, 2024
1 parent 26b1fd0 commit 0fe7eea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/gles3/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ void main() {

if (normal_used || (using_light && bool(read_draw_data_flags & FLAGS_DEFAULT_NORMAL_MAP_USED))) {
normal.xy = texture(normal_texture, uv).xy * vec2(2.0, -2.0) - vec2(1.0, -1.0);
if (bool(read_draw_data_flags & FLAGS_TRANSPOSE_RECT)) {
normal.xy = normal.yx;
}
if (bool(read_draw_data_flags & FLAGS_FLIP_H)) {
normal.x = -normal.x;
}
Expand Down
3 changes: 3 additions & 0 deletions servers/rendering/renderer_rd/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ void main() {

if (normal_used || (using_light && bool(draw_data.flags & FLAGS_DEFAULT_NORMAL_MAP_USED))) {
normal.xy = texture(sampler2D(normal_texture, texture_sampler), uv).xy * vec2(2.0, -2.0) - vec2(1.0, -1.0);
if (bool(draw_data.flags & FLAGS_TRANSPOSE_RECT)) {
normal.xy = normal.yx;
}
if (bool(draw_data.flags & FLAGS_FLIP_H)) {
normal.x = -normal.x;
}
Expand Down

0 comments on commit 0fe7eea

Please sign in to comment.