mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Add enum DitheringMode for better readability.
Few fixes.
This commit is contained in:
parent
350d791596
commit
d621eb4d34
|
@ -258,9 +258,10 @@ u16 ColorBufferToRDRAM::_RGBAtoRGBA16(u32 _c, u32 x, u32 y) {
|
||||||
union RGBA c;
|
union RGBA c;
|
||||||
c.raw = _c;
|
c.raw = _c;
|
||||||
|
|
||||||
if(gDP.otherMode.colorDither <= 1 &&
|
if (gDP.otherMode.colorDither <= G_CD_BAYER // ordered grid dithering enabled in othermode
|
||||||
((config.frameBufferEmulation.nativeResFactor != 1 && config.generalEmulation.ditheringMode >= 3)
|
&& (config.frameBufferEmulation.nativeResFactor != 1 // image is not already dithered
|
||||||
|| config.generalEmulation.ditheringMode < 3)) {
|
|| config.generalEmulation.ditheringMode < Config::DitheringMode::dmFull))
|
||||||
|
{
|
||||||
s32 threshold = 0;
|
s32 threshold = 0;
|
||||||
|
|
||||||
switch(gDP.otherMode.colorDither){
|
switch(gDP.otherMode.colorDither){
|
||||||
|
|
|
@ -39,7 +39,7 @@ void Config::resetToDefaults()
|
||||||
|
|
||||||
generalEmulation.enableLOD = 1;
|
generalEmulation.enableLOD = 1;
|
||||||
generalEmulation.enableNoise = 1;
|
generalEmulation.enableNoise = 1;
|
||||||
generalEmulation.ditheringMode = 1;
|
generalEmulation.ditheringMode = DitheringMode::dmNoise;
|
||||||
generalEmulation.enableHWLighting = 0;
|
generalEmulation.enableHWLighting = 0;
|
||||||
generalEmulation.enableCustomSettings = 1;
|
generalEmulation.enableCustomSettings = 1;
|
||||||
generalEmulation.enableShadersStorage = 1;
|
generalEmulation.enableShadersStorage = 1;
|
||||||
|
|
|
@ -46,6 +46,14 @@ struct Config
|
||||||
tcForce
|
tcForce
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum DitheringMode {
|
||||||
|
dmDisable = 0,
|
||||||
|
dmNoise,
|
||||||
|
dmNoiseWithQuant,
|
||||||
|
dmFull,
|
||||||
|
dmFullWithQuant
|
||||||
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u32 enableNoise;
|
u32 enableNoise;
|
||||||
u32 ditheringMode;
|
u32 ditheringMode;
|
||||||
|
|
|
@ -13,7 +13,10 @@ namespace graphics {
|
||||||
vecOptions.push_back(config.texture.enableHalosRemoval);
|
vecOptions.push_back(config.texture.enableHalosRemoval);
|
||||||
vecOptions.push_back(config.generalEmulation.enableHWLighting);
|
vecOptions.push_back(config.generalEmulation.enableHWLighting);
|
||||||
vecOptions.push_back(config.generalEmulation.enableNoise);
|
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.generalEmulation.enableLOD);
|
||||||
vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare == Config::dcFast ? 1 : 0);
|
vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare == Config::dcFast ? 1 : 0);
|
||||||
vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare == Config::dcCompatible ? 1 : 0);
|
vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare == Config::dcCompatible ? 1 : 0);
|
||||||
|
|
|
@ -719,7 +719,7 @@ public:
|
||||||
ShaderCallDither(const opengl::GLInfo & _glinfo)
|
ShaderCallDither(const opengl::GLInfo & _glinfo)
|
||||||
{
|
{
|
||||||
if (!_glinfo.isGLES2) {
|
if (!_glinfo.isGLES2) {
|
||||||
if (config.generalEmulation.ditheringMode >= 1) {
|
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
|
||||||
m_part =
|
m_part =
|
||||||
" if (uColorDitherMode == 2) { \n"
|
" if (uColorDitherMode == 2) { \n"
|
||||||
" colorNoiseDither(snoiseRGB(), clampedColor.rgb); \n"
|
" colorNoiseDither(snoiseRGB(), clampedColor.rgb); \n"
|
||||||
|
@ -731,7 +731,7 @@ public:
|
||||||
" } \n"
|
" } \n"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if (config.generalEmulation.ditheringMode >= 3) {
|
if (config.generalEmulation.ditheringMode >= Config::DitheringMode::dmFull) {
|
||||||
m_part +=
|
m_part +=
|
||||||
// Try to keep dithering visible even at higher resolutions
|
// Try to keep dithering visible even at higher resolutions
|
||||||
" lowp float divider = 1.0 + step(3.0, uScreenScale.x); \n"
|
" lowp float divider = 1.0 + step(3.0, uScreenScale.x); \n"
|
||||||
|
@ -1042,7 +1042,7 @@ public:
|
||||||
ShaderFragmentHeaderDither(const opengl::GLInfo & _glinfo)
|
ShaderFragmentHeaderDither(const opengl::GLInfo & _glinfo)
|
||||||
{
|
{
|
||||||
if (!_glinfo.isGLES2) {
|
if (!_glinfo.isGLES2) {
|
||||||
if(config.generalEmulation.ditheringMode >= 1) {
|
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
|
||||||
m_part =
|
m_part =
|
||||||
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color);\n"
|
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color);\n"
|
||||||
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n"
|
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n"
|
||||||
|
@ -1631,7 +1631,7 @@ public:
|
||||||
" return 0.5; \n"
|
" return 0.5; \n"
|
||||||
"} \n"
|
"} \n"
|
||||||
;
|
;
|
||||||
if (config.generalEmulation.ditheringMode >= 1) {
|
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
|
||||||
m_part +=
|
m_part +=
|
||||||
"uniform sampler2D uTexNoise; \n"
|
"uniform sampler2D uTexNoise; \n"
|
||||||
;
|
;
|
||||||
|
@ -1667,7 +1667,7 @@ public:
|
||||||
ShaderDither(const opengl::GLInfo & _glinfo)
|
ShaderDither(const opengl::GLInfo & _glinfo)
|
||||||
{
|
{
|
||||||
if (!_glinfo.isGLES2) {
|
if (!_glinfo.isGLES2) {
|
||||||
if( config.generalEmulation.ditheringMode >= 1 ) {
|
if (config.generalEmulation.ditheringMode != Config::DitheringMode::dmDisable) {
|
||||||
m_part =
|
m_part =
|
||||||
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color)\n"
|
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color)\n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
|
@ -1708,7 +1708,8 @@ public:
|
||||||
" return texture(uTexNoise,coord).r; \n"
|
" return texture(uTexNoise,coord).r; \n"
|
||||||
"} \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 +=
|
m_part +=
|
||||||
"void quantizeRGB(inout lowp vec3 _color)\n"
|
"void quantizeRGB(inout lowp vec3 _color)\n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
|
|
|
@ -1042,8 +1042,10 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
|
||||||
const CombinerKey & _key,
|
const CombinerKey & _key,
|
||||||
UniformGroups & _uniforms)
|
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));
|
_uniforms.emplace_back(new UNoiseTex(_program));
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_glInfo.isGLES2) {
|
if (!m_glInfo.isGLES2) {
|
||||||
_uniforms.emplace_back(new UDepthTex(_program));
|
_uniforms.emplace_back(new UDepthTex(_program));
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace glsl {
|
||||||
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
|
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
|
||||||
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
|
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
|
||||||
|
|
||||||
const u32 m_formatVersion = 0x2AU;
|
const u32 m_formatVersion = 0x2BU;
|
||||||
const u32 m_keysFormatVersion = 0x04;
|
const u32 m_keysFormatVersion = 0x04;
|
||||||
const opengl::GLInfo & m_glinfo;
|
const opengl::GLInfo & m_glinfo;
|
||||||
opengl::CachedUseProgram * m_useProgram;
|
opengl::CachedUseProgram * m_useProgram;
|
||||||
|
|
|
@ -106,8 +106,10 @@ void NoiseTexture::_fillTextureData()
|
||||||
|
|
||||||
void NoiseTexture::init()
|
void NoiseTexture::init()
|
||||||
{
|
{
|
||||||
if (config.generalEmulation.enableNoise == 0 && config.generalEmulation.ditheringMode == 0)
|
if (config.generalEmulation.enableNoise == 0 &&
|
||||||
|
config.generalEmulation.ditheringMode == Config::DitheringMode::dmDisable) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_texData[0].empty())
|
if (m_texData[0].empty())
|
||||||
_fillTextureData();
|
_fillTextureData();
|
||||||
|
@ -161,7 +163,7 @@ void NoiseTexture::destroy()
|
||||||
|
|
||||||
void NoiseTexture::update()
|
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;
|
return;
|
||||||
|
|
||||||
u32 rand_value(0U);
|
u32 rand_value(0U);
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool Config_SetDefault()
|
||||||
//#Emulation Settings
|
//#Emulation Settings
|
||||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNoise", config.generalEmulation.enableNoise, "Enable color noise emulation.");
|
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNoise", config.generalEmulation.enableNoise, "Enable color noise emulation.");
|
||||||
assert(res == M64ERR_SUCCESS);
|
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);
|
assert(res == M64ERR_SUCCESS);
|
||||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLOD", config.generalEmulation.enableLOD, "Enable LOD emulation.");
|
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLOD", config.generalEmulation.enableLOD, "Enable LOD emulation.");
|
||||||
assert(res == M64ERR_SUCCESS);
|
assert(res == M64ERR_SUCCESS);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user