mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-25 09:45:02 +00:00
Match retail PreRender_DivotFilter (#1740)
This commit is contained in:
parent
097db907ca
commit
6c405b6ea3
1 changed files with 18 additions and 16 deletions
|
@ -681,6 +681,14 @@ void PreRender_AntiAliasFilter(PreRender* this, s32 x, s32 y) {
|
|||
(((a2) >= (a1)) ? (((a3) >= (a2)) ? (a2) : (((a1) >= (a3)) ? (a1) : (a3))) \
|
||||
: (((a2) >= (a3)) ? (a2) : (((a3) >= (a1)) ? (a1) : (a3))))
|
||||
|
||||
#if OOT_DEBUG
|
||||
#define R_HREG_MODE_DEBUG R_HREG_MODE
|
||||
#else
|
||||
#define R_HREG_MODE_DEBUG ((void)0, 0)
|
||||
#endif
|
||||
|
||||
#define PRERENDER_DIVOT_CONTROL (R_HREG_MODE_DEBUG == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0)
|
||||
|
||||
/**
|
||||
* Applies the Video Interface divot filter to an image.
|
||||
*
|
||||
|
@ -696,7 +704,7 @@ void PreRender_AntiAliasFilter(PreRender* this, s32 x, s32 y) {
|
|||
void PreRender_DivotFilter(PreRender* this) {
|
||||
s32 x;
|
||||
s32 y;
|
||||
s32 pad1;
|
||||
s32 cvg;
|
||||
u8* buffR = alloca(this->width);
|
||||
u8* buffG = alloca(this->width);
|
||||
u8* buffB = alloca(this->width);
|
||||
|
@ -704,14 +712,14 @@ void PreRender_DivotFilter(PreRender* this) {
|
|||
s32 pxR;
|
||||
s32 pxG;
|
||||
s32 pxB;
|
||||
Color_RGBA16 pxIn;
|
||||
Color_RGBA16 pxOut;
|
||||
|
||||
for (y = 0; y < this->height; y++) {
|
||||
// The divot filter is applied row-by-row as it only needs to use pixels that are horizontally adjacent
|
||||
|
||||
// Decompose each pixel into color channels
|
||||
for (x = 0; x < this->width; x++) {
|
||||
Color_RGBA16 pxIn;
|
||||
|
||||
pxIn.rgba = this->fbufSave[x + y * this->width];
|
||||
buffR[x] = pxIn.r;
|
||||
buffG[x] = pxIn.g;
|
||||
|
@ -721,8 +729,7 @@ void PreRender_DivotFilter(PreRender* this) {
|
|||
// Apply the divot filter itself. For pixels with partial coverage, the filter selects the median value from a
|
||||
// window of 3 pixels in a horizontal row and uses that as the value for the center pixel.
|
||||
for (x = 1; x < this->width - 1; x++) {
|
||||
Color_RGBA16 pxOut;
|
||||
s32 cvg = this->cvgSave[x + y * this->width];
|
||||
cvg = this->cvgSave[x + y * this->width];
|
||||
|
||||
// Reject pixels with full coverage. The hardware video filter divot circuit checks if all 3 pixels in the
|
||||
// window have partial coverage, here only the center pixel is checked.
|
||||
|
@ -732,11 +739,10 @@ void PreRender_DivotFilter(PreRender* this) {
|
|||
}
|
||||
|
||||
// This condition is checked before entering this function, it will always pass if it runs.
|
||||
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) != 0) {
|
||||
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) != 0) {}
|
||||
if (PRERENDER_DIVOT_CONTROL != 0) {
|
||||
if (PRERENDER_DIVOT_CONTROL != 0) {}
|
||||
|
||||
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) ==
|
||||
PRERENDER_DIVOT_PARTIAL_CVG_RED) {
|
||||
if (PRERENDER_DIVOT_CONTROL == PRERENDER_DIVOT_PARTIAL_CVG_RED) {
|
||||
// Fill the pixel with full red, likely for debugging
|
||||
pxR = 31;
|
||||
pxG = 0;
|
||||
|
@ -747,8 +753,7 @@ void PreRender_DivotFilter(PreRender* this) {
|
|||
u8* windowG = &buffG[x - 1];
|
||||
u8* windowB = &buffB[x - 1];
|
||||
|
||||
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) ==
|
||||
PRERENDER_DIVOT_PRINT_COLOR) {
|
||||
if (PRERENDER_DIVOT_CONTROL == PRERENDER_DIVOT_PRINT_COLOR) {
|
||||
PRINTF("red=%3d %3d %3d %3d grn=%3d %3d %3d %3d blu=%3d %3d %3d %3d \n", windowR[0], windowR[1],
|
||||
windowR[2], MEDIAN3(windowR[0], windowR[1], windowR[2]), windowG[0], windowG[1],
|
||||
windowG[2], MEDIAN3(windowG[0], windowG[1], windowG[2]), windowB[0], windowB[1],
|
||||
|
@ -758,8 +763,7 @@ void PreRender_DivotFilter(PreRender* this) {
|
|||
// Sample the median value from the 3 pixel wide window
|
||||
|
||||
// (Both blocks contain the same code)
|
||||
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) ==
|
||||
PRERENDER_DIVOT_ALTERNATE_COLOR) {
|
||||
if (PRERENDER_DIVOT_CONTROL == PRERENDER_DIVOT_ALTERNATE_COLOR) {
|
||||
pxR = MEDIAN3(windowR[0], windowR[1], windowR[2]);
|
||||
pxG = MEDIAN3(windowG[0], windowG[1], windowG[2]);
|
||||
pxB = MEDIAN3(windowB[0], windowB[1], windowB[2]);
|
||||
|
@ -803,11 +807,9 @@ void PreRender_ApplyFilters(PreRender* this) {
|
|||
}
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) != 0) {
|
||||
if (PRERENDER_DIVOT_CONTROL != 0) {
|
||||
// Apply divot filter
|
||||
PreRender_DivotFilter(this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue