gpu: add toggle for color banding
Co-authored-by: Toocanzs <dupanzszs@gmail.com>
This commit is contained in:
@@ -220,6 +220,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
private int uniBlockSmall;
|
||||
private int uniBlockLarge;
|
||||
private int uniBlockMain;
|
||||
private int uniSmoothBanding;
|
||||
|
||||
@Override
|
||||
protected void startUp()
|
||||
@@ -469,6 +470,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
{
|
||||
uniProjectionMatrix = gl.glGetUniformLocation(glProgram, "projectionMatrix");
|
||||
uniBrightness = gl.glGetUniformLocation(glProgram, "brightness");
|
||||
uniSmoothBanding = gl.glGetUniformLocation(glProgram, "smoothBanding");
|
||||
|
||||
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
|
||||
uniTextures = gl.glGetUniformLocation(glProgram, "textures");
|
||||
@@ -937,6 +939,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
|
||||
// Brightness happens to also be stored in the texture provider, so we use that
|
||||
gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness());
|
||||
gl.glUniform1f(uniSmoothBanding, config.smoothBanding() ? 0f : 1f);
|
||||
|
||||
for (int id = 0; id < textures.length; ++id)
|
||||
{
|
||||
|
||||
@@ -34,10 +34,22 @@ public interface GpuPluginConfig extends Config
|
||||
@ConfigItem(
|
||||
keyName = "drawDistance",
|
||||
name = "Draw Distance",
|
||||
description = "Draw distance"
|
||||
description = "Draw distance",
|
||||
position = 1
|
||||
)
|
||||
default int drawDistance()
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "smoothBanding",
|
||||
name = "Remove Color Banding",
|
||||
description = "Smooths out the color banding that is present in the CPU renderer",
|
||||
position = 2
|
||||
)
|
||||
default boolean smoothBanding()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,23 @@
|
||||
uniform sampler2DArray textures;
|
||||
uniform vec2 textureOffsets[64];
|
||||
uniform float brightness;
|
||||
uniform float smoothBanding;
|
||||
|
||||
in vec4 Color;
|
||||
in float fHsl;
|
||||
in vec4 fUv;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
#include hsl_to_rgb.glsl
|
||||
|
||||
void main() {
|
||||
float n = fUv.x;
|
||||
|
||||
int hsl = int(fHsl);
|
||||
vec3 rgb = hslToRgb(hsl) * smoothBanding + Color.rgb * (1.f - smoothBanding);
|
||||
vec4 smoothColor = vec4(rgb, Color.a);
|
||||
|
||||
if (n > 0.0) {
|
||||
n -= 1.0;
|
||||
int textureIdx = int(n);
|
||||
@@ -45,8 +54,8 @@ void main() {
|
||||
vec4 textureColor = texture(textures, vec3(animatedUv, n));
|
||||
vec4 textureColorBrightness = pow(textureColor, vec4(brightness, brightness, brightness, 1.0f));
|
||||
|
||||
FragColor = textureColorBrightness * Color;
|
||||
FragColor = textureColorBrightness * smoothColor;
|
||||
} else {
|
||||
FragColor = Color;
|
||||
FragColor = smoothColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,11 @@ uniform mat4 projectionMatrix;
|
||||
|
||||
in ivec3 vPosition[];
|
||||
in vec4 vColor[];
|
||||
in float vHsl[];
|
||||
in vec4 vUv[];
|
||||
|
||||
out vec4 Color;
|
||||
out float fHsl;
|
||||
out vec4 fUv;
|
||||
|
||||
#include to_screen.glsl
|
||||
@@ -67,18 +69,21 @@ void main() {
|
||||
|
||||
vec4 tmp = vec4(screenA.xyz, 1.0);
|
||||
Color = vColor[0];
|
||||
fHsl = vHsl[0];
|
||||
fUv = vUv[0];
|
||||
gl_Position = projectionMatrix * tmp;
|
||||
EmitVertex();
|
||||
|
||||
tmp = vec4(screenB.xyz, 1.0);
|
||||
Color = vColor[1];
|
||||
fHsl = vHsl[1];
|
||||
fUv = vUv[1];
|
||||
gl_Position = projectionMatrix * tmp;
|
||||
EmitVertex();
|
||||
|
||||
tmp = vec4(screenC.xyz, 1.0);
|
||||
Color = vColor[2];
|
||||
fHsl = vHsl[2];
|
||||
fUv = vUv[2];
|
||||
gl_Position = projectionMatrix * tmp;
|
||||
EmitVertex();
|
||||
|
||||
@@ -32,6 +32,7 @@ uniform float brightness;
|
||||
|
||||
out ivec3 vPosition;
|
||||
out vec4 vColor;
|
||||
out float vHsl;
|
||||
out vec4 vUv;
|
||||
|
||||
#include hsl_to_rgb.glsl
|
||||
@@ -47,5 +48,6 @@ void main()
|
||||
|
||||
vPosition = vertex;
|
||||
vColor = vec4(rgb, 1.f - a);
|
||||
vHsl = float(hsl);
|
||||
vUv = uv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user