Skip to content

Commit

Permalink
Wind Waker: Don't frustum cull 2D particles
Browse files Browse the repository at this point in the history
  • Loading branch information
themikelester committed Jan 4, 2025
1 parent a88d2c1 commit d39b97a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
13 changes: 0 additions & 13 deletions src/Common/JSYSTEM/J2Dv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ const enum J2DUVBinding {

export class J2DGrafContext {
private clipSpaceNearZ: GfxClipSpaceNearZ;
private frustum = new Frustum();

public sceneParams = new SceneParams();
public viewport = vec4.create();
public ortho = vec4.create();
Expand Down Expand Up @@ -123,17 +121,6 @@ export class J2DGrafContext {

}

/**
* noclip modification:
* Given a view matrix, return a Frustum which can be used for culling.
* In the original game, frustums are generated from proj matrices alone. But noclip expects viewProj frustums.
*/
public getFrustumForView(viewFromWorldMatrix: mat4): Frustum {
const clipFromWorldMatrix = mat4.mul(scratchMat, this.sceneParams.u_Projection, viewFromWorldMatrix);
this.frustum.updateClipFrustum(clipFromWorldMatrix, this.clipSpaceNearZ);
return this.frustum;
}

public setOnRenderInst(renderInst: GfxRenderInst): void {
const d = renderInst.allocateUniformBufferF32(GX_Material.GX_Program.ub_SceneParams, ub_SceneParamsBufferSize);
fillSceneParamsData(d, 0, this.sceneParams);
Expand Down
3 changes: 1 addition & 2 deletions src/ZeldaWindWaker/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,10 @@ export class WindWakerRenderer implements Viewer.SceneGfx {
{
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);
globals.particleCtrl.setDrawInfo(viewMtx, orthoCtx.sceneParams.u_Projection, null, null);

renderInstManager.setCurrentList(dlst.particle2DBack);
globals.particleCtrl.draw(device, this.renderHelper.renderInstManager, ParticleGroup.TwoDback);
Expand Down
2 changes: 1 addition & 1 deletion src/ZeldaWindWaker/d_particle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class dPa_control_c {
this.simpleCallbacks.push(simple);
}

public setDrawInfo(posCamMtx: ReadonlyMat4, prjMtx: ReadonlyMat4, texPrjMtx: ReadonlyMat4 | null, frustum: Frustum): void {
public setDrawInfo(posCamMtx: ReadonlyMat4, prjMtx: ReadonlyMat4, texPrjMtx: ReadonlyMat4 | null, frustum: Frustum | null): void {
this.drawInfo.posCamMtx = posCamMtx;
this.drawInfo.texPrjMtx = texPrjMtx;
this.drawInfo.frustum = frustum;
Expand Down

0 comments on commit d39b97a

Please sign in to comment.