Help w/Martin Donald's PS1 Vertex Snapping/Wobble Shader

Godot Version

Godot 4.7.1

Question

In this video, he creates a PS1 vertex snapping/wobble shader, but does not explain how to use it. I’ve tried applying it to a ColorRect node and as a Camera3D Compositor effect and neither work and I’m all out of ideas.

// PS1 Vertex Wobble Shader by Martin Donald
// @tutorial: https://youtu.be/_HBICOaFepY
shader_type spatial;


const vec2 SCREEN_RES = vec2(320.0, 240.0);


void vertex() {
	vec4 view_pos = MODELVIEW_MATRIX * vec4(VERTEX, 1.0);
	vec4 clip_pos = PROJECTION_MATRIX * view_pos;
	vec2 ndc = clip_pos.xy / clip_pos.w;
	vec2 screen_pos = ((ndc * 0.5) + 0.5) * SCREEN_RES;
	screen_pos = floor(screen_pos + 0.5);
	vec2 snapped_ndc = ((screen_pos / SCREEN_RES) - 0.5) * 2.0;
	clip_pos.xy = snapped_ndc * clip_pos.w;
	POSITION = clip_pos;
}

The const vec2 SCREEN_RES part was added by me because that constant is not built in to the shader language and is also not explained at all in the video, so I figured that SCREEN_RES should be the game’s internal resolution (320×240).

I’d believe you’d have to attach it to each of your models, do they not have the full source posted elsewhere?

Just tried applying it to the material of the placeholder player model and yep, it looks like it has to be on the model itself. Applying this shader to every model is gonna be a pain :upside_down_face: Thank you for your help!! ^^

@tool scripts, especially EditorScript may help for a task like this

He posted the full source at his patreon. about $1 including the previous one he done.

That’s neat, I’ve never heard of the EditorScript class! Thank you! ^^

Also consider post import scripts! Import configuration — Godot Engine (latest) documentation in English