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

Smoother camera resize and move effect #2612

Open
edmundito opened this issue Dec 11, 2024 · 2 comments
Open

Smoother camera resize and move effect #2612

edmundito opened this issue Dec 11, 2024 · 2 comments

Comments

@edmundito
Copy link
Contributor

edmundito commented Dec 11, 2024

Describe the problem
This is a follow-up from an older conversation in the Tween module Discord channel. The way the camera is resized causes the pixels to a "jiggle". Here is an example:

demo.webm

I have a game project with my demo that you can use here:
https://github.com/edmundito/game-ags-cam-tests

Suggested change
What do you propose to add or change?

What: Camera can be resize frame by frame without causing the jiggle
How: To be discussed here!

This is a problem in other engines as well. Here's one solution for Godot: https://www.youtube.com/watch?v=2JbhkZe22bE

@ericoporto
Copy link
Member

The room script code if I understood does a camera resize and keeps the viewport fixed size.

The video shown uses a shader from here: https://github.com/uheartbeast/jitter-free-pixelart-scaling/blob/master/JitterFreePixelArt.shader

From what I can tell, the shader has a simple smooth, that samples from the center of the pixel, in a texture so it can draw in a different texture. I think there is something related with mipmaps there but I don't understand how this works in the context of camera.

So what I get is the idea would be to use a shader to read the "flattened" result in the camera and then "write" to the texture in the viewport. I am not sure how this will play with the AGS game resolution, vs the actual screen/window resolution. I guess it may need a draw camera in screen resolution setting? I have vague understanding of concepts here but cannot understand the specifics here.

@ivan-mogilko
Copy link
Contributor

I suggest first making a list of the things necessary for this, then see how these may be implemented one by one.
This may take time to have all of them, but even some may have their own uses.

Engine already renders GUI with controls on a target texture then renders that texture on screen with GUI transformation. Similarly, game camera contents may be rendered on a target texture and then rendered in a viewport rectangle on screen.
This final texture render is affected by "render at screen resolution" setting, however it will be "flattened" image, so its parts will not be affected on their own.
In order to have them affected, the target textures have to be created in window resolution too.

OTOH, having room cameras rendered as a texture will have 2 consequences:

  • they may be applied a shader of their own (so there will be shaders on each individual sprite in room, and then a shader for the whole room view);
  • it will be easier to support sorting of room viewports among other items on screen (GUI, screen overlays).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants