Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.3] Calculate pixel snap in canvas space instead of world space #746

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/gles3/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ void main() {

color_interp = color;

vertex = (canvas_transform * vec4(vertex, 0.0, 1.0)).xy;

if (use_pixel_snap) {
vertex = floor(vertex + 0.5);
// precision issue on some hardware creates artifacts within texture
// offset uv by a small amount to avoid
uv += 1e-5;
}

vertex = (canvas_transform * vec4(vertex, 0.0, 1.0)).xy;

vertex_interp = vertex;
uv_interp = uv;

Expand Down
4 changes: 2 additions & 2 deletions servers/rendering/renderer_rd/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ void main() {

color_interp = color;

vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy;

if (canvas_data.use_pixel_snap) {
vertex = floor(vertex + 0.5);
// precision issue on some hardware creates artifacts within texture
// offset uv by a small amount to avoid
uv += 1e-5;
}

vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy;

vertex_interp = vertex;
uv_interp = uv;

Expand Down
Loading