Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

glsl-dither

Bayer matrix dithering in GLSL

Subscribe to updates I use glsl-dither


Statistics on glsl-dither

Number of watchers on Github 70
Number of open issues 0
Main language C
Open pull requests 0+
Closed pull requests 0+
Last commit about 5 years ago
Repo Created about 5 years ago
Repo Last Updated over 1 year ago
Size 888 KB
Homepage http://hughsk.io/...
Organization / Authorhughsk
Contributors1
Page Updated
Do you use glsl-dither? Leave a review!
View glsl-dither activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating glsl-dither for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

glsl-dither experimental

Bayer matrix dithering in GLSL. Originally sourced from @oosmoxiecode's C64 Shader Demo, which in turn was based on the implementation in this article.

glsl-dither

Usage

NPM

Each dithering function takes two arguments:

  • pos: the position of the current pixel you can use gl_FragCoord.xy directly in most cases.
  • brightness: the current pixel's brightness, either as a float or a vec3|vec4 color directly.

The returned value will be the same type as the brightness parameter.

dither8x8(vec2 pos, vec3|vec4|float brightness)

Dither using a 8x8 matrix.

dither4x4(vec2 pos, vec3|vec4|float brightness)

Dither using a 4x4 matrix.

dither2x2(vec2 pos, vec3|vec4|float brightness)

Dither using a 2x2 matrix.

precision mediump float;

uniform sampler2D uTexture;
varying vec2 vUv;

// Use any of the following:
#pragma glslify: dither = require(glsl-dither)
#pragma glslify: dither = require(glsl-dither/8x8)
#pragma glslify: dither = require(glsl-dither/4x4)
#pragma glslify: dither = require(glsl-dither/2x2)

void main() {
  vec4 color = texture2D(uTexture, vUv);
  gl_FragColor = dither(gl_FragCoord.xy, color);
}

License

MIT. See LICENSE.md for details.

glsl-dither list of languages used
Other projects in C