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

v2.0.0

Published

SMAA (Enhanced Subpixel Morphological Antialiasing) post-processing; WebGL (OpenGL ES 2.0) implementation with no fluff.

Downloads

49

Readme

glsl-smaa

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

SMAA (Enhanced Subpixel Morphological Antialiasing) post-processing; WebGL (OpenGL ES 2.0) implementation with no fluff. All credit goes to the incredible work here (iryoku) and there (beakbeak).

paypal coinbase twitter

Installation

npm install glsl-smaa

Usage

Three passes are required to apply the effect:

             |input|------------------·
                v                     |
      [ SMAA*EdgeDetection ]          |
                v                     |
            |edgesTex|                |
                v                     |
[ SMAABlendingWeightCalculation ]     |
                v                     |
            |blendTex|                |
                v                     |
  [ SMAANeighborhoodBlending ] <------·
                v
             |output|

You would typically set this up as part of a post-processing chain with FBOs.

See the demo and its source for an example with REGL.

Attributes

Attributes required for all vertex shaders:

| Name | Type | Description | | ------------- | ---- | ---------------- | | aPosition | vec2 | Screen vertices. |

Uniforms and defines

Uniforms required for all shaders:

| Name | Type | Description | | -------------- | ---- | --------------------- | | resolution | vec2 | The framebuffer size. |

#define can be preprended to the shaders to overwrite default settings. Typically:

const frag = `#define SMAA_PRESET_HIGH
${PRESETS}
${SMAA_WEIGHTS_FRAG}
`;

edges.vert

N/A

edges-<edge-detection-method>.frag

You can use one of the 3 following edge detection method:

  • Depth: the fastest but it may miss some edges.

  • Luma: more expensive than depth edge detection, but catches visible edges that depth edge detection can miss.

  • Color: the most expensive one but catches chroma-only edges.

Defines:

#define SMAA_THRESHOLD 0.1
#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0

| Name | Default [Range] | Description | | ----------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | SMAA_THRESHOLD | 0.1 [0, 0.5] | Specifies the threshold or sensitivity to edges. Lowering this value you will be able to detect more edges at the expense of performance. Range: [0, 0.5]. 0.1 is a reasonable value, and allows to catch most visible edges. 0.05 is a rather overkill value, that allows to catch 'em all. | | SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR | 2.0 | If there is an neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times bigger contrast than current edge, current edge will be discarded. This allows to eliminate spurious crossing edges, and is based on the fact that, if there is too much contrast in a direction, that will hide perceptually contrast in the other neighbors. |

Uniforms:

luma-edges.frag

| Name | Type | Description | | ------------ | --------- | ---------------------------- | | colorTex | sampler2D | The input color framebuffer. |

color-edges.frag

| Name | Type | Description | | ------------ | --------- | ---------------------------- | | colorTex | sampler2D | The input color framebuffer. |

depth-edges.frag

| Name | Type | Description | | ------------ | --------- | ---------------------------- | | depthTex | sampler2D | The input depth framebuffer. |


smaa-weights.(vert|frag)

Defines from presets.glsl:

# Use presets:
#define SMAA_PRESET_LOW
#define SMAA_PRESET_MEDIUM
#define SMAA_PRESET_HIGH
#define SMAA_PRESET_ULTRA

# or individually setting:
#define SMAA_THRESHOLD 0.1
#define SMAA_MAX_SEARCH_STEPS 16
#define SMAA_MAX_SEARCH_STEPS_DIAG 8
#define SMAA_CORNER_ROUNDING 25

# and optionally disable diagonal and corner detection:
#define SMAA_DISABLE_DIAG_DETECTION
#define SMAA_DISABLE_CORNER_DETECTION

| Name | Default [Range] | Description | | ------------------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | SMAA_THRESHOLD | 0.1 [0, 0.5] | Should the same as for the edge pass. | | SMAA_MAX_SEARCH_STEPS | 16 [0, 112] | Specifies the maximum steps performed in the horizontal/vertical pattern searches, at each side of the pixel. In number of pixels, it's actually the double. So the maximum line length perfectly handled by, for example 16, is 64 (by perfectly, we meant that longer lines won't look as good, but still antialiased. | | SMAA_MAX_SEARCH_STEPS_DIAG | 8 [0, 20] | Specifies the maximum steps performed in the diagonal pattern searches, at each side of the pixel. In this case we jump one pixel at time, instead of two. | | SMAA_CORNER_ROUNDING | 25 [0, 100] | Specifies how much sharp corners will be rounded. |

Uniforms:

| Name | Type | Description | | ------------- | --------- | --------------------------------------------------------------- | | edgesTex | sampler2D | The framebuffer with edges. | | areaTex | sampler2D | Precalculated textures loadable from textures.js base64 urls. | | searchTex | sampler2D | Precalculated textures loadable from textures.js base64 urls. |


smaa-blend.(vert|frag)

| Name | Type | Description | | ------------ | --------- | ----------------------------- | | colorTex | sampler2D | The input color framebuffer. | | blendTex | sampler2D | The framebuffer with weights. |


License

Copyright (C) 2013 Jorge Jimenez ([email protected]) Copyright (C) 2013 Jose I. Echevarria ([email protected]) Copyright (C) 2013 Belen Masia ([email protected]) Copyright (C) 2013 Fernando Navarro ([email protected]) Copyright (C) 2013 Diego Gutierrez ([email protected])

MIT. See license file.