What if you set pi to 4 or swapped sine and cosine in the Portal 2 engine?
Commissions open: https://ko-fi.com/portalrunner/commis...
Code available on GitHub: https://github.com/p2r3/sinswap
Thanks to dustyhobo for the amazing music, and thank you for watching.
Streamed live on Twitch: portalrunner
Join our Discord server! https://p2r3.com/discord
Tracks used in order:
Portal 2 OST - The Friendly Faith Plate
Portal 2 OST - Technical Difficulties
SoundCloud: goat
SoundCloud: rnb
truly
SoundCloud: years
SoundCloud: ring-dance
What if you set pi to 4 or swapped sine and cosine in the Portal 2 engine?
Commissions open: https://ko-fi.com/portalrunner/commis...
Code available on GitHub: https://github.com/p2r3/sinswap
Thanks to dustyhobo for the amazing music, and thank you for watching.
Streamed live on Twitch: portalrunner
Join our Discord server! https://p2r3.com/discord
Tracks used in order:
Portal 2 OST - The Friendly Faith Plate
Portal 2 OST - Technical Difficulties
SoundCloud: goat
SoundCloud: rnb
truly
SoundCloud: years
SoundCloud: ring-dance
- The `tan` function is actually very important in math and game development. The reason I skipped over it here is because the only noticeable effect breaking it had was changing FOV and the scale of menu animations.
- The reason the game is at all playable is because the Source engine likely uses wrappers or custom implementations of many functions which I can’t hook. Anything precalculated or any GPU code is also obviously off limits, so this only really messed with some dynamic parts of the engine. Some other math (like movement) is also primarily done with vector operations, which often avoid using many of these functions.
- The audio and lighting are messed up because of the modifications to the `sqrt` and `pow` functions, which handle the square root and exponentiation respectively. Source has a sound system that adjusts reverb to the scale of the room you’re in, and that uses `pow` for its calculations. We’re effectively inverting the function, which means that small rooms are loud and bigger rooms are fine. Lighting is a similar story - the fog distance and light intensity are also products of exponentiation.
- I’ve seen some comments suggesting that I should’ve tried using bad approximations for these functions, but rather unsurprisingly, that would still cause less chaos than pi being 4 or sine and cosine being swapped. I even tried turning sin/cos into a triangle wave, but that changed virtually nothing besides making physics a bit jittery.
- The ""physics engine"" I made in 10 minutes is really not as impressive as it sounds. It’s just doing ray-AABB intersection checks for all physics props and either simulating gravity if something is in the air or not doing anything depending on if there’s a collision. There’s some more code for picking up and throwing things, but that’s about it.
- I somewhat regret not adding this appendix to the video with some neat animations and a voiceover explanation, but if you have any other questions, comment them below.