mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2025-06-18 16:45:39 -04:00
17 lines
691 B
GLSL
17 lines
691 B
GLSL
uniform sampler2D Texture0;
|
|
uniform vec2 old_frame_offset;
|
|
const float inner_divisor = 128.0;
|
|
const float bit_crusher = 255.0 / inner_divisor;
|
|
|
|
vec4 get_nth_bit_component(vec4 colors) {
|
|
return floor(colors * bit_crusher) * inner_divisor;
|
|
}
|
|
|
|
void main() {
|
|
gl_FragColor = texture2D(Texture0, gl_TexCoord[0].xy);
|
|
vec4 OldFragColor = texture2D(Texture0, gl_TexCoord[0].xy + old_frame_offset);
|
|
vec4 actual_nth_bit_component = get_nth_bit_component(gl_FragColor);
|
|
vec4 old_nth_bit_component = get_nth_bit_component(OldFragColor);
|
|
gl_FragColor = clamp((floor(gl_FragColor * 255.0) - actual_nth_bit_component + ((actual_nth_bit_component + old_nth_bit_component) / 2.0)) / 255.0, 0.0, 1.0);
|
|
}
|