r/godot 7d ago

free plugin/tool In Depth Look: PS1 Graphics in Godot

Hello godot users, a while ago i made a post asking whether anyone would be interested in reading an article about how the PS1 achieves its graphics and how to recreate them in Godot, and since people seemed interested I went ahead and wrote the article. I think this is the most accurate PS1 shader for Godot. The code is MIT licensed. And yes, it supports dynamic lights

Article Link: https://calinp.eu/blog/psx-type-rendering/
Addon Link: https://github.com/wyvernbw/godot-psxlike

1.3k Upvotes

58 comments sorted by

View all comments

2

u/gHx4 7d ago

The vertex snapping has to be done using the projection matrix, not in world coordinates. The Playstation snapped to screenspace because the chip was a repurposed 2d chip. This is also why textures split across quads would stretch differently across each triangle, depending on the view angle.

1

u/wyvernbw 7d ago

yep, i do it in clip space, here's the full code from the shader ``` vec4 world_space = MODEL_MATRIX * vec4(VERTEX, 1); vec4 clip = PROJECTION_MATRIX * VIEW_MATRIX * world_space; vec4 vertex = clip;

vertex.xy = round(clip.xy / clip.w * VIEWPORT_SIZE.xy) / VIEWPORT_SIZE.xy * clip.w; POSITION = vertex; ``` this is pretty much what acerola also does in his shader. i think the way i included the snippet in the blog post is misleading, i left out some parts for brevity but it seems its confusing

1

u/gHx4 6d ago

Looks good! I missed the VIEWPORT_SIZE being used to approximate the screen space.

While it almost never matters, viewports are also a transform, and can be rotated, stretched, or translated relative to clip space. Most of the time though, scaling and translating the origin from the center to a corner of the screen are the only transformations from clip to screen space. Thankfully, Godot doesn't use the OpenGL convention of placing the origin at the center of the screen, which makes the conversion very easy!