From a88d2c181d67a04389400a84fbda2c44ecae5ecf Mon Sep 17 00:00:00 2001 From: Mike Lester Date: Fri, 3 Jan 2025 15:31:23 -0700 Subject: [PATCH] Wind Waker: Add new drawlists for fore/background 2D particles This aligns with the game and fixes sorting issues with the title screen emitters --- src/ZeldaWindWaker/Main.ts | 18 +++++++++++++----- src/ZeldaWindWaker/d_drawlist.ts | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/ZeldaWindWaker/Main.ts b/src/ZeldaWindWaker/Main.ts index 0ac56fa35..0dd5309ac 100644 --- a/src/ZeldaWindWaker/Main.ts +++ b/src/ZeldaWindWaker/Main.ts @@ -416,8 +416,8 @@ export class WindWakerRenderer implements Viewer.SceneGfx { globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, group); } - // From mDoGph_Painter(). Draw the 2D particle groups with 640x480 ortho matrices. - for (let group = ParticleGroup.TwoDfore; group <= ParticleGroup.TwoDmenuBack; group++) { + // From mDoGph_Painter(). Draw the 2D particle groups with different view/proj matrices. + { const orthoCtx = this.globals.scnPlay.currentGrafPort; const viewMtx = mat4.fromTranslation(scratchMatrix, [orthoCtx.aspectRatioCorrection * 320, 240, 0]); const frustum = orthoCtx.getFrustumForView(viewMtx); @@ -425,8 +425,14 @@ export class WindWakerRenderer implements Viewer.SceneGfx { orthoCtx.setOnRenderInst(template); globals.particleCtrl.setDrawInfo(viewMtx, orthoCtx.sceneParams.u_Projection, null, frustum); - renderInstManager.setCurrentList(dlst.effect[EffectDrawGroup.Main]); - globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, group); + + renderInstManager.setCurrentList(dlst.particle2DBack); + globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, ParticleGroup.TwoDback); + globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, ParticleGroup.TwoDmenuBack); + + renderInstManager.setCurrentList(dlst.particle2DFore); + globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, ParticleGroup.TwoDfore); + globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, ParticleGroup.TwoDmenuFore); } } @@ -494,9 +500,11 @@ export class WindWakerRenderer implements Viewer.SceneGfx { this.executeList(passRenderer, dlst.effect[EffectDrawGroup.Main]); this.executeList(passRenderer, dlst.wetherEffect); - this.executeListSet(passRenderer, dlst.ui); + this.executeList(passRenderer, dlst.particle2DBack); + this.executeListSet(passRenderer, dlst.ui); this.executeListSet(passRenderer, dlst.ui2D); + this.executeList(passRenderer, dlst.particle2DFore); }); }); diff --git a/src/ZeldaWindWaker/d_drawlist.ts b/src/ZeldaWindWaker/d_drawlist.ts index 1f625413f..d5120bf13 100644 --- a/src/ZeldaWindWaker/d_drawlist.ts +++ b/src/ZeldaWindWaker/d_drawlist.ts @@ -205,6 +205,9 @@ export class dDlst_list_c { new GfxRenderInstList(gfxRenderInstCompareNone, GfxRenderInstExecutionOrder.Forwards) ]; + public particle2DBack = new GfxRenderInstList(gfxRenderInstCompareNone, GfxRenderInstExecutionOrder.Forwards); + public particle2DFore = new GfxRenderInstList(gfxRenderInstCompareNone, GfxRenderInstExecutionOrder.Forwards); + public alphaModel = new GfxRenderInstList(gfxRenderInstCompareNone, GfxRenderInstExecutionOrder.Forwards); public peekZ = new PeekZManager(128); public alphaModel0: dDlst_alphaModel_c;