gpu: add toggle for color banding
Co-authored-by: Toocanzs <dupanzszs@gmail.com>
This commit is contained in:
@@ -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