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

Wind Waker: Particle system improvements #739

Merged
merged 25 commits into from
Jan 4, 2025
Merged

Wind Waker: Particle system improvements #739

merged 25 commits into from
Jan 4, 2025

Conversation

themikelester
Copy link
Collaborator

@themikelester themikelester commented Jan 1, 2025

  • Added Simple particle system (shares emitters for common particle types, eg. flame)
    • Removed a few TODOs and HACKs related to this (more to come)
    • Allow particles for which (userID & 0x4000) is true to be drawn in a particle group other than Projection/Indirect
  • Introduced ParticleGroup enum. Partially determines partical draw order, and in the future some other state such as the current view matrix
  • Add support for 2D/UI particle groups
    • These emitters expect different view/proj matrices (ortho, 640x480), and to be drawn later than the 3D emitters
  • Fixes incorrect Y position of flame emitters (d_a_ep). Simple particles ignore the emitter translation from their definition, resulting in flame emitters being 20 units lower which matches up with the original game (see flame positioning against torches)

zww_title_2025-01-03T19_05_20 592Z

zww_Cave01_2025-01-03T17_23_11 201Z

Impetus here is that the emitters used in d_a_title need to draw into a new ParticleGroup that supports ortho view/proj matrices. Since those emitters have their 0x4000 ID bit set, fixing up the simple system seemed appropriate.

"Bomb Island" and "Beedle's Shop" are good scene's to analyze d_a_ep (flames) which are the first actor to use the new simple system. "Dragon Roost Cavern" features d_a_obj_flame actors that have useSimpleEm set. The "Title Screen" demo can be used to test 2D emitters.

Now `workData.volumeEmitCount` is always valid when it should be
The game uses these to consolidate commonly used emitters, such as flames.

This fixes a big long-standing TODO in d_particle.ts, but the main goal is to fix the HACK related to indirect/projection particles
This is done almost the same as the game, but we modify the TEV settings at emitter creation time rather than at draw time (because generating the material is expensive)
Particles now keep the groupID that was assigned to them at creation.  Projection particles are determined at simple emitter creation time, or if ParticleGroup.Projection is specified manually.
Actors such as d_a_ep must call `setSimple()` each frame
These should be handled by the d_a_lamp actor (e.g. in Beedle's ship shop), but that is not yet implemented. For now, let's handle them in d_a_ep
This TEV patching is now done in a more proper place, inside the the simple particle callback
Given a view matrix, return a Frustum which can be used for culling. In the original game, frustums are generated from proj matrices alone. Points were transformed by the view matrix before being tested against the frustum. But noclip typically expects viewProj frustums.
@themikelester themikelester marked this pull request as ready for review January 3, 2025 19:09
This aligns with the game and fixes sorting issues with the title screen emitters
src/Common/JSYSTEM/J2Dv1.ts Outdated Show resolved Hide resolved
src/ZeldaWindWaker/Main.ts Outdated Show resolved Hide resolved
@magcius magcius merged commit ab10965 into master Jan 4, 2025
2 checks passed
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.

2 participants