diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index e0db061e..029195de 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2206,7 +2206,7 @@ egg/gfx/eggDrawPathBase.cpp: .text start:0x804A0C30 end:0x804A0E98 .data start:0x8056EE60 end:0x8056EEB0 -egg/gfx/eggDrawPathUnk1.cpp: +egg/gfx/eggDrawPathBloom.cpp: .text start:0x804A0EA0 end:0x804A29B8 egg/gfx/eggDrawPathDOF.cpp: @@ -2296,16 +2296,16 @@ egg/gfx/eggPostEffectBlur.cpp: .data start:0x8056F170 end:0x8056F190 .sdata2 start:0x8057F750 end:0x8057F788 -egg/gfx/eggPostEffectUnk1.cpp: +egg/gfx/eggPostEffectBlurGather.cpp: .text start:0x804AFC10 end:0x804B0098 - .data start:0x8056F190 end:0x8056F1B0 + .data start:0x8056F190 end:0x8056F1AC .sdata2 start:0x8057F788 end:0x8057F798 egg/gfx/eggPostEffectUnk2.cpp: .text start:0x804B00A0 end:0x804B0AA4 .rodata start:0x804FBD50 end:0x804FBD88 .data start:0x8056F1B0 end:0x8056F1D0 - .sdata2 start:0x8057F798 end:0x8057F7C8 + .sdata2 start:0x8057F798 end:0x8057F7C4 egg/gfx/eggPostEffectMask.cpp: .text start:0x804B0AB0 end:0x804B0F60 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 93a856f0..cd6d5f2a 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -26486,7 +26486,7 @@ scnProcDraw__Q23EGG12DrawPathBaseFUs = .text:0x804A0E60; // type:function size:0 @20@__dt__Q23EGG12DrawPathBaseFv = .text:0x804A0E90; // type:function size:0x8 scope:weak FUN_804a0ea0 = .text:0x804A0EA0; // type:function size:0x188 __dt__Q23EGG14PostEffectMaskFv = .text:0x804A1030; // type:function size:0x40 -__dt__Q23EGG14PostEffectUnk1Fv = .text:0x804A1070; // type:function size:0x40 +__dt__Q23EGG20PostEffectBlurGatherFv = .text:0x804A1070; // type:function size:0x40 __dt__Q23EGG16PostEffectSimpleFv = .text:0x804A10B0; // type:function size:0x40 FUN_804a10f0 = .text:0x804A10F0; // type:function size:0x60 FUN_804a1150 = .text:0x804A1150; // type:function size:0x21C @@ -26705,8 +26705,8 @@ setProjection__Q23EGG14PostEffectBaseFRCQ23EGG6Screen = .text:0x804AF3C0; // typ __ct__Q23EGG14PostEffectBlurFv = .text:0x804AF4C0; // type:function size:0xE0 draw__Q23EGG14PostEffectBlurFff = .text:0x804AF5A0; // type:function size:0x190 drawInternal__Q23EGG14PostEffectBlurFUcUcff = .text:0x804AF730; // type:function size:0x4D4 -__ct__Q23EGG14PostEffectUnk1Fv = .text:0x804AFC10; // type:function size:0xC0 -setMaterialInternal__Q23EGG14PostEffectUnk1Fv = .text:0x804AFCD0; // type:function size:0x3C8 +__ct__Q23EGG20PostEffectBlurGatherFv = .text:0x804AFC10; // type:function size:0xC0 +setMaterialInternal__Q23EGG20PostEffectBlurGatherFv = .text:0x804AFCD0; // type:function size:0x3C8 __ct__Q23EGG14PostEffectUnk2Fv = .text:0x804B00A0; // type:function size:0x1F8 __dt__Q23EGG14PostEffectUnk2Fv = .text:0x804B02A0; // type:function size:0x80 draw__Q23EGG14PostEffectUnk2Fff = .text:0x804B0320; // type:function size:0x2D4 @@ -37377,7 +37377,7 @@ lbl_8056F110 = .data:0x8056F110; // type:object size:0x9 data:string jumptable_8056F120 = .data:0x8056F120; // type:object size:0x30 scope:local __vt__Q23EGG14PostEffectBase = .data:0x8056F150; // type:object size:0x1C __vt__Q23EGG14PostEffectBlur = .data:0x8056F170; // type:object size:0x1C -__vt__Q23EGG14PostEffectUnk1 = .data:0x8056F190; // type:object size:0x20 +__vt__Q23EGG20PostEffectBlurGather = .data:0x8056F190; // type:object size:0x1C __vt__Q23EGG14PostEffectUnk2 = .data:0x8056F1B0; // type:object size:0x1C __vt__Q23EGG14PostEffectMask = .data:0x8056F1D0; // type:object size:0x1C lbl_8056F1F0 = .data:0x8056F1F0; // type:object size:0x1C diff --git a/configure.py b/configure.py index 34797012..83c05073 100644 --- a/configure.py +++ b/configure.py @@ -873,7 +873,7 @@ config.libs = [ Object(NonMatching, "egg/gfx/eggCpuTexture.cpp"), Object(NonMatching, "egg/gfx/eggDrawGX.cpp"), Object(Matching, "egg/gfx/eggDrawPathBase.cpp"), - Object(NonMatching, "egg/gfx/eggDrawPathUnk1.cpp"), + Object(NonMatching, "egg/gfx/eggDrawPathBloom.cpp"), Object(NonMatching, "egg/gfx/eggDrawPathDOF.cpp"), Object(Matching, "egg/gfx/eggDrawPathLightMap.cpp"), Object(NonMatching, "egg/gfx/eggFog.cpp"), @@ -891,7 +891,7 @@ config.libs = [ Object(NonMatching, "egg/gfx/eggModelEx.cpp"), Object(NonMatching, "egg/gfx/eggPostEffectBase.cpp"), Object(NonMatching, "egg/gfx/eggPostEffectBlur.cpp"), - Object(NonMatching, "egg/gfx/eggPostEffectUnk1.cpp"), # Unknown + Object(Matching, "egg/gfx/eggPostEffectBlurGather.cpp"), Object(NonMatching, "egg/gfx/eggPostEffectUnk2.cpp"), # Unknown Object(Matching, "egg/gfx/eggPostEffectMask.cpp"), Object(NonMatching, "egg/gfx/eggPostEffectMaskDOF.cpp"), diff --git a/include/egg/gfx/eggDrawPathBloom.h b/include/egg/gfx/eggDrawPathBloom.h new file mode 100644 index 00000000..7f0b0f30 --- /dev/null +++ b/include/egg/gfx/eggDrawPathBloom.h @@ -0,0 +1,20 @@ +#ifndef EGG_DRAW_PATH_BLOOM_H +#define EGG_DRAW_PATH_BLOOM_H + +#include "egg/gfx/eggDrawPathBase.h" +namespace EGG { + +class DrawPathBloom : public DrawPathBase { +public: + virtual ~DrawPathBloom(); + + virtual u16 getNumStep() const override { + return 3; + } + +private: +}; + +} // namespace EGG + +#endif diff --git a/include/egg/gfx/eggDrawPathUnk1.h b/include/egg/gfx/eggDrawPathUnk1.h deleted file mode 100644 index 4b2c3cc7..00000000 --- a/include/egg/gfx/eggDrawPathUnk1.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef EGG_DRAW_PATH_UNK1_H -#define EGG_DRAW_PATH_UNK1_H - -namespace EGG {} // namespace EGG - -#endif diff --git a/include/egg/gfx/eggPostEffectBlurGather.h b/include/egg/gfx/eggPostEffectBlurGather.h new file mode 100644 index 00000000..9a1966d7 --- /dev/null +++ b/include/egg/gfx/eggPostEffectBlurGather.h @@ -0,0 +1,40 @@ +#ifndef EGG_POST_EFFECT_BLUR_GATHER_H +#define EGG_POST_EFFECT_BLUR_GATHER_H + +#include "common.h" +#include "egg/gfx/eggCpuTexture.h" +#include "egg/gfx/eggDrawGX.h" +#include "egg/gfx/eggPostEffectBase.h" +#include "rvl/GX/GXTypes.h" + +namespace EGG { + +class PostEffectBlurGather : public PostEffectBase { + // Size 0x18 + struct BlurGatherData { + void reset() { + mpCapTexture = nullptr; + mColor = DrawGX::WHITE; + mColorScale = 1.f; + field_0x10 = 0; + } + /* 0x00 */ EGG::CpuTexture *mpCapTexture; + /* 0x04 */ GXTexMapID mTexMapId; + /* 0x08 */ GXColor mColor; + /* 0x0C */ f32 mColorScale; + /* 0x10 */ u8 field_0x10; + }; + +public: + PostEffectBlurGather(); + virtual void setMaterialInternal() override; + + /* 0x2C */ u8 field_0x2C; + /* 0x2D */ u8 field_0x2D; + /* 0x30 */ f32 field_0x30; + /* 0x34 */ BlurGatherData mBlurGatherData[3]; +}; + +} // namespace EGG + +#endif diff --git a/include/egg/gfx/eggPostEffectUnk1.h b/include/egg/gfx/eggPostEffectUnk1.h deleted file mode 100644 index e2a6c03b..00000000 --- a/include/egg/gfx/eggPostEffectUnk1.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef EGG_POST_EFFECT_UNK1_H -#define EGG_POST_EFFECT_UNK1_H - -#include "egg/gfx/eggCpuTexture.h" -#include "egg/gfx/eggPostEffectBase.h" -#include "rvl/GX/GXTypes.h" -namespace EGG { - -class PostEffectUnk1 : public PostEffectBase { - // Size 0x18 - struct Stage { - /* 0x00 */ EGG::CpuTexture *field_0x00; - /* 0x04 */ GXTexMapID mTexMapId; - /* 0x08 */ GXColor field_0x08; - /* 0x0C */ f32 field_0x0C; - /* 0x10 */ u8 field_0x10; - }; - -public: - PostEffectUnk1(); - virtual void setMaterialInternal() override; - - /* 0x2C */ u8 field_0x2C; - /* 0x2D */ u8 field_0x2D; - /* 0x30 */ f32 field_0x30; - /* 0x34 */ Stage field_0x34[3]; -}; - -} // namespace EGG - -#endif diff --git a/include/egg/gfx/eggPostEffectUnk2.h b/include/egg/gfx/eggPostEffectUnk2.h index 64173db6..8cd8ac97 100644 --- a/include/egg/gfx/eggPostEffectUnk2.h +++ b/include/egg/gfx/eggPostEffectUnk2.h @@ -3,6 +3,7 @@ #include "egg/egg_types.h" #include "egg/gfx/eggPostEffectBase.h" +#include "egg/math/eggVector.h" namespace EGG { @@ -14,13 +15,12 @@ public: virtual void setMaterialInternal() override; private: - /* 0x2C */ s32 field_0x2C; + /* 0x2C */ u32 field_0x2C; /* 0x30 */ u32 field_0x30; /* 0x34 */ u8 field_0x34; /* 0x35 */ u8 field_0x35; /* 0x36 */ s16 field_0x36; - /* 0x38 */ f32 field_0x38; - /* 0x3C */ f32 field_0x3C; + /* 0x38 */ Vector2f field_0x38; /* 0x40 */ f32 field_0x40; /* 0x44 */ f32 field_0x44; /* 0x48 */ f32 field_0x48; diff --git a/include/egg/math/eggVector.h b/include/egg/math/eggVector.h index 3fa0c871..2d030d45 100644 --- a/include/egg/math/eggVector.h +++ b/include/egg/math/eggVector.h @@ -3,6 +3,7 @@ #include "common.h" #include "egg/math/eggMath.h" +#include "nw4r/math/math_triangular.h" #include "nw4r/math.h" diff --git a/src/egg/gfx/eggDrawPathBloom.cpp b/src/egg/gfx/eggDrawPathBloom.cpp new file mode 100644 index 00000000..5a42210b --- /dev/null +++ b/src/egg/gfx/eggDrawPathBloom.cpp @@ -0,0 +1,3 @@ +#include "egg/gfx/eggDrawPathBloom.h" + +namespace EGG {} // namespace EGG diff --git a/src/egg/gfx/eggDrawPathUnk1.cpp b/src/egg/gfx/eggDrawPathUnk1.cpp deleted file mode 100644 index 2a89d9da..00000000 --- a/src/egg/gfx/eggDrawPathUnk1.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "egg/gfx/eggDrawPathUnk1.h" - -namespace EGG {} // namespace EGG diff --git a/src/egg/gfx/eggPostEffectUnk1.cpp b/src/egg/gfx/eggPostEffectBlurGather.cpp similarity index 85% rename from src/egg/gfx/eggPostEffectUnk1.cpp rename to src/egg/gfx/eggPostEffectBlurGather.cpp index ade510b4..0f01e6e1 100644 --- a/src/egg/gfx/eggPostEffectUnk1.cpp +++ b/src/egg/gfx/eggPostEffectBlurGather.cpp @@ -1,8 +1,7 @@ -#include "egg/gfx/eggPostEffectUnk1.h" +#include "egg/gfx/eggPostEffectBlurGather.h" #include "common.h" #include "egg/gfx/eggCpuTexture.h" -#include "egg/gfx/eggDrawGX.h" #include "egg/gfx/eggGXUtility.h" #include "nw4r/math/math_types.h" #include "rvl/GX/GXAttr.h" @@ -12,20 +11,16 @@ namespace EGG { -PostEffectUnk1::PostEffectUnk1() { - // NONMATCHING +PostEffectBlurGather::PostEffectBlurGather() { field_0x2C = 1; field_0x2D = 1; field_0x30 = 0.5f; - for (int i = 0; i < ARRAY_LENGTH(field_0x34); i++) { - field_0x34[i].field_0x00 = nullptr; - field_0x34[i].field_0x08 = DrawGX::WHITE; - field_0x34[i].field_0x0C = 1.0f; - field_0x34[i].field_0x10 = 0; - } + mBlurGatherData[0].reset(); + mBlurGatherData[1].reset(); + mBlurGatherData[2].reset(); } -void PostEffectUnk1::setMaterialInternal() { +void PostEffectBlurGather::setMaterialInternal() { u8 hasExtraStage = (mpCapTexture != nullptr && (field_0x2D & 1) == 0) ? 1 : 0; u8 numStages = field_0x2C + hasExtraStage * 2; setMatColorChannel(); @@ -37,7 +32,7 @@ void PostEffectUnk1::setMaterialInternal() { int texMtxIdx = GXUtility::getTexMtxID(i); GXSetTexCoordGen2(static_cast(i), GX_TG_MTX2x4, GX_TG_TEX0, texMtxIdx, 0, 0x7D); if (i < field_0x2C) { - field_0x34[i].field_0x00->load(field_0x34[i].mTexMapId); + mBlurGatherData[i].mpCapTexture->load(mBlurGatherData[i].mTexMapId); } else { loadTextureInternal(); } @@ -50,13 +45,13 @@ void PostEffectUnk1::setMaterialInternal() { GXSetNumTevStages(numStages); for (int i = 0; i < numStages; i++) { - Stage &k = field_0x34[i]; + BlurGatherData &k = mBlurGatherData[i]; GXTevStageID stage = static_cast(i); GXSetTevDirect(stage); GXSetTevSwapMode(stage, GX_TEV_SWAP0, GX_TEV_SWAP0); if (i < field_0x2C) { GXColor scaledColor; - scaleColor(scaledColor, k.field_0x08, false, k.field_0x0C); + scaleColor(scaledColor, k.mColor, false, k.mColorScale); GXSetTevKColorSel(stage, static_cast(GX_TEV_KCSEL_K0 + i)); GXSetTevKAlphaSel(stage, static_cast(GX_TEV_KASEL_K0_A + i)); diff --git a/src/egg/gfx/eggPostEffectMask.cpp b/src/egg/gfx/eggPostEffectMask.cpp index 5162e3a7..06424a66 100644 --- a/src/egg/gfx/eggPostEffectMask.cpp +++ b/src/egg/gfx/eggPostEffectMask.cpp @@ -19,8 +19,8 @@ void PostEffectMask::setMaterialInternal() { setMatColorChannel(); GXSetNumTexGens(2); - GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3c, 0, 0x7d); - GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, 0x3c, 0, 0x7d); + GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX_IDENT, false, GX_DUALMTX_IDENT); + GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX_IDENT, false, GX_DUALMTX_IDENT); setMatInd(); GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); GXSetTevDirect(GX_TEVSTAGE0); diff --git a/src/egg/gfx/eggPostEffectUnk2.cpp b/src/egg/gfx/eggPostEffectUnk2.cpp index f61134cf..abf57b73 100644 --- a/src/egg/gfx/eggPostEffectUnk2.cpp +++ b/src/egg/gfx/eggPostEffectUnk2.cpp @@ -16,33 +16,32 @@ namespace EGG { -PostEffectUnk2::PostEffectUnk2() { - // NONMATCHING - field_0x2C = 0; - field_0x30 = 0; - field_0x34 = 1; - field_0x35 = 0xFE; - field_0x36 = 7; - field_0x38 = 0.0f; - field_0x3C = 0.0f; - field_0x40 = 1.0f; - field_0x44 = 1.0f; - field_0x48 = 1.0f; +inline f32 GetColor(f32 x, u16 w) { + return nw4r::ut::Min(x / (w - 1), 1.f) * 0xFF; +} + +PostEffectUnk2::PostEffectUnk2() + : // NONMATCHING + field_0x2C(0), + field_0x30(0), + field_0x34(1), + field_0x35(0xFE), + field_0x36(7), + field_0x38(0.0f, 0.0f), + field_0x40(1.0f), + field_0x44(1.0f), + field_0x48(1.0f) { mpTexture = new CpuTexture(32, 4, GX_TF_RGBA8); mpTexture->configure(); mpTexture->allocate(nullptr); mpTexture->setWrapS(GX_CLAMP); mpTexture->setWrapT(GX_CLAMP); + for (u16 y = 0; y < mpTexture->getHeight(); y++) { for (u16 x = 0; x < mpTexture->getWidth(); x++) { - // The conversion constant 0x43000000 needs to - // be stored at the start of the function... - f32 xF = x; - f32 widF = mpTexture->getWidth() - 1; - f32 ratio = nw4r::ut::Min(xF / widF, 1.0f); - u8 val = ratio * 255.0f; - GXColor color = {val, val, val, val}; - mpTexture->setColor(x, y, color); + u8 val = GetColor(x, mpTexture->getWidth()); + + mpTexture->setColor(x, y, (GXColor){val, val, val, val}); } } @@ -62,7 +61,7 @@ void PostEffectUnk2::draw(f32 width, f32 height) { GXSetVtxDesc(GX_VA_TEX1, GX_DIRECT); nw4r::math::MTX34 mtx; - PSMTXScale(mtx, mScaleX * width, mScaleY * height, 1.0f); + PSMTXScale(mtx, width * mScaleX, height * mScaleY, 1.0f); PSMTXTransApply(mtx, mtx, mOffsetX, mOffsetY, 0.0f); GXLoadPosMtxImm(mtx, 0); @@ -75,38 +74,40 @@ void PostEffectUnk2::draw(f32 width, f32 height) { {-1.0f, 1.0f}, }; - // TODO - f32 s1 = field_0x40 / mpCapTexture->getWidth(); - f32 s2 = field_0x40 / mpCapTexture->getHeight(); - f32 f = 0.0f; + const f32 s1 = field_0x40 / mpCapTexture->getWidth(); + const f32 s2 = field_0x40 / mpCapTexture->getHeight(); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - EGG::Vector3f(0.0f, 0.0f, 0.0f); + f32 mtx[2][4]; + EGG::Vector3f a(0.f, 0.f, 0.f); + f32 sin, cos; - nw4r::math::SinCosRad(&sin, &cos, f); - nw4r::math::MTX34 mtx2; - mtx2._00 = cos; - mtx2._01 = -sin; - mtx2._02 = -cos * f + sin * f + (s1 * floats1[i][j]); - mtx2._03 = f; - mtx2._10 = sin; - mtx2._11 = cos; - mtx2._12 = -sin * f - cos * f + (s2 * floats2[i][j]); - mtx2._13 = f; - GXLoadTexMtxImm(mtx2, GXUtility::getTexMtxID(j), GX_MTX_2x4); + nw4r::math::SinCosRad(&sin, &cos, a.z); + + mtx[0][0] = cos; + mtx[0][1] = -sin; + mtx[0][2] = -cos * a.x + sin * a.y + a.x + (s1 * floats1[i][j]); + + mtx[1][0] = sin; + mtx[1][1] = cos; + mtx[1][2] = -sin * a.x - cos * a.y + a.y + (s2 * floats2[i][j]); + + mtx[1][3] = 0.f; + mtx[0][3] = 0.f; + GXLoadTexMtxImm(mtx, GXUtility::getTexMtxID(j), GX_MTX_2x4); } if (i == 1 && field_0x2C <= 1) { GXSetBlendMode(GX_BM_LOGIC, GX_BL_ZERO, GX_BL_ZERO, GX_LO_OR); } GXBegin(GX_QUADS, GX_VTXFMT0, 4); GXPosition2u8(0, 0); - GXPosition2f32(field_0x38, field_0x3C); + GXPosition2f32(field_0x38.x, field_0x38.y); GXPosition2u8(1, 1); - GXPosition2f32(field_0x38, field_0x3C); + GXPosition2f32(field_0x38.x, field_0x38.y); GXPosition2u8(2, 2); - GXPosition2f32(field_0x38, field_0x3C); + GXPosition2f32(field_0x38.x, field_0x38.y); GXPosition2u8(3, 3); - GXPosition2f32(field_0x38, field_0x3C); + GXPosition2f32(field_0x38.x, field_0x38.y); } } @@ -153,7 +154,7 @@ void PostEffectUnk2::setMaterialInternal() { GXSetTevSwapMode(GX_TEVSTAGE3, GX_TEV_SWAP0, GX_TEV_SWAP0); GXSetTevOrder(GX_TEVSTAGE3, GX_TEXCOORD_NULL, GX_TEXMAP1, GX_COLOR_NULL); - if (field_0x2C == 2) { + if ((int)field_0x2C == 2) { GXSetTevColorIn(GX_TEVSTAGE3, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); GXSetTevAlphaIn(GX_TEVSTAGE3, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA); GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_GREATER, field_0x35);