mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Added an option to force gamma correction level
This commit is contained in:
parent
d205b02c2e
commit
0b6e4068dc
|
@ -36,6 +36,8 @@ void Config::resetToDefaults()
|
|||
generalEmulation.enableCustomSettings = 1;
|
||||
generalEmulation.enableShadersStorage = 1;
|
||||
generalEmulation.hacks = 0;
|
||||
generalEmulation.forceGammaCorrection = 0;
|
||||
generalEmulation.gammaCorrectionLevel = 2.0f;
|
||||
#ifdef ANDROID
|
||||
generalEmulation.forcePolygonOffset = 0;
|
||||
generalEmulation.polygonOffsetFactor = 0.0f;
|
||||
|
|
|
@ -48,6 +48,8 @@ struct Config
|
|||
u32 enableCustomSettings;
|
||||
u32 enableShadersStorage;
|
||||
u32 hacks;
|
||||
u32 forceGammaCorrection;
|
||||
f32 gammaCorrectionLevel;
|
||||
#ifdef ANDROID
|
||||
u32 forcePolygonOffset;
|
||||
f32 polygonOffsetFactor;
|
||||
|
|
|
@ -202,7 +202,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
|
|||
" if (uFogUsage == 257) \n"
|
||||
" fragColor.rgb = mix(fragColor.rgb, uFogColor.rgb, vFogFragCoord); \n"
|
||||
" if (uGammaCorrectionEnabled != 0) \n"
|
||||
" fragColor.rgb = sqrt(fragColor.rgb); \n"
|
||||
" fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / uGammaCorrectionLevel)); \n"
|
||||
" gl_FragColor = fragColor; \n"
|
||||
);
|
||||
|
||||
|
@ -263,6 +263,7 @@ void ShaderCombiner::_locateUniforms() {
|
|||
LocateUniform(uFogUsage);
|
||||
LocateUniform(uAlphaCompareMode);
|
||||
LocateUniform(uGammaCorrectionEnabled);
|
||||
LocateUniform(uGammaCorrectionLevel);
|
||||
LocateUniform(uEnableAlphaTest);
|
||||
LocateUniform(uEnableDepth);
|
||||
LocateUniform(uEnableDepthCompare)
|
||||
|
@ -325,7 +326,10 @@ void ShaderCombiner::updateRenderState(bool _bForce)
|
|||
|
||||
void ShaderCombiner::updateGammaCorrection(bool _bForce)
|
||||
{
|
||||
m_uniforms.uGammaCorrectionEnabled.set(*REG.VI_STATUS & 8, _bForce);
|
||||
m_uniforms.uGammaCorrectionEnabled.set(((*REG.VI_STATUS & 8)|config.generalEmulation.forceGammaCorrection), _bForce);
|
||||
|
||||
f32 gammaLevel = (config.generalEmulation.forceGammaCorrection != 0) ? config.generalEmulation.gammaCorrectionLevel : 2.0f;
|
||||
m_uniforms.uGammaCorrectionLevel.set(gammaLevel, _bForce);
|
||||
}
|
||||
|
||||
void ShaderCombiner::updateFogMode(bool _bForce)
|
||||
|
|
|
@ -162,6 +162,7 @@ SHADER_VERSION
|
|||
"uniform mediump vec2 uScreenScale; \n"
|
||||
"uniform lowp int uAlphaCompareMode; \n"
|
||||
"uniform lowp int uGammaCorrectionEnabled; \n"
|
||||
"uniform lowp float uGammaCorrectionLevel; \n"
|
||||
"uniform lowp int uFogUsage; \n"
|
||||
"uniform lowp ivec2 uFbMonochrome; \n"
|
||||
"uniform lowp ivec2 uFbFixedAlpha;\n"
|
||||
|
@ -201,6 +202,7 @@ SHADER_VERSION
|
|||
"uniform mediump vec2 uScreenScale; \n"
|
||||
"uniform lowp int uAlphaCompareMode; \n"
|
||||
"uniform lowp int uGammaCorrectionEnabled; \n"
|
||||
"uniform lowp float uGammaCorrectionLevel; \n"
|
||||
"uniform lowp int uFogUsage; \n"
|
||||
"uniform lowp int uSpecialBlendMode;\n"
|
||||
"uniform lowp int uEnableAlphaTest; \n"
|
||||
|
|
|
@ -99,7 +99,7 @@ private:
|
|||
uMaxTile, uTextureDetail, uTexturePersp, uTextureFilterMode, uMSAASamples,
|
||||
uAlphaCompareMode, uAlphaDitherMode, uColorDitherMode, uGammaCorrectionEnabled;
|
||||
|
||||
fUniform uFogAlpha, uMinLod, uDeltaZ, uAlphaTestValue, uMSAAScale;
|
||||
fUniform uFogAlpha, uMinLod, uDeltaZ, uAlphaTestValue, uMSAAScale, uGammaCorrectionLevel;
|
||||
|
||||
fv2Uniform uScreenScale, uDepthScale, uFogScale;
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
|
|||
" if (uFogUsage == 257) \n"
|
||||
" fragColor.rgb = mix(fragColor.rgb, uFogColor.rgb, vFogFragCoord); \n"
|
||||
" if (uGammaCorrectionEnabled != 0) \n"
|
||||
" fragColor.rgb = sqrt(fragColor.rgb); \n"
|
||||
" fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / uGammaCorrectionLevel)); \n"
|
||||
);
|
||||
|
||||
strFragmentShader.append(fragment_shader_end);
|
||||
|
@ -455,6 +455,7 @@ void ShaderCombiner::_locateUniforms() {
|
|||
LocateUniform(uAlphaDitherMode);
|
||||
LocateUniform(uColorDitherMode);
|
||||
LocateUniform(uGammaCorrectionEnabled);
|
||||
LocateUniform(uGammaCorrectionLevel);
|
||||
LocateUniform(uEnableLod);
|
||||
LocateUniform(uEnableAlphaTest);
|
||||
LocateUniform(uEnableDepth);
|
||||
|
@ -535,7 +536,10 @@ void ShaderCombiner::updateRenderState(bool _bForce)
|
|||
|
||||
void ShaderCombiner::updateGammaCorrection(bool _bForce)
|
||||
{
|
||||
m_uniforms.uGammaCorrectionEnabled.set(*REG.VI_STATUS & 8, _bForce);
|
||||
m_uniforms.uGammaCorrectionEnabled.set(((*REG.VI_STATUS & 8)|config.generalEmulation.forceGammaCorrection), _bForce);
|
||||
|
||||
f32 gammaLevel = (config.generalEmulation.forceGammaCorrection != 0) ? config.generalEmulation.gammaCorrectionLevel : 2.0f;
|
||||
m_uniforms.uGammaCorrectionLevel.set(gammaLevel, _bForce);
|
||||
}
|
||||
|
||||
void ShaderCombiner::updateFogMode(bool _bForce)
|
||||
|
|
|
@ -169,6 +169,7 @@ MAIN_SHADER_VERSION
|
|||
"uniform lowp int uAlphaDitherMode; \n"
|
||||
"uniform lowp int uColorDitherMode; \n"
|
||||
"uniform lowp int uGammaCorrectionEnabled; \n"
|
||||
"uniform lowp float uGammaCorrectionLevel; \n"
|
||||
"uniform lowp int uFogUsage; \n"
|
||||
"uniform lowp ivec2 uFbMonochrome; \n"
|
||||
"uniform lowp ivec2 uFbFixedAlpha;\n"
|
||||
|
@ -206,6 +207,7 @@ MAIN_SHADER_VERSION
|
|||
"uniform lowp int uAlphaDitherMode; \n"
|
||||
"uniform lowp int uColorDitherMode; \n"
|
||||
"uniform lowp int uGammaCorrectionEnabled; \n"
|
||||
"uniform lowp float uGammaCorrectionLevel; \n"
|
||||
"uniform lowp int uFogUsage; \n"
|
||||
"uniform lowp int uSpecialBlendMode;\n"
|
||||
"uniform lowp int uEnableAlphaTest; \n"
|
||||
|
|
|
@ -68,6 +68,10 @@ bool Config_SetDefault()
|
|||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableShadersStorage", config.generalEmulation.enableShadersStorage, "Use persistent storage for compiled shaders.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "ForceGammaCorrection", config.generalEmulation.forceGammaCorrection, "Force gamma correction.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultFloat(g_configVideoGliden64, "GammaCorrectionLevel", config.generalEmulation.gammaCorrectionLevel, "Gamma correction level.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
#ifdef ANDROID
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "ForcePolygonOffset", config.generalEmulation.forcePolygonOffset, "If true, use polygon offset values specified below");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
@ -182,6 +186,8 @@ void Config_LoadConfig()
|
|||
config.generalEmulation.enableLOD = ConfigGetParamBool(g_configVideoGliden64, "EnableLOD");
|
||||
config.generalEmulation.enableHWLighting = ConfigGetParamBool(g_configVideoGliden64, "EnableHWLighting");
|
||||
config.generalEmulation.enableShadersStorage = ConfigGetParamBool(g_configVideoGliden64, "EnableShadersStorage");
|
||||
config.generalEmulation.forceGammaCorrection = ConfigGetParamBool(g_configVideoGliden64, "ForceGammaCorrection");
|
||||
config.generalEmulation.gammaCorrectionLevel = ConfigGetParamFloat(g_configVideoGliden64, "GammaCorrectionLevel");
|
||||
#ifdef ANDROID
|
||||
config.generalEmulation.forcePolygonOffset = ConfigGetParamBool(g_configVideoGliden64, "ForcePolygonOffset");
|
||||
config.generalEmulation.polygonOffsetFactor = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetFactor");
|
||||
|
|
Loading…
Reference in New Issue
Block a user