Skip to content

Fix rounding bug in camera projection#16828

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
musjj:rounding-bug
Dec 15, 2024
Merged

Fix rounding bug in camera projection#16828
alice-i-cecile merged 1 commit intobevyengine:mainfrom
musjj:rounding-bug

Conversation

@musjj
Copy link
Copy Markdown
Contributor

@musjj musjj commented Dec 15, 2024

Objective

Fixes #16773

Solution

#15969 introduces a regression that causes image tearing when ImageFilterMode::Nearest is used as the sampler. Rounding the origin fixes the issue.

Credits to @sophrosyne97 for bisecting and finding the commit that broke it.

Testing

You can test it with this repository: https://github.com/musjj/nearest_filter_bug

git clone https://github.com/musjj/nearest_filter_bug
cd nearest_filter_bug
echo '[patch.crates-io]\nbevy = { git = "https://github.com/musjj/bevy.git", branch = "rounding-bug" }' >>Cargo.toml
sed -i -e 's/0.15.0/0.15.0-dev/' Cargo.toml
cargo update && cargo run

Gradually resize the window to various sizes, while paying attention to the sprite and font. No tearing should occur on any window resolution, even on odd numbers.

Tested on Linux with Gnome. Tests on other platforms would be appreciated.


Showcase

Before:

image

After:

image

@github-actions
Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added this to the 0.15.1 milestone Dec 15, 2024
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Dec 15, 2024
Copy link
Copy Markdown
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both for spotting this. I was the one to introduce this regression!

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 15, 2024
Merged via the queue into bevyengine:main with commit ae52222 Dec 15, 2024
@mockersf mockersf modified the milestones: 0.15.1, 0.15.2 Dec 26, 2024
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Jan 6, 2025
# Objective

Fixes bevyengine#16773

## Solution

bevyengine#15969 introduces a regression
that causes image tearing when `ImageFilterMode::Nearest` is used as the
sampler. Rounding the origin fixes the issue.

Credits to @sophrosyne97 for bisecting and finding the commit that broke
it.

## Testing

You can test it with this repository:
https://github.com/musjj/nearest_filter_bug

```bash
git clone https://github.com/musjj/nearest_filter_bug
cd nearest_filter_bug
echo '[patch.crates-io]\nbevy = { git = "https://github.com/musjj/bevy.git", branch = "rounding-bug" }' >>Cargo.toml
sed -i -e 's/0.15.0/0.15.0-dev/' Cargo.toml
cargo update && cargo run
```
Gradually resize the window to various sizes, while paying attention to
the sprite and font. No tearing should occur on any window resolution,
even on odd numbers.

Tested on Linux with Gnome. Tests on other platforms would be
appreciated.

---

## Showcase

Before:


![image](https://github.com/user-attachments/assets/785edeae-7b28-4735-bb8e-d7f79eb09ac2)


After:


![image](https://github.com/user-attachments/assets/9288bc45-a3cf-4e4e-b941-85a00844c627)
hukasu added a commit to hukasu/bevy that referenced this pull request Jan 28, 2025
@mockersf mockersf removed this from the 0.15.2 milestone Feb 2, 2025
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
# Objective

Fixes bevyengine#16773

## Solution

bevyengine#15969 introduces a regression
that causes image tearing when `ImageFilterMode::Nearest` is used as the
sampler. Rounding the origin fixes the issue.

Credits to @sophrosyne97 for bisecting and finding the commit that broke
it.

## Testing

You can test it with this repository:
https://github.com/musjj/nearest_filter_bug

```bash
git clone https://github.com/musjj/nearest_filter_bug
cd nearest_filter_bug
echo '[patch.crates-io]\nbevy = { git = "https://github.com/musjj/bevy.git", branch = "rounding-bug" }' >>Cargo.toml
sed -i -e 's/0.15.0/0.15.0-dev/' Cargo.toml
cargo update && cargo run
```
Gradually resize the window to various sizes, while paying attention to
the sprite and font. No tearing should occur on any window resolution,
even on odd numbers.

Tested on Linux with Gnome. Tests on other platforms would be
appreciated.

---

## Showcase

Before:


![image](https://github.com/user-attachments/assets/785edeae-7b28-4735-bb8e-d7f79eb09ac2)


After:


![image](https://github.com/user-attachments/assets/9288bc45-a3cf-4e4e-b941-85a00844c627)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Visual tearing with ImageFilterMode::Nearest

3 participants