mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Some dithering shaders refactoring.
This commit is contained in:
parent
897fc35d51
commit
d7e3b4c84b
|
@ -723,12 +723,10 @@ public:
|
||||||
|
|
||||||
m_part =
|
m_part =
|
||||||
" if (uColorDitherMode == 2) { \n"
|
" if (uColorDitherMode == 2) { \n"
|
||||||
" colorNoiseDither(snoiseRGB(), clampedColor.rgb); \n"
|
" colorDither(snoiseRGB(), clampedColor.rgb); \n"
|
||||||
" quantizeRGB(clampedColor.rgb); \n"
|
|
||||||
" } \n"
|
" } \n"
|
||||||
" if (uAlphaDitherMode == 2) { \n"
|
" if (uAlphaDitherMode == 2) { \n"
|
||||||
" alphaNoiseDither(snoiseA(), clampedColor.a); \n"
|
" alphaDither(snoiseA(), clampedColor.a); \n"
|
||||||
" quantizeA(clampedColor.a); \n"
|
|
||||||
" } \n"
|
" } \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -752,9 +750,7 @@ public:
|
||||||
" \n"
|
" \n"
|
||||||
" if (uColorDitherMode < 2) { \n"
|
" if (uColorDitherMode < 2) { \n"
|
||||||
" lowp float threshold = mix(mSquareThreshold,bayerThreshold,float(uColorDitherMode));\n"
|
" lowp float threshold = mix(mSquareThreshold,bayerThreshold,float(uColorDitherMode));\n"
|
||||||
" colorNoiseDither(vec3(threshold), clampedColor.rgb); \n"
|
" colorDither(vec3(threshold), clampedColor.rgb); \n"
|
||||||
// 16 Bit quantization
|
|
||||||
" quantizeRGB(clampedColor.rgb); \n"
|
|
||||||
" } \n"
|
" } \n"
|
||||||
" if (uAlphaDitherMode < 2) { \n"
|
" if (uAlphaDitherMode < 2) { \n"
|
||||||
" lowp float thresholdPattern = mix(mSquareThreshold,bayerThreshold,clamp(float(uColorDitherMode),0.0,1.0));\n"
|
" lowp float thresholdPattern = mix(mSquareThreshold,bayerThreshold,clamp(float(uColorDitherMode),0.0,1.0));\n"
|
||||||
|
@ -766,9 +762,7 @@ public:
|
||||||
" thresholdNotPattern = mix(thresholdNotPattern,mSquareThreshold,clamp(float(uColorDitherMode - 2),0.0,1.0));\n" // uColorDitherMode = 3
|
" thresholdNotPattern = mix(thresholdNotPattern,mSquareThreshold,clamp(float(uColorDitherMode - 2),0.0,1.0));\n" // uColorDitherMode = 3
|
||||||
" \n"
|
" \n"
|
||||||
" lowp float threshold = mix(thresholdNotPattern, thresholdPattern,float(uAlphaDitherMode));\n"
|
" lowp float threshold = mix(thresholdNotPattern, thresholdPattern,float(uAlphaDitherMode));\n"
|
||||||
" alphaNoiseDither(threshold, clampedColor.a); \n"
|
" alphaDither(threshold, clampedColor.a); \n"
|
||||||
// 16 Bit quantization
|
|
||||||
" quantizeA(clampedColor.a); \n"
|
|
||||||
" } \n"
|
" } \n"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -1046,10 +1040,8 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_part =
|
m_part =
|
||||||
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color);\n"
|
"void colorDither(in lowp vec3 _threshold, inout lowp vec3 _color);\n"
|
||||||
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n"
|
"void alphaDither(in lowp float _threshold, inout lowp float _alpha);\n"
|
||||||
"void quantizeRGB(inout lowp vec3 _color);\n"
|
|
||||||
"void quantizeA(inout lowp float _alpha);\n"
|
|
||||||
"lowp vec3 snoiseRGB();\n"
|
"lowp vec3 snoiseRGB();\n"
|
||||||
"lowp float snoiseA();\n"
|
"lowp float snoiseA();\n"
|
||||||
;
|
;
|
||||||
|
@ -1654,16 +1646,36 @@ public:
|
||||||
if (_glinfo.isGLES2)
|
if (_glinfo.isGLES2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (config.generalEmulation.enableDitheringQuantization != 0) {
|
||||||
m_part =
|
m_part =
|
||||||
"void colorNoiseDither(in lowp vec3 _noise, inout lowp vec3 _color)\n"
|
"void quantizeRGB(inout lowp vec3 _color) \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" mediump vec3 threshold = 7.0 / 255.0 * (_noise - 0.5);\n"
|
" _color.rgb = round(_color.rgb * 32.0)/32.0; \n"
|
||||||
" _color = clamp(_color + threshold,0.0,1.0); \n"
|
|
||||||
"} \n"
|
"} \n"
|
||||||
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha)\n"
|
"void quantizeA(inout lowp float _alpha) \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" mediump float threshold = 7.0 / 255.0 * (_noise - 0.5);\n"
|
" _alpha = round(_alpha * 32.0)/32.0; \n"
|
||||||
|
"} \n"
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
m_part =
|
||||||
|
"void quantizeRGB(inout lowp vec3 _color){}\n"
|
||||||
|
"void quantizeA(inout lowp float _alpha){}\n"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_part +=
|
||||||
|
"void colorDither(in lowp vec3 _noise, inout lowp vec3 _color)\n"
|
||||||
|
"{ \n"
|
||||||
|
" mediump vec3 threshold = 7.0 / 255.0 * (_noise - 0.5); \n"
|
||||||
|
" _color = clamp(_color + threshold,0.0,1.0); \n"
|
||||||
|
" quantizeRGB(_color); \n"
|
||||||
|
"} \n"
|
||||||
|
"void alphaDither(in lowp float _noise, inout lowp float _alpha)\n"
|
||||||
|
"{ \n"
|
||||||
|
" mediump float threshold = 7.0 / 255.0 * (_noise - 0.5); \n"
|
||||||
" _alpha = clamp(_alpha + threshold,0.0,1.0); \n"
|
" _alpha = clamp(_alpha + threshold,0.0,1.0); \n"
|
||||||
|
" quantizeA(_alpha); \n"
|
||||||
"} \n"
|
"} \n"
|
||||||
"lowp vec3 snoiseRGB() \n"
|
"lowp vec3 snoiseRGB() \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
|
@ -1694,24 +1706,6 @@ public:
|
||||||
" return texture(uTexNoise,coord).r; \n"
|
" return texture(uTexNoise,coord).r; \n"
|
||||||
"} \n"
|
"} \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
if (config.generalEmulation.enableDitheringQuantization != 0) {
|
|
||||||
m_part +=
|
|
||||||
"void quantizeRGB(inout lowp vec3 _color) \n"
|
|
||||||
"{ \n"
|
|
||||||
" _color.rgb = round(_color.rgb * 32.0)/32.0; \n"
|
|
||||||
"} \n"
|
|
||||||
"void quantizeA(inout lowp float _alpha) \n"
|
|
||||||
"{ \n"
|
|
||||||
" _alpha = round(_alpha * 32.0)/32.0; \n"
|
|
||||||
"} \n"
|
|
||||||
;
|
|
||||||
} else {
|
|
||||||
m_part +=
|
|
||||||
"void quantizeRGB(inout lowp vec3 _color){}\n"
|
|
||||||
"void quantizeA(inout lowp float _alpha){}\n"
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user