1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Add enum DitheringMode for better readability.

Few fixes.
This commit is contained in:
Sergey Lipskiy 2020-03-12 17:29:53 +07:00
parent 350d791596
commit d621eb4d34
9 changed files with 33 additions and 16 deletions

View File

@ -258,9 +258,10 @@ u16 ColorBufferToRDRAM::_RGBAtoRGBA16(u32 _c, u32 x, u32 y) {
union RGBA c;
c.raw = _c;
if(gDP.otherMode.colorDither <= 1 &&
((config.frameBufferEmulation.nativeResFactor != 1 && config.generalEmulation.ditheringMode >= 3)
|| config.generalEmulation.ditheringMode < 3)) {
if (gDP.otherMode.colorDither <= G_CD_BAYER // ordered grid dithering enabled in othermode
&& (config.frameBufferEmulation.nativeResFactor != 1 // image is not already dithered
|| config.generalEmulation.ditheringMode < Config::DitheringMode::dmFull))
{
s32 threshold = 0;
switch(gDP.otherMode.colorDither){

View File

@ -39,7 +39,7 @@ void Config::resetToDefaults()
generalEmulation.enableLOD = 1;
generalEmulation.enableNoise = 1;
generalEmulation.ditheringMode = 1;
generalEmulation.ditheringMode = DitheringMode::dmNoise;
generalEmulation.enableHWLighting = 0;
generalEmulation.enableCustomSettings = 1;
generalEmulation.enableShadersStorage = 1;

View File

@ -46,6 +46,14 @@ struct Config
tcForce
};
enum DitheringMode {
dmDisable = 0,
dmNoise,
dmNoiseWithQuant,
dmFull,
dmFullWithQuant
};
struct {
u32 enableNoise;
u32 ditheringMode;

View File

@ -13,7 +13,10 @@ namespace graphics {
vecOptions.push_back(config.texture.enableHalosRemoval);
vecOptions.push_back(config.generalEmulation.enableHWLighting);
vecOptions.push_back(config.generalEmulation.enableNoise);
vecOptions.push_back(config.generalEmulation.ditheringMode);
vecOptions.push_back(config.generalEmulation.ditheringMode == Config::DitheringMode::dmNoise ? 1 : 0);
vecOptions.push_back(config.generalEmulation.ditheringMode == Config::DitheringMode::dmNoiseWithQuant ? 1 : 0);
vecOptions.push_back(config.generalEmulation.ditheringMode == Config::DitheringMode::dmFull ? 1 : 0);
vecOptions.push_back(config.generalEmulation.ditheringMode == Config::DitheringMode::dmFullWithQuant ? 1 : 0);
vecOptions.push_back(config.generalEmulation.enableLOD);
vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare == Config::dcFast ? 1 : 0);
vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare == Config::dcCompatible ? 1 : 0);

View File

@ -719,7 +719,7 @@ public:
ShaderCallDither(const opengl::GLInfo & _glinfo)
{
if (!_glinfo.isGLES2) {
if (config.generalEmulation.ditheringMode >= 1) {
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
m_part =
" if (uColorDitherMode == 2) { \n"
" colorNoiseDither(snoiseRGB(), clampedColor.rgb); \n"
@ -731,7 +731,7 @@ public:
" } \n"
;
}
if (config.generalEmulation.ditheringMode >= 3) {
if (config.generalEmulation.ditheringMode >= Config::DitheringMode::dmFull) {
m_part +=
// Try to keep dithering visible even at higher resolutions
" lowp float divider = 1.0 + step(3.0, uScreenScale.x); \n"
@ -1042,7 +1042,7 @@ public:
ShaderFragmentHeaderDither(const opengl::GLInfo & _glinfo)
{
if (!_glinfo.isGLES2) {
if(config.generalEmulation.ditheringMode >= 1) {
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
m_part =
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color);\n"
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n"
@ -1631,7 +1631,7 @@ public:
" return 0.5; \n"
"} \n"
;
if (config.generalEmulation.ditheringMode >= 1) {
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
m_part +=
"uniform sampler2D uTexNoise; \n"
;
@ -1667,7 +1667,7 @@ public:
ShaderDither(const opengl::GLInfo & _glinfo)
{
if (!_glinfo.isGLES2) {
if( config.generalEmulation.ditheringMode >= 1 ) {
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
m_part =
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color)\n"
"{ \n"
@ -1708,7 +1708,8 @@ public:
" return texture(uTexNoise,coord).r; \n"
"} \n"
;
if ( config.generalEmulation.ditheringMode == 2 || config.generalEmulation.ditheringMode == 4 ) {
if (config.generalEmulation.ditheringMode == Config::DitheringMode::dmNoiseWithQuant ||
config.generalEmulation.ditheringMode == Config::DitheringMode::dmFullWithQuant) {
m_part +=
"void quantizeRGB(inout lowp vec3 _color)\n"
"{ \n"

View File

@ -1042,8 +1042,10 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
const CombinerKey & _key,
UniformGroups & _uniforms)
{
if (config.generalEmulation.enableNoise != 0 || config.generalEmulation.ditheringMode > 0)
if (config.generalEmulation.enableNoise != 0 ||
config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
_uniforms.emplace_back(new UNoiseTex(_program));
}
if (!m_glInfo.isGLES2) {
_uniforms.emplace_back(new UDepthTex(_program));

View File

@ -20,7 +20,7 @@ namespace glsl {
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
const u32 m_formatVersion = 0x2AU;
const u32 m_formatVersion = 0x2BU;
const u32 m_keysFormatVersion = 0x04;
const opengl::GLInfo & m_glinfo;
opengl::CachedUseProgram * m_useProgram;

View File

@ -106,8 +106,10 @@ void NoiseTexture::_fillTextureData()
void NoiseTexture::init()
{
if (config.generalEmulation.enableNoise == 0 && config.generalEmulation.ditheringMode == 0)
if (config.generalEmulation.enableNoise == 0 &&
config.generalEmulation.ditheringMode == Config::DitheringMode::dmDisable) {
return;
}
if (m_texData[0].empty())
_fillTextureData();
@ -161,7 +163,7 @@ void NoiseTexture::destroy()
void NoiseTexture::update()
{
if (m_DList == dwnd().getBuffersSwapCount() || (config.generalEmulation.enableNoise == 0 && config.generalEmulation.ditheringMode == 0))
if (m_texData[0].empty() || m_DList == dwnd().getBuffersSwapCount())
return;
u32 rand_value(0U);

View File

@ -69,7 +69,7 @@ bool Config_SetDefault()
//#Emulation Settings
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNoise", config.generalEmulation.enableNoise, "Enable color noise emulation.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultInt(g_configVideoGliden64, "DitheringMode", config.generalEmulation.ditheringMode, "Dithering mode. (0=disable, 1=only noise dithering (default), 2=noise dithering with 16bit quantization,3=noise and ordered grid dithering, 4=dithering with 16bit quantization)");
res = ConfigSetDefaultInt(g_configVideoGliden64, "DitheringMode", config.generalEmulation.ditheringMode, "Dithering mode. (0=disable, 1=noise dithering (default), 2=noise dithering with 5bit quantization, 3=full dithering, 4=full dithering with 5bit quantization)");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLOD", config.generalEmulation.enableLOD, "Enable LOD emulation.");
assert(res == M64ERR_SUCCESS);