← Pixel Dreamer Studio

PS1 vertex wobble that is the same near and far

Snap each vertex to a low-resolution screen grid after projection, not to a fixed distance in the world or in view space.

The PS1 wobble comes from vertices landing on whole pixels of a low-resolution screen. Many shaders copy the look by rounding VERTEX in view space to a fixed step, but a step in metres is many pixels close up and less than one far away. In our Godot 4.7 test, a quad sliding sideways jumped 4 px at a time at 3 m and moved smoothly, 1 px at a time, at 12 m, the same as with no snapping. The script below snaps in clip space, after the projection, to a 320 by 240 grid and writes POSITION: 3 px steps at 3 m and at 12 m, which is one 320-wide pixel on our 960 px screen.

The code

Save it as psx_snap.gd and load it with const PsxSnap := preload("res://psx_snap.gd"). Then $Crate.material_override = PsxSnap.make(preload("res://textures/crate.png")), with the grid size as an optional second value. The shader code is in the script, so you can also copy it into a .gdshader file.

extends RefCounted
## PS1-style vertex wobble: snap every vertex to a low-resolution screen grid,
## so the wobble is the same size in pixels near and far.
##   const PsxSnap := preload("res://psx_snap.gd")
##   $Crate.material_override = PsxSnap.make(preload("res://textures/crate.png"))

const CODE := """
shader_type spatial;
uniform sampler2D albedo_tex : source_color, filter_nearest;
uniform vec2 snap_resolution = vec2(320.0, 240.0); // the old console's screen

void vertex() {
	vec4 clip = PROJECTION_MATRIX * MODELVIEW_MATRIX * vec4(VERTEX, 1.0);
	vec2 half_res = snap_resolution * 0.5;
	// to the screen (-1..1), onto the grid, and back
	clip.xy = round(clip.xy / clip.w * half_res) / half_res * clip.w;
	POSITION = clip;
}

void fragment() {
	ALBEDO = texture(albedo_tex, UV).rgb;
}
"""


static func make(tex: Texture2D, resolution := Vector2(320, 240)) -> ShaderMaterial:
	var sh := Shader.new()
	sh.code = CODE
	var m := ShaderMaterial.new()
	m.shader = sh
	m.set_shader_parameter("albedo_tex", tex)
	m.set_shader_parameter("snap_resolution", resolution)
	return m

What we measured

A 1 m white quad facing the camera, slid 0.6 m to the right in 120 steps of 5 mm, 3 m and 12 m from the camera, on a 960 by 540 screen. After each step we read where its left edge was on the screen and counted the size of every jump. Two runs gave the same numbers.

Why it happens

The farther away something is, the fewer pixels a metre covers on screen. A fixed step in view space is a fixed distance, so it turns into a big jump up close and a jump smaller than a pixel far away. After PROJECTION_MATRIX the vertex is in clip space, and dividing x and y by w gives its place on the screen from -1 to 1. Rounding there, to half the grid's width and height, puts every vertex on the same pixel grid whatever its distance, close to what the old hardware did. Multiplying back by w keeps the depth and perspective as they were.

What to change

Ready-made PS1 effects: PSX Retro VFX Collection for Godot 4 has 291 PS1-style effects in one project, all with low-res pixel textures: explosions, magic, gunfire, horror, weather and rewards.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: PSX Retro VFX Collection for Godot 4 has 291 PS1-style effects in one project, all with low-res pixel textures: explosions, magic, gunfire, horror, weather and rewards.

More how-tos for PSX Retro VFX Collection for Godot 4: Play animations in 12 steps a second, at the right speed on any screen

More how-tos: Shaders, materials and lights