Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nayala |
Hello !
I need some help about weird lines appearing above sprites. I can’t figure out what they are or what I need to do to remove them.
My scene consists of sprites (12px/10px) arranged in an hexagonal grid like that (with debug lines) :
Really rarely when I move the camera and zoom weird lines appear, here an horizontal line :
Script attached to the camera :
extends Camera2D
const MAX_ZOOM_LEVEL = 0.25
const MIN_ZOOM_LEVEL = 2.0
const ZOOM_PERCENT = 0.02
signal moved()
signal zoomed()
var _current_zoom_level = 1
var _drag = false
func _input(event):
if event.is_action_pressed("cam_drag"):
_drag = true
elif event.is_action_released("cam_drag"):
_drag = false
elif event.is_action("cam_zoom_in"):
_update_zoom(1-ZOOM_PERCENT, get_local_mouse_position())
elif event.is_action("cam_zoom_out"):
_update_zoom(1+ZOOM_PERCENT, get_local_mouse_position())
elif event is InputEventMouseMotion && _drag:
set_offset(get_offset() - event.relative * _current_zoom_level)
emit_signal("moved")
func _update_zoom(percent, zoom_anchor):
var old_zoom = _current_zoom_level
_current_zoom_level *= percent
if _current_zoom_level < MAX_ZOOM_LEVEL:
_current_zoom_level = MAX_ZOOM_LEVEL
elif _current_zoom_level > MIN_ZOOM_LEVEL:
_current_zoom_level = MIN_ZOOM_LEVEL
if old_zoom == _current_zoom_level:
return
var zoom_center = zoom_anchor - get_offset()
var ratio = 1-_current_zoom_level/old_zoom
set_offset(get_offset() + zoom_center*ratio)
set_zoom(Vector2(_current_zoom_level, _current_zoom_level))
emit_signal("zoomed")
Stretch settings are 2d Mode and ignore Aspect.
I use default settings when importing my sprites (expect removing filtering).
So where do these lines come from ? I’ve tried using bigger sprites (48px/40px) and lines aren’t appearing.
Is it linked to pixel-perfect stuff or settings when importing sprites ?
I would really appreciate if someone can figure it out.
My first thought was pixel snapping. Do you have Use Pixel Snap
set to On
in the settings? Rendering > Quality > Use Pixel Snap
.
I’d also try importing the art using 2D Pixel
preset.
i_love_godot | 2019-01-27 13:10
If you are using a TileMap, enable YSort
fpicoral | 2019-01-27 13:50
It’s way worse setting Use Pixel Snap
to On
:
Importing using 2D Pixel
preset did nothing.
And i’m not using TileMap, I place each sprite for more control. (Positions are integer values)
nayala | 2019-01-27 14:53
Is it just the image, or are some lines blurry and some sharp?
i_love_godot | 2019-01-27 14:59
All the lines are sharp and they appear when I zoom with the camera (independant from the camera’s position).
As shown below different zoom levels make different lines :
nayala | 2019-01-27 15:18
Do the lines appear if you use integer zoom values?
i_love_godot | 2019-01-27 15:35
Zoom values aren’t integer values, since 2x zoom corresponds to set_zoom(Vector2(0.5, 0.5))
on my camera.
nayala | 2019-01-27 15:47
Yes but have you tried integer values to see if the lines still appear?
i_love_godot | 2019-01-27 16:06
Lines appear even with zoom Vector(2, 2)
nayala | 2019-01-27 16:16
I’m out of ideas I’m afraid. Hopefully someone will chip in and help you figure this out
i_love_godot | 2019-01-27 17:01
No problem, thanks a lot. <3
nayala | 2019-01-27 17:16