More PostEffect Progress

This commit is contained in:
elijah-thomas774
2025-03-23 21:01:17 -04:00
parent 3ef9b0df8b
commit 31728178d9
7 changed files with 88 additions and 30 deletions
+4 -1
View File
@@ -122,8 +122,11 @@ void PostEffectBase::lerpColor(GXColor &out, const GXColor &c1, const GXColor &c
}
void PostEffectBase::getBaseTexMtx(nw4r::math::MTX34 *mtx) const {
// Feels wrong -> maybe an inline with rotation and pi
f32 rot = Math<f32>::pi();
f32 sin, cos;
nw4r::math::SinCosRad(&sin, &cos, mRotation * M_PI);
nw4r::math::SinCosRad(&sin, &cos, rot * mRotation);
f32 zero = 0.0f;
f32 scale = 1.0f;
f32 f8 = zero - 0.5f;
+7 -6
View File
@@ -50,11 +50,12 @@ void PostEffectBlur::drawInternal(u8 kernelIdx, u8 p2, f32 f1, f32 f2) {
nw4r::math::MTX34 mtx;
const Stage &k = field_0x38[kernelIdx];
f32 f4 = k.field_0x0C * f1;
f32 f3 = k.field_0x0C * f2;
f32 rad1 = k.field_0x08 - mRotation * Math<f32>::pi();
f32 tx = k.field_0x0C * f1;
f32 ty = k.field_0x0C * f2;
f32 rad1 = k.field_0x08 - Math<f32>::pi() * mRotation;
f32 abc = 2.f * Math<f32>::pi() / k.field_0x00;
int unk_00_scale = (p2 & 0x1F) * 8;
f32 abc = (2.f * Math<f32>::pi() / k.field_0x00);
u8 numTexGens = k.field_0x00 - unk_00_scale;
if (numTexGens > 8) {
@@ -70,8 +71,8 @@ void PostEffectBlur::drawInternal(u8 kernelIdx, u8 p2, f32 f1, f32 f2) {
nw4r::math::SinCosRad(&sin, &cos, rad1 + abc * unk_00_scale);
nw4r::math::MTX34 m(
// clang-format off
1.0f, 0.0f, cos * f4, 0.0f,
0.0f, 1.0f, sin * f3, 0.0f,
1.0f, 0.0f, cos * tx, 0.0f,
0.0f, 1.0f, sin * ty, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f
// clang-format on
);
+50 -1
View File
@@ -39,7 +39,56 @@ PostEffectMaskDOF::PostEffectMaskDOF()
field_0x00 = 0;
}
void PostEffectMaskDOF::setUpGradation() {}
void PostEffectMaskDOF::setUpGradation() {
for (int i = 0; i < 3; i++) {
const u16 width = mpCpuTexArr[i]->getWidth();
const int mid = width / 2;
for (u16 x = 0; x < mid; x++) {
f32 val = 1.f - (f32)x / (mid - 1);
switch (i) {
case 1: val *= val; break;
case 2:
val *= val;
val *= val;
break;
}
GXColor clr1, clr2;
lerpColor(clr1, getCenterColor(), getNearColor(), val);
lerpColor(clr2, getCenterColor(), getFarColor(), val);
mpCpuTexArr[i]->setColor(x, 0, clr1);
mpCpuTexArr[i]->setColor(x, 1, clr1);
mpCpuTexArr[i]->setColor((width - 1) - x, 0, clr2);
mpCpuTexArr[i]->setColor((width - 1) - x, 1, clr2);
}
mpCpuTexArr[i]->flush();
}
const u16 width = mpCpuTex->getWidth() / 2;
for (u16 y = 0; y < mpCpuTex->getHeight(); y++) {
const f32 fy = ((f32)y / mpCpuTex->getHeight());
for (u16 x = 0; x < width; x++) {
f32 fx = (f32)x / width;
f32 ratio = fx / (1.f - fy);
if (ratio > 1.f) {
ratio = 1.f;
} else if (ratio < 0.f) {
ratio = 0.f;
}
ratio *= ratio;
ratio *= ratio;
GXColor clr1, clr2;
lerpColor(clr1, getCenterColor(), getNearColor(), ratio);
lerpColor(clr2, getCenterColor(), getFarColor(), ratio);
mpCpuTex->setColor((width - 1) - x, y, clr1);
mpCpuTex->setColor(width + x, y, clr2);
}
}
mpCpuTex->flush();
}
void PostEffectMaskDOF::draw(f32 width, f32 height) {
setMaterialInternal();