From 0ea9612b7e1ea82b771b0d85a42a86f9bd530b4a Mon Sep 17 00:00:00 2001 From: KiritoDev <36680385+KiritoDv@users.noreply.github.com> Date: Mon, 25 Apr 2022 17:04:15 -0500 Subject: [PATCH] Moved vismono effect to the gpu --- .../libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h | 4 ++-- .../libultraship/Lib/Fast3D/gfx_direct3d_common.cpp | 3 ++- libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp | 3 ++- soh/src/code/z_play.c | 11 +++++++---- soh/src/overlays/actors/ovl_End_Title/z_end_title.c | 5 ++++- soh/src/overlays/gamestates/ovl_title/z_title.c | 2 ++ .../misc/ovl_kaleido_scope/z_kaleido_equipment.c | 2 +- .../overlays/misc/ovl_kaleido_scope/z_kaleido_item.c | 2 +- 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h index 3b4b8f7d8..b91856ef6 100644 --- a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h +++ b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h @@ -3175,8 +3175,8 @@ _DW({ \ (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) -#define gsDPSetGrayscaleColor(pkt, r, g, b) \ - DPRGBColor(pkt, G_SETINTENSITY, r, g, b, 255) +#define gsDPSetGrayscaleColor(pkt, r, g, b, lerp) \ + DPRGBColor(pkt, G_SETINTENSITY, r, g, b, lerp) #define gDPSetEnvColor(pkt, r, g, b, a) \ DPRGBColor(pkt, G_SETENVCOLOR, r,g,b,a) #define gsDPSetEnvColor(r, g, b, a) \ diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_direct3d_common.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_direct3d_common.cpp index 8df273be7..a8197b321 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_direct3d_common.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_direct3d_common.cpp @@ -310,7 +310,8 @@ void gfx_direct3d_common_build_shader(char buf[4096], size_t& len, size_t& num_f if (cc_features.opt_grayscale) { append_line(buf, &len, "float intensity = (texel.r + texel.g + texel.b) / 3.0;"); - append_line(buf, &len, "texel.rgb = input.grayscale.rgb * intensity;"); + append_line(buf, &len, "float3 new_texel = input.grayscale.rgb * intensity;"); + append_line(buf, &len, "texel.rgb = input.grayscale.a > 0 ? lerp(texel.rgb, new_texel, input.grayscale.a) : new_texel;"); } if (cc_features.opt_alpha && cc_features.opt_noise) { diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp index 808b0a558..c8dc4666e 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp @@ -370,7 +370,8 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad if (cc_features.opt_grayscale) { append_line(fs_buf, &fs_len, "float intensity = (texel.r + texel.g + texel.b) / 3.0;"); - append_line(fs_buf, &fs_len, "texel.rgb = vGrayscaleColor.rgb * intensity;"); + append_line(fs_buf, &fs_len, "vec3 new_texel = vGrayscaleColor.rgb * intensity;"); + append_line(fs_buf, &fs_len, "texel.rgb = vGrayscaleColor.a > 0 ? mix(texel.rgb, new_texel, vGrayscaleColor.a) : new_texel;"); } if (cc_features.opt_alpha) { diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 193b14164..f62e719ba 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -1,3 +1,5 @@ +#include + #include "global.h" #include "vt.h" @@ -1119,6 +1121,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) { gfxP = Graph_GfxPlusOne(sp1CC); gSPDisplayList(OVERLAY_DISP++, gfxP); + gsSPGrayscale(gfxP++, false); if ((globalCtx->transitionMode == 3) || (globalCtx->transitionMode == 11) || (globalCtx->transitionCtx.transitionType >= 56)) { @@ -1136,8 +1139,8 @@ void Gameplay_Draw(GlobalContext* globalCtx) { TransitionFade_Draw(&globalCtx->transitionFade, &gfxP); if (D_801614B0.a > 0) { - D_80161498.primColor.rgba = D_801614B0.rgba; - VisMono_Draw(&D_80161498, &gfxP); + gsDPSetGrayscaleColor(gfxP++, D_801614B0.r, D_801614B0.g, D_801614B0.b, D_801614B0.a); + gsSPGrayscale(gfxP++, true); } gSPEndDisplayList(gfxP++); @@ -1171,7 +1174,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) { //goto Gameplay_Draw_DrawOverlayElements; } - //else + //else { s32 sp80; @@ -1472,7 +1475,7 @@ void Gameplay_InitEnvironment(GlobalContext* globalCtx, s16 skyboxId) { Environment_Init(globalCtx, &globalCtx->envCtx, 0); } -void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn) +void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn) { globalCtx->curSpawn = spawn; globalCtx->linkActorEntry = NULL; diff --git a/soh/src/overlays/actors/ovl_End_Title/z_end_title.c b/soh/src/overlays/actors/ovl_End_Title/z_end_title.c index f76ac084d..0c903bb80 100644 --- a/soh/src/overlays/actors/ovl_End_Title/z_end_title.c +++ b/soh/src/overlays/actors/ovl_End_Title/z_end_title.c @@ -84,6 +84,8 @@ void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) { } OVERLAY_DISP = func_80093F34(OVERLAY_DISP); + if (D_801614B0.a > 0) + gsSPGrayscale(OVERLAY_DISP++, false); gDPSetTextureLUT(OVERLAY_DISP++, G_TT_NONE); gDPSetEnvColor(OVERLAY_DISP++, 255, 120, 30, 0); gDPSetRenderMode(OVERLAY_DISP++, G_RM_PASS, G_RM_XLU_SURF2); @@ -108,7 +110,8 @@ void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) { G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 0, 0, 0, 0); gSPTextureRectangle(OVERLAY_DISP++, 104 << 2, 177 << 2, 216 << 2, 192 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - + if (D_801614B0.a > 0) + gsSPGrayscale(OVERLAY_DISP++, true); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_end_title.c", 515); } diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 3b7cfe84c..380720dd1 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -271,6 +271,8 @@ void Title_Init(GameState* thisx) { //ResourceMgr_CacheDirectory("nintendo_rogo_static*"); + // Disable vismono + D_801614B0.a = 0; R_UPDATE_RATE = 1; Matrix_Init(&this->state); View_Init(&this->view, this->state.gfxCtx); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 1e778663d..ba981c58f 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -578,7 +578,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { int itemId = ITEM_SWORD_KOKIRI + temp; bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge); if (not_acquired) { - gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109); + gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 0); gsSPGrayscale(POLY_KAL_DISP++, true); } KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 2ce63cf51..26f37deb9 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -470,7 +470,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { int itemId = gSaveContext.inventory.items[i]; bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge); if (not_acquired) { - gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109); + gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 0); gsSPGrayscale(POLY_KAL_DISP++, true); } KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32,