Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement King Dodongo's Lava texture effects #3434

Merged

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Nov 23, 2023

After introducing the HD and alternate resource system, the wavy and cooling off lava effects in KD's room were disabled as they are CPU modified textures. One of the blended effects was disabled due to crashing but I believe that was due to an incorrect height/width values for the lava texture that have since been fixed by various asset related PRs.

To resolve all this I have recreated the CPU modified texture effects in the actor code with two flows: one for the original asset size, and the other for HD/raw loaded assets. The original functions were updated to use a copied texture value rather than a pointer to the resource manager. The HD/raw methods copy this pattern but are adjusted to handle the different sizes and the texture being RGBA32 instead of RGBA16.

On init for KD, the textures from the resource manager are copied to a static pointer, the HD/raw ones are malloc'd (and free'd). I've also added a GI hook for detecting when the Alt assets toggle is changed. The texture copy process is registered to run on this hook to handle updating everything appropriately when toggling alt assets.


The cooling effect is achieved by taking the values that would have normally applied to the original asset, but setting extra pixels to account for the increased width and height scales. This makes it look like square chunks are being filled in the same as the original texture, just not with the tri-linear filtering.

The wavy effect for HD/raw assets has the calculation adjusted to try and scale the effect up to for the texture size while trying to still look similar to the original effect. Unlike the cooling effect, I decided to have the math scale like this so that the wavy effect looks smooth and good for the HD texture, instead of being chunky.


I opted for doing this in the actor file instead of a shader, largely because I don't know how to work with shaders, but also because it felt like the effect was tied pretty closely to the actor and this is like two different compounding effects applied on top of each other.. If someone knows how to handle it as a shader instead, I'm also open to solutions.


kd-lava-wavy2.mp4

Based on top of #3420

Build Artifacts

@Archez
Copy link
Contributor Author

Archez commented Nov 23, 2023

I'm pointing this to MacReady cause I think it can be excepted as a bugfix, but if others would prefer this for develop instead then I can retarget it.

Comment on lines +187 to +189
void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)) {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnAssetAltChange>(fn);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first example of making a C bridge method for registering to a hook on the C side. Sticking it here to go with the other bridge methods.

Copy link
Contributor

@briaguya-ai briaguya-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think some of the resource stuff in OTRGlobals could probably be a part of LUS, but i have no problem with it being in SoH for now

i also agree that macready is a good place for this, it's a bugfix for sure

:shipit:

@briaguya-ai briaguya-ai merged commit f4e4545 into HarbourMasters:develop-macready Nov 23, 2023
8 checks passed
@Archez Archez deleted the fix-kd-lava-textures branch November 24, 2023 19:43
A-Green-Spoon pushed a commit to A-Green-Spoon/Shipwright that referenced this pull request Nov 30, 2023
* fix alt backgrounds not always loading

* include gfx lookup with the original unload

* Add hook for alt toggle

* handle cpu modified texture for kd lava

* malloc array instead of illegal initialize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants