[HN Gopher] Building a PS1 style retro 3D renderer
___________________________________________________________________
Building a PS1 style retro 3D renderer
Author : bwidlar
Score : 250 points
Date : 2021-12-08 15:41 UTC (7 hours ago)
(HTM) web link (www.david-colson.com)
(TXT) w3m dump (www.david-colson.com)
| kingcharles wrote:
| This was great, and took me back to the late 80s/early 90s when I
| was studying Michael Abrash and building software renderers
| before the first hardware 3D accelerators appeared on the market.
|
| While I eventually figured out that the reason my textures looked
| fucked up, especially in long corridors, was because they didn't
| take into account perspective and thus needed an extra set of
| per-row and per-pixel interpolations (which killed the frame
| rate), I actually never realized until this article that my
| Gouraud shading was actually suffering from the same issue
| because it was so much less noticeable to the eye.
| ggambetta wrote:
| Interestingly, even the depth buffer is wrong if you
| interpolate Z linearly, but it's such a subtle effect, it's
| almost imperceptible.
|
| IIRC games back then also used to do perspective-correct
| interpolation every 8 or 16 pixels, and linearly in between,
| which is a good compromise (you always have to interpolate U
| and V, what they wanted to avoid was the division, which is
| more expensive).
|
| I've written about this here,
| https://gabrielgambetta.com/computer-graphics-from-
| scratch/1..., including some detailed examples of how the math
| works. Very fun topic :)
| bennysomething wrote:
| Retro gamer (UK magazine) did a great piece on indie Devs going
| for this look. Think this vice article says something similar:
|
| https://www.vice.com/en/article/3an385/were-in-the-beginning...
| staindk wrote:
| Cool - reminded me of this guy's project [1]. I had to mission
| about to find the channel again because I forgot the name, but
| his videos are (were? hmm it's been a while) really cool.
|
| [1] https://www.youtube.com/watch?v=IPzl9FmKVjI
| dietrichepp wrote:
| Love these "tiny" 128x128 textures when meanwhile, anyone doing
| development for the contemporaneous Nintendo 64 gets something
| like 44x44@16bpp color, or 64x64@8bpp grayscale. The maximum
| texture size is 4 KB with some major caveats (e.g. it drops to 2
| KB if you use indexed color).
|
| The N64 is, in a lot of ways, on paper, a more powerful system
| than the PS1. Better CPU, depth buffer / Z test, perspective-
| correct texturing, antialiasing, subpixel precision, etc. And yet
| the PS1 completely dominated the N64 in the marketplace and in
| terms of longetivity--a big part of that how cheap it is to
| manufacture CDs. And so people lovingly remember PS1-style
| graphics, but there isn't as much of a resurgence of N64-style
| graphics.
|
| Another cute thing to note about PS1 is how it renders dark
| clouds on-screen. You might be familiar with the "add" blend mode
| for things like lens flares. Well, the PS1 also had a _subtract_
| blend mode, which has some unusual effects... basically, anything
| partially obscured by a dark cloud gets darker but also more
| colorful.
| thesuitonym wrote:
| At the time, I hated how ugly PS1 games looked, and wished they
| were nice and smooth like N64. now I realize that N64 textures
| weren't smooth, they were blurry.
| Grazester wrote:
| The textures were blurry along with the images itself due to
| its poor digital to analog converter. The latter can be
| addressed with HDMI mod boards now available for the N64.
| yumaikas wrote:
| It's funny how the particular constraints of a system can
| matter in different ways the designers didn't have a solid
| handle on at first.
| pkdpic wrote:
| I just want to say this is a beautiful and inspiring project so
| far. Im looking forward to seeing how it evolves.
| lostgame wrote:
| I actually sought out techniques to do very similar in Unity for
| a Saturn/PS1 inspired 3D platformer I'm developing.
|
| It's such a cool aesthetic, I'm surprised it hasn't 'caught on'
| yet as a modern design fad.
| dave84 wrote:
| It has definitely caught on with the indies. Specifically the
| Haunted PS1 genre.
| atum47 wrote:
| back when I was a 3D artist this was my favorite things to model
| - low poly things. I loved being as efficient as I can with my
| polygons. I'll make sure to follow the development. Great job so
| far.
| prvc wrote:
| Yes, but: why have these characteristics, especially the
| perspective-incorrect textures (which look terrible, and do not
| provide an efficiency advantage in the context of a "fantasy
| console")? Why not just write for the PS1 instead (if you must
| have these traits)?
| AnIdiotOnTheNet wrote:
| The aesthetic itself has value, not just for the nostalgia but
| because it can evoke a particularly creepy vibe when used
| correctly. The low-poly designs have a surreal and sometimes
| uncanny-valley quality to them, the texture warping is
| unsettling, the fog and dithering need no explanation.
|
| Highly recommend the Haunted PS1 Game Demo Disc 2021[0] if
| you're into horror, indie games, and the PS1 aesthetic.
|
| [0] https://hauntedps1.itch.io/demodisc2021
| cheeseomlit wrote:
| There are plenty of people who find those characteristics
| aesthetically pleasing, I enjoy the affine texture mapping
| effect and vertex jitter when they're used effectively- depends
| on the game. For example in Silent hill these sort of effects
| enhance the eerie atmosphere, giving it a more warped and
| dream-like feel.
|
| As for developing directly for the PS1 there are many practical
| reasons not to, like ease of development and actually being
| able to release/sell your game on modern storefronts
| lloeki wrote:
| In Ridge Racer the texture warping and geometry raster gave
| some heightened sense of raw speed. Later versions on
| subsequent platforms (or emulated ones that correct this
| technical fault) felt way too smooth and much less intense.
|
| e.g around 1:47, the tunnel walls go zigzag in a very obvious
| way but the effect is present in most textures, only more
| subtle https://youtu.be/WLJqWtnFkdY
| adamrezich wrote:
| someone should make a racing game where the vertices get
| more "unstable" the faster you go...
| corysama wrote:
| Why do it all? Brian Eno had an answer for that:
| https://www.goodreads.com/quotes/649039-whatever-you-now-fin...
|
| I've considered doing this --digging out PS1 homebrew tools and
| targeting libRetro. I even worked on PS1 games just a bit a
| long time ago.
|
| Then I looked at actually doing it and, oh man, it's a lot of
| work to get started! If I was a younger man with more free time
| I could pull it off. But, at the moment I need to keep my side
| projects smaller scope.
|
| As far as OP goes, setting up a renderer like this requires
| digging out some unusual techniques. But, they aren't hard to
| implement once you figure them out. And, then you can go back
| to the speed and convenience of modern gamedev environments.
| lostgame wrote:
| The PS1 is extremely limited in terms of hardware. This is
| about liking the aesthetic but being able to create without the
| limitations the PS1 put on us.
|
| The PS1 has 2MB RAM. The average consumer laptop these days has
| 8GB. My dev laptop has 16GB. And that's just RAM. Video memory,
| similarly; allows us a lot more _physical space_ in our game
| areas while still retaining this aesthetic, if we choose - it
| allows more enemies, or objects on the screen...more complexity
| in AI, etc, etc.
|
| None of these have to do with the visual aesthetic, but are all
| previously creative restrictions we no longer have to deal with
| as creators.
|
| I'm a Homebrew dev for the SEGA Saturn, whose architecture is
| actually way more of a pain in the ass to dev for than the PS1
| ever was - but I do it specifically for the challenge and joy
| of learning the ins and outs of the hardware.
|
| That being said - in no way would I want to take on a project
| specifically for that architecture, especially because; if the
| project is successful in any way - porting it to another
| platform would be a _nightmare_.
|
| Much better to use something like Unity, or - if you're a
| 'total control' kinda person, SDL, etc.
| 999900000999 wrote:
| I think it depends on what you want to do.
|
| I use Unity extensively and adding a PS1 filter to an
| existing game takes a 15$ asset. The only real downside is
| your stuck in the Unity verse.
|
| I would absolutely love for Godot to have a robust asset
| store ( yes paid assets , I've no problem paying for good
| code ). Let's hope Godot 4 is nice.
| lostgame wrote:
| Again, I stated use whatever toolchain you'd like - it's
| really the fact that we're not limited to 2MB RAM that
| matters.
|
| Unity just works for me. Whatever works for you is great. I
| have never once found the 'Unity-verse' to limit or hamper
| my creativity or ability to do anything I wanted, and; in
| fact, have found it more empowering than the dozens of
| other game IDE's I've worked with in 20+ years of game dev.
| Since Unity provides me with more than I could possibly
| need for myself; and I've been using it since I had it on
| my PowerMac G5 back when that was still a thing - I never
| foresee myself swapping IDE's for any reason. Especially
| with a backlog of 10+ years of projects backed up.
| 999900000999 wrote:
| Oh don't get me wrong. I love Unity. I'm actually coming
| out with my first larger scale Unity games next year .But
| I'm a bit afraid of having all my skills locked into one
| platform, controlled by a single for-profit company, for
| my next side project, I really want to use anything else.
| Preferably a fully opened source solution like Godot
|
| Can you explain this, you have games planned ?
|
| >Especially with a backlog of 10+ years of projects
| backed up.
| lostgame wrote:
| I have an incredibly unique project that I'm honestly
| very proud of, and very surprised how far I've managed to
| get with on my own.
|
| For better or worse, that project is going to require a
| decent budget to organize, as hardware is a big part of
| some of the subprojects. Unity is at the core of both the
| interactive and less interactive aspects of the project.
|
| It'll need to be pretty much a full-time gig for 6-9
| months to pull off the stability the project will require
| to be safely scaled to the mammoth size it'll need to be.
|
| Knowing that, I've saved dozens of prototypes over the
| years which represent different important iterations of
| the technology, and as technology grows some of those
| demos and ideas become more or less important.
|
| I expect this year I'll finally have the finances to
| truly get started on some serious demos with the
| expectation/assumption that I will actually be going into
| full-time development shortly after the releases of the
| demos - I expect the demos to be fairly mind-blowing if
| executed better than they were able to due to
| technological and budget limitations, say - 5 years ago;
| and I've held out on speaking to investors or doing
| crowdfunding until I absolutely knew everything was
| there.
|
| Since...well, the main _chunk_ of this project has always
| been...not a video game - Unity allowed me the
| _environment_ to create, I guess...something incredibly
| unique, because it was more of a sandbox to me than a
| game engine. I 'm interested to see where I can take the
| project when I'm not hampered by the tech.
| 999900000999 wrote:
| Make sure to post something here when you have a
| prototype, I'm not exactly sure what you're building, but
| anything that's out of the ordinary is always of interest
| to me.
|
| I'm considering taking off a few months myself to finish
| my side projects.
| pcwalton wrote:
| Because it's fun.
| ant6n wrote:
| Developing against this seems much easier than making an actual
| ps1 game, if you want to get that retro look.
| agumonkey wrote:
| I wonder if people try to retrofit post ps2 ideas onto ps1
| hardware. Or new techniques on older hardware when the knowledge
| wasn't there or spread.
| xgkickt wrote:
| The most obvious one I can think of is triangle strips and
| MIPmaps. The 60fps demo that came with Ridge Racer Type 4 had
| MIPmaps.
|
| I made an internal "cel-shading" tech demo back in 1998,
| tracking the polygon edges and then using line primitives to
| outline the objects but there was no game to apply it to.
|
| There were bump/normal mapping demos around then too, where a
| palette entry was assigned to a vector (so 256 vectors max),
| lit, and the texture applied additively (or subtractively).
|
| On a personal project attempting a mesh shader like approach
| (although you can say it's really a PS2 VU1 workflow) to
| transform and sort a cluster on scratchpad, then triple buffer
| the output in memory, ready to be kicked off to the GPU in
| slice mode. It might end up slower than the old brute-force OTZ
| approach but it's fun to figure this stuff out.
| TrackerFF wrote:
| Me and a friend were talking about this some time ago.
|
| He brought up an interesting point: One thing that made for
| example Silent Hill extra scary, was the janky PS1 graphics.
| Narishma wrote:
| One missing effect is dithering. Unless my memory fails me, it
| was quite prevalent on the PS1.
| wk_end wrote:
| Indeed - it was built-in hardware functionality that developers
| (or GameShark users!) could enable/disable on a case-by-case
| basis https://www.chrismcovell.com/psxdither.html
| stevebmark wrote:
| As an aside, one thing that's interesting and sad to me about
| WebGL is that WebGL + modern browsers are significantly more
| powerful than the PS1 and Nintendo 64, but we haven't had
| _anything_ even _remotely_ close to the completeness of an N64
| nor PS1 game. Lots of small experiments and impressive
| demoscenes, but nothing in WebGL that takes advantage of this
| potential power. Frankly even compared to the completeness of
| Flash games, there are very few WebGL projects that even come
| close to that.
|
| This article and output would make a great WebGL project, and
| they could embed real demos of it running right in the site.
|
| What's missing that prevents us from building these types of
| complete projects in WebGL?
| feiss wrote:
| A webgl game is hard to monetize, specially if you compare it
| with other options.
| kderbyma wrote:
| I have been reading a bit up on it for a side project and it's
| great, but resources for troubleshooting are slim and it's not
| compatible easily with modern frameworks so people tend to use
| particular Libraries for everything and finding vanilla webgl
| is a bit trickier.
| modeless wrote:
| Monetization is the answer. Nobody is paying $50 for web games,
| there's no in-app purchase system, no web gift cards in stores,
| and the exploitative interstitial ad networks that enable free
| mobile games to make boatloads of money don't exist on the web.
|
| That said, there is an ecosystem of web games and you might be
| surprised by the sophistication of some of them.
| https://venge.io/ is a good example, try https://poki.com/ for
| a sampling of more. https://playcanvas.com/ is the most
| advanced WebGL-specific engine.
| Shared404 wrote:
| Nothing but lack of desire afaik.
|
| Iirc, Godot and Unity can both target WebGL.
| mywittyname wrote:
| There have been lots of complete games built targeting the web
| browser.
|
| Crosscode is pure HTML5 according to the devs. No webgl at all.
| Games like Quake have been ported to run in the browsers (and
| did so ~10 years ago).
|
| I'm sure there are a lot more complete games out there
| targeting web browsers, but it isn't immediately apparent
| that's what they are using. A lot of the newer games I play
| feel like they are running in a web browser.
| wodenokoto wrote:
| Any modern indiegames that go for the PS1 look? Tons of indie
| games pay homage to the 8-bit era, but I don't recall much
| nostalgia for warped textures.
| Grazester wrote:
| Amongst retro gamers there is universal agreement that 5th
| generation console games(specifically 3d games) aged the worse.
| burlesona wrote:
| I think 8-bit/16-bit retro games were kind of at the apex of 2D
| sprite game design, and many of them were quite lovely, hence
| the nostalgia.
|
| The PS1 3D games look worse when you look back at them, because
| they were not really the next logical increment of 2D gaming,
| but the first step into 3D. So more like the Pong, Asteroids,
| etc of the 3D era. They were exciting at the time as a glimpse
| of where things were going, but objectively they looked pretty
| bad.
| matheusmoreira wrote:
| I agree. Retro 2D games are amazing. The SNK games are works
| of art. Modern 2D games don't quite feel the same. I don't
| even understand why.
| adamrezich wrote:
| there's been a bit of a surge of low-poly fake-PS1-wobbly-
| vertices horror games lately
| daxelrod wrote:
| BallisticNG has tried really hard to get the look and feel of
| the PSX Wiepout games, including an optional PSX shader that
| adds vertex wobble.
|
| https://neognosis.games/ballisticng/
| cosmobot wrote:
| Valheim is an indie game with a PS1-style aesthetic built using
| Unity.
|
| https://www.valheimgame.com/home/#anchor4
| mywittyname wrote:
| Kinda.
|
| I know that's what the developers claim, but the game looks
| so much better than a PS1 game. The only PS1 aesthetic the
| game can honestly claim to have is low-res textures. It
| doesn't have the weird texture warping, shallow draw
| distances, rigid animations, or really anything else that we
| associate with the PS1.
| moth-fuzz wrote:
| This is an excellent article, a good insight into the
| particularities of the hardware. I particularly admire the
| explanation of why the polygons snap to the pixel, and why that's
| not the fault of floating-point mathematics but rather the
| rasterizer itself. One thing the article approaches, but doesn't
| really quite get to the bottom however, and which is the crux of
| all the ps1's 'flaws' is that its GPU was 2-dimensional
| fundamentally. That's why things snap to pixels, that's why the
| textures do not have a depth component and are thus not
| perspective-correct, that's why there is no z-buffer, because it
| had no z-coordinate. Essentially, every single PS1 game 'faked'
| 3D by using the GTE (which was separate from the GPU) to project
| 3D points and polygons into a 2D rasterizer. And it worked quite
| well! For the time.
|
| Another thought - I also wrote a similar renderer under similar
| constraints a while back, just for funsies, and I'm wondering
| what would have came if I thought "I should write an article
| about this". I generally don't think to write articles over every
| side project I do, what's the impulse for when someone decides to
| detail their work to the internet?
| munificent wrote:
| _> what 's the impulse for when someone decides to detail their
| work to the internet?_
|
| When it comes to writing, I think the biggest factor that
| determines if/what/and how you write is the audience you
| imagine. When you write, you sort of picture yourself telling
| the story _to someone_. And the way that scene plays out in
| your mind depends entirely on who that person is.
|
| If your mental image of the audience is "some random Internet
| user whose interests are different from mine", then you can't
| imagine them standing there patiently while you laboriously
| walk through all the details of your renderer. So you don't.
|
| But if you imagine an audience that is "another retro renderer
| enthusiast who has similar projects", then you can imagine them
| getting hyped up by what you're saying and gleaning bits of
| useful stuff from it that they can apply to their own side
| projects. It almost feels wrong to _not_ write it and let them
| down.
| [deleted]
| akdas wrote:
| Adding to this, if you imagine the audience is _you_, then
| you might feel motivated to write the article you _wished_
| you had before embarking on your project. That audience falls
| under your second one ("another retro renderer enthusiast who
| has similar projects"), but maybe is even more targeted.
|
| One advantage of this is being able to look back on previous
| projects in the future, as a form of documentation. That
| helps me pick up on a project I haven't worked on in a bit.
| True, you don't need to publish the documentation publicly,
| but since I wrote it, putting it up publicly is almost no
| effort now that I have a blog.
| jayd16 wrote:
| >that's why there is no z-buffer, because it had no
| z-coordinate
|
| Z-buffer is just an array of values you can sample, often as a
| texture. There is no inherit coordinates, unlike, say,
| vertices. Z-buffer is a 2d map anyway. The offset into that
| buffer would be the x and y.
|
| Or do you just mean there's no hardware accelerated z-buffer?
| codeflo wrote:
| In early 3D hardware, the Z buffer was a bit more special
| cased than it is now, where you quite literally allocate a
| texture. In either case, the interesting (and expensive to
| emulate in software) part is of course _using_ the depth
| buffer to perform depth testing, that is, rejecting pixels
| that would be hidden.
| xgkickt wrote:
| The GTE truncated too early, and in too many places and there
| is a register for adding a fraction to the post-perspective-
| pre-truncate result to round instead. I didn't implement this
| back in the day, but thought about scaling the target
| dimensions in the GTE (watching for overflow) to get 1 bit of
| fraction back to refine the screen coordinate.
| mywittyname wrote:
| > what's the impulse for when someone decides to detail their
| work to the internet?
|
| The company I work for considers this kind of writing to be
| fundamental to being a considered a principal engineer. I can't
| imagine they invented this idea; it's probably relatively
| common in the startup world.
|
| While this might not have been the author's motivation, having
| a popular tech blog certainly doesn't hurt one's employment
| prospects.
| flipacholas wrote:
| > Essentially, every single PS1 game 'faked' 3D by using the
| GTE (which was separate from the GPU) to project 3D points and
| polygons into a 2D rasterizer.
|
| While it's true that the PS1 handles perspective projection
| through the GTE (as the GPU is a primitive rasterizer, after
| all) I don't think it's fair to call it 'faked 3D' since, in my
| understanding, 3D projection is another fundamental stage in
| the graphics pipeline (our displays are 2D grids of pixels, so
| we need to transform the 3D world into something it can be
| displayed there). Other consoles like the Nintendo 64 provided
| more capability on the GPU side (the RCP) which allowed to move
| part of the matrix operations away from the CPU chip.
|
| Be as it may, I've seen the 'fake 3D' claim before and I'm
| starting to wonder if I'm missing something in my understanding
| of this technology, maybe someone can offer a third opinion?
|
| P.S I'm the one that wrote
| https://www.copetti.org/writings/consoles/playstation which is
| referenced at the bottom of the article (the 'Other reading'),
| I'm glad the author found it helpful (or interesting)!
| codeflo wrote:
| Fake/real is not the most precise terminology, but I think it
| gets the important point across, so I'll use it.
|
| In a "real 3D" rasterizer, you interpolate the depth
| coordinate for each individual pixel. You need this value to
| perform two steps in the pixel pipeline that are required to
| get the correct look: First, you use the depth coordinate the
| perform depth testing (reject pixels that should be hidden).
| Then, you use it to perform a perspective correct texture
| lookup.
|
| If you throw out the depth coordinate anywhere earlier in the
| pipeline, as the PS1 did, you can't do either of those
| things, so you get artifacts where objects flicker and warp
| when rotating. The rasterizer really needs to be "3D aware"
| right until writing out the final pixel values.
|
| Note that both artifacts can be lessened, to some degree at
| least, with workarounds. For depth testing, you simply sort
| the polygons (which doesn't work in every case, as triangles
| can overlap in cycles). And for the texture lookup problem,
| you subdivide the polygons (which is expensive, and doesn't
| fully solve the problem).
|
| As an aside, the PS1 had another issue where the rasterizer
| didn't support subpixel precision, which also leads to
| artifacts. But IMO that's mostly unrelated to the 3D
| coordinate problems -- 2D games need that as well to get
| smooth movement.
| yumaikas wrote:
| I could see an argument being made for 'fake 3D' pretty
| strongly here. DF Retro has a few videos comparing various
| consoles, and one of the things that the PS1 and Saturn both
| got wrong, IIRC, was that textures would warp*, because the
| 3D look was being provided by affine transforms (as I
| understand, I may be misremembering the details), rather than
| perspective correct rasterization.
|
| So, like, the vertexes are in the right spots, but the
| texture mapping is off. So it kinda depends on if you need
| texture mapping to be perspective correct to consider a given
| example of 3D "real" vs "fake". Dark Forces also has
| perspective warping that happens in it's engine when you look
| up/down, as an example.
|
| * https://youtu.be/VutzIK3DqZE?t=341 DF Retro analyzes ports
| of Tomb Raider
| moth-fuzz wrote:
| > Be as it may, I've seen the 'fake 3D' claim before and I'm
| starting to wonder if I'm missing something in my
| understanding of this technology, maybe someone can offer a
| third opinion?
|
| I agree that all 3D is 'faked' in the sense that it's drawn
| to a 2D grid of lights eventually, I guess it just depends on
| where in the pipeline you make that fundamental
| transformation. I only meant faked in that the GPU itself is
| 2D, whereas the GTE is just math. So it's kinda like doing
| CSS transformations to make a web page all 3D-looking (a
| gross understatement I know, but, nevertheless). Though,
| semantically, I guess the '3D' part of a modern GPU is also
| 'just math'. Well now you've got me thinking about it
| harder...
|
| Wonderful article by the way! I've read yours a few times
| myself.
___________________________________________________________________
(page generated 2021-12-08 23:00 UTC)