Moved vismono effect to the gpu

This commit is contained in:
KiritoDev 2022-04-25 17:04:15 -05:00 committed by Nicholas Estelami
parent eecad3dc15
commit 0ea9612b7e
8 changed files with 21 additions and 11 deletions

View File

@ -3175,8 +3175,8 @@ _DW({ \
(_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \
_SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)))
#define gsDPSetGrayscaleColor(pkt, r, g, b) \ #define gsDPSetGrayscaleColor(pkt, r, g, b, lerp) \
DPRGBColor(pkt, G_SETINTENSITY, r, g, b, 255) DPRGBColor(pkt, G_SETINTENSITY, r, g, b, lerp)
#define gDPSetEnvColor(pkt, r, g, b, a) \ #define gDPSetEnvColor(pkt, r, g, b, a) \
DPRGBColor(pkt, G_SETENVCOLOR, r,g,b,a) DPRGBColor(pkt, G_SETENVCOLOR, r,g,b,a)
#define gsDPSetEnvColor(r, g, b, a) \ #define gsDPSetEnvColor(r, g, b, a) \

View File

@ -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) { if (cc_features.opt_grayscale) {
append_line(buf, &len, "float intensity = (texel.r + texel.g + texel.b) / 3.0;"); 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) { if (cc_features.opt_alpha && cc_features.opt_noise) {

View File

@ -370,7 +370,8 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
if (cc_features.opt_grayscale) { 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, "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) { if (cc_features.opt_alpha) {

View File

@ -1,3 +1,5 @@
#include <stdio.h>
#include "global.h" #include "global.h"
#include "vt.h" #include "vt.h"
@ -1119,6 +1121,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) {
gfxP = Graph_GfxPlusOne(sp1CC); gfxP = Graph_GfxPlusOne(sp1CC);
gSPDisplayList(OVERLAY_DISP++, gfxP); gSPDisplayList(OVERLAY_DISP++, gfxP);
gsSPGrayscale(gfxP++, false);
if ((globalCtx->transitionMode == 3) || (globalCtx->transitionMode == 11) || if ((globalCtx->transitionMode == 3) || (globalCtx->transitionMode == 11) ||
(globalCtx->transitionCtx.transitionType >= 56)) { (globalCtx->transitionCtx.transitionType >= 56)) {
@ -1136,8 +1139,8 @@ void Gameplay_Draw(GlobalContext* globalCtx) {
TransitionFade_Draw(&globalCtx->transitionFade, &gfxP); TransitionFade_Draw(&globalCtx->transitionFade, &gfxP);
if (D_801614B0.a > 0) { if (D_801614B0.a > 0) {
D_80161498.primColor.rgba = D_801614B0.rgba; gsDPSetGrayscaleColor(gfxP++, D_801614B0.r, D_801614B0.g, D_801614B0.b, D_801614B0.a);
VisMono_Draw(&D_80161498, &gfxP); gsSPGrayscale(gfxP++, true);
} }
gSPEndDisplayList(gfxP++); gSPEndDisplayList(gfxP++);
@ -1171,7 +1174,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) {
//goto Gameplay_Draw_DrawOverlayElements; //goto Gameplay_Draw_DrawOverlayElements;
} }
//else //else
{ {
s32 sp80; s32 sp80;
@ -1472,7 +1475,7 @@ void Gameplay_InitEnvironment(GlobalContext* globalCtx, s16 skyboxId) {
Environment_Init(globalCtx, &globalCtx->envCtx, 0); Environment_Init(globalCtx, &globalCtx->envCtx, 0);
} }
void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn) void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn)
{ {
globalCtx->curSpawn = spawn; globalCtx->curSpawn = spawn;
globalCtx->linkActorEntry = NULL; globalCtx->linkActorEntry = NULL;

View File

@ -84,6 +84,8 @@ void EndTitle_DrawFull(Actor* thisx, GlobalContext* globalCtx) {
} }
OVERLAY_DISP = func_80093F34(OVERLAY_DISP); OVERLAY_DISP = func_80093F34(OVERLAY_DISP);
if (D_801614B0.a > 0)
gsSPGrayscale(OVERLAY_DISP++, false);
gDPSetTextureLUT(OVERLAY_DISP++, G_TT_NONE); gDPSetTextureLUT(OVERLAY_DISP++, G_TT_NONE);
gDPSetEnvColor(OVERLAY_DISP++, 255, 120, 30, 0); gDPSetEnvColor(OVERLAY_DISP++, 255, 120, 30, 0);
gDPSetRenderMode(OVERLAY_DISP++, G_RM_PASS, G_RM_XLU_SURF2); 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); 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, gSPTextureRectangle(OVERLAY_DISP++, 104 << 2, 177 << 2, 216 << 2, 192 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10,
1 << 10); 1 << 10);
if (D_801614B0.a > 0)
gsSPGrayscale(OVERLAY_DISP++, true);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_end_title.c", 515); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_end_title.c", 515);
} }

View File

@ -271,6 +271,8 @@ void Title_Init(GameState* thisx) {
//ResourceMgr_CacheDirectory("nintendo_rogo_static*"); //ResourceMgr_CacheDirectory("nintendo_rogo_static*");
// Disable vismono
D_801614B0.a = 0;
R_UPDATE_RATE = 1; R_UPDATE_RATE = 1;
Matrix_Init(&this->state); Matrix_Init(&this->state);
View_Init(&this->view, this->state.gfxCtx); View_Init(&this->view, this->state.gfxCtx);

View File

@ -578,7 +578,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
int itemId = ITEM_SWORD_KOKIRI + temp; int itemId = ITEM_SWORD_KOKIRI + temp;
bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge); bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (not_acquired) { if (not_acquired) {
gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109); gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 0);
gsSPGrayscale(POLY_KAL_DISP++, true); gsSPGrayscale(POLY_KAL_DISP++, true);
} }
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point); KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point);

View File

@ -470,7 +470,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
int itemId = gSaveContext.inventory.items[i]; int itemId = gSaveContext.inventory.items[i];
bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge); bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (not_acquired) { if (not_acquired) {
gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109); gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 0);
gsSPGrayscale(POLY_KAL_DISP++, true); gsSPGrayscale(POLY_KAL_DISP++, true);
} }
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32,