This should be required reading for anyone that trying to emulate the PS1 rendering aesthetic. Too many developers seem to think that PS1 games probably looked worse than how they remember them and try to compensate for their nostalgia (or just want to heighten the aesthetic) by introducing far, far more wobbling and warping than there actually was!
Love the project and the spirit of it. Brings be back to playing FFT.
Question to all C/C++ programmers out there. Why are your variables so terse? I have no idea what td and dt mean and why they are both in the same function. I'm genuinely trying to read your code and have no idea what is happening because there is seemingly a desire by the author to keep variables as short as possible. Why?
Don’t go to ShaderToy. You will find a really cool shader and then be disappointed when the code is incomprehensible because whoever wrote it want used one letter variables (starting alphabetically! So x, y, and x coordinates might not even be “x, y, z” but “o, p, q”).
Amazing. On the other hand it makes use of a graphics library that is way bigger than 500 lines. Regardless thank you for sharing but I get the feeling it was good fun.
It's true that https://github.com/nkanaev/tipsy/blob/master/src/tigr.c is 5500 lines of C but, as far as I can tell, it's just being used to load texture images, draw lines, get double-buffered pixel buffers onto the screen, and get keyboard and mouse events. It wouldn't be difficult to port it to something like https://gitlab.com/kragen/bubbleos/blob/master/yeso. yeso.h yeso-pic.c yeso-xlib.c png.c total 560 lines of C, and all you're missing then is a line-drawing function.
i came across this a few days ago searching n64 style rendering, its awesome! i plan on trying to make a spiritual successor of sorts for blast corps using those techniques in another renderer
If anyone is interested in learning how graphics rendering works under the hood without too much scaffolding, there's a great course at https://pikuma.com/courses/learn-3d-computer-graphics-progra... (I'm no way associated with that website, just loved the course). That course starts from absolute basics: creating a colour buffer as in memory array and gradually covers lot of ground on 3D rendering: drawing pixels, lines, triangle fill rasterisation, texturing. The course uses minimal help: SDL is used for rendering on window and dynamic arrays are provided as a small C library. But everything else is coded from scratch in C by the instructor in the lecture, word by word.
Glad to see PS1 style rendering that simulates the affine texture warping side effects of the console. The original Playstation was very much not designed with 3D in mind, lack of perspective correction on textures lead to the aforementioned warping.
Vertex coordinates were rounded to whole integers, giving that hallmark polygon jiggle effect from the rounding that 'snapped' them in place. The complete lack of a z-buffer also lead to lots of z fighting, as the system rendered polygons strictly in the order they were calculated.
I couldn't help noticing that it tests every pixel on the "screen" to see whether it's inside a face. Back in the software renderer days we'd run the inner loop just for the pixels that fell inside a triangle. But then you'd need to explicitly handle polygon clipping and it would greatly complicate the code. I guess 320*240 tests is nothing these days.
would love to see this run inside a browser. how do you create ps1 texture and lo-poly models like this? I so badly want to create a PS1 style game in the browser.
For lot of us, our childhood was defined by this console. N64 as well but just something about the PS1 graphic that really speaks to me. Anybody else feel the same?
No clue what people use today, but when I worked on a psx game 3D Studio Max was the the main choice, with Lightwave 3D having a lot of fans as well. Doing low poly modeling you basically just live between the edge split, rotate, merge, and vertex move tools, so it's incredibly important they have a low friction UI.
From a quick glance at the graphics library being used here[1], it doesn't seem like a terrible amount of work to add support for WebGL and then get this entire project compiled into wasm (at least for someone more comfortable working in C than myself!)
> fgetc() does not return 'char', it returns 'int' else EOF won't fit.
Or more precisely: don't store the return value in a 'char' and check if it is EOF. On some platforms (e.g. gcc ARM eabi), regular 'char' is unsigned and the check fails.
They need to be coupled with the same bespoke, precise controls and input handling though. There's a tightness to a lot of PS1 and N64 games that takes care to replicate. And Unity and friends don't exactly help you in that department.
I was wondering how this was done in 500 lines...then I saw the 5000+ line library file borrowed from another project. I do enjoy the look of your results though.
How long before somebody includes your library and says they created PSX graphics in 25 lines?
ok_dad|3 years ago
Pulcinella|3 years ago
ppeetteerr|3 years ago
Question to all C/C++ programmers out there. Why are your variables so terse? I have no idea what td and dt mean and why they are both in the same function. I'm genuinely trying to read your code and have no idea what is happening because there is seemingly a desire by the author to keep variables as short as possible. Why?
Pulcinella|3 years ago
ptsneves|3 years ago
kragen|3 years ago
glouwbug|3 years ago
https://github.com/glouw/gel
SandmanDP|3 years ago
andrewmcwatters|3 years ago
Edit: It looks like all of your C is actually very well written. What a pleasure to read!
sitzkrieg|3 years ago
havercosine|3 years ago
If anyone is interested in learning how graphics rendering works under the hood without too much scaffolding, there's a great course at https://pikuma.com/courses/learn-3d-computer-graphics-progra... (I'm no way associated with that website, just loved the course). That course starts from absolute basics: creating a colour buffer as in memory array and gradually covers lot of ground on 3D rendering: drawing pixels, lines, triangle fill rasterisation, texturing. The course uses minimal help: SDL is used for rendering on window and dynamic arrays are provided as a small C library. But everything else is coded from scratch in C by the instructor in the lecture, word by word.
crabbygrabby|3 years ago
angarg12|3 years ago
confident_inept|3 years ago
Vertex coordinates were rounded to whole integers, giving that hallmark polygon jiggle effect from the rounding that 'snapped' them in place. The complete lack of a z-buffer also lead to lots of z fighting, as the system rendered polygons strictly in the order they were calculated.
0xf00ff00f|3 years ago
I couldn't help noticing that it tests every pixel on the "screen" to see whether it's inside a face. Back in the software renderer days we'd run the inner loop just for the pixels that fell inside a triangle. But then you'd need to explicitly handle polygon clipping and it would greatly complicate the code. I guess 320*240 tests is nothing these days.
Anyway, great job!
herpderperator|3 years ago
yomkippur|3 years ago
For lot of us, our childhood was defined by this console. N64 as well but just something about the PS1 graphic that really speaks to me. Anybody else feel the same?
jasonwatkinspdx|3 years ago
BHSPitMonkey|3 years ago
[1] https://github.com/erkkah/tigr
doubled112|3 years ago
unknown|3 years ago
[deleted]
unwind|3 years ago
Also, due to Stack Overflow conditioning: fgetc() does not return 'char', it returns 'int' else EOF won't fit.
st_goliath|3 years ago
Or more precisely: don't store the return value in a 'char' and check if it is EOF. On some platforms (e.g. gcc ARM eabi), regular 'char' is unsigned and the check fails.
aliswe|3 years ago
LAC-Tech|3 years ago
klodolph|3 years ago
https://www.nme.com/features/gaming-features/the-resurgence-...
https://hauntedps1.itch.io/demodisc2021
whateveracct|3 years ago
codetrotter|3 years ago
https://old.reddit.com/r/ps1graphics/
There's also some people on YouTube doing PS1 and N64 style graphics.
zem|3 years ago
klipklop|3 years ago
How long before somebody includes your library and says they created PSX graphics in 25 lines?
chii|3 years ago
And what about any of the operating system calls that might get used? It's also a library (despite the source code not being in the project).
The actual code to compute the logic of the graphics PS1 style, is indeed around 500 lines.
unknown|3 years ago
[deleted]
angry-1|3 years ago
[deleted]