1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Rewrite monochrome effect for Zeldas.

Fixed #1505 OoT Ending Screen Freeze Effect Color Wrong
This commit is contained in:
Sergey Lipskiy 2017-06-19 17:49:23 +07:00
parent 08366f5c09
commit a6babb418f
3 changed files with 45 additions and 36 deletions

View File

@ -972,26 +972,42 @@ public:
" lowp vec4 tex3Point = c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); \n"
"#define READ_TEX(name, tex, texCoord, fbMonochrome, fbFixedAlpha) \\\n"
" { \\\n"
" lowp vec4 texStandard = texture(tex, texCoord); \\\n"
" FILTER_3POINT(tex, texCoord); \\\n"
" name = uTextureFilterMode == 0 ? texStandard : tex3Point; \\\n"
" if (fbMonochrome == 3) { \\\n"
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \\\n"
" name = texelFetch(tex, coord, 0); \\\n"
" } else { \\\n"
" lowp vec4 texStandard = texture(tex, texCoord); \\\n"
" FILTER_3POINT(tex, texCoord); \\\n"
" name = uTextureFilterMode == 0 ? texStandard : tex3Point; \\\n"
" } \\\n"
" if (fbMonochrome == 1) name = vec4(name.r); \\\n"
" else if (fbMonochrome == 2) \\\n"
" else if (fbMonochrome == 2) \\\n"
" name.rgb = vec3(dot(vec3(0.2126, 0.7152, 0.0722), name.rgb)); \\\n"
" if (fbFixedAlpha == 1) name.a = 0.825; \\\n"
" else if (fbMonochrome == 3) { \\\n"
" name.rgb = vec3(dot(vec3(0.2126, 0.7152, 0.0722), name.rgb)); \\\n"
" name.a = 0.0; \\\n"
" } \\\n"
" if (fbFixedAlpha == 1) name.a = 0.825; \\\n"
" } \n"
;
} else {
m_part =
"#define READ_TEX(name, tex, texCoord, fbMonochrome, fbFixedAlpha) \\\n"
" { \\\n"
" name = texture(tex, texCoord); \\\n"
" if (fbMonochrome == 1) name = vec4(name.r); \\\n"
" else if (fbMonochrome == 2) \\\n"
" { \\\n"
" if (fbMonochrome == 3) { \\\n"
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \\\n"
" name = texelFetch(tex, coord, 0); \\\n"
" } else name = texture(tex, texCoord); \\\n"
" if (fbMonochrome == 1) name = vec4(name.r); \\\n"
" else if (fbMonochrome == 2) \\\n"
" name.rgb = vec3(dot(vec3(0.2126, 0.7152, 0.0722), name.rgb)); \\\n"
" if (fbFixedAlpha == 1) name.a = 0.825; \\\n"
" else if (fbMonochrome == 3) { \\\n"
" name.rgb = vec3(dot(vec3(0.2126, 0.7152, 0.0722), name.rgb)); \\\n"
" name.a = 0.0; \\\n"
" } \\\n"
" if (fbFixedAlpha == 1) name.a = 0.825; \\\n"
" } \n"
;
;
}
} else {
m_part =
@ -1543,12 +1559,21 @@ public:
" \n"
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in mediump vec2 texCoord, in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"{ \n"
" mediump vec2 msTexSize = vec2(textureSize(mstex)); \n"
" mediump ivec2 itexCoord = ivec2(msTexSize * texCoord); \n"
" mediump ivec2 itexCoord; \n"
" if (fbMonochrome == 3) { \n"
" itexCoord = ivec2(gl_FragCoord.xy); \n"
" } else { \n"
" mediump vec2 msTexSize = vec2(textureSize(mstex)); \n"
" itexCoord = ivec2(msTexSize * texCoord); \n"
" } \n"
" lowp vec4 texColor = sampleMS(mstex, itexCoord); \n"
" if (fbMonochrome == 1) texColor = vec4(texColor.r); \n"
" else if (fbMonochrome == 2) \n"
" texColor.rgb = vec3(dot(vec3(0.2126, 0.7152, 0.0722), texColor.rgb)); \n"
" else if (fbMonochrome == 3) { \n"
" texColor.rgb = vec3(dot(vec3(0.2126, 0.7152, 0.0722), texColor.rgb)); \n"
" texColor.a = 0.0; \n"
" } \n"
" if (fbFixedAlpha == 1) texColor.a = 0.825; \n"
" return texColor; \n"
"} \n"

View File

@ -201,9 +201,14 @@ public:
nFbMonochromeMode0 = 1;
if (gDP.otherMode.imageRead == 0)
nFbFixedAlpha0 = 1;
}
else if (gSP.textureTile[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->format == G_IM_FMT_IA)
} else if (gSP.textureTile[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->format == G_IM_FMT_IA) {
nFbMonochromeMode0 = 2;
} else if (cache.current[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->size == G_IM_SIZ_8b && gSP.textureTile[0]->format == G_IM_FMT_CI) {
// Zelda monochrome effect
nFbMonochromeMode0 = 3;
nFbMonochromeMode1 = 3;
}
nMSTex0Enabled = cache.current[0]->frameBufferTexture == CachedTexture::fbMultiSample ? 1 : 0;
}
if (cache.current[1] != nullptr && cache.current[1]->frameBufferTexture != CachedTexture::fbNone) {

View File

@ -1039,25 +1039,6 @@ bool texturedRectPaletteMod(const GraphicsDrawer::TexturedRectParams & _params)
return true;
}
static
bool texturedRectMonochromeBackground(const GraphicsDrawer::TexturedRectParams & _params)
{
if (gDP.textureImage.address >= gDP.colorImage.address &&
gDP.textureImage.address <= (gDP.colorImage.address + gDP.colorImage.width*gDP.colorImage.height * 2)) {
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
if (pCurrentBuffer != nullptr) {
FrameBuffer_ActivateBufferTexture(0, pCurrentBuffer);
CombinerInfo::get().setMonochromeCombiner();
return false;
} else
return true;
}
return false;
}
// Special processing of textured rect.
// Return true if actuial rendering is not necessary
bool(*texturedRectSpecial)(const GraphicsDrawer::TexturedRectParams & _params) = nullptr;
@ -1556,8 +1537,6 @@ void GraphicsDrawer::_setSpecialTexrect() const
texturedRectSpecial = texturedRectBGCopy;
else if (strstr(name, (const char *)"PAPER MARIO") || strstr(name, (const char *)"MARIO STORY"))
texturedRectSpecial = texturedRectPaletteMod;
else if (strstr(name, (const char *)"ZELDA"))
texturedRectSpecial = texturedRectMonochromeBackground;
else
texturedRectSpecial = nullptr;
}