[HN Gopher] GTA III and Vice City fully reverse engineered: re3
___________________________________________________________________
GTA III and Vice City fully reverse engineered: re3
Author : blewboarwastake
Score : 343 points
Date : 2021-02-14 07:10 UTC (15 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| llarsson wrote:
| Dumb question: can I play this using assets from the PS2, it does
| it have to be the PC version?
| aap_ wrote:
| It can actually load most of the PS2 files, but generally no,
| you need PC files.
| james_woods wrote:
| Nice! Btw: Is there a list with projects that got done due to the
| pandemic? :)
| jcpham2 wrote:
| I still play my PC CD Roms patched under wine so this is neat
| thanks!
| rambojazz wrote:
| How is it possible to RE a whole videogame? What's the process to
| go from bits to C++?
| ThrowawayR2 wrote:
| You have a long list of machine language instructions. You know
| (roughly) what the output of the compiler looks like when
| translating from source code to machine language for various
| constructs like functions, if statements, etc. (a compiler
| course helps here). Some reverse engineering tools provide
| partial automation for that to assist in this deciphering.
| After that, it's just a lot of painstaking, grinding work.
| [deleted]
| CodeArtisan wrote:
| the bits are cpu instructions that you can analyze the data
| flow to revert the instructions into c++ code, either manually
| or assisted with a decompiler.
|
| https://en.wikipedia.org/wiki/Decompiler
|
| https://en.wikipedia.org/wiki/Ghidra
|
| https://ghidra-sre.org/
| boyadjian wrote:
| WOW, need ! Vice City was my favorite video game of all times.
| Will try to compile this soon
| high_byte wrote:
| Mine too and I must have spent way too many hours on it as a
| kid... but WHY?
| MaxBarraclough wrote:
| Very impressive. Neat that they're even intending to get a PS2
| build working.
|
| Wonder if they plan to do further work on graphical improvements.
| aap_ wrote:
| PS2 build is a lot of work unfortunately and I'm afraid it is
| me who'll have to do it. Guess we'll see how far we'll get...
|
| I've done some graphical improvements but we want to keep it
| mostly true to the original spirit. But yes, there are some
| things i would still like to improve upon a bit.
| mraza007 wrote:
| I'm just curious to know how do developers reverse engineer
| eimrine wrote:
| Can we spend a minute for paying respect a license? How it is
| called?
| [deleted]
| tnolet wrote:
| As a basic web / JS developer I'm envious that creators of this
| repo get to work on awesome methods and classes called "Crime.h"
| and "!ped->bRenderScorched && !ped->bBodyPartJustCameOff".
|
| Beats "div.container" in my book.
| ggambetta wrote:
| I get you. I was a game developer a couple of lifetimes ago. I
| once had to investigate and fix a bug called "HANDBAG TURNS
| INTO A BANANA". Never had anything like that in the corp world
| :_(
| ttt0 wrote:
| Reminds me of the interview with Tarn Adams from Dwarf
| Fortress.
|
| https://www.youtube.com/watch?v=VAhHkJQ3KgY
| fnord77 wrote:
| is it more stressful working on games than in the corp world?
| [deleted]
| BossingAround wrote:
| Ask CDPR developers.
| SeanBoocock wrote:
| I have never had a job that wasn't at least games adjacent,
| but I expect the comparison is not that clear. There is a
| huge diversity of commercial game development, just as
| there is for commercial software development generally. On
| average game development is probably more stressful
| because: it is an entertainment product in addition to
| being a piece of software; the funding models for
| independent game developers are often project based, which
| can lead to a lot of instability.
|
| There are corners of game development that are more "chill"
| than others. Studios doing work-for-hire for other projects
| can build sustainable businesses. People in the "serious"
| game and simulation space seem to have a pretty normal work
| experience. Likewise shared tech teams at the biggest
| publishers/developers are more insulated from business
| variability and shifting project deadlines.
| skeeter2020 wrote:
| of course it's going to vary, but yes.
|
| I don't know if the new development model of "hit release
| date and fix everything after we sell the DLC" has made
| this better or worse.
| alisonatwork wrote:
| Hang in there. We once had a bug "PRODUCT IMAGE TURNS INTO A
| DOG" due to some code that kept falling back to an
| embarrassing placeholder.
| monocasa wrote:
| Had 'under strained conditions, debug console comments
| negatively about your mother.'
|
| A debug line someone thought wouldn't ever see the light of
| day.
| dannywheeler wrote:
| I think "Right-click, see spiderman" was the highlight of
| my career.
| rvense wrote:
| In my very first developer job, I was creating a backend
| for a social media-type phone app. This was sort of a skunk
| works project that the founder and "Chief Innovation
| Officer" of a successful company wanted to do on the side,
| but he only had the budget for a couple of juniors.
|
| Anyway, I didn't know a lot of things, so at one point I
| got the test environment and production environment tangled
| up in the code. I don't even remember the details of this
| confusion and I'm not sure I'd be capable of understanding
| how this was possible, but the long and the short of it is
| that one time the boss came down and asked something like
| "Why am I a horse?", and the answer was that he was being
| logged in as a user on the test environment which had a
| name that was a horse pun and a horse for a profile
| picture. Fun times.
| rkuykendall-com wrote:
| Great collection of real video game changelog entries:
| https://twitter.com/thestrangelog
| tmpz22 wrote:
| Quirky variable names does not a good code base make.
| bzb6 wrote:
| Rockstar forgot to strip the PlayStation binaries so I
| suppose those are the variable names of the original
| codebase.
| aap_ wrote:
| Those are struct names though. So they wouldn't be in
| there. They did share some headers with the MTA developers
| though and that's where we got bRenderScorched from. i
| think the body part name is ours though.
| [deleted]
| bzb6 wrote:
| Wow... how did mta convince rockstar to share stuff like
| that? For what purpose?
| aap_ wrote:
| R* was a lot more open at the time and I guess they
| wanted to help them implement a multiplayer mode. that
| was before the whole hot coffee story.
| Hamuko wrote:
| Guess it was good market research.
|
| Now GTA V / GTA Online made half a billion dollars in
| 2019, six years after it was released.
| spoonjim wrote:
| It's not a quirky variable name, it's just the description of
| what's happening in the game.
| onion2k wrote:
| A lot of my frontend code should probably live in a file called
| crime.js
| grokkedit wrote:
| You can still write a fully working page with a body but
| without a head, and a parent can do whatever it wants with
| their children, destroy them if necessary... It's not that
| bad...
| jonplackett wrote:
| I remember when GTA 3 came out on PC and I found just a simple
| human-readable text file you could edit to modify all the
| settings for all the cars.
|
| We turned the Karuma into a physics defying monster. It was 1000x
| heavier than the tank, so as you drove down the road other cars
| just bounced off and flew over the horizon, or exploded on
| impact.
|
| Yet it still did 0-100 in 0.1 seconds and could drive up walls.
|
| One time we jumped it from the third island, over the middle
| island and landed on a skyscraper roof on the 1st island.
|
| From there we spent about an hour dropping grenades on police
| cars and the army who had no way to reach us up there.
|
| Fun times. Shame Twitch or YouTube didn't exist back then to tell
| anyone about it!
| artemonster wrote:
| If I remember correctly the file called "handling.cfg" and it
| was a huge unreadable CSV table :) good times.
| asadlionpk wrote:
| Yes. It was a csv table with all the configs for physics
| engine for all vehicles.
| aap_ wrote:
| Not exactly CSV but close. The good thing is now you get to
| see the...less than optimal code that reads this file: http
| s://github.com/GTAmodding/re3/blob/master/src/vehicles/H...
| jonplackett wrote:
| Yeah that rings a bell!
|
| Really couldn't believe my luck when I found something so
| obvious (I still felt like I had mad hacker skills)
| pylua wrote:
| Yes ! I have a similiar memory. When I was a kid, My parents
| did not like me playing the game for many reasons, one being
| the in game prostitutes . I simply changed a file to have them
| removed .
| unicornporn wrote:
| Opened this thread expecting to share this fond gaming memory.
| I've wished that modern games was more like this more than
| once. Finding jumps for crossing entire maps was incredibly
| liberating!
| Rodeoclash wrote:
| Haha, you weren't the only one doing this. I used to alter the
| fire engine to also have some absurd weight but and engine
| powerful enough to still move it. Their was also a time scaling
| option somewhere which would slow the game down and put it into
| a "matrix"-esque mode.
|
| I used to jump into the fire engine, get on the wrong side of
| the road on a freeway and activate the slow motion before
| driving head on into the traffic. Their was something
| mesmerising about smashing your way through the cars and seeing
| them lift off into the air and fly into the buildings on either
| side of the freeway.
|
| Eventually the police would show up but what could they do
| against a fire engine that was as dense as a sky scraper!
| jonplackett wrote:
| Yes now I remember the time changing too! That was so much
| fun.
|
| Another fun thing I now remember was to turn the dampening on
| the Taxi's suspension to a positive value, so if you even
| gave them the smallest possible knock they would gradually
| start to wobble like a jelly and then start bouncing and
| bouncing until they were leaping up higher than buildings.
| raisedbyninjas wrote:
| We modded an SUV to have monster truck tires. It allowed you to
| drive over passenger vehicles like speed bumps.
| m00dy wrote:
| Im not sure how long it takes for someone to port this into
| webassembly and distribute the assets along with a decentralized
| anonymous file network ?
| aap_ wrote:
| There have been emscripten ports of this already. Distributing
| the assets is probably the most problematic thing.
| noname120 wrote:
| Check the other branches out! There is one for GTA Liberty City
| Stories[1], and another one for GTA Vice City[2].
|
| This project enabled people to port GTA to the PS Vita device[3].
| This device hasn't seen any games from the franchise, so this is
| a big thing.
|
| [1] https://github.com/GTAmodding/re3/tree/lcs
|
| [2] https://github.com/GTAmodding/re3/tree/miami
|
| [3] https://github.com/TheOfficialFloW/re3
| 4gotunameagain wrote:
| I think that for games like those, which more or less defined
| entire generations of people (the ones that were into gaming ofc)
| in a lot of countries, it should be mandatory that their source
| code is made public after like, ten years or something.
|
| Sure, a company created it and it should be its intellectual
| property for enough time to return the investment etc. But
| something ingrained so much into people imo trancends that and
| should be considered belonging to the public realm.
| jrrrr wrote:
| I can imagine a policy mandating that for all commercial
| software, source code goes into escrow for automatic release 10
| or 20 years later.
|
| The company doesn't have to be around anymore, rights don't
| have to be negotiated, etc.
|
| Short of that I wish more companies would do it voluntarily.
| I'm not into id games, but they're one example that comes to
| mind.
| spideymans wrote:
| This is critical imo, if only because software are cultural
| artifacts that should be able to be archived just like any
| other cultural artifacts.
| news_to_me wrote:
| Have you ever heard of free software? ;)
| 4gotunameagain wrote:
| I have never heard of compulsory source releasing
| jeofken wrote:
| Any law in the end requires a violent threat. This suggestion
| implies that someone who does not publish their source code
| should, after som ignored formal letters, get armed men sent to
| their office to kidnap whoever is responsible.
|
| All nice sounding laws, such as gov funded welfare, gov funded
| hospitals, gov funded schools, and the endless regulations,
| implicitly carry a threat of violence, and when judging the
| ethics of a carrying a law out, that violent threat must be
| included. Government is firstly about guns.
| zymhan wrote:
| Quite the slippery slope fallacy.
|
| You're also conflating civil and criminal law. Copyright is
| civil law. The government doesn't send the FBI in to ensure
| some publisher respects that a book's copyright has lapsed.
| tnolet wrote:
| Random question from a web developer who has zero knowledge of
| C++ or game development: I see no tests in this repo. Is this
| normal, or am I missing something?
| stefan_ wrote:
| Lots of games are throwaway code - you essentially start over
| for the next one. That's wildly inefficient of course, which is
| why the generic reusable parts have been factored out into huge
| _engines_ like Unreal Engine, and those generally have some
| test coverage.
| softwhale wrote:
| I'm pretty sure that Rockstar North would have some tests in
| place. The creators of the reverse engineered project, simply
| couldn't access these tests as they wouldn't be included in the
| build. (At least, I'd imagine). Also: It may be interesting to
| note that GTA:V's leaked build logs featured some notes about
| an "auto play bot test failed at {mission}". I'm pretty sure
| they would have to have similar tests (although perhaps at a
| smaller scale) for older GTA's as well.
| aap_ wrote:
| It's quite hard to test heavily interactive code like this. Not
| totally impossible but you have to question if it's worth the
| effort.
| softwhale wrote:
| It may be interesting to note that GTA:V's leaked build logs
| featured some notes about an "auto play bot test failed at
| {mission}". I'm pretty sure they would have to have similar
| tests (although perhaps at a smaller scale) for older GTA's
| as well.
| rushilhalflife wrote:
| I had a short stint at a AAA games company and I worked on one
| of the games. It was all written in C++ and we had absolutely 0
| unit tests. All the testing was done by an army of QA guys.
| tnolet wrote:
| That is wildly interesting. Every SaaS startup doing some
| 100k of $$$ in ARR will probably have long testing suites.
| AAA games making possibly tens of millions. 0 tests.
| ThrowawayR2 wrote:
| That's because in the games industry there is no
| expectation of a v 2.0 (most games never sell well enough
| to warrant it) and therefore little concern about
| mantainability or the future. It's hard enough to get the
| 1.0 release out the door without the studio running out of
| budget.
| mschuster91 wrote:
| Lots of things are at play here (excuse the bad pun):
|
| * SaaS stuff can be built very quickly (if you use cached
| node_modules or PHP composer's vendor directory) and
| deployed to parallel CI test runners that don't have much
| requirements. In contrast, your typical game takes much
| longer to (re)compile and as soon as you touch anything
| that requires graphics, you need some sort of (beefy) GPU
| in the server. Anyone who has ever tried virtualization
| with PCIe passthrough knows what a _pain_ that is to set
| up, not to mention NVIDIA explicitly disallowing to
| virtualize their GPUs.
|
| * It's easy to do unit tests for simple entities and
| operations (e.g. collision detection, physics)... but games
| are _full_ of global state mutated from across the place.
|
| * For everything that tests visual (or, god forbid, audio)
| output, computers are _bad_ at testing. Change a texture?
| Great, now you have to re-check all your tests if they 're
| still accurate and working. Humans are, for now, still
| better.
|
| * Hardware-specific bugs: these are one of a goddamn
| nightmare. For most software, it behaves identically across
| computers - let's take most Docker containerized
| software... it will essentially run on anything that's
| amd64. But games integrate with OSes, especially the OS 3D
| stack (DX, OpenGL, Vulkan, Metal and on top of that the GPU
| drivers and GPU firmware) so incredibly deep that there are
| lots and lots of potential issues and workarounds. It's
| simply _impossible_ to test for these.
|
| * Closed source components in the loop: Games ship with all
| sorts of blobs, from video codecs to sound effect
| libraries. These are in your address space, but you can't
| really test them.
|
| * Human tests are cheaper than writing test suites and
| setting up CI test farms (see the first point in my list).
| otabdeveloper4 wrote:
| Because unit tests are usually worthless, except in some
| specific circumstances.
| throw1234651234 wrote:
| This. We write unit tests when we do math on financial
| transactions, clear cut migrations of data, and other
| very well-defined, high risk circumstances.
|
| The other use-case for tests is explaining the
| expectation to new developers / teams under tight
| timelines. Example - we had a "surge" team come in - we
| were writing software that pulls data out of emails in
| hundreds of formats.
|
| We set up infrastructure for it that says - here is your
| input, here is your ouput, here is 100 sample records,
| make unit tests pass for them. This worked amazingly well
| when you had a team writing RegEx, another team writing
| csv stuff, one team using ML, etc. Basically, the goal
| was "make it work, in 2 weeks, no one will ever touch
| this code again." Btw, the latter is ALWAYS, ALWAYS a lie
| - if a company sinks a few hundred thousand into a
| project, you WILL touch it again.
|
| Anyway, this was more of a rant - basically unit tests
| ARE useless 90% of the time. Unit tests in Angular that
| are basically integration tests are absolutely
| disgusting.
|
| Keep in mind that if you have coverage, any time you
| modify a class, you are now fixing a bunch of broken
| tests.
|
| I guess that's why I am for testing individual methods
| and SRP.
| nmfisher wrote:
| While I totally agree with you, I also wonder if unit
| testing is used in the engine itself.
| Yavvn wrote:
| Game designer checking in. Unit tests are very rarely used in
| games. This is partially because they are so interactive, and
| partially because it would take a lot of time away from
| something else. The video game industry has always been under
| severe crunch. Why would you waste time writing something to
| check for a bug rather than fixing a different bug or adding a
| cool new feature? It's not the healthiest approach but it was
| inevitable now that we can patch games at any moment.
|
| Here is an example of a game called Factorio running its own
| unit tests. It's a lot easier for this game as its
| deterministic and doesn't need player interaction to function.
| https://youtu.be/LXnyTZBmfXM
|
| There have also been attempts to use machine learning agents
| that act as human players. It's going to be a while but the
| idea is that it would automate playtests which are used to hunt
| down the same bugs. https://youtu.be/ZZsSx6kAi6Y
| mentos wrote:
| Of all the systems that you guys reverse engineered here what do
| you think is the coolest? Ai/pathfinding, quest systems, large
| world rendering?
| aap_ wrote:
| I think everybody did the thing he was interested in most. For
| me that was rendering, physics, vehicles, camera and ps2
| specific stuff like VU0 collision detection.
| albertzeyer wrote:
| Can you give some more details how the reverse engineering was
| done exactly? (And maybe put that also in the README or
| somewhere, because I think this is probably interesting to some.)
|
| You write:
|
| > re3 was started sometime in the spring of 2018, initially as a
| way to test reversed collision and physics code inside the game.
| This was done by replacing single functions of the game with
| their reversed counterparts using a dll.
|
| How exactly? So the game EXE exported all the function symbol
| names? How did you know the function signature (arguments, return
| type)? And then it is enough to preload a DLL to replace the
| function? There is no global state or so which must be accessed?
| aap_ wrote:
| Maybe you'll find the first commit instructive:
| https://github.com/GTAmodding/re3/tree/600bf0351476a5a21aabb...
|
| We were very lucky that we had symbols for global things, which
| inludes function names and signatures but not return types. We
| then replaced the first instruction of a function with a jump
| to our own. global variables can be done with a reference to a
| raw address. virtual methods are a bit of a challenge but we
| found way to handle them.
| dom96 wrote:
| Wow, that's cool, so you replaced each of the game's
| functions individually until you had the majority replaced
| and working stand-alone?
| aap_ wrote:
| Not the majority. every single one!
| d26900 wrote:
| Wow, impressive!
|
| Can the assets be "reverse engineered" as well?
|
| Also, can R* shut this project down? Is there a legal
| basis for them?
| softwhale wrote:
| Apparently, this project requires the game assets to work
| - so you have to own a (legitimate) PC version of the
| game. https://github.com/GTAmodding/re3#intro
|
| Of course, R*/Take-Two could always make a case.
| kmeisthax wrote:
| Assets are typically "reverse engineered" by writing
| tools that convert them to and from whatever proprietary
| formats the game uses. Other than that, there's not much
| else to do with them once they're in standard format.
|
| As for the legality of the whole project: there's several
| different legal objections one could raise under
| copyright law:
|
| 1. That the EULA prohibits reverse-engineering
|
| 2. That the resulting reverse-engineering project is
| infringing the copyright on GTA3's program code (which it
| kind of has to in order to be a faithful disassembly)
| aap_ wrote:
| Not sure what reverse engineering assets means. There is
| source code for them so they are what they are.
| d26900 wrote:
| With "asset reverse engineering" I meant: recreating the
| assets from scratch. Just like a painter reproducing
| another painting.
| aap_ wrote:
| Of course you can create new assets.
| breakingcups wrote:
| (Except libraries like Renderware and Miles Sound System,
| because there'd be almost no point in wasting time on
| that. Only R* code was reversed.)
| aap_ wrote:
| That's true, though I did write a replacement for RW.
| It's not an exact copy but it does the job.
| [deleted]
| butz wrote:
| Now someone must add multiplayer to this.
| aap_ wrote:
| Hi, (co-)author here. Cool to see this here :)
| NullPrefix wrote:
| >Do not use features from C++11 or later.
|
| Is this a technical requirement to have compiler feature parity
| on all platforms?
| aap_ wrote:
| Pretty much, but also our goal is to recreate the code in a
| way that R* could have plausibly written it. And that implies
| no C++11.
| app4soft wrote:
| Any ideas to make it usable under ATI RS600 on Linux with Mesa
| drivers?
| aap_ wrote:
| I assume you have tested it and it doesn't work? Maybe the
| GPU is simply too old. I'm doing everything with shaders and
| it's possible they are just too much for this GPU. Supporting
| a wide range of hardware (especially old one that nobody has
| anymore), is not easy.
| ChuckNorris89 wrote:
| Thanks for your efforts.
| [deleted]
| ayoubElk wrote:
| This is fascinating, thanks!
|
| Can you speak about what it took to achieve this? (required
| knowledge, process, etc...)
| aap_ wrote:
| We were lucky that we had symbols from PS2 gta3 and the
| android games. other than that it was a lot of reading code
| in IDA and massaging it back into c++. I made a little video
| about part of the process [1] but i never did part 2.
|
| The strategy for gta3 was to replace function by function of
| the game until we had everything replaced. for VC we evolved
| our existing code base by, again, reversing function by
| function until we had everything done. Just not by dll
| injection this time.
|
| [1] https://www.youtube.com/watch?v=22BeuOOERLo
| marosgrego wrote:
| Now, somebody implement multiplayer!
| marcodiego wrote:
| One thing I like about these re projects: they allow porting to
| different systems by recompiling.
|
| It is an interesting feat to run SDLPoP (re'd prince of persia)
| on modern systems.
| rvnx wrote:
| This is very very impressive ! This reminds me the efforts to
| reverse-engineer Super Mario 64 that led to SM64 PC (and looking
| forward to the Zelda Ocarina of Time reverse!)
| olologin wrote:
| Is it true that NPC cars are not checked for collision? And
| collision checking only starts when something happens near?
| OneGuy123 wrote:
| Guessing but most likely so.
|
| I remember cleary that once I touched a car in GTA (can't
| remember which) the car visibly "fallen" to the road for a very
| small amount: so it was clear it was driving on tracks and was
| not properly physics simulated.
| breakingcups wrote:
| This is sort of true, they are "on rails" (meaning no physics
| calculations are performed) until something collides with it,
| like a bullet, a car or a player.
|
| At that point they are handed off to a more expensive process
| which includes checking physics each frame.
| aap_ wrote:
| Maybe this site is the best place to ask. There are two major
| things we could use help with:
|
| - the games do not run particularly well on the raspberry pi (any
| version really) and I have a feeling it's at least partially due
| to the OpenGL layer. We could really use someone with how to
| optimize OpenGL (especially on the pi).
|
| - physics have always been wonky beyond 30fps. I think someone
| with a good knowledge of game physics could really help us here.
| sokoloff wrote:
| I did some of the physics work (but was not the lead) for
| Papyrus racing games in the '95-'97 era. Email's in my profile
| if I can help.
|
| My recollection of Vice City is that the vehicle dynamics model
| is not particularly realistic but optimized for "fun gameplay
| with a hint of realism" whereas Papyrus optimized towards
| "realistic gameplay with a hint of fun". :D
|
| Our physics engine was deeply, deeply tied to a particular
| isochronous rate (30 Hz, then later 60Hz, IIRC) with all kinds
| of hackery to make that happen and divorce rendering rate from
| physics rate. (On the PSX, we ran physics engine tied to the
| VBlank.)
| aap_ wrote:
| Yeah, i think so too. In Vice City the most surprising thing
| to me was that they actually modelled tire temperature. it's
| probably a bit crude but i found it interesting. As for the
| physics code, there's a big ProcessControl function all sorts
| of physical entities that does everything that has to happen
| to that entity each frame. some of it is physics, some not.
| My theory as to why varying timestep produces different
| results is that the physics calculations form some sort of
| differential equations whose solution depends on the
| timestep. That may be wrong but it makes sense to me at
| least. My approach to fixing it would be to log all sorts of
| forces applied to the physical objects each frame and log
| them so they can be compared. this is quite a bit of stuff to
| implement though so nobody has done it yet. if you or
| somebody is interested in that, we'd appreciate that a lot.
| mypalmike wrote:
| Ha, back in that same era I was working at a small game
| company that was in discussions with Papyrus about doing some
| work on the Indy Car Racing game - probably a Playstation
| port. It never happened - I think it was determined that it
| wouldn't sell enough to cover the development costs. I don't
| remember much else except we played the PC game ("research")
| and it was super difficult - you needed a lot of skill not to
| crash at every curve. I also seem to recall that the polygon
| models for the cars were based on manually edited text files.
| Good times.
| rzzzt wrote:
| The physics engine of Vice City is definitely tied to the
| frame rate. If you switch off vsync, you can only drive in
| reverse veeery slowly.
| aap_ wrote:
| That one i was actually able to fix :)
| rwmj wrote:
| _> physics have always been wonky beyond 30fps_
|
| I suppose this is because the original developers knew exactly
| what hardware this would run on and the achievable framerate on
| the PS2 and so took lots of short-cuts in the code?
|
| Edit: Incredible project by the way.
| aap_ wrote:
| They actually did try to make it work at all frame rates but
| I don't think they were actually able to test it very well
| because the hardware, as you said, didn't do it.
| peruvian wrote:
| A lot of games were hardcoded for a specific FPS. Even
| modern-ish ones!
| ricardobayes wrote:
| Our local computer graphics prof hated this and set the
| loop rate random for the opengl idle function on our
| submission server. At one point it hang for 5 minutes
| between frames.
| lostgame wrote:
| Brilliant move, must have been one hell of a smart guy.
|
| I hate to say it, but fixed frame rates these days seem
| very 'lazy'? Obviously depending on use case and
| hardware.
| dagmx wrote:
| I wouldn't call it lazy. All development is compromise.
| Especially game development.
|
| If you know the game is only going to run on certain
| hardware, and you make the most money during the launch
| period of the game, it doesn't make sense to spend time,
| effort and money on something niche for the future.
| zamalek wrote:
| Time corrected vertlet integration[1] is really approachable
| and I'd strongly recommend trying it out.
|
| [1]: https://www.gamedev.net/articles/programming/math-and-
| physic... Edit:
| http://archive.gamedev.net/archive/reference/articles/articl...
| Const-me wrote:
| > We could really use someone with how to optimize OpenGL
| (especially on the pi).
|
| Not sure that gonna help much.
|
| I think what you should do instead, port your OpenGL code to
| OpenGL ES. Specifically, Raspberry Pi 1-3 support GLES 2.0, Pi
| 4 supports GLES 3.1. As a nice side effect, renderer will
| become portable to smartphones.
|
| This may or may not be a lot of work, depending how exactly you
| use OpenGL.
|
| Pi 4 introduced Vulkan as well, but unlike GLES I have not
| tested it and not sure how good is the support.
| aap_ wrote:
| I have in fact tested everything with GLES 2.0, 3.1, and
| desktop GL 2.1 and 3.3 and they should all work. If it's as
| efficient as it could be is another question. I find OpenGL
| rather messy as an API compared to d3d9.
| Const-me wrote:
| I don't have GTA3 but I do have VC on Steam. Compiled
| 32-bit Windows build of VC with GL2. Here's a renderdoc
| capture from my PC: http://const.me/tmp/vc-win10-gl.zip
|
| 1. On the main rendering pass, your code renders stuff
| mostly back to front. Consider sorting opaque objects by Z
| and render then front to back. If you do that, early Z
| rejection gonna save tons of pixel shaders and fill rate.
| The sorting doesn't need to be perfect, an approximate will
| do as well, but with these ~5k draw calls I'm pretty sure
| even C qsort gonna be adequate on Pi4.
|
| Translucent objects need to be rendered back to front like
| you're currently doing.
|
| 2. In your pixel shader you often have this code:
| if( a < u_alphaRef.x || a >= u_alphaRef.y ) discard;
|
| Where u_alphaRef is [ -1000; +1000 ] i.e. very large
| interval.
|
| Don't do that. Write another pixel shader for cases when
| you don't need alpha tests. GPUs disable some optimizations
| (early Z rejection is one of them) when you calling discard
| in GLSL/HLSL.
|
| 3. Up to EID 5328, the game rendered the next frame.
| Starting from EID 5377, the game was finishing rendering of
| the previous one. That's a good idea by itself, the problem
| with that, the temporary texture has size 4096*4096 pixels.
| Only top-center 3840*2160 portion was actually used. My
| desktop PC is fast enough to deliver 60 FPS, but on RPi you
| should not use textures much larger than necessary. All
| modern GPUs support non-power-of-2 textures, Pi4 included.
|
| 4. You are using 2x MSAA for the main pass. At least for my
| test cases on Pi4 (see e.g. this project
| https://github.com/Const-me/Vrmac ), even 2x MSAA ruined
| performance, if you use the same setting on Pi4, I think
| that contributed the most to the performance issue.
|
| Try to disable MSAA and see what gonna happen. If you'll
| find out it helps with the performance but the quality is
| too bad now, try to implement a cheaper substitute somehow,
| search the web for FXAA and SMAA keywords.
| aap_ wrote:
| Thank you for your input!
|
| For shaders I'm never sure if I should do something
| dynamically or switch to a different shader, but it makes
| sense of course to kill the alpha test code if it's not
| used.
|
| As for MSAA, our support for that is pretty rather young
| and it gives artifacts. I'm actually surprised it's on at
| all by default...
| phire wrote:
| It's a bit of an underpowered GPU, but I would have thought it
| would be powerful enough to run an early PS2 era game like
| this.
|
| It might just be really unhappy with the number of draw calls
| that you are doing. Looks like you are currently doing a
| drawcall per mesh; You might need to pack multiple meshes into
| a single drawcall.
|
| Do you have any idea how many drawcalls per frame you are
| currently doing?
| aap_ wrote:
| Using renderdoc with normal opengl i count 660 draw calls on
| a hopefully representative frame. Multiple meshes per
| drawcall are hard due to the architecture of renderware. I
| have considered sharing vertex and index buffers though. Do
| you think that will make a big difference?
| phire wrote:
| I suspect that sharing vertex/index buffers won't really
| help (alone).
|
| Last time I profiled something graphically intensive on the
| pi 4, I found that touching any of the draw state or
| uniforms between draw calls would trigger an expensive re-
| validation on the whole pipeline. 50% of my cpu time was
| spent in the driver.
|
| Of course, the app I was profiling was pushing quite a lot
| of uniforms per draw call. Your workload might be
| different, so profile before doing anything drastic.
|
| I recommend building a version of mesa with symbols so you
| can see exactly where CPU time is spent.
|
| BTW, try prepending `mesa_glthread=true` to your command to
| see if that gives you a free speed boost.
| aap_ wrote:
| hm, state changes between draw calls are hard to get rid
| of...after all that's why they're separate calls in the
| first place. profiling the driver is probably indeed
| something i should look into.
| garaetjjte wrote:
| You should be able to batch CPU-side drawcalls by packing
| multiple meshes into bigger vertex buffer, then
| generating draw parameters for every object into
| SSBO/UBO, and then utilizing ARB_multi_draw_indirect to
| draw everything at once. To change textures inside these
| batched drawcalls you might need ARB_bindless_texture.
| This talk is helpful:
| https://www.gdcvault.com/play/1020791/Approaching-Zero-
| Drive...
|
| I don't know if these extensions are available on Pi
| driver, though.
| reasonabl_human wrote:
| I am a developer but you guys are speaking a foreign
| language from my perspective in this thread. Where can I
| learn about graphical programming for the Pi, or are you
| guys well versed in game programming in general and
| applying it here? Sounds like an interesting skill set
| and challenge
| wxkn wrote:
| Try out an introductory OpenGL tutorial. There are many
| out ther. Just drawing a square will be a good lesson
| FillardMillmore wrote:
| Seconded, I too would like resources to learn more about
| this topic. Spend most of my time with business logic.
| wheybags wrote:
| https://antongerdelan.net/opengl/ is a decent resource
| for learning opengl (the author was a TA in my graphics
| course in college :D). And I do think it's worth Lear ing
| opengl over vulkan today. Vulkan dials the api complexity
| up to 11. If you're happy with windows only, then directx
| 11 would be a good choice too, but I don't have a good
| reference off hand.
|
| The problem with graphics programming is that really you
| need to learn two things simultaneously: how 3d graphics
| are rendered, and how to use a GPU api. They can both be
| a significant thing to learn alone, and the complexity of
| cramming the two into your brain together makes things
| hard.
| zennit wrote:
| Could box86 help here? https://github.com/ptitSeb/box86
| terramex wrote:
| No, according to README.md re3 works natively on arm64.
| 65a wrote:
| What is this premake binary, and where are the sources for it?
|
| EDIT: you can just install premake from package management, and
| use that instead of the checked in binaries.
| simonh wrote:
| Excellent work, I replay these on my iPad every few years. It
| would be great to get these on the Switch.
| lostphilosopher wrote:
| Do you use a controller? I've thought about trying one of the
| mobile ports but the idea of playing with a touch screen
| doesn't seem viable. Is this solved somehow?
| simonh wrote:
| It's an excellent experience in my opinion. The virtual D-pad
| is fine for driving. It's not ideal for on foot gunplay, but
| serviceable and that's really a side dish to the main course
| driving experience. In just one or two places in some of the
| games you get a bit stuck. In GtA3 there's a challenge where
| you need to chuck a grenade through an upper story window
| that's really tricky, for example, but apart from that it's
| fine and IMHO these games are incredible value for money at
| their current prices.
| eimrine wrote:
| Any new technics revealed for speedrun community? AFAIK, WR for
| GTA VC is 8 minutes and this run cannot be possible w/o reverse
| engineering.
| eimrine wrote:
| I have just realised that this is not a leak of source code but
| a new implementation. This version definitely needs a new
| speedrun, I have contacted Marushko.
| mraza007 wrote:
| Oh no I'm so excited to try this out on Linux. By the way i just
| want to thank you from the bottom of my heart for reverse
| engineering it.
|
| Now i don't have to use Wine to run my childhood game on Linux
___________________________________________________________________
(page generated 2021-02-14 23:01 UTC)