From 390f83bf5a1751ec2dc7892f6830285c2373985f Mon Sep 17 00:00:00 2001 From: jainl28patel Date: Sat, 14 Jan 2023 11:50:42 +0530 Subject: fix normal map not flipping in sprite2D --- servers/rendering/renderer_rd/shaders/canvas.glsl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'servers/rendering/renderer_rd/shaders/canvas.glsl') diff --git a/servers/rendering/renderer_rd/shaders/canvas.glsl b/servers/rendering/renderer_rd/shaders/canvas.glsl index eb5f68849e..1fb8b28b15 100644 --- a/servers/rendering/renderer_rd/shaders/canvas.glsl +++ b/servers/rendering/renderer_rd/shaders/canvas.glsl @@ -502,6 +502,12 @@ 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_FLIP_H)) { + normal.x = -normal.x; + } + if (bool(draw_data.flags & FLAGS_FLIP_V)) { + normal.y = -normal.y; + } normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); normal_used = true; } else { -- cgit v1.2.3