mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Make frame buffer texture monochrome when it is used as IA texture.
Fixes sepia effect in Pokemon Stadium 2 during credits, #721
This commit is contained in:
parent
d506d6134d
commit
a98aac9fd4
|
@ -164,11 +164,11 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
|
|||
} else {
|
||||
if (usesTile(0)) {
|
||||
strFragmentShader.append(" nCurrentTile = 0; \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex0 = readTex(uTex0, vTexCoord0, uFb8Bit[0] != 0, uFbFixedAlpha[0] != 0); \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex0 = readTex(uTex0, vTexCoord0, uFbMonochrome[0], uFbFixedAlpha[0] != 0); \n");
|
||||
}
|
||||
if (usesTile(1)) {
|
||||
strFragmentShader.append(" nCurrentTile = 1; \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFb8Bit[1] != 0, uFbFixedAlpha[1] != 0); \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFbMonochrome[1], uFbFixedAlpha[1] != 0); \n");
|
||||
}
|
||||
}
|
||||
const bool bUseHWLight = config.generalEmulation.enableHWLighting != 0 && GBI.isHWLSupported() && usesShadeColor();
|
||||
|
@ -269,7 +269,7 @@ void ShaderCombiner::_locateUniforms() {
|
|||
LocateUniform(uEnableDepthUpdate);
|
||||
LocateUniform(uDepthMode);
|
||||
LocateUniform(uDepthSource);
|
||||
LocateUniform(uFb8Bit);
|
||||
LocateUniform(uFbMonochrome);
|
||||
LocateUniform(uFbFixedAlpha);
|
||||
LocateUniform(uMaxTile)
|
||||
LocateUniform(uTexturePersp);
|
||||
|
@ -441,25 +441,27 @@ void ShaderCombiner::updateFBInfo(bool _bForce) {
|
|||
if (!usesTexture())
|
||||
return;
|
||||
|
||||
int nFb8bitMode0 = 0, nFb8bitMode1 = 0;
|
||||
int nFbMonochromeMode0 = 0, nFbMonochromeMode1 = 0;
|
||||
int nFbFixedAlpha0 = 0, nFbFixedAlpha1 = 0;
|
||||
int nMSTex0Enabled = 0, nMSTex1Enabled = 0;
|
||||
TextureCache & cache = textureCache();
|
||||
if (cache.current[0] != NULL && cache.current[0]->frameBufferTexture != CachedTexture::fbNone) {
|
||||
if (cache.current[0]->size == G_IM_SIZ_8b) {
|
||||
nFb8bitMode0 = 1;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha0 = 1;
|
||||
}
|
||||
if (cache.current[0]->size == G_IM_SIZ_8b)
|
||||
nFbMonochromeMode0 = 1;
|
||||
else if (gSP.textureTile[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->format == G_IM_FMT_IA)
|
||||
nFbMonochromeMode0 = 2;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha0 = 1;
|
||||
}
|
||||
if (cache.current[1] != NULL && cache.current[1]->frameBufferTexture != CachedTexture::fbNone) {
|
||||
if (cache.current[1]->size == G_IM_SIZ_8b) {
|
||||
nFb8bitMode1 = 1;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha1 = 1;
|
||||
}
|
||||
if (cache.current[1]->size == G_IM_SIZ_8b)
|
||||
nFbMonochromeMode1 = 1;
|
||||
else if (gSP.textureTile[1]->size == G_IM_SIZ_16b && gSP.textureTile[1]->format == G_IM_FMT_IA)
|
||||
nFbMonochromeMode1 = 2;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha1 = 1;
|
||||
}
|
||||
m_uniforms.uFb8Bit.set(nFb8bitMode0, nFb8bitMode1, _bForce);
|
||||
m_uniforms.uFbMonochrome.set(nFbMonochromeMode0, nFbMonochromeMode1, _bForce);
|
||||
m_uniforms.uFbFixedAlpha.set(nFbFixedAlpha0, nFbFixedAlpha1, _bForce);
|
||||
|
||||
gDP.changed &= ~CHANGED_FB_TEXTURE;
|
||||
|
|
|
@ -169,7 +169,7 @@ SHADER_VERSION
|
|||
"uniform lowp int uAlphaCompareMode; \n"
|
||||
"uniform lowp int uGammaCorrectionEnabled; \n"
|
||||
"uniform lowp int uFogUsage; \n"
|
||||
"uniform lowp ivec2 uFb8Bit; \n"
|
||||
"uniform lowp ivec2 uFbMonochrome; \n"
|
||||
"uniform lowp ivec2 uFbFixedAlpha;\n"
|
||||
"uniform lowp int uSpecialBlendMode;\n"
|
||||
"uniform lowp int uEnableAlphaTest; \n"
|
||||
|
@ -224,7 +224,7 @@ static const char* fragment_shader_header_common_functions =
|
|||
"lowp float snoise(); \n"
|
||||
"void calc_light(in lowp float fLights, in lowp vec3 input_color, out lowp vec3 output_color);\n"
|
||||
"mediump float mipmap(out lowp vec4 readtex0, out lowp vec4 readtex1); \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha); \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha); \n"
|
||||
#ifdef USE_TOONIFY
|
||||
"void toonify(in mediump float intensity); \n"
|
||||
#endif
|
||||
|
@ -295,10 +295,12 @@ static const char* fragment_shader_fake_mipmap =
|
|||
;
|
||||
|
||||
static const char* fragment_shader_readtex =
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha) \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha) \n"
|
||||
"{ \n"
|
||||
" lowp vec4 texColor = texture2D(tex, texCoord); \n"
|
||||
" if (fb8bit) texColor = vec4(texColor.r); \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"
|
||||
" if (fbFixedAlpha) texColor.a = 0.825; \n"
|
||||
" return texColor; \n"
|
||||
"} \n"
|
||||
|
@ -321,12 +323,14 @@ static const char* fragment_shader_readtex_3point =
|
|||
" lowp vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y))); \n"
|
||||
" return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); \n"
|
||||
"} \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha) \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha) \n"
|
||||
"{ \n"
|
||||
" lowp vec4 texStandard = texture2D(tex, texCoord); \n"
|
||||
" lowp vec4 texStandard = texture2D(tex, texCoord); \n"
|
||||
" lowp vec4 tex3Point = filter3point(tex, texCoord); \n"
|
||||
" lowp vec4 texColor = uTextureFilterMode == 0 ? texStandard : tex3Point; \n"
|
||||
" if (fb8bit) texColor = vec4(texColor.r); \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"
|
||||
" if (fbFixedAlpha) texColor.a = 0.825; \n"
|
||||
" return texColor; \n"
|
||||
"} \n"
|
||||
|
|
|
@ -96,7 +96,7 @@ private:
|
|||
|
||||
fv2Uniform uScreenScale, uDepthScale, uFogScale;
|
||||
|
||||
iv2Uniform uMSTexEnabled, uFb8Bit, uFbFixedAlpha;
|
||||
iv2Uniform uMSTexEnabled, uFbMonochrome, uFbFixedAlpha;
|
||||
};
|
||||
|
||||
#ifdef OS_MAC_OS_X
|
||||
|
|
|
@ -296,24 +296,24 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
|
|||
if (usesTile(0)) {
|
||||
if (config.video.multisampling > 0) {
|
||||
strFragmentShader.append(" lowp vec4 readtex0; \n");
|
||||
strFragmentShader.append(" if (uMSTexEnabled[0] == 0) readtex0 = readTex(uTex0, vTexCoord0, uFb8Bit[0] != 0, uFbFixedAlpha[0] != 0); \n");
|
||||
strFragmentShader.append(" else readtex0 = readTexMS(uMSTex0, vTexCoord0, uFb8Bit[0] != 0, uFbFixedAlpha[0] != 0); \n");
|
||||
strFragmentShader.append(" if (uMSTexEnabled[0] == 0) readtex0 = readTex(uTex0, vTexCoord0, uFbMonochrome[0], uFbFixedAlpha[0] != 0); \n");
|
||||
strFragmentShader.append(" else readtex0 = readTexMS(uMSTex0, vTexCoord0, uFbMonochrome[0], uFbFixedAlpha[0] != 0); \n");
|
||||
} else
|
||||
strFragmentShader.append(" lowp vec4 readtex0 = readTex(uTex0, vTexCoord0, uFb8Bit[0] != 0, uFbFixedAlpha[0] != 0); \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex0 = readTex(uTex0, vTexCoord0, uFbMonochrome[0], uFbFixedAlpha[0] != 0); \n");
|
||||
}
|
||||
if (usesTile(1)) {
|
||||
if (config.video.multisampling > 0) {
|
||||
strFragmentShader.append(" lowp vec4 readtex1; \n");
|
||||
strFragmentShader.append(" if (uMSTexEnabled[1] == 0) readtex1 = readTex(uTex1, vTexCoord1, uFb8Bit[1] != 0, uFbFixedAlpha[1] != 0); \n");
|
||||
strFragmentShader.append(" else readtex1 = readTexMS(uMSTex1, vTexCoord1, uFb8Bit[1] != 0, uFbFixedAlpha[1] != 0); \n");
|
||||
strFragmentShader.append(" if (uMSTexEnabled[1] == 0) readtex1 = readTex(uTex1, vTexCoord1, uFbMonochrome[1], uFbFixedAlpha[1] != 0); \n");
|
||||
strFragmentShader.append(" else readtex1 = readTexMS(uMSTex1, vTexCoord1, uFbMonochrome[1], uFbFixedAlpha[1] != 0); \n");
|
||||
} else
|
||||
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFb8Bit[1] != 0, uFbFixedAlpha[1] != 0); \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFbMonochrome[1], uFbFixedAlpha[1] != 0); \n");
|
||||
}
|
||||
#else
|
||||
if (usesTile(0))
|
||||
strFragmentShader.append(" lowp vec4 readtex0 = readTex(uTex0, vTexCoord0, uFb8Bit[0] != 0, uFbFixedAlpha[0] != 0); \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex0 = readTex(uTex0, vTexCoord0, uFbMonochrome[0], uFbFixedAlpha[0] != 0); \n");
|
||||
if (usesTile(1))
|
||||
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFb8Bit[1] != 0, uFbFixedAlpha[1] != 0); \n");
|
||||
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFbMonochrome[1], uFbFixedAlpha[1] != 0); \n");
|
||||
#endif // GL_MULTISAMPLING_SUPPORT
|
||||
}
|
||||
const bool bUseHWLight = config.generalEmulation.enableHWLighting != 0 && GBI.isHWLSupported() && usesShadeColor();
|
||||
|
@ -454,7 +454,7 @@ void ShaderCombiner::_locateUniforms() {
|
|||
LocateUniform(uEnableDepthUpdate);
|
||||
LocateUniform(uDepthMode);
|
||||
LocateUniform(uDepthSource);
|
||||
LocateUniform(uFb8Bit);
|
||||
LocateUniform(uFbMonochrome);
|
||||
LocateUniform(uFbFixedAlpha);
|
||||
LocateUniform(uMaxTile)
|
||||
LocateUniform(uTextureDetail);
|
||||
|
@ -656,27 +656,29 @@ void ShaderCombiner::updateFBInfo(bool _bForce) {
|
|||
if (!usesTexture())
|
||||
return;
|
||||
|
||||
int nFb8bitMode0 = 0, nFb8bitMode1 = 0;
|
||||
int nFbMonochromeMode0 = 0, nFbMonochromeMode1 = 0;
|
||||
int nFbFixedAlpha0 = 0, nFbFixedAlpha1 = 0;
|
||||
int nMSTex0Enabled = 0, nMSTex1Enabled = 0;
|
||||
TextureCache & cache = textureCache();
|
||||
if (cache.current[0] != NULL && cache.current[0]->frameBufferTexture != CachedTexture::fbNone) {
|
||||
if (cache.current[0]->size == G_IM_SIZ_8b) {
|
||||
nFb8bitMode0 = 1;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha0 = 1;
|
||||
}
|
||||
if (cache.current[0]->size == G_IM_SIZ_8b)
|
||||
nFbMonochromeMode0 = 1;
|
||||
else if (gSP.textureTile[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->format == G_IM_FMT_IA)
|
||||
nFbMonochromeMode0 = 2;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha0 = 1;
|
||||
nMSTex0Enabled = cache.current[0]->frameBufferTexture == CachedTexture::fbMultiSample ? 1 : 0;
|
||||
}
|
||||
if (cache.current[1] != NULL && cache.current[1]->frameBufferTexture != CachedTexture::fbNone) {
|
||||
if (cache.current[1]->size == G_IM_SIZ_8b) {
|
||||
nFb8bitMode1 = 1;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha1 = 1;
|
||||
}
|
||||
if (cache.current[1]->size == G_IM_SIZ_8b)
|
||||
nFbMonochromeMode1 = 1;
|
||||
else if (gSP.textureTile[1]->size == G_IM_SIZ_16b && gSP.textureTile[1]->format == G_IM_FMT_IA)
|
||||
nFbMonochromeMode1 = 2;
|
||||
if (gDP.otherMode.imageRead == 0)
|
||||
nFbFixedAlpha1 = 1;
|
||||
nMSTex1Enabled = cache.current[1]->frameBufferTexture == CachedTexture::fbMultiSample ? 1 : 0;
|
||||
}
|
||||
m_uniforms.uFb8Bit.set(nFb8bitMode0, nFb8bitMode1, _bForce);
|
||||
m_uniforms.uFbMonochrome.set(nFbMonochromeMode0, nFbMonochromeMode1, _bForce);
|
||||
m_uniforms.uFbFixedAlpha.set(nFbFixedAlpha0, nFbFixedAlpha1, _bForce);
|
||||
m_uniforms.uMSTexEnabled.set(nMSTex0Enabled, nMSTex1Enabled, _bForce);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ MAIN_SHADER_VERSION
|
|||
"uniform lowp int uColorDitherMode; \n"
|
||||
"uniform lowp int uGammaCorrectionEnabled; \n"
|
||||
"uniform lowp int uFogUsage; \n"
|
||||
"uniform lowp ivec2 uFb8Bit; \n"
|
||||
"uniform lowp ivec2 uFbMonochrome; \n"
|
||||
"uniform lowp ivec2 uFbFixedAlpha;\n"
|
||||
"uniform lowp int uSpecialBlendMode;\n"
|
||||
"uniform lowp int uEnableAlphaTest; \n"
|
||||
|
@ -229,9 +229,9 @@ static const char* fragment_shader_header_common_functions =
|
|||
"lowp float snoise(); \n"
|
||||
"void calc_light(in lowp float fLights, in lowp vec3 input_color, out lowp vec3 output_color);\n"
|
||||
"mediump float mipmap(out lowp vec4 readtex0, out lowp vec4 readtex1); \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha); \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha); \n"
|
||||
#ifdef GL_MULTISAMPLING_SUPPORT
|
||||
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha); \n"
|
||||
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha); \n"
|
||||
#endif // GL_MULTISAMPLING_SUPPORT
|
||||
"bool depth_compare(); \n"
|
||||
"void colorNoiseDither(in lowp float _noise, inout lowp vec3 _color); \n"
|
||||
|
@ -414,10 +414,12 @@ static const char* fragment_shader_fake_mipmap =
|
|||
|
||||
static const char* fragment_shader_readtex =
|
||||
AUXILIARY_SHADER_VERSION
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha) \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha) \n"
|
||||
"{ \n"
|
||||
" lowp vec4 texColor = texture(tex, texCoord); \n"
|
||||
" if (fb8bit) texColor = vec4(texColor.r); \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"
|
||||
" if (fbFixedAlpha) texColor.a = 0.825; \n"
|
||||
" return texColor; \n"
|
||||
"} \n"
|
||||
|
@ -440,12 +442,14 @@ AUXILIARY_SHADER_VERSION
|
|||
" lowp vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y))); \n"
|
||||
" return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); \n"
|
||||
"} \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha) \n"
|
||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha) \n"
|
||||
"{ \n"
|
||||
" lowp vec4 texStandard = texture(tex, texCoord); \n"
|
||||
" lowp vec4 tex3Point = filter3point(tex, texCoord); \n"
|
||||
" lowp vec4 texColor = uTextureFilterMode == 0 ? texStandard : tex3Point; \n"
|
||||
" if (fb8bit) texColor = vec4(texColor.r); \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"
|
||||
" if (fbFixedAlpha) texColor.a = 0.825; \n"
|
||||
" return texColor; \n"
|
||||
"} \n"
|
||||
|
|
Loading…
Reference in New Issue
Block a user