All Projects → mattdesl → Glsl Fxaa

mattdesl / Glsl Fxaa

Licence: mit
FXAA implementation for glslify in WebGL

Labels

Projects that are alternatives of or similar to Glsl Fxaa

Godot 3 2d Crt Shader
A 2D shader for Godot 3 simulating a CRT
Stars: ✭ 183 (-18.67%)
Mutual labels:  glsl
Pixelplanets
Stars: ✭ 194 (-13.78%)
Mutual labels:  glsl
Unity
Unity Resource Pack [Vanilla Minecraft Only]
Stars: ✭ 213 (-5.33%)
Mutual labels:  glsl
Godot Psx Shaders
PSOne visuals through shaders in Godot 3.1
Stars: ✭ 185 (-17.78%)
Mutual labels:  glsl
Mpv Prescalers
prescalers for mpv, as user shaders
Stars: ✭ 191 (-15.11%)
Mutual labels:  glsl
Glmark2
glmark2 is an OpenGL 2.0 and ES 2.0 benchmark
Stars: ✭ 199 (-11.56%)
Mutual labels:  glsl
Glsl Noise
webgl-noise shaders ported to work with glslify
Stars: ✭ 179 (-20.44%)
Mutual labels:  glsl
Gamestarter
🎮 Retrogaming kodi add-on repository for LibreELEC
Stars: ✭ 222 (-1.33%)
Mutual labels:  glsl
Possumwood
Possumwood is a graph-based procedural authoring tool, in concept not dissimilar to popular CG packages like Houdini, Blender or Maya. It is intended to serve as a sandbox for computer graphics algorithms and libraries, providing a user-friendly and coding-free UI for libraries that would otherwise be inaccessible for an average user.
Stars: ✭ 197 (-12.44%)
Mutual labels:  glsl
Gl React
gl-react – React library to write and compose WebGL shaders
Stars: ✭ 2,536 (+1027.11%)
Mutual labels:  glsl
Anime4k
A High-Quality Real Time Upscaler for Anime Video
Stars: ✭ 14,083 (+6159.11%)
Mutual labels:  glsl
Nomansscanner
A Depth-based Image Effect recreating the Topographic Scanner of No Man's Sky.
Stars: ✭ 191 (-15.11%)
Mutual labels:  glsl
Glslviewer
Console-based GLSL Sandbox for 2D/3D shaders shaders
Stars: ✭ 2,834 (+1159.56%)
Mutual labels:  glsl
Vim Glsl
Vim runtime files for OpenGL Shading Language
Stars: ✭ 184 (-18.22%)
Mutual labels:  glsl
Bsnes Hd
bsnes fork that adds HD video features
Stars: ✭ 216 (-4%)
Mutual labels:  glsl
Varjo
Lisp to GLSL Language Translator
Stars: ✭ 181 (-19.56%)
Mutual labels:  glsl
Inviwo
Inviwo - Interactive Visualization Workshop
Stars: ✭ 199 (-11.56%)
Mutual labels:  glsl
Frontend Boilerplate
An ES20XX starter with common frontend tasks using Webpack 4 as module bundler and npm scripts as task runner.
Stars: ✭ 224 (-0.44%)
Mutual labels:  glsl
Unitythirdpersontutorial
Sample project showing third person camera behavior and Mecanim animations
Stars: ✭ 220 (-2.22%)
Mutual labels:  glsl
Magicshader
🔮 Tiny helper for three.js to debug and write shaders
Stars: ✭ 205 (-8.89%)
Mutual labels:  glsl

glsl-fxaa

unstable

(demo) - (source)

A WebGL implementation of Fast Approximate Anti-Aliasing (FXAA v2). This is a screen-space technique. The code was originally from Geeks3D.com and cleaned up by Armin Ronacher for WebGL.

FXAA is particularly useful in WebGL since most browsers do not currently support MSAA, and even those that do (e.g. Chrome) will not support it outside of the main frame buffer (which is common when doing post-processing effects like color grading).

Usage

NPM

vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution)

Returns the anti-aliased color from your frame texture.

Inside GLSL fragment shader:

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

uniform vec2 resolution;

void main() {
	vec2 fragCoord = v_texCoord0 * resolution;
	gl_FragColor = fxaa(u_texture0, fragCoord, resolution);
}

optimizing

If you plan on using FXAA instead of native anti-aliasing (i.e. for post-processed 3D scenes), disabling native AA when creating your WebGL context should give you a performance boost in some browsers.

This FXAA shader uses 9 dependent texture reads. For various mobile GPUs (particularly iOS), we can optimize the shader by making 5 of the texture2D calls non-dependent. To do this, the coordinates have to be computed in the vertex shader and passed along:

vert shader:

varying vec2 v_rgbNW;
varying vec2 v_rgbNE;
varying vec2 v_rgbSW;
varying vec2 v_rgbSE;
varying vec2 v_rgbM;

uniform vec2 resolution;

#pragma glslify: texcoords = require(glsl-fxaa/texcoords.glsl)

void main() {
   //compute the texture coords and store them in varyings
   vec2 fragCoord = vTexCoord0 * resolution;
   texcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);

   //.. rest of shader
}

frag shader:

varying vec2 v_rgbNW;
varying vec2 v_rgbNE;
varying vec2 v_rgbSW;
varying vec2 v_rgbSE;
varying vec2 v_rgbM;

uniform vec2 resolution;

#pragma glslify: fxaa = require(glsl-fxaa/fxaa.glsl)

void main() {
    //can also use gl_FragCoord.xy
    vec2 fragCoord = vTexCoord0 * resolution; 

	gl_FragColor = fxaa(u_texture0, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
}

In most cases, you should just use the simplest index.glsl use case demonstrated earlier.

demo

See the demo folder. To run:

# clone repo
git clone https://github.com/mattdesl/glsl-fxaa.git

# install deps
npm install

# run local host
npm start

Now open localhost:9966 to test. Use npm run build to build a bundle.

License

MIT, see LICENSE.md for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].