Skip to content

Commit

Permalink
Merge pull request godotengine#97602 from patowen/fix-region-filter-c…
Browse files Browse the repository at this point in the history
…lip-enabled

Fix `region_filter_clip_enabled` to avoid sprite bleeding for interpolated sprite sheets
  • Loading branch information
akien-mga committed Oct 1, 2024
2 parents 3b17e34 + d720eb8 commit 6c13305
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/classes/Sprite2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
If [code]true[/code], texture is cut from a larger atlas texture. See [member region_rect].
</member>
<member name="region_filter_clip_enabled" type="bool" setter="set_region_filter_clip_enabled" getter="is_region_filter_clip_enabled" default="false">
If [code]true[/code], the outermost pixels get blurred out. [member region_enabled] must be [code]true[/code].
If [code]true[/code], the area outside of the [member region_rect] is clipped to avoid bleeding of the surrounding texture pixels. [member region_enabled] must be [code]true[/code].
</member>
<member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)">
The region of the atlas texture to display. [member region_enabled] must be [code]true[/code].
Expand Down
3 changes: 2 additions & 1 deletion drivers/gles3/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ void main() {

#endif
if (bool(read_draw_data_flags & FLAGS_CLIP_RECT_UV)) {
uv = clamp(uv, read_draw_data_src_rect.xy, read_draw_data_src_rect.xy + abs(read_draw_data_src_rect.zw));
vec2 half_texpixel = read_draw_data_color_texture_pixel_size * 0.5;
uv = clamp(uv, read_draw_data_src_rect.xy + half_texpixel, read_draw_data_src_rect.xy + abs(read_draw_data_src_rect.zw) - half_texpixel);
}

#endif
Expand Down
3 changes: 2 additions & 1 deletion servers/rendering/renderer_rd/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ void main() {

#endif
if (bool(draw_data.flags & FLAGS_CLIP_RECT_UV)) {
uv = clamp(uv, draw_data.src_rect.xy, draw_data.src_rect.xy + abs(draw_data.src_rect.zw));
vec2 half_texpixel = draw_data.color_texture_pixel_size * 0.5;
uv = clamp(uv, draw_data.src_rect.xy + half_texpixel, draw_data.src_rect.xy + abs(draw_data.src_rect.zw) - half_texpixel);
}

#endif
Expand Down

0 comments on commit 6c13305

Please sign in to comment.