Last active
December 14, 2021 01:48
-
-
Save marioecg/41e856b21cdd27c86e5348393cee5689 to your computer and use it in GitHub Desktop.
Collection of GLSL code throughout my learning journey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define PI 3.1415926538 | |
#define TWO_PI 6.28318530718 | |
vec2 scaleFromCenter = (uv - 0.5) + 0.5; | |
mat2 scale(vec2 scale){ | |
return mat2(scale.x, 0.0, | |
0.0, scale.y); | |
} | |
mat2 rotate2d(float angle){ | |
return mat2(cos(angle), -sin(angle), | |
sin(angle), cos(angle)); | |
} | |
mat3 yuv2rgb = mat3(1.0, 0.0, 1.13983, | |
1.0, -0.39465, -0.58060, | |
1.0, 2.03211, 0.0); | |
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722, | |
-0.09991, -0.33609, 0.43600, | |
0.615, -0.5586, -0.05639); | |
vec2 id = floor(uv * repeat); | |
float hash11(float p) { | |
p = fract(p * .1031); | |
p *= p + 33.33; | |
p *= p + p; | |
return fract(p); | |
} | |
float random(vec2 st) { | |
return fract(sin(dot(st.xy, | |
vec2(12.9898,78.233)))* | |
43758.5453123); | |
} | |
float map(float value, float inMin, float inMax, float outMin, float outMax) { | |
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin); | |
} | |
vec3 cosPalette(float t) { | |
vec3 brightness = vec3(0.5, 0.5, 0.5); | |
vec3 contrast = vec3(0.5, 0.5, 0.5); | |
vec3 oscillation = vec3(1.0); | |
vec3 phase = vec3(0.00, 0.10, 0.20); | |
return brightness + contrast * cos(6.28318 * (oscillation * t + phase)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment