class

FPixelPerfectCamera

Pixel-perfect orthographic framing for 2D games: the view always shows a whole number of screen pixels per texel, so a 16 px sprite never lands on a fractional pixel and never shimmers while the camera pans.

Module
Camera
Header
#include "Camera/PixelPerfect.h"
Namespace
Mowo

Public functions

ReturnsNameDescription
uint32_tIntegerScaleThe largest whole-number multiple of the reference height that fits the viewport, never below 1 (a window smaller than the reference crops instead of shrinking the art).
floatOrthoHalfHeightHalf the viewport height in world units for scale screen pixels per texel and pixelsPerUnit texels per world unit.
floatPixelWorldSizeWorld length of one screen pixel.
floatSnapToPixelRounds value to a whole screen pixel.
voidResolveResolves the component's scale and ortho size for a viewport of this height.
voidSnapPositionSnaps a camera position along its own right and up axes so the pan moves in whole pixels.

Function details

IntegerScale

C++
static uint32_t IntegerScale(uint32_t viewportHeightPx, uint32_t referenceHeightPx)

The largest whole-number multiple of the reference height that fits the viewport, never below 1 (a window smaller than the reference crops instead of shrinking the art).

OrthoHalfHeight

C++
static float OrthoHalfHeight(uint32_t viewportHeightPx, uint32_t scale, float pixelsPerUnit)

Half the viewport height in world units for scale screen pixels per texel and pixelsPerUnit texels per world unit.

PixelWorldSize

C++
static float PixelWorldSize(uint32_t scale, float pixelsPerUnit)

World length of one screen pixel.

SnapToPixel

C++
static float SnapToPixel(float value, float pixelWorldSize)

Rounds value to a whole screen pixel.

Resolve

C++
static void Resolve(CameraComponent& camera, uint32_t viewportHeightPx)

Resolves the component's scale and ortho size for a viewport of this height. A component that is not pixel-perfect is left alone.

SnapPosition

C++
static void SnapPosition(const CameraComponent& camera, const Vec3& right, const Vec3& up, Vec3& position)

Snaps a camera position along its own right and up axes so the pan moves in whole pixels. No-op until Resolve has run for the component.

Generated from Camera/PixelPerfect.h via camera.json · Dec 4, 2026Version 1.1.0