All objects using nearest filter jitter when a collision occurs

Godot Version

Godot_v4.3-stable_mono

Question

This is a 3D scene that simulates 2D using orthogonal projection. I’ve noticed that when my character moves towards an object and causes a collision, all objects using the Nearest Filter exhibit a certain degree of jitter, while this doesn’t happen with the Linear Filter.
I’m using CharacterBody3D for the character and StaticBody3D for the objects, moving by calling MoveAndSlide. I’ve tried adjusting some physics parameters, but it hasn’t had any effect.
Is this an issue with Godot itself, or is there a misconfiguration on my part? If it’s a problem with Godot, is there a fix for it?

problem

1 Like

My guess is that the camera moves with the player (it could be a walk bob), then the physics moves the player back, due to collision, causing a re-render.

Maybe give your camera a little lerp smoothing instead of hard position changes?

These are all assumptions.

The artifacts you see look to be pixel wobble, but I’m not sure how to control that off the top of my head. There are ways.

1 Like

I tried using a static camera instead of a moving one, but the problem still persists. However, re-rendering may be a possible cause, thanks for your suggestion.

I discovered that the issue stemmed from a camera in my project that follows the player. Even though I stopped using it later, it still affected the rendering results.

I referred to Unity’s PixelPerfectCamera code and applied a simple RoundToPixel function in both the camera and player control code. The code is as follows:

public Vector3 RoundToPixel(Vector3 position)
{
	float unitsPerPixel = 1f / PixelsPerUnit;

	Vector3 result;
	result.X = Mathf.Round(position.X / unitsPerPixel) * unitsPerPixel;
	result.Y = Mathf.Round(position.Y / unitsPerPixel) * unitsPerPixel;
	result.Z = Mathf.Round(position.Z / unitsPerPixel) * unitsPerPixel;

	return result;
}

This has essentially solved the pixel jitter problem I was encountering.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.