mirror of
https://github.com/CookieCollective/Live-Coding-Sources.git
synced 2025-02-08 05:50:07 +01:00
Added a capture for leon's shader + updated readme
This commit is contained in:
parent
c177018529
commit
330fa485e9
BIN
2023-02-15_FabriqueACookie05/Leon1.png
Normal file
BIN
2023-02-15_FabriqueACookie05/Leon1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
@ -5,11 +5,14 @@ On February 15th 2023 on [La fabrique à cookie 05](https://fb.me/e/2C2EVX0sL).
|
||||
## Shaders
|
||||
|
||||
Leon
|
||||
<!-- ![](Missing a picture :( )) -->
|
||||
![](https://raw.githubusercontent.com/CookieCollective/Live-Coding-Sources/master/2023-02-15_FabriqueACookie05/Leon1.png)
|
||||
z0rg
|
||||
![](https://raw.githubusercontent.com/CookieCollective/Live-Coding-Sources/master/2023-02-15_FabriqueACookie05/z0rg.png)
|
||||
lsdlive
|
||||
|
||||
## Sound
|
||||
Jules Cipher
|
||||
Azertype
|
||||
|
||||
## Software
|
||||
- [Atom](https://github.com/atom/atom)
|
||||
|
237
2023-02-15_FabriqueACookie05/common.glsl
Normal file
237
2023-02-15_FabriqueACookie05/common.glsl
Normal file
@ -0,0 +1,237 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
uniform vec2 resolution, mouse;
|
||||
uniform float time, volume;
|
||||
uniform sampler2D backbuffer, spectrum;
|
||||
uniform int PASSINDEX;
|
||||
#define N(x,y,z) normalize(vec3(x,y,z))
|
||||
#define repeat(p,r) (mod(p,r)-r/2.)
|
||||
#define ss(a,b,t) smoothstep(a,b,t)
|
||||
float luminance(vec3 c) { return (c.r+c.g+c.b)/3.; }
|
||||
float gyroid (vec3 s) { return dot(sin(s),cos(s.yzx)); }
|
||||
float fbm0 (vec3 seed) {
|
||||
float result = 0.;
|
||||
float a = .5;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
result += gyroid(seed/a)*a;
|
||||
a /= 2.;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
float fbmSin (vec3 seed, float t) {
|
||||
float result = 0.;
|
||||
float a = .5;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
result += sin(gyroid(seed/a)*3.14+t/a)*a;
|
||||
a /= 2.;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
float fbmSin (vec3 seed, float cycles, float t) {
|
||||
float result = 0.;
|
||||
float a = .5;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
result += sin(gyroid(seed/a)*3.14*cycles+t/a)*a;
|
||||
a /= 2.;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float intensity(in vec4 color){
|
||||
return sqrt((color.x*color.x)+(color.y*color.y)+(color.z*color.z));
|
||||
}
|
||||
|
||||
vec3 sobel(sampler2D map, float stepx, float stepy, vec2 center){
|
||||
// get samples around pixel
|
||||
float tleft = intensity(texture2D(map,center + vec2(-stepx,stepy)));
|
||||
float left = intensity(texture2D(map,center + vec2(-stepx,0)));
|
||||
float bleft = intensity(texture2D(map,center + vec2(-stepx,-stepy)));
|
||||
float top = intensity(texture2D(map,center + vec2(0,stepy)));
|
||||
float bottom = intensity(texture2D(map,center + vec2(0,-stepy)));
|
||||
float tright = intensity(texture2D(map,center + vec2(stepx,stepy)));
|
||||
float right = intensity(texture2D(map,center + vec2(stepx,0)));
|
||||
float bright = intensity(texture2D(map,center + vec2(stepx,-stepy)));
|
||||
|
||||
// Sobel masks (see http://en.wikipedia.org/wiki/Sobel_operator)
|
||||
// 1 0 -1 -1 -2 -1
|
||||
// X = 2 0 -2 Y = 0 0 0
|
||||
// 1 0 -1 1 2 1
|
||||
|
||||
// You could also use Scharr operator:
|
||||
// 3 0 -3 3 10 3
|
||||
// X = 10 0 -10 Y = 0 0 0
|
||||
// 3 0 -3 -3 -10 -3
|
||||
|
||||
float x = tleft + 2.0*left + bleft - tright - 2.0*right - bright;
|
||||
float y = -tleft - 2.0*top - tright + bleft + 2.0 * bottom + bright;
|
||||
float color = sqrt((x*x) + (y*y));
|
||||
return vec3(color,color,color);
|
||||
}
|
||||
|
||||
|
||||
// blackle https://suricrasia.online/demoscene/functions/
|
||||
vec3 erot(vec3 p, vec3 ax, float ro) {
|
||||
return mix(dot(ax, p)*ax, p, cos(ro)) + cross(ax,p)*sin(ro);
|
||||
}
|
||||
|
||||
vec3 rndrot(vec3 p, vec4 rnd) {
|
||||
return erot(p, normalize(tan(rnd.xyz)), rnd.w*3.1415);
|
||||
}
|
||||
|
||||
mat2 rot(float a) { return mat2(cos(a),-sin(a),sin(a),cos(a)); }
|
||||
|
||||
|
||||
// Dave Hoskins
|
||||
// https://www.shadertoy.com/view/4djSRW
|
||||
float hash11(float p){
|
||||
p = fract(p * .1031);
|
||||
p *= p + 33.33;
|
||||
p *= p + p;
|
||||
return fract(p);
|
||||
}
|
||||
float hash12(vec2 p){
|
||||
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
||||
p3 += dot(p3, p3.yzx + 33.33);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
float hash13(vec3 p3){
|
||||
p3 = fract(p3 * .1031);
|
||||
p3 += dot(p3, p3.zyx + 31.32);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
float hash14(vec4 p4) {
|
||||
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
|
||||
p4 += dot(p4, p4.wzxy+33.33);
|
||||
return fract((p4.x + p4.y) * (p4.z + p4.w));
|
||||
}
|
||||
vec2 hash21(float p) {
|
||||
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yzx + 33.33);
|
||||
return fract((p3.xx+p3.yz)*p3.zy);
|
||||
}
|
||||
vec2 hash22(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yzx+33.33);
|
||||
return fract((p3.xx+p3.yz)*p3.zy);
|
||||
}
|
||||
vec2 hash23(vec3 p3) {
|
||||
p3 = fract(p3 * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yzx+33.33);
|
||||
return fract((p3.xx+p3.yz)*p3.zy);
|
||||
}
|
||||
vec3 hash31(float p) {
|
||||
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yzx+33.33);
|
||||
return fract((p3.xxy+p3.yzz)*p3.zyx);
|
||||
}
|
||||
vec3 hash32(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yxz+33.33);
|
||||
return fract((p3.xxy+p3.yzz)*p3.zyx);
|
||||
}
|
||||
vec3 hash33(vec3 p3) {
|
||||
p3 = fract(p3 * vec3(.1031, .1030, .0973));
|
||||
p3 += dot(p3, p3.yxz+33.33);
|
||||
return fract((p3.xxy + p3.yxx)*p3.zyx);
|
||||
}
|
||||
vec4 hash41(float p){
|
||||
vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
|
||||
p4 += dot(p4, p4.wzxy+33.33);
|
||||
return fract((p4.xxyz+p4.yzzw)*p4.zywx);
|
||||
}
|
||||
// Inigo Quilez https://iquilezles.org/articles/distfunctions/
|
||||
float sdBox (vec3 p, vec3 b) { vec3 d = abs(p) - b; return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); }
|
||||
float sdTorus( vec3 p, vec2 t ) {
|
||||
vec2 q = vec2(length(p.xz)-t.x,p.y);
|
||||
return length(q)-t.y;
|
||||
}
|
||||
float sdBoxFrame( vec3 p, vec3 b, float e )
|
||||
{
|
||||
p = abs(p )-b;
|
||||
vec3 q = abs(p+e)-e;
|
||||
return min(min(
|
||||
length(max(vec3(p.x,q.y,q.z),0.0))+min(max(p.x,max(q.y,q.z)),0.0),
|
||||
length(max(vec3(q.x,p.y,q.z),0.0))+min(max(q.x,max(p.y,q.z)),0.0)),
|
||||
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
|
||||
}
|
||||
float sdCapsule( vec3 p, vec3 a, vec3 b, float r ){
|
||||
vec3 pa = p - a, ba = b - a;
|
||||
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
|
||||
return length( pa - ba*h ) - r;
|
||||
}
|
||||
float sdCappedTorus(in vec3 p, in float an, in float ra, in float rb) {
|
||||
vec2 sc = vec2(sin(an),cos(an));
|
||||
p.x = abs(p.x);
|
||||
float k = (sc.y*p.x>sc.x*p.y) ? dot(p.xy,sc) : length(p.xy);
|
||||
return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;
|
||||
}
|
||||
float smin( float d1, float d2, float k ) {
|
||||
float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );
|
||||
return mix( d2, d1, h ) - k*h*(1.0-h); }
|
||||
|
||||
// mercury https://mercury.sexy/hg_sdf/
|
||||
float moda(inout vec2 p, float repetitions) {
|
||||
float angle = 2.*3.1415/repetitions;
|
||||
float a = atan(p.y, p.x) + angle/2.;
|
||||
float r = length(p);
|
||||
float c = floor(a/angle);
|
||||
a = mod(a,angle) - angle/2.;
|
||||
p = vec2(cos(a), sin(a))*r;
|
||||
// For an odd number of repetitions, fix cell index of the cell in -x direction
|
||||
// (cell index would be e.g. -5 and 5 in the two halves of the cell):
|
||||
if (abs(c) >= (repetitions/2.)) c = abs(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
vec3 lookAt (vec3 from, vec3 at, vec2 uv, float fov)
|
||||
{
|
||||
vec3 z = normalize(at-from);
|
||||
vec3 x = normalize(cross(z, vec3(0,1,0)));
|
||||
vec3 y = normalize(cross(x, z));
|
||||
return normalize(z * fov + uv.x * x + uv.y * y);
|
||||
}
|
||||
|
||||
// Shortcut for 45-degrees rotation
|
||||
void pR45(inout vec2 p) {
|
||||
p = (p + vec2(p.y, -p.x))*sqrt(0.5);
|
||||
}
|
||||
|
||||
// Repeat space along one axis. Use like this to repeat along the x axis:
|
||||
// <float cell = pMod1(p.x,5);> - using the return value is optional.
|
||||
float pMod1(inout float p, float size) {
|
||||
float halfsize = size*0.5;
|
||||
float c = floor((p + halfsize)/size);
|
||||
p = mod(p + halfsize, size) - halfsize;
|
||||
return c;
|
||||
}
|
||||
|
||||
float fOpUnionColumns(float a, float b, float r, float n) {
|
||||
if ((a < r) && (b < r)) {
|
||||
vec2 p = vec2(a, b);
|
||||
float columnradius = r*sqrt(2.)/((n-1.)*2.+sqrt(2.));
|
||||
pR45(p);
|
||||
p.x -= sqrt(2.)/2.*r;
|
||||
p.x += columnradius*sqrt(2.);
|
||||
if (mod(n,2.) == 1.) {
|
||||
p.y += columnradius;
|
||||
}
|
||||
// At this point, we have turned 45 degrees and moved at a point on the
|
||||
// diagonal that we want to place the columns on.
|
||||
// Now, repeat the domain along this direction and place a circle.
|
||||
pMod1(p.y, columnradius*2.);
|
||||
float result = length(p) - columnradius;
|
||||
result = min(result, p.x);
|
||||
result = min(result, a);
|
||||
return min(result, b);
|
||||
} else {
|
||||
return min(a, b);
|
||||
}
|
||||
}
|
||||
// The "Stairs" flavour produces n-1 steps of a staircase:
|
||||
// much less stupid version by paniq
|
||||
float fOpUnionStairs(float a, float b, float r, float n) {
|
||||
float s = r/n;
|
||||
float u = b-r;
|
||||
return min(min(a,b), 0.5 * (u + a + abs ((mod (u - a + s, 2. * s)) - s)));
|
||||
}
|
Loading…
Reference in New Issue
Block a user