summaryrefslogtreecommitdiff
path: root/src/egg/gfx/eggPostEffectMaskDOF.cpp
diff options
context:
space:
mode:
authorelijah-thomas774 <elijahthomas774@gmail.com>2025-03-23 21:01:17 -0400
committerelijah-thomas774 <elijahthomas774@gmail.com>2025-03-23 21:01:17 -0400
commit31728178d9d83de43cb1dfd9a1ff1f8cf568edd6 (patch)
tree8a8c4afe12bffc167434a88388fb8bf88b462d2c /src/egg/gfx/eggPostEffectMaskDOF.cpp
parent3ef9b0df8b956bdb3f371ee118ef6dc881ea61e6 (diff)
More PostEffect Progress
Diffstat (limited to 'src/egg/gfx/eggPostEffectMaskDOF.cpp')
-rw-r--r--src/egg/gfx/eggPostEffectMaskDOF.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/egg/gfx/eggPostEffectMaskDOF.cpp b/src/egg/gfx/eggPostEffectMaskDOF.cpp
index 7e9bc43a..fce42b94 100644
--- a/src/egg/gfx/eggPostEffectMaskDOF.cpp
+++ b/src/egg/gfx/eggPostEffectMaskDOF.cpp
@@ -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();