mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 21:52:51 +00:00
Merge pull request #71382 from jainl28patel/sprite2d_flip_normal_map
fix normal map not flipping in sprite2D
This commit is contained in:
commit
59dcf64dd6
@ -905,10 +905,12 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
||||
|
||||
if (rect->flags & CANVAS_RECT_FLIP_H) {
|
||||
src_rect.size.x *= -1;
|
||||
state.instance_data_array[r_index].flags |= FLAGS_FLIP_H;
|
||||
}
|
||||
|
||||
if (rect->flags & CANVAS_RECT_FLIP_V) {
|
||||
src_rect.size.y *= -1;
|
||||
state.instance_data_array[r_index].flags |= FLAGS_FLIP_V;
|
||||
}
|
||||
|
||||
if (rect->flags & CANVAS_RECT_TRANSPOSE) {
|
||||
|
@ -75,6 +75,9 @@ class RasterizerCanvasGLES3 : public RendererCanvasRender {
|
||||
|
||||
FLAGS_USE_MSDF = (1 << 28),
|
||||
FLAGS_USE_LCD = (1 << 29),
|
||||
|
||||
FLAGS_FLIP_H = (1 << 30),
|
||||
FLAGS_FLIP_V = (1 << 31),
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -579,6 +579,12 @@ 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(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 {
|
||||
|
@ -27,6 +27,9 @@
|
||||
#define FLAGS_USE_MSDF uint(1 << 28)
|
||||
#define FLAGS_USE_LCD uint(1 << 29)
|
||||
|
||||
#define FLAGS_FLIP_H uint(1 << 30)
|
||||
#define FLAGS_FLIP_V uint(1 << 31)
|
||||
|
||||
layout(std140) uniform GlobalShaderUniformData { //ubo:1
|
||||
vec4 global_shader_uniforms[MAX_GLOBAL_SHADER_UNIFORMS];
|
||||
};
|
||||
|
@ -525,10 +525,12 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend
|
||||
|
||||
if (rect->flags & CANVAS_RECT_FLIP_H) {
|
||||
src_rect.size.x *= -1;
|
||||
push_constant.flags |= FLAGS_FLIP_H;
|
||||
}
|
||||
|
||||
if (rect->flags & CANVAS_RECT_FLIP_V) {
|
||||
src_rect.size.y *= -1;
|
||||
push_constant.flags |= FLAGS_FLIP_V;
|
||||
}
|
||||
|
||||
if (rect->flags & CANVAS_RECT_TRANSPOSE) {
|
||||
|
@ -86,6 +86,9 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
||||
|
||||
FLAGS_USE_MSDF = (1 << 28),
|
||||
FLAGS_USE_LCD = (1 << 29),
|
||||
|
||||
FLAGS_FLIP_H = (1 << 30),
|
||||
FLAGS_FLIP_V = (1 << 31),
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -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 {
|
||||
|
@ -27,6 +27,9 @@
|
||||
#define FLAGS_USE_MSDF (1 << 28)
|
||||
#define FLAGS_USE_LCD (1 << 29)
|
||||
|
||||
#define FLAGS_FLIP_H (1 << 30)
|
||||
#define FLAGS_FLIP_V (1 << 31)
|
||||
|
||||
#define SAMPLER_NEAREST_CLAMP 0
|
||||
#define SAMPLER_LINEAR_CLAMP 1
|
||||
#define SAMPLER_NEAREST_WITH_MIPMAPS_CLAMP 2
|
||||
|
Loading…
Reference in New Issue
Block a user