glsl-crosshatch-filter

a simple crosshatch effect for 2D scenes

Usage no npm install needed!

<script type="module">
  import glslCrosshatchFilter from 'https://cdn.skypack.dev/glsl-crosshatch-filter';
</script>

README

glsl-crosshatch-filter

stable

crosshatch

(glslbin demo)

A very basic crosshatch effect for post-processing, from geeks3d.com.

#pragma glslify: crosshatch = require('glsl-crosshatch-filter')

void main() {
  vec4 texColor = texture2D(sampler, uv);
  gl_FragColor.rgb = crosshatch(texColor.rgb);
  gl_FragColor.a = texColor.a;
}

Usage

NPM

vec3 crosshatch(vec3 texColor)

Applies a cross-hatch filter to the texColor RGB based on its luminance, using the thresholds 1.0, 0.75, 0.5, 0.3. Returns the new RGB color.

vec3 crosshatch(vec3 texColor, float t1, float t2, float t3, float t4)

Applies a cross-hatch filter to the texColor RGB based on its luminance, using the thresholds from t1 (brightest) to t4 (darkest). Returns the new RGB color.

License

MIT, see LICENSE.md for details.