Skip to content

Commit

Permalink
Wind Waker: Add new drawlists for fore/background 2D particles
Browse files Browse the repository at this point in the history
This aligns with the game and fixes sorting issues with the title screen emitters
  • Loading branch information
themikelester committed Jan 3, 2025
1 parent fe73bef commit a88d2c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/ZeldaWindWaker/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,17 +416,23 @@ 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);
const template = renderInstManager.pushTemplate();
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);
}
}

Expand Down Expand Up @@ -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);
});
});

Expand Down
3 changes: 3 additions & 0 deletions src/ZeldaWindWaker/d_drawlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a88d2c1

Please sign in to comment.