ramokz / phantom-camera

👻🎥 Control the movement and dynamically tween 2D & 3D cameras. Built for Godot 4. Inspired by Cinemachine.
https://phantom-camera.dev/
MIT License
1.97k stars 65 forks source link

pixel_perfect camera feature makes my game camera to jitter on Zoom out at Vector2(0.4,0.4) #165

Closed ciso507 closed 6 months ago

ciso507 commented 6 months ago

Issue description

Hello, on the new pcamera version the pixel_perfect seems wrong:

*Testing the pixel_perfect camera feature makes my game camera to jitter in a bad way when switching from a pcamera zoom at Vector2(0.4,0.4) to a pcamera zoom at Vector2(4,4). I managed to get some information and its mostly because im zooming out at Vector2(0.4,0.4) >>also i was able to find that this is a known issue in godot since snap to pixel on settings makes tilemaps not to jitter anymore, but it creates some jitter on the camera itself. So the best is to keep the camera without zooming out. For sprites i found a pixelPerfect shader that works from a video i saw from HeartBeast. (hope this helps in some way, Anyways thanks a lot for the addon!)

FIXED*The error from pCamera: Attempt to call function 'pcam_removed_from_scene' in base 'previously freed' on a null instance. I had this error before so I was able to fix it by calling is_instance_valid() on an old version of the addon and also queue_free() all the pcamera system. (I got it fixed by writing an await 👍 ) i get this error when restarting my game as Godot Docs recommend: var simultaneous_scene = preload("res://levels/level2.tscn").instantiate()

func _add_a_scene_manually():

This is like autoloading the scene, only

# it happens after already loading the main scene.
get_tree().root.add_child(simultaneous_scene)

Steps to reproduce

Make a game with pCamera Zoom out at Vector2(0.4,0.4)

(Optional) Minimal reproduction project

No response

ciso507 commented 6 months ago
It seems to be working again on the new version after doing this:

await get_tree().create_timer(0.5).timeout $PanthomCameras.queue_free() $Camera2D.queue_free() Globals.mecha_player.queue_free() Globals.emit_signal("Level_delete", string)

ramokz commented 6 months ago

Testing the pixel_perfect camera feature makes my game camera to jitter in a bad way when switching from a pcamera zoom at Vector2(0.4,0.4) to a pcamera zoom at Vector2(4,4). I managed to get some information and its mostly because im zooming out at Vector2(0.4,0.4) >>also i was able to find that this is a known issue in godot since snap to pixel on settings makes tilemaps not to jitter anymore, but it creates some jitter on the camera itself. So the best is to keep the camera without zooming out. For sprites i found a pixelPerfect shader that works from a video i saw from HeartBeast. (hope this helps in some way, Anyways thanks a lot for the addon!)

Have stumbled upon quite a few known issues with pixel perfection for 2D cameras on Godot's Issue board. Though, am not too sure if there's anything that can be done on an addon side of things. Do you feel that there would be a benefit of having a pixel perfect shader option baked into the addon? The property toggle for the PCam2D merely just forces the Camera2D to never sit in-between pixels and cause smearing, as seen in the examples in PR (#156).

await get_tree().create_timer(0.5).timeout $PanthomCameras.queue_free() $Camera2D.queue_free() Globals.mecha_player.queue_free() Globals.emit_signal("Level_delete", string)

Is this related to the error you mentioned in this discussion thread?

Tried loading a scene from another using the same method from the docs you mention, but can't replicate that error / crash, so am not sure if I'm doing something different from.

Is there a reason why you're calling queue_free() on the Camera2Dwhen you load a new scene, as opposed to having the Camera2D (+ PCamHost) node always be available on a root node, and then only load scenes containing the map + the PCam2Ds?

ciso507 commented 6 months ago

The shader that toggles a pixel perfect could be a good idea to implement if its for the entire screen, the solution i have for sprites is a shader for each sprite (but the tilemaps dont benefit from this solution... all of this is only when someone needs to zoom out/in a game like i need to).

*As for the reason im queueing free instead of having it on a root node its because I have a simple node that is the root of everything(Core) as a child of it i have a 3D scene then when i start the game im removing the 3D scene then I go to the 2D scene that has the pcameras. It might not trigger at your end because i think it only happens to big scenes that take more time to queue_free. I also have a 2D scene with pcameras for the tutorial.. and when i queue free that scene and come back to the 3D scene(The Hub scene) it doesnt trigger the error. It only happened to me when i was queue free the main 2d Game scene and then instantiating the same level. If I dont do that my game breaks and i get the error "Attempt to call function 'pcam_removed_from_scene' in base 'previously freed' on a null instance."


De: Marcus Skov @.> Enviado: lunes, 8 de enero de 2024 3:15 p. m. Para: ramokz/phantom-camera @.> Cc: Ciso507 @.>; Author @.> Asunto: Re: [ramokz/phantom-camera] pixel_perfect camera feature makes my game camera to jitter on Zoom out at Vector2(0.4,0.4) (Issue #165)

Testing the pixel_perfect camera feature makes my game camera to jitter in a bad way when switching from a pcamera zoom at Vector2(0.4,0.4) to a pcamera zoom at Vector2(4,4). I managed to get some information and its mostly because im zooming out at Vector2(0.4,0.4) >>also i was able to find that this is a known issue in godot since snap to pixel on settings makes tilemaps not to jitter anymore, but it creates some jitter on the camera itself. So the best is to keep the camera without zooming out. For sprites i found a pixelPerfect shader that works from a video i saw from HeartBeast. (hope this helps in some way, Anyways thanks a lot for the addon!)

Have stumbled upon quite a few known issues with pixel perfection for 2D cameras on Godot's Issue board. Though, am not too sure if there's anything that can be done on an addon side of things. Do you feel that there would be a benefit of having a pixel perfect shader option baked into the addon? The property toggle for the PCam2D merely just forces the Camera2D to never sit in-between pixels and cause smearing, as seen in the examples in PR (#156https://github.com/ramokz/phantom-camera/pull/156).

await get_tree().create_timer(0.5).timeout $PanthomCameras.queue_free() $Camera2D.queue_free() Globals.mecha_player.queue_free() Globals.emit_signal("Level_delete", string)

Is this related to the error you mentioned in this discussion threadhttps://github.com/ramokz/phantom-camera/discussions/117#discussioncomment-7624249?

Tried loading a scene from another using the same method from the docs you mention, but can't replicate that error / crash, so am not sure if I'm doing something different from.

Is there a reason why you're calling queue_free() on the Camera2Dwhen you load a new scene, as opposed to having the Camera2D (+ PCamHost) node always be available on a root node, and then only load scenes containing the map + the PCam2Ds?

— Reply to this email directly, view it on GitHubhttps://github.com/ramokz/phantom-camera/issues/165#issuecomment-1881757070, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASL6XIBABRYMJJXLKVKFCK3YNRHX5AVCNFSM6AAAAABBQTHIC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBRG42TOMBXGA. You are receiving this because you authored the thread.Message ID: @.***>

ramokz commented 6 months ago

I getcha now.

Is there anything you want to get out of this issue then? Am not too sure what is needed to be solved. Can add a null checker for the PCamHost in the PCam2D/3Ds's _exit() function, but since I can't reproduce that particular issue myself, I don't know if that would help solve the error.

ciso507 commented 6 months ago

That fixed it, my solution also broke but checking for is_instance_valid in the exit_tree works thanks