npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

glsl-lut

v1.1.3

Published

lookup table color transforms for glslify

Downloads

74

Readme

glsl-lut unstable

ABTest

Demo here

Use a texture as a lookup table to apply color transforms in a shader. Original implementation from GPUImage, see here. For more details on the concept, see here.

This is geared towards OpenGL ES, so no 3D textures are used, and the lookup table is 512x512 (using every 4th color).

Usage

NPM

First, grab the original (un-altered) lookup table from the image folder, or with the CLI.

Then you can apply any filters with Photoshop or at runtime to the lookup table image. These can be things like curves, levels, grayscale, etc. Each transform must be independent of surrounding pixels (no blurs, median, etc).

In your shader, sample the lookup texture (uLookup below) and pass the original vec4 color to the transform method.


uniform sampler2D uLookup;

#pragma glslify: transform = require('glsl-lut')

...
    vec4 original = texture2D(uTexture, vUv);
	gl_FragColor = transform(original, uLookup);

Important: Make sure to set TEXTURE_MIN_FILTER and TEXTURE_MAG_FILTER to NEAREST on the lookup table texture.

Flipped Y Lookup

Depending on your environment, the Y texture coordinate may need to be inverted during the lookup to get the correct color output. If your colours look messed up, this is most likely the case. Require the inverted function like so:

#pragma glslify: transform = require(glsl-lut/flipY)

Defines

Requiring glsl-lut/flipY is the same as making a define for LUT_FLIP_Y. You can also define LUT_NO_CLAMP before requiring the function and the incoming texture color will not have a clamp(c, 0.0, 1.0) operation applied. This may be useful if you plan to take advantage of hardware texture wrapping.

CLI

You can also use this tool as a command-line application to create a new (default) lookup table PNG image.

npm install -g glsl-lut

Then:

glsl-lut > images/lut.png

LUT Generation

You can also generate the LUT in software, for example see example/generate.mjs (requires [email protected] or higher) which generates a new LUT and writes the PNG to disk. This gives you the option to create specific filtering, for example "desaturate all colours some distance from a target hue in OKLAB color space," which is difficult to achieve with just Photoshop colour adjustments.

See this file for further details on generating a lookup table programmatically.

License

MIT, see LICENSE.md for details.