This commit is contained in:
elijah-thomas774
2025-03-24 21:28:54 -04:00
parent 3e7dd3283a
commit a8327ffc92
5 changed files with 75 additions and 6 deletions
+4
View File
@@ -38,6 +38,10 @@ public:
mClearColor = clr;
}
void setCopyFilter(const CopyFilter &filt) {
mCopyFilterArg = filt;
}
private:
/* 0x18 */ u8 mCapFlags;
/* 0x19 */ GXColor mClearColor;
+4
View File
@@ -68,6 +68,10 @@ public:
u16 getHeight() const {
return mHeight;
}
// Needed for PostEffectMaskDOF::setUpGradation
u16 getHeight2() {
return mHeight;
}
void setHeight(u16 h) {
mHeight = h;
}
+1 -1
View File
@@ -27,7 +27,7 @@ public:
return mRotation;
}
protected:
public:
u32 field_0x00; // at 0x0
CapTextureWrapper mTex1; // at 0x4
CapTextureWrapper mTex2; // at 0xC
+4 -3
View File
@@ -68,10 +68,11 @@ void PostEffectMaskDOF::setUpGradation() {
const u16 width = mpCpuTex->getWidth() / 2;
for (u16 y = 0; y < mpCpuTex->getHeight(); y++) {
const f32 fy = ((f32)y / mpCpuTex->getHeight());
f32 fy = (f32)y / mpCpuTex->getHeight2();
for (u16 x = 0; x < width; x++) {
f32 fx = (f32)x / width;
f32 ratio = fx / (1.f - fy);
// Don't even have to use this one!
(void)(f32)width;
f32 ratio = ((f32)x / width) / (1.f - fy);
if (ratio > 1.f) {
ratio = 1.f;
+62 -2
View File
@@ -1,6 +1,7 @@
#include "egg/gfx/eggScreenEffectBlur.h"
#include "common.h"
#include "egg/gfx/eggCpuTexture.h"
#include "egg/gfx/eggDrawGX.h"
#include "egg/gfx/eggPostEffectBase.h"
#include "egg/gfx/eggPostEffectBlur.h" // IWYU pragma: keep
@@ -12,6 +13,8 @@
#include "rvl/GX/GXTypes.h"
#include "rvl/MTX/mtx.h"
#include <cstddef>
namespace EGG {
static const GXColor sDefaultColor = {0, 0, 0, 0xFF};
@@ -41,9 +44,66 @@ ScreenEffectBlur::~ScreenEffectBlur() {
delete mpUnk2;
delete mpBlur;
}
static const CopyFilter copyFilter = {
{0x15, 0, 0, 0x16, 0, 0x15, 0}
};
void ScreenEffectBlur::fn_804B32B0() {
// Oh god
if (mFlag & 1) {
StateGX::invalidateTexAllGX();
PostEffectBase::setProjection(GetScreen());
const Screen::DataEfb &efb = GetScreen().GetDataEfb();
u16 x1 = efb.vp.x1;
u16 y1 = efb.vp.y1;
f32 sizeX = (u16)sScreen.GetSize().x * field_0x10;
f32 sizeY = (u16)sScreen.GetSize().y * field_0x10;
u16 x2 = efb.vp.x2 * field_0x10;
u16 y2 = efb.vp.y2 * field_0x10;
StateGX::ScopedColor _clr(true);
StateGX::ScopedAlpha _alpha(false);
StateGX::ScopedDither _dither(false);
TextureBuffer *pTex0 = NULL;
if (field_0x0C & 1) {
pTex0 = TextureBuffer::alloc(x2, y2, GX_TF_RGBA8);
pTex0->capture(x1, y1, 0, GX_TF_RGBA8);
}
TextureBuffer *pTex1 = TextureBuffer::alloc(x2, y2, GX_TF_IA8);
pTex1->setMinFilt(GX_NEAR);
pTex1->setMagFilt(GX_NEAR);
pTex1->capture(x1, y1, false, GX_TF_Z16);
// . . .
if (field_0x0C & 2) {
TextureBuffer *pTex2 = TextureBuffer::alloc(x2, y2, GX_TF_RGBA8);
pTex2->onCapFlag(0x8);
pTex2->setCopyFilter(copyFilter);
pTex2->capture(x1, y1, false, GX_CTF_R8);
u8 val = field_0x18 * 255.f;
GXColor clr = {val, val, val, val};
mpBlur->setStage0Color(clr);
mpBlur->setStage0F(field_0x1C);
mpBlur->mTex1 = (PostEffectBase::CapTextureWrapper){pTex2, GX_TEXMAP1};
mpBlur->draw(sizeX * 1.0f, sizeY * 1.0f);
pTex2->free();
}
// . . .
mpCpuTexture = TextureBuffer::alloc(x2, y2, GX_TF_I8);
mpCpuTexture->onCapFlag(0x8);
mpCpuTexture->setCopyFilter(copyFilter);
mpCpuTexture->capture(x1, y1, false, GX_CTF_R8);
pTex1->free();
if (field_0x0C & 1) {
nw4r::math::MTX34 m;
PSMTXScale(m, sizeY, sizeY, 1.f);
pTex0->load(GX_TEXMAP0);
DrawGX::BeginDrawScreen(true, true, false);
DrawGX::SetBlendMode(DrawGX::BLEND_14);
DrawGX::DrawDL16(m, DrawGX::WHITE);
pTex0->free();
}
}
}
void ScreenEffectBlur::fn_804B3710() {