Hazel icon indicating copy to clipboard operation
Hazel copied to clipboard

Pixel perfect 2D camera?

Open L4ZZA opened this issue 5 years ago • 3 comments

Description

One very common problem of 2D games is the compatibility with pixel art, or art in general. When it comes to showing pixel accurate art (i.e. 16x16, 32x32, 64x64 bit sprites) Hazel is not handling it well and artefacts appear as soon as you "zoom out" far enough to misplace the pixel and get artefacts when moving around the camera.

Proposed solution

An option should be introduced to the orthographic camera_controller by which a different logic should be triggered.

if(pixel_perfect)
  // zoom in/out of a precise amount to keep the pixel ratio intact
else
 // current zoomLevel logic

Additional context

Here some articles I've found that could help. Unfortunately all the good examples are based on unity.

  • https://forum.unity.com/threads/2d-pixel-art-game-with-smooth-and-pixel-perfect-camera.522322/
  • https://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/
  • https://blogs.unity3d.com/2019/03/13/2d-pixel-perfect-how-to-set-up-your-unity-project-for-retro-8-bits-games/#:~:text=If%20you%20want%20a%20pixel,such%20as%20320×180).
  • https://stackoverflow.com/questions/34382798/pixel-perfect-projection-matrix
  • https://indiehoodgames.wordpress.com/2013/07/27/pixel-perfect-calculator-for-orthographic-camera-unity3d/
  • https://github.com/cmilr/DeadSimple-Pixel-Perfect-Camera/blob/master/Assets/DSPixelPerfectCamera.cs

L4ZZA avatar Jun 05 '20 10:06 L4ZZA

This seems more like it could be a derived class of the OrthographicCameraController like PixelPerfectOrthographicCameraController, which could override the scrolling and resizing behaviour.

LovelySanta avatar Jul 22 '20 15:07 LovelySanta

Shouldn't that be a default option for a orthographic camera? Why would you not have a pixel perfect camera in a 2D game?

L4ZZA avatar Jul 23 '20 10:07 L4ZZA

I need to know how I could fix this because the line artefacts are driving me (hazel)nuts!

Qlii256 avatar May 22 '22 11:05 Qlii256