Skip to content

Instantly share code, notes, and snippets.

View raphaelameaume's full-sized avatar

Raphaël Améaume raphaelameaume

View GitHub Profile
@activetheory
activetheory / levels.glsl
Created January 5, 2016 00:06
A GLSL module for color levels manipulation
float levelChannel(float inPixel, float inBlack, float inGamma, float inWhite, float outBlack, float outWhite) {
return (pow(((inPixel * 255.0) - inBlack) / (inWhite - inBlack), inGamma) * (outWhite - outBlack) + outBlack) / 255.0;
}
vec3 levels(vec3 inPixel, float inBlack, float inGamma, float inWhite, float outBlack, float outWhite) {
vec3 o = vec3(1.0);
o.r = levelChannel(inPixel.r, inBlack, inGamma, inWhite, outBlack, outWhite);
o.g = levelChannel(inPixel.g, inBlack, inGamma, inWhite, outBlack, outWhite);
o.b = levelChannel(inPixel.b, inBlack, inGamma, inWhite, outBlack, outWhite);
return o;
@edankwan
edankwan / snoise2d.js
Created April 6, 2014 06:42
2d snoise Javascript post
// port from GLSL code base on https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl
//JS SNOISE PORT
function snoise2d(x, y) {
var C0 = 0.211324865405187;
var C1 = -0.577350269189626;
var C2 = 1.79284291400159;
var OVER_289 = 1 / 289;
@paulirish
paulirish / rAF.js
Last active June 24, 2025 18:39
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];