Migrates all code, there should be no change in the compilation output
(linter should check this)
At first i was considering making these builtins, which short of a bunch
of code generation, would require some sort of dynamic definition in
`Atoms.cpp`. This isn't hard but, i figured it would be better to keep
it simple and just generate the OG macros.
Fixes https://github.com/open-goal/jak-project/issues/233
Kind of silly fix.
The cloth update function sometimes runs before the "setup" is done
(`need-setup` is set), which divides by zero in a bunch of places. This
fix prevents NaNs from spreading during this time.
Co-authored-by: water111 <awaterford1111445@gmail.com>
This should fix the crash when entering the freedom HQ elevator. It was
caused by a large number of prints, one for each process in the city
being killed by `check-for-rougue-process`, which would overflow the
print buffer. So I increased the print buffer.
Detecting buffer overflow here is hard because lots of things are
allowed to write to it, including the user's GOAL print methods. I added
a basic check that will assert when there's 1k or less space in the
buffer. It won't catch every overflow, but it would have caught this
one.
Co-authored-by: water111 <awaterford1111445@gmail.com>
I finally went through and worked out the math for the camera matrix,
and improved how it works for PC rendering. I was able to finally avoid
the double perspective divide issue, which I always thought would cause
accuracy issues.
This will help tfrag, tie (no envmap), shrub, and hfrag have less
z-fighting in cases where the camera and the thing you're looking at are
pretty close, but the entire level is far from the origin - like jak 3
temple. I was able to modify the camera matrix so we don't have to do
all the weird scaling/addition in the shader.
Here's a screenshot from the temple oracle checkpoint, cropped from 4k.
This used to have a lot of fighting issues.

It doesn't help issues where the thing you're looking at is very far
away (jak 1 mountains, some jak 2 city stuff). It also doesn't help with
jak's skirt/scarf, since those use a different renderer.
There's definitely more to do here, but this is a good starting point
and proof that I can at least figure out the math.
Co-authored-by: water111 <awaterford1111445@gmail.com>
In Jak 3, the default PC settings file would have a language of 255
because it runs before the first settings update. This would cause the
game to crash the second time it is started.
I also added this simple imgui window to see the names of streams in the
"SPU" memory, which has been useful for debugging

---------
Co-authored-by: water111 <awaterford1111445@gmail.com>
Accidentally incrementing `s` twice in the loop, so queued streams in
slot 1, and 3 were skipped by the overlord.
This would usually cause the audio to never start playing because the
game would wait for the audio to successfully get queued.
Co-authored-by: water111 <awaterford1111445@gmail.com>
Change jak 3 SPU DMA to run the interrupt handler "immediately" (or at
least before `DMA_SendToSPUAndSync` returns).
This fixes an issue where audio can hang during fast cutscene playback.
I'm hoping it fixes more issues with looping/stuck audio as well, but
this needs more testing.
I originally wanted to do it this way, but thought that it didn't work -
from Jak 2 it seemed like things broke if the DMA was too fast. But, at
least for Jak 3, everything seems to work like this. This will remove a
huge source of non-deterministic timing in audio stuff and hopefully
make things easier to debug. It also means that a large portion of
streaming audio code will never have to run - from the game's point of
view there's always the next SPU buffer available.
If this works well, I might revisit jak 2 as well.
Co-authored-by: water111 <awaterford1111445@gmail.com>
Fix a missing scale factor when using the large mode in the animation
compressor. This would make some joints have a translation of near 0 if
the original animation had stuff moving a large distance
Co-authored-by: water111 <awaterford1111445@gmail.com>
Two new flags were added to the Blender plugin to allow reusing the mod
and/or eye draws of the original model that is being replaced. Works
pretty well for eyes, but the blerc draws can cause some Z-fighting with
the non-moving parts of the model.
Also a small refactor to the merc replacement code to de-duplicate some
code by moving stuff to `gltf_util.cpp`.
A few improvements to color palette selection. These were made by
tracing some particularly bad colors through and seeing where it made
obviously bad decisions for splitting. I tested on crystal cave, and a
test GLBs from Kuitar that previously had issues with alpha.
- The previous approach to splitting was based on trying to keep a tree
of deduplicated colors balanced (same count in each leaf). This is not
really a good idea for generating color palettes. A better approach is
to try to minimize the volume of the child node, limiting how inaccurate
a color can be. Splitting is now chosen based on the average of the
_deduplicated channel values_, which in practice seems to work pretty
well for Kuitar's levels. Other approaches could work here too.
- The previous approach of alternating through dimensions to split on
was kept.
- The depth of the KD tree during the initial split was increased,
allowing it to use up to 8192 colors, instead of just 1024.
- In most cases, not all child nodes of the tree have colors in them,
meaning that a tree of depth 13 would have less than 8192 colors. If
this happens, child nodes are split until the color count reaches 8192.
The selection of which nodes to split is somewhat arbitrary, but is
breadth-first. The axis for splitting is the one with the largest range.
(which might be a better idea in general?)
On crystal-cave, the worst case color error was reduced from 221 to 9.
---------
Co-authored-by: water111 <awaterford1111445@gmail.com>
Fixes the issue with animations doing a full 180 degree rotation and
disappearing. The quaternions in the GLB export "flip", and when
interpolating animation frames in between a flip, we got bogus
quaternions.
Fixes https://github.com/open-goal/jak-project/issues/3786
Also fix a crash in `goalc` when using merc models without any
materials.
Co-authored-by: water111 <awaterford1111445@gmail.com>
Add instance limits to the sound library, and a `dump-info` command to
`sndplay` to print out all the sounds/flags in an SBK file.
This is based on the decompiled 989snd library @Ziemas is working on
(https://github.com/Ziemas/dec989snd/blob/main/src/sndhand.c#L77)
Co-authored-by: water111 <awaterford1111445@gmail.com>
After collecting 600 orbs, cloth systems that didn't have any
`alt-tex-name`s defined would vanish because the `static-cloth-params`
macro doesn't default them to `#f`.
Store a small database of which models have already been swapped out in
a level to prevent duplicate processing.
Also a small fix for cases where using a model replacement that has no
armature would cause merc nightmares due to only having a `max_bones` of
3.
Folder names were in common with the normal intel x86 build, the release
wasn't going to work. Hopefully with these changes it will but, still
technically untested. Don't have time to do so tonight.
Several users have reported that ArchipelaGOAL is not launching
properly, even when using the OpenGOAL Launcher. The window pops up with
a black screen, and then quits. The only way they can run it is if they
double click gk.exe.
This comes down to the Launcher providing gk.exe with the `config_path`
parameter, which leads the program to find `archipelagoal-settings.gc`.
Here is an example from me:
```
D:\Applications\Games\OpenGOAL\features\jak1\mods\JakMods\_settings\archipelagoal\OpenGOAL\jak1\settings/Mods/archipelagoal-settings.gc
```
If a user's base OpenGOAL install directory is long enough, this path
becomes longer than 128 characters. This overflows the character buffer
in `kopen` which is used to open file streams. If you're only slightly
over the limit like myself, at 135 characters, you may not have noticed
a problem. But some users have paths a little longer, like 168
characters, and they report the issue is consistent.
Water111 suggested we remove the 128 character buffer and use the
filename data directly. This fix requires no changes to the Launcher,
just to the kernel, and every mod could stand to benefit from this fix.
When a material in Blender has its IOR level changed to anything other
than the default value of 0.5, the `KHR_materials_specular` extension is
applied during the glTF export, which is what we use to check for
envmaps in custom models. If an envmap is undesired, but the IOR value
was accidentally changed, the program would assert during model
processing if there is no metallic roughness texture attached to the
material.
Since this is an easy mistake to make and is hard to spot, this adds a
better error message for such cases.
Create explicit x86_64 and ARM64 macOS build targets, so it's clear that
the CI is building x86_64 binaries (on both Intel and ARM64 build
machines). Also, use the `CMAKE_APPLE_SILICON_PROCESSOR` CMake variable
(which sets `CMAKE_SYSTEM_PROCESSOR`) so `BUILD_X86_ON_MACOS` is not
necessary.
And update the README.
Simple workaround to put an effect in a different bucket. I don't think
there's a difference in the result, but this is just easier to handle on
the PC renderer side.
Co-authored-by: water111 <awaterford1111445@gmail.com>
Base implementation of the popup menu and speedrunner mode in Jak 3.
Autosplitter is untested because I'm on Linux.
Also a couple of other misc changes:
- Model replacements can now have custom bone weights. Needs the "Use
Custom Bone Weights" property (provided by the OpenGOAL Blender plugin)
enabled in Blender.
- Better error message for lump syntax errors in custom level JSON
files.
Fix compiler warnings, and a bug where the `snd_handle` of
`SoundBankInfo` was never set, leading to sound banks never unloading.
The game relies on unloading soundbanks to make sure certain sounds
don't play, like the blue gun 1 fire noise when using blue gun 2.
---------
Co-authored-by: water111 <awaterford1111445@gmail.com>
The fundamental issue is related to hiDPI / Retina displays, I don't
think our rendering code is setup properly to handle the scaling between
the two (which you can derive by comparing `SDL_GetWindowSize` and
`SDL_GL_GetDrawableSize`).
So rather than opening that can of worms, I just removed the window
flag.
Also fixed an unrelated issue for displaying resolution options when in
windowed mode, it was previously only adding options to the list if they
were invalid for full-screen.
Fixes#3099
if you sideflip into grind in the digsite mission, the clasps wont break
because it is considered a `board-spin` attack instead of `board`. This
extends the condition to allow for `board-spin` as well.
~~Should I wrap this in an `#if PC_PORT`?~~ done
DMA sizes are 16-bits, not 12-bits. This would cause rare crashes when
the ocean far renderer uses more than this.
I'm not really sure what the ocean far rendering is doing at this time,
but it happens as stuff is loading in.
There's a chance this fixes crashes in jak 2 as well, since we used to
see errors that would be explained by this.
Co-authored-by: water111 <awaterford1111445@gmail.com>