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-vignette

v1.1.0

Published

Vignette functions for glslify

Downloads

11

Readme

glsl-vignette

A GLSL function for computing vignette values from UV coordinates. Designed to work with glslify. To test out how the different vignettes look, a demo can be found here.

NPM

Usage

#pragma glslify: vignette = require(glsl-vignette/simple)

float vignette(vec2 uv, float radius, float smoothness)

Returns a value from 0 to 1 (black to white) corresponding to the intensity of the vignette at that UV coordinate.

uv - UV coordinates, expected to be in the range 0 to 1 on both axes.

radius - the vignette's radius in UV coordinates. A radius of 0.5 results in a vignette that will just touch the edges of the UV coordinate system.

smoothness - how quickly the vignette fades in. The vignette will start fading in at radius - smoothness and be fully opaque at radius + smoothness from the center. A value of zero results in a hard edge.

Example:

#pragma glslify: vignette = require(glsl-vignette)

uniform sampler2D tex;
varying vec2 uv;

void main() {
    float vignetteValue = vignette(uv, 0.5, 0.5);
    gl_FragColor = texture2D(tex, uv) * vignetteValue;
}

#pragma glslify: vignette = require(glsl-vignette/advanced)

float vignette(vec2 uv, vec2 size, float roundness, float smoothness)

Returns a value from 0 to 1 (black to white) corresponding to the intensity of the vignette at that UV coordinate. Allows for fine-grained control of the vignette shape and size.

uv - UV coordinates, expected to be in the range 0 to 1 on both axes.

size - the size of the vignette in the form (width / 2, height / 2). To make a vignette that starts fading in halfway between the center and edges of UV space you would pass in vec2(0.25, 0.25).

roundness - how round the vignette will be. A value from 0 to 1 where 1 is perfectly round (forming a circle or oval) and 0 is not round at all (forming a square or rectangle).

smoothness - how quickly the vignette fades in. The vignette will start fading in at the edge of the values provided by size, and will be fully faded in at vec2(size.x + smoothness, size.y + smoothness). A value of zero results in a hard edge.

Example:

#pragma glslify: vignette = require(glsl-vignette/advanced)

uniform sampler2D tex;
varying vec2 uv;

void main() {
    // Create a boxy vignette that is wider than it is tall
    float vignetteValue = vignette(uv, vec2(0.4, 0.3), 0.7, 0.1);
    gl_FragColor = texture2D(tex, uv) * vignetteValue;
}