Skip to content

Commit e75900e

Browse files
committed
Calculate pixel snap in canvas space instead of world space
This ensures that you are actually snapping to pixels in the viewport and not an arbitrary amount
1 parent 621cadc commit e75900e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/gles3/shaders/canvas.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,15 @@ void main() {
262262

263263
color_interp = color;
264264

265+
vertex = (canvas_transform * vec4(vertex, 0.0, 1.0)).xy;
266+
265267
if (use_pixel_snap) {
266268
vertex = floor(vertex + 0.5);
267269
// precision issue on some hardware creates artifacts within texture
268270
// offset uv by a small amount to avoid
269271
uv += 1e-5;
270272
}
271273

272-
vertex = (canvas_transform * vec4(vertex, 0.0, 1.0)).xy;
273-
274274
vertex_interp = vertex;
275275
uv_interp = uv;
276276

servers/rendering/renderer_rd/shaders/canvas.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ void main() {
214214

215215
color_interp = color;
216216

217+
vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy;
218+
217219
if (canvas_data.use_pixel_snap) {
218220
vertex = floor(vertex + 0.5);
219221
// precision issue on some hardware creates artifacts within texture
220222
// offset uv by a small amount to avoid
221223
uv += 1e-5;
222224
}
223225

224-
vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy;
225-
226226
vertex_interp = vertex;
227227
uv_interp = uv;
228228

0 commit comments

Comments
 (0)