id stringlengths 6 6 | author stringclasses 55
values | date timestamp[ns] | image_code stringlengths 746 52.3k | license stringclasses 7
values | func_bytes listlengths 5 5 | functions listlengths 1 32 | comment stringlengths 7 1.29k | header stringlengths 18 169 | body stringlengths 18 2.14k | model_inp stringlengths 30 1.35k | function_frequency int64 1 176 | header_frequency int64 1 16.3k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
lldyzM | ollj | 2018-07-20T10:46:29 | //self https://www.shadertoy.com/view/lldyzM
//analytical filter kernel,triangular
//https://www.shadertoy.com/view/llffWs
// Similar to https://www.shadertoy.com/view/XlXBWs,but with a triangular filter kernel,
// which produces less flickering animations that a box filter. Luckily,it's still easily
// http://iquile... | mit | [
4543,
4570,
4592,
4592,
4615
] | [
[
3872,
3952,
3992,
3992,
4018
],
[
4018,
4067,
4089,
4089,
4114
],
[
4114,
4262,
4285,
4285,
4314
],
[
4314,
4334,
4357,
4357,
4386
],
[
4386,
4403,
4426,
4426,
4455
],
[
4455,
4482,
... | //dual dotprodiuct on v33s
| vec2 dt(v33 a,vec3 b){ | return dt(a,v33(b,b));} | //dual dotprodiuct on v33s
vec2 dt(v33 a,vec3 b){ | 1 | 1 |
lldyzM | ollj | 2018-07-20T10:46:29 | //self https://www.shadertoy.com/view/lldyzM
//analytical filter kernel,triangular
//https://www.shadertoy.com/view/llffWs
// Similar to https://www.shadertoy.com/view/XlXBWs,but with a triangular filter kernel,
// which produces less flickering animations that a box filter. Luckily,it's still easily
// http://iquile... | mit | [
4718,
4730,
4752,
4752,
4781
] | [
[
3872,
3952,
3992,
3992,
4018
],
[
4018,
4067,
4089,
4089,
4114
],
[
4114,
4262,
4285,
4285,
4314
],
[
4314,
4334,
4357,
4357,
4386
],
[
4386,
4403,
4426,
4426,
4455
],
[
4455,
4482,
... | //dual mult
| v33 mul(v33 a,vec2 b){ | return v33(a.a*b.x,a.b*b.y);} | //dual mult
v33 mul(v33 a,vec2 b){ | 1 | 1 |
lldyzM | ollj | 2018-07-20T10:46:29 | //self https://www.shadertoy.com/view/lldyzM
//analytical filter kernel,triangular
//https://www.shadertoy.com/view/llffWs
// Similar to https://www.shadertoy.com/view/XlXBWs,but with a triangular filter kernel,
// which produces less flickering animations that a box filter. Luckily,it's still easily
// http://iquile... | mit | [
5691,
5837,
5868,
5868,
6013
] | [
[
3872,
3952,
3992,
3992,
4018
],
[
4018,
4067,
4089,
4089,
4114
],
[
4114,
4262,
4285,
4285,
4314
],
[
4314,
4334,
4357,
4357,
4386
],
[
4386,
4403,
4426,
4426,
4455
],
[
4455,
4482,
... | //noe to self,maybe replace iMouse.y by abs(angleBetween(rayDirection,Normal))/quaterRotation
//tri(a,Fa)2xTap for box-filtering,used a lot in CG
| float checkerF2(vec3 p,vec3 w){ | w+=iMouse.y/iResolution.y//filter kernel increase this value over inverse squared distance?
;return u6(prv((tri(p-.5*w,Fa)-tri(p+.5*w,Fa))/w));} | //noe to self,maybe replace iMouse.y by abs(angleBetween(rayDirection,Normal))/quaterRotation
//tri(a,Fa)2xTap for box-filtering,used a lot in CG
float checkerF2(vec3 p,vec3 w){ | 1 | 1 |
lldyzM | ollj | 2018-07-20T10:46:29 | //self https://www.shadertoy.com/view/lldyzM
//analytical filter kernel,triangular
//https://www.shadertoy.com/view/llffWs
// Similar to https://www.shadertoy.com/view/XlXBWs,but with a triangular filter kernel,
// which produces less flickering animations that a box filter. Luckily,it's still easily
// http://iquile... | mit | [
6013,
6130,
6161,
6161,
6317
] | [
[
3872,
3952,
3992,
3992,
4018
],
[
4018,
4067,
4089,
4089,
4114
],
[
4114,
4262,
4285,
4285,
4314
],
[
4314,
4334,
4357,
4357,
4386
],
[
4386,
4403,
4426,
4426,
4455
],
[
4455,
4482,
... | //analytical integral(box filter),xor pattern
//tri(a,Fb)3xTap for tri-filtering,is slightly better than checkerF2()
| float checkerF3(vec3 p,vec3 w){ | w+=iMouse.y/iResolution.y//filter kernel increase this value over inverse squared distance?
;return u6(prv((tri(p+w,Fb)-2.*tri(p,Fb)+tri(p-w,Fb))/(w*w)));} | //analytical integral(box filter),xor pattern
//tri(a,Fb)3xTap for tri-filtering,is slightly better than checkerF2()
float checkerF3(vec3 p,vec3 w){ | 1 | 1 |
lldyzM | ollj | 2018-07-20T10:46:29 | //self https://www.shadertoy.com/view/lldyzM
//analytical filter kernel,triangular
//https://www.shadertoy.com/view/llffWs
// Similar to https://www.shadertoy.com/view/XlXBWs,but with a triangular filter kernel,
// which produces less flickering animations that a box filter. Luckily,it's still easily
// http://iquile... | mit | [
6365,
6400,
6425,
6425,
6530
] | [
[
3872,
3952,
3992,
3992,
4018
],
[
4018,
4067,
4089,
4089,
4114
],
[
4114,
4262,
4285,
4285,
4314
],
[
4314,
4334,
4357,
4357,
4386
],
[
4386,
4403,
4426,
4426,
4455
],
[
4455,
4482,
... | //sphere softShadow of(ray,sphere)
| float sssp(v33 r,vec4 s){ | vec3 oc=s.xyz-r.a;float b=dot(oc,r.b),z=1.;if(b>0.){float h=dd(oc)-b*b-s.w*s.w;z=ss01(2.*h/b);}return z;} | //sphere softShadow of(ray,sphere)
float sssp(v33 r,vec4 s){ | 1 | 1 |
lldyzM | ollj | 2018-07-20T10:46:29 | //self https://www.shadertoy.com/view/lldyzM
//analytical filter kernel,triangular
//https://www.shadertoy.com/view/llffWs
// Similar to https://www.shadertoy.com/view/XlXBWs,but with a triangular filter kernel,
// which produces less flickering animations that a box filter. Luckily,it's still easily
// http://iquile... | mit | [
6531,
6550,
6588,
6588,
6648
] | [
[
3872,
3952,
3992,
3992,
4018
],
[
4018,
4067,
4089,
4089,
4114
],
[
4114,
4262,
4285,
4285,
4314
],
[
4314,
4334,
4357,
4357,
4386
],
[
4386,
4403,
4426,
4426,
4455
],
[
4455,
4482,
... | //sphere occlusion
| float occSphere(vec3 u,vec3 n,vec4 s){ | vec3 i=s.xyz-u;return 1.-dot(n,normalize(i))*s.w*s.w/dd(i);} | //sphere occlusion
float occSphere(vec3 u,vec3 n,vec4 s){ | 1 | 1 |
lsyfWc | iq | 2018-07-05T10:21:12 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1781,
1817,
1871,
1887,
2480
] | [
[
1781,
1817,
1871,
1887,
2480
],
[
2483,
2526,
2586,
2586,
2688
],
[
2781,
2781,
2819,
2819,
2938
],
[
2940,
2940,
2992,
2992,
3102
],
[
3104,
3104,
3168,
3346,
4686
],
[
4688,
4688,
... | // Exact BBox to a quadratic bezier
| vec4 bboxBezier(in vec2 p0, in vec2 p1, in vec2 p2 )
{ |
vec2 mi = min(p0,p2);
vec2 ma = max(p0,p2);
// maxima/minima point, if p1 is outside the current bbox/hull
if( p1.x<mi.x || p1.x>ma.x || p1.y<mi.y || p1.y>ma.y )
{
// p = (1-t)^2*p0 + 2(1-t)t*p1 + t^2*p2
// dp/dt = 2(t-1)*p0 + 2(1-2t)*p1 + 2t*p2 = t*(2*p0-4*p1+2*p2) + 2*(p1-p0)
... | // Exact BBox to a quadratic bezier
vec4 bboxBezier(in vec2 p0, in vec2 p1, in vec2 p2 )
{ | 1 | 1 |
lsyfWc | iq | 2018-07-05T10:21:12 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2483,
2526,
2586,
2586,
2688
] | [
[
1781,
1817,
1871,
1887,
2480
],
[
2483,
2526,
2586,
2586,
2688
],
[
2781,
2781,
2819,
2819,
2938
],
[
2940,
2940,
2992,
2992,
3102
],
[
3104,
3104,
3168,
3346,
4686
],
[
4688,
4688,
... | // Approximated BBox to a quadratic bezier
| vec4 bboxBezierSimple(in vec2 p0, in vec2 p1, in vec2 p2 )
{ |
vec2 mi = min(p0,min(p1,p2));
vec2 ma = max(p0,max(p1,p2));
return vec4( mi, ma );
} | // Approximated BBox to a quadratic bezier
vec4 bboxBezierSimple(in vec2 p0, in vec2 p1, in vec2 p2 )
{ | 1 | 1 |
MdKBWt | iq | 2018-07-09T04:51:27 | // The MIT License
// Copyright © 2017 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1895,
2167,
2236,
2252,
3324
] | [
[
1895,
2167,
2236,
2252,
3324
],
[
3327,
3355,
3514,
3514,
3716
],
[
3719,
3756,
3820,
3858,
4138
],
[
4140,
4140,
4168,
4168,
4187
],
[
4189,
4189,
4252,
4252,
4643
],
[
4646,
4646,
... | //---------------------------------------------------------------------------------------
// bounding box for a bezier (http://iquilezles.org/www/articles/bezierbbox/bezierbbox.htm)
//---------------------------------------------------------------------------------------
| bound3 BezierAABB( in vec3 p0, in vec3 p1, in vec3 p2, in vec3 p3 )
{ |
vec3 mi = min(p0,p3);
vec3 ma = max(p0,p3);
// note pascal triangle coefficnets
vec3 c = -1.0*p0 + 1.0*p1;
vec3 b = 1.0*p0 - 2.0*p1 + 1.0*p2;
vec3 a = -1.0*p0 + 3.0*p1 - 3.0*p2 + 1.0*p3;
vec3 h = b*b - a*c;
// real solutions
if( any(greaterThan(h,vec3(0.0))))
{
vec3 ... | //---------------------------------------------------------------------------------------
// bounding box for a bezier (http://iquilezles.org/www/articles/bezierbbox/bezierbbox.htm)
//---------------------------------------------------------------------------------------
bound3 BezierAABB( in vec3 p0, in vec3 p1, in ve... | 1 | 1 |
XdVBWd | iq | 2018-07-09T00:11:27 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
4468,
4520,
4592,
4592,
4710
] | [
[
4468,
4520,
4592,
4592,
4710
],
[
4803,
4803,
4841,
4841,
4960
],
[
4962,
4962,
4990,
4990,
5009
],
[
5011,
5011,
5065,
5065,
5176
],
[
5178,
5178,
5230,
5230,
5266
],
[
5268,
5366,
... | // Approximated conservative BBox to a cubic bezier
| vec4 bboxBezierSimple(in vec2 p0, in vec2 p1, in vec2 p2, in vec2 p3 )
{ |
vec2 mi = min(min(p0,p1),min(p2,p3));
vec2 ma = max(max(p0,p1),max(p2,p3));
return vec4( mi, ma );
} | // Approximated conservative BBox to a cubic bezier
vec4 bboxBezierSimple(in vec2 p0, in vec2 p1, in vec2 p2, in vec2 p3 )
{ | 1 | 1 |
XdVBWd | iq | 2018-07-09T00:11:27 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
5268,
5366,
5430,
5430,
5826
] | [
[
4468,
4520,
4592,
4592,
4710
],
[
4803,
4803,
4841,
4841,
4960
],
[
4962,
4962,
4990,
4990,
5009
],
[
5011,
5011,
5065,
5065,
5176
],
[
5178,
5178,
5230,
5230,
5266
],
[
5268,
5366,
... | // slow, do not use in production. Can probably do better than
// tesselation in linear segments.
| vec2 udBezier(vec2 p0, vec2 p1, vec2 p2, in vec2 p3, vec2 pos)
{ |
const int kNum = 50;
vec2 res = vec2(1e10,0.0);
vec2 a = p0;
for( int i=1; i<kNum; i++ )
{
float t = float(i)/float(kNum-1);
float s = 1.0-t;
vec2 b = p0*s*s*s + p1*3.0*s*s*t + p2*3.0*s*t*t + p3*t*t*t;
float d = sdSegmentSq( pos, a, b );
if( d<res.x ) res ... | // slow, do not use in production. Can probably do better than
// tesselation in linear segments.
vec2 udBezier(vec2 p0, vec2 p1, vec2 p2, in vec2 p3, vec2 pos)
{ | 2 | 2 |
MlGcDz | iq | 2018-09-12T08:22:36 | // The MIT License
// Copyright © 2014 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1547,
1593,
1674,
1674,
2641
] | [
[
1547,
1593,
1674,
1674,
2641
],
[
2645,
2686,
2770,
2770,
3291
],
[
3350,
3350,
3390,
3390,
3423
],
[
3482,
3482,
3510,
3510,
3700
]
] | // Triangle intersection. Returns { t, u, v }
| vec3 triIntersect( in vec3 ro, in vec3 rd, in vec3 v0, in vec3 v1, in vec3 v2 )
{ |
vec3 v1v0 = v1 - v0;
vec3 v2v0 = v2 - v0;
vec3 rov0 = ro - v0;
#if 0
// Cramer's rule for solcing p(t) = ro+t·rd = p(u,v) = vo + u·(v1-v0) + v·(v2-v1)
float d = 1.0/determinant(mat3(v1v0, v2v0, -rd ));
float u = d*determinant(mat3(rov0, v2v0, -rd ));
float v = d*determinant(mat3(v1v0, ... | // Triangle intersection. Returns { t, u, v }
vec3 triIntersect( in vec3 ro, in vec3 rd, in vec3 v0, in vec3 v1, in vec3 v2 )
{ | 3 | 5 |
MlGcDz | iq | 2018-09-12T08:22:36 | // The MIT License
// Copyright © 2014 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2645,
2686,
2770,
2770,
3291
] | [
[
1547,
1593,
1674,
1674,
2641
],
[
2645,
2686,
2770,
2770,
3291
],
[
3350,
3350,
3390,
3390,
3423
],
[
3482,
3482,
3510,
3510,
3700
]
] | // Triangle occlusion (if fully visible)
| float triOcclusion( in vec3 pos, in vec3 nor, in vec3 v0, in vec3 v1, in vec3 v2 )
{ |
vec3 a = normalize(v0-pos);
vec3 b = normalize(v1-pos);
vec3 c = normalize(v2-pos);
float s = -sign(dot(v0-pos,cross(v0-v1,v2-v1))); // other side of the triangle
// page 300 in http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.466.963&rep=rep1&type=pdf
float r = dot(nor,normalize(... | // Triangle occlusion (if fully visible)
float triOcclusion( in vec3 pos, in vec3 nor, in vec3 v0, in vec3 v1, in vec3 v2 )
{ | 1 | 2 |
MlKcDD | iq | 2018-09-08T04:57:14 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1439,
1480,
1544,
1544,
3448
] | [
[
1325,
1325,
1350,
1350,
1369
],
[
1370,
1370,
1408,
1408,
1436
],
[
1439,
1480,
1544,
1544,
3448
],
[
3450,
3450,
3502,
3502,
3622
],
[
3624,
3624,
3681,
3681,
4877
]
] | // signed distance to a quadratic bezier
| float sdBezier( in vec2 pos, in vec2 A, in vec2 B, in vec2 C )
{ |
vec2 a = B - A;
vec2 b = A - 2.0*B + C;
vec2 c = a * 2.0;
vec2 d = A - pos;
float kk = 1.0/dot(b,b);
float kx = kk * dot(a,b);
float ky = kk * (2.0*dot(a,a)+dot(d,b))/3.0;
float kz = kk * dot(d,a);
float res = 0.0;
float sgn = 0.0;
float p = ky - kx*kx;
flo... | // signed distance to a quadratic bezier
float sdBezier( in vec2 pos, in vec2 A, in vec2 B, in vec2 C )
{ | 1 | 7 |
MlycD3 | iq | 2018-09-26T08:53:33 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1321,
1377,
1442,
1442,
1766
] | [
[
1276,
1276,
1300,
1300,
1319
],
[
1321,
1377,
1442,
1442,
1766
],
[
1768,
1795,
1872,
1872,
2418
],
[
2419,
2419,
2476,
2476,
3645
]
] | // trapezoid / capped cone, specialized for Y alignment
| float sdTrapezoid( in vec2 p, in float r1, float r2, float he )
{ |
vec2 k1 = vec2(r2,he);
vec2 k2 = vec2(r2-r1,2.0*he);
p.x = abs(p.x);
vec2 ca = vec2(max(0.0,p.x-((p.y<0.0)?r1:r2)), abs(p.y)-he);
vec2 cb = p - k1 + k2*clamp( dot(k1-p,k2)/dot2(k2), 0.0, 1.0 );
float s = (cb.x < 0.0 && ca.y < 0.0) ? -1.0 : 1.0;
return s*sqrt( min(dot2(ca),dot2(cb)) ... | // trapezoid / capped cone, specialized for Y alignment
float sdTrapezoid( in vec2 p, in float r1, float r2, float he )
{ | 3 | 28 |
MlycD3 | iq | 2018-09-26T08:53:33 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1768,
1795,
1872,
1872,
2418
] | [
[
1276,
1276,
1300,
1300,
1319
],
[
1321,
1377,
1442,
1442,
1766
],
[
1768,
1795,
1872,
1872,
2418
],
[
2419,
2419,
2476,
2476,
3645
]
] | // trapezoid / capped cone
| float sdTrapezoid( in vec2 p, in vec2 a, in vec2 b, in float ra, float rb )
{ |
float rba = rb-ra;
float baba = dot(b-a,b-a);
float papa = dot(p-a,p-a);
float paba = dot(p-a,b-a)/baba;
float x = sqrt( papa - paba*paba*baba );
float cax = max(0.0,x-((paba<0.5)?ra:rb));
float cay = abs(paba-0.5)-0.5;
float k = rba*rba + baba;
float f = clamp( (rba*(x-ra)+paba*ba... | // trapezoid / capped cone
float sdTrapezoid( in vec2 p, in vec2 a, in vec2 b, in float ra, float rb )
{ | 3 | 3 |
lt3BW2 | iq | 2018-11-01T04:49:23 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
4550,
4614,
4646,
4646,
4880
] | [
[
1702,
1702,
1739,
1739,
1764
],
[
1766,
1766,
1809,
1809,
1835
],
[
1837,
1837,
1881,
1881,
1906
],
[
1908,
1908,
1960,
1960,
2131
],
[
2133,
2133,
2191,
2191,
2365
],
[
2367,
2367,
... | // http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
| vec3 calcNormal( in vec3 pos )
{ |
const float ep = 0.0001;
vec2 e = vec2(1.0,-1.0)*0.5773;
return normalize( e.xyy*map( pos + e.xyy*ep ) +
e.yyx*map( pos + e.yyx*ep ) +
e.yxy*map( pos + e.yxy*ep ) +
e.xxx*map( pos + e.xxx*ep ) );
} | // http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
vec3 calcNormal( in vec3 pos )
{ | 6 | 360 |
lt3BW2 | iq | 2018-11-01T04:49:23 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
4882,
4944,
5031,
5031,
5289
] | [
[
1702,
1702,
1739,
1739,
1764
],
[
1766,
1766,
1809,
1809,
1835
],
[
1837,
1837,
1881,
1881,
1906
],
[
1908,
1908,
1960,
1960,
2131
],
[
2133,
2133,
2191,
2191,
2365
],
[
2367,
2367,
... | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
| float calcSoftshadow( in vec3 ro, in vec3 rd, float tmin, float tmax, const float k )
{ |
float res = 1.0;
float t = tmin;
for( int i=0; i<50; i++ )
{
float h = map( ro + rd*t );
res = min( res, k*h/t );
t += clamp( h, 0.02, 0.20 );
if( res<0.005 || t>tmax ) break;
}
return clamp( res, 0.0, 1.0 );
} | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
float calcSoftshadow( in vec3 ro, in vec3 rd, float tmin, float tmax, const float k )
{ | 4 | 10 |
WslGz4 | iq | 2018-12-19T08:01:23 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
4547,
4615,
4784,
4821,
5767
] | [
[
4547,
4615,
4784,
4821,
5767
],
[
5770,
5838,
5926,
5926,
7986
],
[
8081,
8081,
8128,
8128,
8532
],
[
8534,
8534,
8579,
8579,
8695
],
[
8697,
8773,
8809,
8830,
9053
]
] | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| bool boxIntersect( in vec3 ro, in vec3 rd, in mat4 txx, in mat4 txi, in vec3 rad,
out vec2 outT, out vec3 outNor, out vec2 outST, out int outFaceID )
{ |
vec3 rdd = (txx*vec4(rd,0.0)).xyz;
vec3 roo = (txx*vec4(ro,1.0)).xyz;
vec3 s = vec3((rdd.x<0.0)?1.0:-1.0,
(rdd.y<0.0)?1.0:-1.0,
(rdd.z<0.0)?1.0:-1.0);
// ray-box intersection in box space
vec3 m = 1.0/rdd;
vec3 t1 = m*(-roo + s*rad);
vec3 t2 = m*(-roo - s*rad);
... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
bool boxIntersect( in vec3 ro, in vec3 rd, in mat4 txx, in mat4 txi, in vec3 rad,
out vec2 outT, out vec3 outNor, out vec2 outST, out int outFaceID )
{ | 1 | 1 |
WslGz4 | iq | 2018-12-19T08:01:23 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
5770,
5838,
5926,
5926,
7986
] | [
[
4547,
4615,
4784,
4821,
5767
],
[
5770,
5838,
5926,
5926,
7986
],
[
8081,
8081,
8128,
8128,
8532
],
[
8534,
8534,
8579,
8579,
8695
],
[
8697,
8773,
8809,
8830,
9053
]
] | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| float boxOcclusion( in vec3 pos, in vec3 nor, in mat4 txx, in mat4 txi, in vec3 rad )
{ |
vec3 p = (txx*vec4(pos,1.0)).xyz;
vec3 n = (txx*vec4(nor,0.0)).xyz;
// 8 verts
vec3 v0 = normalize( vec3(-1.0,-1.0,-1.0)*rad - p);
vec3 v1 = normalize( vec3( 1.0,-1.0,-1.0)*rad - p);
vec3 v2 = normalize( vec3(-1.0, 1.0,-1.0)*rad - p);
vec3 v3 = normalize( vec3( 1.0, 1.0,-1.0)*rad - p);
v... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
float boxOcclusion( in vec3 pos, in vec3 nor, in mat4 txx, in mat4 txi, in vec3 rad )
{ | 1 | 4 |
WslGz4 | iq | 2018-12-19T08:01:23 | // The MIT License
// Copyright © 2018 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
8697,
8773,
8809,
8830,
9053
] | [
[
4547,
4615,
4784,
4821,
5767
],
[
5770,
5838,
5926,
5926,
7986
],
[
8081,
8081,
8128,
8128,
8532
],
[
8534,
8534,
8579,
8579,
8695
],
[
8697,
8773,
8809,
8830,
9053
]
] | // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
| float checkersGradBox( in vec2 p )
{ |
vec2 w = fwidth(p) + 0.001;
// analytical integral (box filter)
vec2 i = 2.0*(abs(fract((p-0.5*w)*0.5)-0.5)-abs(fract((p+0.5*w)*0.5)-0.5))/w;
// xor pattern
return 0.5 - 0.5*i.x*i.y;
} | // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
float checkersGradBox( in vec2 p )
{ | 19 | 21 |
3d2GRh | iq | 2019-01-23T11:08:33 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1079,
1094,
1120,
1205,
1366
] | [
[
1079,
1094,
1120,
1205,
1366
],
[
1368,
1389,
1425,
1425,
1732
],
[
1734,
1751,
1785,
1785,
1962
],
[
1964,
1964,
2021,
2021,
2627
]
] | // random hash
| float hash( in ivec2 q )
{ |
int n = q.x*131 + q.y*57;
n = (n << 13) ^ n;
n = n * (n * n * 15731 + 789221) + 1376312589;
return float((n>>8)&0x007fffff)/float(0x007fffff);
} | // random hash
float hash( in ivec2 q )
{ | 2 | 2 |
3d2GRh | iq | 2019-01-23T11:08:33 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1368,
1389,
1425,
1425,
1732
] | [
[
1079,
1094,
1120,
1205,
1366
],
[
1368,
1389,
1425,
1425,
1732
],
[
1734,
1751,
1785,
1785,
1962
],
[
1964,
1964,
2021,
2021,
2627
]
] | // basic value noise
| float noise( in vec2 x, in int p )
{ |
ivec2 i = ivec2(floor(x));
vec2 f = fract(x);
f = f*f*(3.0-2.0*f);
return mix(mix( hash((i+ivec2(0,0))&(p-1)),
hash((i+ivec2(1,0))&(p-1)),f.x),
mix( hash((i+ivec2(0,1))&(p-1)),
hash((i+ivec2(1,1))&(p-1)),f.x),f.y);
} | // basic value noise
float noise( in vec2 x, in int p )
{ | 1 | 1 |
3d2GRh | iq | 2019-01-23T11:08:33 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1734,
1751,
1785,
1785,
1962
] | [
[
1079,
1094,
1120,
1205,
1366
],
[
1368,
1389,
1425,
1425,
1732
],
[
1734,
1751,
1785,
1785,
1962
],
[
1964,
1964,
2021,
2021,
2627
]
] | // fractal noise
| float fbm( in vec2 x, in int p )
{ |
float f = 0.0;
float s = 0.5;
for( int i=0; i<9; i++ )
{
f += s*noise( x, p );
s *= 0.5;
x *= 2.0;
p *= 2;
}
return f;
} | // fractal noise
float fbm( in vec2 x, in int p )
{ | 1 | 1 |
WdBGW1 | yasuo | 2019-01-28T17:09:52 | // The MIT License
// Copyright © 2014 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3007,
3121,
3202,
3202,
4169
] | [
[
3007,
3121,
3202,
3202,
4169
],
[
4171,
4239,
4316,
4353,
4871
],
[
4873,
4873,
4920,
4920,
5324
],
[
5326,
5326,
5371,
5371,
5487
],
[
5489,
5489,
5519,
5519,
5566
]
] | // Triangle intersection. Returns { t, u, v }
// http://iquilezles.org/www/articles/intersectors/intersectors.htm
| vec3 triIntersect( in vec3 ro, in vec3 rd, in vec3 v0, in vec3 v1, in vec3 v2 )
{ |
vec3 v1v0 = v1 - v0;
vec3 v2v0 = v2 - v0;
vec3 rov0 = ro - v0;
#if 0
// Cramer's rule for solcing p(t) = ro+t·rd = p(u,v) = vo + u·(v1-v0) + v·(v2-v1)
float d = 1.0/determinant(mat3(v1v0, v2v0, -rd ));
float u = d*determinant(mat3(rov0, v2v0, -rd ));
float v = d*determinant(mat3(v1v0, ... | // Triangle intersection. Returns { t, u, v }
// http://iquilezles.org/www/articles/intersectors/intersectors.htm
vec3 triIntersect( in vec3 ro, in vec3 rd, in vec3 v0, in vec3 v1, in vec3 v2 )
{ | 3 | 5 |
WdBGW1 | yasuo | 2019-01-28T17:09:52 | // The MIT License
// Copyright © 2014 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
4171,
4239,
4316,
4353,
4871
] | [
[
3007,
3121,
3202,
3202,
4169
],
[
4171,
4239,
4316,
4353,
4871
],
[
4873,
4873,
4920,
4920,
5324
],
[
5326,
5326,
5371,
5371,
5487
],
[
5489,
5489,
5519,
5519,
5566
]
] | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| vec4 iBox( in vec3 ro, in vec3 rd, in mat4 txx, in mat4 txi, in vec3 rad )
{ |
vec3 rdd = (txx*vec4(rd,0.0)).xyz;
vec3 roo = (txx*vec4(ro,1.0)).xyz;
// ray-box intersection in box space
vec3 m = 1.0/rdd;
vec3 n = m*roo;
vec3 k = abs(m)*rad;
vec3 t1 = -n - k;
vec3 t2 = -n + k;
float tN = max( max( t1.x, t1.y ), t1.z );
float tF = min( min( t2.x, t2.y ), t2.z );
if(... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
vec4 iBox( in vec3 ro, in vec3 rd, in mat4 txx, in mat4 txi, in vec3 rad )
{ | 5 | 7 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
1111,
2215,
2240,
2240,
2347
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | // The MIT License
// Copyright © 2013 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge... | float hash(vec2 p)
{ |
p = 50.0*fract( p*0.3183099 + vec2(0.71,0.113));
return -1.0+2.0*fract( p.x*p.y*(p.x+p.y) );
} | // The MIT License
// Copyright © 2013 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge... | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
2847,
2876,
2907,
2907,
2936
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | // Base distance function
| float ball(vec3 p,float s)
{ |
return length(p)-s;
} | // Base distance function
float ball(vec3 p,float s)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
2945,
2970,
3000,
3000,
3313
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | // Making ball status
| vec4 metaballvalue(int i)
{ |
float ifloat = float(i);
float kt = 3.*iTime*(0.1+0.01*ifloat);
vec3 ballpos = 0.3*vec3(noise(vec2(ifloat,ifloat)+kt),noise(vec2(ifloat+10.,ifloat*20.)+kt),noise(vec2(ifloat*20.,ifloat+20.)+kt));
float scale = 0.05+0.02*hash(vec2(ifloat,ifloat));
return vec4(ballpos,scale);
} | // Making ball status
vec4 metaballvalue(int i)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
3317,
3353,
3390,
3390,
3522
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | // Making ball distance function
| float metaballone(vec3 p, int i)
{ |
vec4 value = metaballvalue(i);
vec3 ballpos = p-value.xyz;
float scale =value.w;
return ball(ballpos,scale);
} | // Making ball distance function
float metaballone(vec3 p, int i)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
3527,
3567,
3594,
3594,
3781
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | //Making metaballs distance function
| float metaball(vec3 p)
{ |
float d1;
float d2 = metaballone(p,0);
for (int i = 1; i < 6; ++i) {
d1 = metaballone(p,i);
d1 = smoothMin(d1,d2,20.);
d2 =d1;
}
return d1;
} | //Making metaballs distance function
float metaball(vec3 p)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
3788,
3819,
3842,
3842,
3981
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | // Making distance function
| float dist(vec3 p)
{ |
float y = p.y;
float d1 =metaball(p);
float d2 = y-(_ypos); //For floor
d1 = smoothMin(d1,d2,20.);
return d1;
} | // Making distance function
float dist(vec3 p)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
6190,
6279,
6310,
6310,
6521
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | //Tetrahedron technique http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
| vec3 getnormal( in vec3 p)
{ |
vec2 e = vec2(0.5773,-0.5773)*0.0001;
vec3 nor = normalize( e.xyy*dist(p+e.xyy) + e.yyx*dist(p+e.yyx) + e.yxy*dist(p+e.yxy ) + e.xxx*dist(p+e.xxx));
nor = normalize(vec3(nor));
return nor ;
} | //Tetrahedron technique http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
vec3 getnormal( in vec3 p)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
6606,
6626,
6674,
6674,
6898
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | // Making shadow
| float softray( vec3 ro, vec3 rd , float hn)
{ |
float t = 0.000001;
float jt = 0.0;
float res = 1.;
for (int i = 0; i < 20; ++i) {
jt = dist(ro+rd*t);
res = min(res,jt*hn/t);
t = t+ clamp(0.02,2.,jt);
}
return clamp(res,0.,1.);
} | // Making shadow
float softray( vec3 ro, vec3 rd , float hn)
{ | 1 | 1 |
3dlSDn | butadiene | 2019-02-25T04:15:29 | // The MIT License
// Copyright © 2019 Butadiene
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish... | mit | [
8857,
8904,
8940,
8940,
9408
] | [
[
1111,
2215,
2240,
2240,
2347
],
[
2352,
2352,
2381,
2381,
2648
],
[
2742,
2742,
2789,
2789,
2836
],
[
2847,
2876,
2907,
2907,
2936
],
[
2945,
2970,
3000,
3000,
3313
],
[
3317,
3353,
... | //Phong reflection model ,Directional light
| vec4 lighting(vec3 pos,vec3 ro)
{ |
vec3 mpos =pos;
vec3 normal =getnormal(mpos);
vec3 viewdir = normalize(pos-ro);
vec3 lightdir = normalize(vec3(0.5,0.5,-0.5));
float sha = softray(mpos,lightdir,3.3);
vec4 Color = material(mpos);
float NdotL = max(0.,dot(normal,lightdir));
vec3 R = -normalize(reflect(li... | //Phong reflection model ,Directional light
vec4 lighting(vec3 pos,vec3 ro)
{ | 1 | 1 |
MldfWn | iq | 2019-02-11T07:14:46 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2955,
3039,
3083,
3083,
3172
] | [
[
1778,
1847,
1886,
1886,
2951
],
[
2955,
3039,
3083,
3083,
3172
],
[
3174,
3214,
3261,
3261,
3317
],
[
3389,
3389,
3420,
3437,
3670
],
[
3672,
3672,
3720,
3720,
3988
],
[
3991,
3991,
... | // generic ellipsoid - approximated distance: https://www.shadertoy.com/view/tdS3DG
| float sdEllipsoid( in vec3 p, in vec3 r )
{ |
float k0 = length(p/r);
float k1 = length(p/(r*r));
return k0*(k0-1.0)/k1;
} | // generic ellipsoid - approximated distance: https://www.shadertoy.com/view/tdS3DG
float sdEllipsoid( in vec3 p, in vec3 r )
{ | 6 | 7 |
MldfWn | iq | 2019-02-11T07:14:46 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3174,
3214,
3261,
3261,
3317
] | [
[
1778,
1847,
1886,
1886,
2951
],
[
2955,
3039,
3083,
3083,
3172
],
[
3174,
3214,
3261,
3261,
3317
],
[
3389,
3389,
3420,
3437,
3670
],
[
3672,
3672,
3720,
3720,
3988
],
[
3991,
3991,
... | // symmetric ellipsoid - EXACT distance
| float sdEllipsoidXXZ( in vec3 p, in vec2 r )
{ |
return sdEllipse( vec2( length(p.xy), p.z ), r );
} | // symmetric ellipsoid - EXACT distance
float sdEllipsoidXXZ( in vec3 p, in vec2 r )
{ | 1 | 1 |
tdS3DG | iq | 2019-02-11T07:14:34 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2405,
2465,
2513,
2513,
2567
] | [
[
2405,
2465,
2513,
2513,
2567
],
[
2570,
2624,
2668,
2668,
2757
],
[
2829,
2829,
2860,
2877,
3109
],
[
3111,
3111,
3159,
3159,
3428
],
[
3431,
3431,
3489,
3489,
3776
],
[
3778,
3778,
... | // generic ellipsoid - simple but bad approximated distance
| float sdEllipsoid_Bad( in vec3 p, in vec3 r )
{ |
return (length(p/r)-1.0)*min(min(r.x,r.y),r.z);
} | // generic ellipsoid - simple but bad approximated distance
float sdEllipsoid_Bad( in vec3 p, in vec3 r )
{ | 2 | 2 |
tdS3DG | iq | 2019-02-11T07:14:34 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2570,
2624,
2668,
2668,
2757
] | [
[
2405,
2465,
2513,
2513,
2567
],
[
2570,
2624,
2668,
2668,
2757
],
[
2829,
2829,
2860,
2877,
3109
],
[
3111,
3111,
3159,
3159,
3428
],
[
3431,
3431,
3489,
3489,
3776
],
[
3778,
3778,
... | // generic ellipsoid - improved approximated distance
| float sdEllipsoid( in vec3 p, in vec3 r )
{ |
float k0 = length(p/r);
float k1 = length(p/(r*r));
return k0*(k0-1.0)/k1;
} | // generic ellipsoid - improved approximated distance
float sdEllipsoid( in vec3 p, in vec3 r )
{ | 6 | 7 |
3lsGD4 | tpfto | 2019-04-27T10:27:51 | // The MIT License
// Copyright © 2019 J. M.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di... | mit | [
1537,
1629,
1661,
1661,
1711
] | [
[
1537,
1629,
1661,
1661,
1711
],
[
1713,
1732,
1766,
1766,
1902
],
[
1904,
2102,
2130,
2130,
2283
],
[
2285,
2363,
2392,
2392,
2590
],
[
2640,
2640,
2665,
2665,
3031
],
[
3055,
3055,
... | // Schlick bias function, from http://dept-info.labri.u-bordeaux.fr/~schlick/DOC/gem2.ps.gz
| float bias( float a, float x )
{ |
return x/((1.0/a - 2.0) * (1.0 - x) + 1.0);
} | // Schlick bias function, from http://dept-info.labri.u-bordeaux.fr/~schlick/DOC/gem2.ps.gz
float bias( float a, float x )
{ | 6 | 6 |
3lsGD4 | tpfto | 2019-04-27T10:27:51 | // The MIT License
// Copyright © 2019 J. M.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di... | mit | [
1713,
1732,
1766,
1766,
1902
] | [
[
1537,
1629,
1661,
1661,
1711
],
[
1713,
1732,
1766,
1766,
1902
],
[
1904,
2102,
2130,
2130,
2283
],
[
2285,
2363,
2392,
2392,
2590
],
[
2640,
2640,
2665,
2665,
3031
],
[
3055,
3055,
... | // biased sawtooth
| float my_saw( float x, float p )
{ |
float xs = mod(x, 1.0);
float xh = clamp(xs, 0.0, p);
return 0.5 + 0.5 * bias(0.95, xh) * (1.0 - smoothstep(p, 1.0, xs));
} | // biased sawtooth
float my_saw( float x, float p )
{ | 6 | 6 |
3lsGD4 | tpfto | 2019-04-27T10:27:51 | // The MIT License
// Copyright © 2019 J. M.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di... | mit | [
2285,
2363,
2392,
2392,
2590
] | [
[
1537,
1629,
1661,
1661,
1711
],
[
1713,
1732,
1766,
1766,
1902
],
[
1904,
2102,
2130,
2130,
2283
],
[
2285,
2363,
2392,
2392,
2590
],
[
2640,
2640,
2665,
2665,
3031
],
[
3055,
3055,
... | // modified DLMF coloring, adapted from https://www.shadertoy.com/view/WtXGWN
| vec3 smooth_dlmf( float h )
{ |
vec3 rgb = clamp( vec3(1., -1., -1.) * abs((vec3(8., 4., 8.) * mod(h, 1.0) - vec3(4.5, 1.5, 5.5))) + vec3(-1.5, 1.5, 2.5), 0.0, 1.0 );
return rgb * rgb * rgb/(1.0 - 3.0 * rgb * (1.0 - rgb));
} | // modified DLMF coloring, adapted from https://www.shadertoy.com/view/WtXGWN
vec3 smooth_dlmf( float h )
{ | 10 | 10 |
3s2SRV | iq | 2019-04-04T11:39:08 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2452,
2524,
2602,
2602,
3333
] | [
[
2062,
2272,
2331,
2331,
2450
],
[
2452,
2524,
2602,
2602,
3333
],
[
3335,
3353,
3418,
3418,
3544
],
[
3547,
3571,
3635,
3635,
3915
],
[
3918,
3918,
3944,
3944,
4011
]
] | // http://www.iquilezles.org/www/articles/intersectors/intersectors.htm
| float iCapsule( in vec3 ro, in vec3 rd, in vec3 pa, in vec3 pb, in float r )
{ |
vec3 ba = pb - pa;
vec3 oa = ro - pa;
float baba = dot(ba,ba);
float bard = dot(ba,rd);
float baoa = dot(ba,oa);
float rdoa = dot(rd,oa);
float oaoa = dot(oa,oa);
float a = baba - bard*bard;
float b = baba*rdoa - baoa*bard;
float c = baba*oaoa - baoa*baoa - r*r*baba;
... | // http://www.iquilezles.org/www/articles/intersectors/intersectors.htm
float iCapsule( in vec3 ro, in vec3 rd, in vec3 pa, in vec3 pb, in float r )
{ | 3 | 3 |
tsSXzK | iq | 2019-04-04T06:43:51 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1563,
1633,
1691,
1691,
2251
] | [
[
1563,
1633,
1691,
1691,
2251
],
[
2254,
2254,
2280,
2280,
2359
],
[
2361,
2425,
2457,
2457,
2696
]
] | // http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
| float sdCone(vec3 p, vec3 a, vec3 b, float ra, float rb)
{ |
float rba = rb-ra;
float baba = dot(b-a,b-a);
float papa = dot(p-a,p-a);
float paba = dot(p-a,b-a)/baba;
float x = sqrt( papa - paba*paba*baba );
float cax = max(0.0,x-((paba<0.5)?ra:rb));
float cay = abs(paba-0.5)-0.5;
float k = rba*rba + baba;
float f = clamp( (rba*(x-ra)+paba... | // http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
float sdCone(vec3 p, vec3 a, vec3 b, float ra, float rb)
{ | 5 | 5 |
MlGczG | iq | 2019-05-16T12:05:45 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1739,
1768,
1857,
1857,
2579
] | [
[
1739,
1768,
1857,
1857,
2579
],
[
2582,
2670,
2752,
2752,
3483
],
[
3485,
3503,
3568,
3568,
3694
],
[
3697,
3715,
3793,
3793,
4007
]
] | // fakesoft shadow occlusion
| float capShadow( in vec3 ro, in vec3 rd, in vec3 a, in vec3 b, in float r, in float k )
{ |
vec3 ba = b - a;
vec3 oa = ro - a;
// closest distance between ray and segment
#if 1
// naive way to solve the 2x2 system of equations
float oad = dot( oa, rd );
float dba = dot( rd, ba );
float baba = dot( ba, ba );
float oaba = dot( oa, ba );
vec2 th = vec2( -oad*baba + dba*oaba, oaba - oad*dba... | // fakesoft shadow occlusion
float capShadow( in vec3 ro, in vec3 rd, in vec3 a, in vec3 b, in float r, in float k )
{ | 1 | 1 |
Wt2GRh | eliemichel | 2019-05-23T01:27:45 | // Released under the MIT licence
// Copyright (c) 2019 - Alt144 (Élie Michel)
// Study around the snake() function, to build uv-space shaped like a snake,
// where each section is half a circle.
#define PI 3.141593
float pbeat(float t, float p)
{
return pow(1. - fract(t), p);
}
mat2 rot(float t)
{
float s =... | mit | [
1170,
1301,
1356,
1356,
1897
] | [
[
219,
219,
250,
250,
286
],
[
288,
288,
307,
307,
383
],
[
385,
385,
406,
406,
443
],
[
445,
445,
465,
465,
492
],
[
494,
494,
533,
533,
640
],
[
642,
642,
666,
666,
890
],
... | /**
* uv: us-space to deform
* rad1: Radius of the top arcs
* rad2: Radius of the bottom arcs
* th: Thickness of the snake
*/
| vec2 snake(vec2 uv, float rad1, float rad2, float th)
{ |
float radsum = rad1 + th + rad2;
vec2 uv0 = uv;
vec2 uv2 = uv;
uv.x = mod(uv.x - radsum, 2. * radsum) - radsum;
uv2.x = mod(uv2.x, 2. * radsum) - radsum;
uv = ring(uv, rad1, rad1 + th);
uv2 = ring(uv2 * vec2(-1.,1.), rad2, rad2 + th);
float mid = (rad2+th/2.)/radsum;
uv2.x... | /**
* uv: us-space to deform
* rad1: Radius of the top arcs
* rad2: Radius of the bottom arcs
* th: Thickness of the snake
*/
vec2 snake(vec2 uv, float rad1, float rad2, float th)
{ | 1 | 1 |
3l23RK | iq | 2019-06-11T14:16:47 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1234,
1284,
1333,
1333,
1476
] | [
[
1234,
1284,
1333,
1333,
1476
],
[
1478,
1478,
1535,
1571,
2424
]
] | // c is the sin/cos of the angle. r is the radius
| float sdPie( in vec2 p, in vec2 c, in float r )
{ |
p.x = abs(p.x);
float l = length(p) - r;
float m = length(p - c*clamp(dot(p,c),0.0,r) );
return max(l,m*sign(c.y*p.x-c.x*p.y));
} | // c is the sin/cos of the angle. r is the radius
float sdPie( in vec2 p, in vec2 c, in float r )
{ | 3 | 11 |
3tj3DW | iq | 2019-06-03T23:28:36 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3227,
3286,
3316,
3316,
3355
] | [
[
1466,
1503,
1558,
1662,
3225
],
[
3227,
3286,
3316,
3316,
3355
]
] | // df/dx,df/dy,df/dx for f(x,y,z) = x^4 + y^4 + z^4 - ra^4
| vec3 nSphere4( in vec3 pos )
{ |
return normalize( pos*pos*pos );
} | // df/dx,df/dy,df/dx for f(x,y,z) = x^4 + y^4 + z^4 - ra^4
vec3 nSphere4( in vec3 pos )
{ | 1 | 1 |
wl23RK | iq | 2019-06-12T02:32:30 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1274,
1353,
1431,
1431,
1612
] | [
[
1274,
1353,
1431,
1431,
1612
],
[
1614,
1614,
1671,
1707,
2653
]
] | // sca is the sin/cos of the orientation
// scb is the sin/cos of the aperture
| float sdArc( in vec2 p, in vec2 sca, in vec2 scb, in float ra, in float rb )
{ |
p *= mat2(sca.x,sca.y,-sca.y,sca.x);
p.x = abs(p.x);
float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p);
return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;
} | // sca is the sin/cos of the orientation
// scb is the sin/cos of the aperture
float sdArc( in vec2 p, in vec2 sca, in vec2 scb, in float ra, in float rb )
{ | 1 | 4 |
wlXSD7 | iq | 2019-07-15T08:58:25 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2847,
2909,
2987,
2987,
3250
] | [
[
1503,
1503,
1569,
1569,
1675
],
[
1677,
1677,
1703,
1718,
2050
],
[
2506,
2570,
2602,
2602,
2841
],
[
2847,
2909,
2987,
2987,
3250
],
[
3252,
3252,
3301,
3301,
3594
]
] | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
| float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
{ |
float res = 1.0;
float t = mint;
for( int i=0; i<16; i++ )
{
float h = map( ro + rd*t );
res = min( res, 8.0*h/t );
t += clamp( h, 0.02, 0.10 );
if( res<0.005 || t>tmax ) break;
}
return clamp( res, 0.0, 1.0 );
} | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
{ | 1 | 60 |
WtB3Wt | iq | 2019-07-19T06:36:25 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2194,
2258,
2305,
2305,
2569
] | [
[
1439,
1439,
1476,
1476,
1577
],
[
1579,
1579,
1604,
1604,
1775
],
[
1777,
1777,
1815,
1838,
2192
],
[
2194,
2258,
2305,
2305,
2569
],
[
2571,
2633,
2723,
2723,
2994
],
[
2996,
2996,
... | // http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
| vec3 calcNormal( in vec3 pos, in float time )
{ |
vec2 e = vec2(1.0,-1.0)*0.5773;
const float eps = 0.00025;
return normalize( e.xyy*map( pos + e.xyy*eps, time ) +
e.yyx*map( pos + e.yyx*eps, time ) +
e.yxy*map( pos + e.yxy*eps, time ) +
e.xxx*map( pos + e.xxx*eps, time ) );
} | // http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
vec3 calcNormal( in vec3 pos, in float time )
{ | 1 | 6 |
WtB3Wt | iq | 2019-07-19T06:36:25 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2571,
2633,
2723,
2723,
2994
] | [
[
1439,
1439,
1476,
1476,
1577
],
[
1579,
1579,
1604,
1604,
1775
],
[
1777,
1777,
1815,
1838,
2192
],
[
2194,
2258,
2305,
2305,
2569
],
[
2571,
2633,
2723,
2723,
2994
],
[
2996,
2996,
... | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
| float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax, float time )
{ |
float res = 1.0;
float t = mint;
for( int i=0; i<128; i++ )
{
float h = map( ro + rd*t, time );
res = min( res, 16.0*h/t );
t += clamp( h, 0.01, 0.25 );
if( res<0.001 || t>tmax ) break;
}
return clamp( res, 0.0, 1.0 );
} | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax, float time )
{ | 1 | 1 |
WtB3Wt | iq | 2019-07-19T06:36:25 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3492,
3568,
3632,
3653,
3886
] | [
[
1439,
1439,
1476,
1476,
1577
],
[
1579,
1579,
1604,
1604,
1775
],
[
1777,
1777,
1815,
1838,
2192
],
[
2194,
2258,
2305,
2305,
2569
],
[
2571,
2633,
2723,
2723,
2994
],
[
2996,
2996,
... | // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
| float checkersGradBox( in vec2 p, in vec2 dpdx, in vec2 dpdy )
{ |
vec2 w = abs(dpdx)+abs(dpdy) + 0.001;
// analytical integral (box filter)
vec2 i = 2.0*(abs(fract((p-0.5*w)*0.5)-0.5)-abs(fract((p+0.5*w)*0.5)-0.5))/w;
// xor pattern
return 0.5 - 0.5*i.x*i.y;
} | // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
float checkersGradBox( in vec2 p, in vec2 dpdx, in vec2 dpdy )
{ | 15 | 15 |
ttBXRG | iq | 2019-08-19T20:19:09 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1080,
1264,
1307,
1307,
1457
] | [
[
1080,
1264,
1307,
1307,
1457
],
[
1459,
1459,
1516,
1540,
2121
]
] | // Staircase function y=f(x)
//
// k>1 : flat horizontals
// k<1 : flat verticals
//
// The inverse function x=f^-1(x) is just the function itselft
// with parameter 1/k instead of k.
| float staircase( in float x, in float k )
{ |
float i = floor(x);
float f = fract(x);
float a = 0.5*pow(2.0*((f<0.5)?f:1.0-f), k);
f = (f<0.5)?a:1.0-a;
return i+f;
} | // Staircase function y=f(x)
//
// k>1 : flat horizontals
// k<1 : flat verticals
//
// The inverse function x=f^-1(x) is just the function itselft
// with parameter 1/k instead of k.
float staircase( in float x, in float k )
{ | 2 | 3 |
wlBXWK | skythedragon | 2019-08-29T17:22:10 | /*
MIT License
Copyright (c) 2019 - 2021 Dimas "Dimev", "Skythedragon" Leenman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use,... | mit | [
16068,
16254,
16344,
16413,
17996
] | [
[
5752,
6075,
7734,
7829,
15295
],
[
15488,
15488,
15650,
15787,
16066
],
[
16068,
16254,
16344,
16413,
17996
],
[
17998,
18385,
18440,
18491,
19945
],
[
19947,
20147,
20200,
20200,
20347
],
[
... | /*
To make the planet we're rendering look nicer, we implemented a skylight function here
Essentially it just takes a sample of the atmosphere in the direction of the surface normal
*/
| vec3 skylight(vec3 sample_pos, vec3 surface_normal, vec3 light_dir, vec3 background_col) { |
surface_normal = normalize(mix(surface_normal, light_dir, 0.6));
// and sample the atmosphere
return calculate_scattering(
sample_pos, // the position of the camera
surface_normal, // the camera vector (ray direction of this pixel)
3.0 * ATMOS_RADIUS, // max dist, sinc... | /*
To make the planet we're rendering look nicer, we implemented a skylight function here
Essentially it just takes a sample of the atmosphere in the direction of the surface normal
*/
vec3 skylight(vec3 sample_pos, vec3 surface_normal, vec3 light_dir, vec3 background_col) { | 1 | 1 |
wlBXWK | skythedragon | 2019-08-29T17:22:10 | /*
MIT License
Copyright (c) 2019 - 2021 Dimas "Dimev", "Skythedragon" Leenman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use,... | mit | [
17998,
18385,
18440,
18491,
19945
] | [
[
5752,
6075,
7734,
7829,
15295
],
[
15488,
15488,
15650,
15787,
16066
],
[
16068,
16254,
16344,
16413,
17996
],
[
17998,
18385,
18440,
18491,
19945
],
[
19947,
20147,
20200,
20200,
20347
],
[
... | /*
The following function returns the scene color and depth
(the color of the pixel without the atmosphere, and the distance to the surface that is visible on that pixel)
in this case, the function renders a green sphere on the place where the planet should be
color is in .xyz, distance in .w
I won't explain too muc... | vec4 render_scene(vec3 pos, vec3 dir, vec3 light_dir) { |
vec4 color = vec4(0.0, 0.0, 0.0, 1e12);
// add a sun, if the angle between the ray direction and the light direction is small enough, color the pixels white
color.xyz = vec3(dot(dir, light_dir) > 0.9998 ? 3.0 : 0.0);
// get where the ray intersects the planet
vec2 planet_intersect = ray_s... | /*
The following function returns the scene color and depth
(the color of the pixel without the atmosphere, and the distance to the surface that is visible on that pixel)
in this case, the function renders a green sphere on the place where the planet should be
color is in .xyz, distance in .w
I won't explain too muc... | 1 | 1 |
wlBXWK | skythedragon | 2019-08-29T17:22:10 | /*
MIT License
Copyright (c) 2019 - 2021 Dimas "Dimev", "Skythedragon" Leenman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use,... | mit | [
19947,
20147,
20200,
20200,
20347
] | [
[
5752,
6075,
7734,
7829,
15295
],
[
15488,
15488,
15650,
15787,
16066
],
[
16068,
16254,
16344,
16413,
17996
],
[
17998,
18385,
18440,
18491,
19945
],
[
19947,
20147,
20200,
20200,
20347
],
[
... | /*
next, we need a way to do something with the scattering function
to do something with it we need the camera vector (which is the ray direction) of the current pixel
this function calculates it
*/
| vec3 get_camera_vector(vec3 resolution, vec2 coord) { |
vec2 uv = coord.xy / resolution.xy - vec2(0.5);
uv.x *= resolution.x / resolution.y;
return normalize(vec3(uv.x, uv.y, -1.0));
} | /*
next, we need a way to do something with the scattering function
to do something with it we need the camera vector (which is the ray direction) of the current pixel
this function calculates it
*/
vec3 get_camera_vector(vec3 resolution, vec2 coord) { | 1 | 1 |
wtjSDW | iq | 2019-08-16T07:15:19 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1455,
1501,
1547,
1547,
1717
] | [
[
1455,
1501,
1547,
1547,
1717
],
[
1719,
1719,
1745,
1745,
1863
],
[
1865,
1929,
1961,
1961,
2200
]
] | // c is the sin/cos of the desired cone angle
| float sdSolidAngle(vec3 p, vec2 c, float ra)
{ |
vec2 q = vec2( length(p.xz), p.y );
float l = length(q) - ra;
float m = length(q - c*clamp(dot(q,c),0.0,ra) );
return max(l,m*sign(c.y*q.x-c.x*q.y));
} | // c is the sin/cos of the desired cone angle
float sdSolidAngle(vec3 p, vec2 c, float ra)
{ | 1 | 6 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
2998,
3074,
3134,
3134,
3508
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Get surface color given a material number
// plus ray intersection data.
| vec3 get_material_color(int material, cast_ray_result ray) { |
return (
material == MATERIAL_RED_LIGHTER ? vec3(1.0, 0.8, 0.8) :
material == MATERIAL_RED_DARKER ? vec3(1.0, 0.4, 0.4) :
material == MATERIAL_GREEN_LIGHTER ? vec3(0.1, 0.8, 0.3) :
material == MATERIAL_GREEN_DARKER ? vec3(0.0, 0.6, 0.1) :
material == MATERIAL_PLANE ? vec3(0.... | // Get surface color given a material number
// plus ray intersection data.
vec3 get_material_color(int material, cast_ray_result ray) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
3510,
3628,
3675,
3675,
3895
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Get reflectivity of a material.
// 0.0 is not reflective at all.
// 1.0 is maximally reflective, a perfect mirror.
| float get_material_reflectivity(int material) { |
return (
material == MATERIAL_NONE ? 0.0 :
material == MATERIAL_PLANE ? 0.8 :
material == MATERIAL_RED_LIGHTER ? 0.25 :
material == MATERIAL_RED_DARKER ? 0.25 :
0.125
);
} | // Get reflectivity of a material.
// 0.0 is not reflective at all.
// 1.0 is maximally reflective, a perfect mirror.
float get_material_reflectivity(int material) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
3897,
3939,
3984,
3984,
4117
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Get index of refraction of a material.
| float get_material_refraction(int material) { |
return (
material == MATERIAL_RED_LIGHTER ? 1.25 :
material == MATERIAL_RED_DARKER ? 1.25 :
0.0
);
} | // Get index of refraction of a material.
float get_material_refraction(int material) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
4119,
4209,
4251,
4251,
4384
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Get opacity of a material.
// 0.0 is totally transparent.
// 1.0 is completely opaque.
| float get_material_opacity(int material) { |
return (
material == MATERIAL_RED_LIGHTER ? 0.25 :
material == MATERIAL_RED_DARKER ? 0.25 :
1.0
);
} | // Get opacity of a material.
// 0.0 is totally transparent.
// 1.0 is completely opaque.
float get_material_opacity(int material) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
4386,
4541,
4629,
4629,
5005
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Determine whether a line intersects a triangle.
// Returns a vector whose components are: (intersected?, U, V)
// https://www.shadertoy.com/view/MlGcDz
| vec3 line_intersects_tri(vec3 line_a, vec3 line_b, vec3 tri_a, vec3 tri_b, vec3 tri_c) { |
vec3 v1v0 = tri_b - tri_a;
vec3 v2v0 = tri_c - tri_a;
vec3 rov0 = line_a - tri_a;
vec3 n = cross(v1v0, v2v0);
vec3 q = cross(rov0, line_b);
float d = 1.0 / dot(line_b, n);
float u = d * dot(-q, v2v0);
float v = d * dot(q, v1v0);
float t = d * dot(-n, rov0);
if(u < 0.0 || v < 0.0... | // Determine whether a line intersects a triangle.
// Returns a vector whose components are: (intersected?, U, V)
// https://www.shadertoy.com/view/MlGcDz
vec3 line_intersects_tri(vec3 line_a, vec3 line_b, vec3 tri_a, vec3 tri_b, vec3 tri_c) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
5007,
5235,
5300,
5300,
5393
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Given the three points of a triangle in clockwise order,
// compute the surface normal of that triangle.
// https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal#targetText=A%20surface%20normal%20for%20a,winding).
| vec3 get_tri_surface_normal(vec3 tri_a, vec3 tri_b, vec3 tri_c) { |
vec3 u = tri_b - tri_a;
vec3 v = tri_c - tri_a;
return normalize(cross(u, v));
} | // Given the three points of a triangle in clockwise order,
// compute the surface normal of that triangle.
// https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal#targetText=A%20surface%20normal%20for%20a,winding).
vec3 get_tri_surface_normal(vec3 tri_a, vec3 tri_b, vec3 tri_c) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
5395,
5579,
5642,
5642,
5846
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Generate a look-at rotation matrix based on a camera
// position and view target.
// https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/lookat-function
| mat3 look_at_matrix(vec3 camera_position, vec3 camera_target) { |
vec3 forward = normalize(camera_target - camera_position);
vec3 right = normalize(cross(vec3(0.0, 1.0, 0.0), forward));
vec3 up = cross(forward, right);
return mat3(right, up, forward);
} | // Generate a look-at rotation matrix based on a camera
// position and view target.
// https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/lookat-function
mat3 look_at_matrix(vec3 camera_position, vec3 camera_target) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
5848,
6015,
6075,
6075,
7284
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Check all triangles in the scene for intersection with a ray.
// Return information about the intersection nearest to ray_origin,
// if there was any intersection.
| cast_ray_result cast_ray(vec3 ray_origin, vec3 ray_target) { |
int result_tri_index = -1;
vec2 result_uv = vec2(0.0);
float result_dist = 1e18;
vec3 result_intersection = vec3(0.0);
for(int tri_index = 0; tri_index < NUM_TRIANGLES; tri_index++) {
vec3 tri_a = vertices[triangles[tri_index].x];
vec3 tri_b = vertices[triangles[tri_index].y];
... | // Check all triangles in the scene for intersection with a ray.
// Return information about the intersection nearest to ray_origin,
// if there was any intersection.
cast_ray_result cast_ray(vec3 ray_origin, vec3 ray_target) { | 1 | 1 |
Wdd3zs | pineapplemachine | 2019-09-22T07:35:58 | // This shader was written by Sophie Kirschner.
// It is released under a CC0 public domain license.
// Maximum number of reflections/refractions per fragment
// Higher numbers look better but are more demanding
#define MAX_PATHS 8
// Color of the "void" - the space behind the scene
#define VOID_COLOR vec3(0.45, 0.65... | cc0-1.0 | [
7286,
7453,
7510,
7510,
8476
] | [
[
2998,
3074,
3134,
3134,
3508
],
[
3510,
3628,
3675,
3675,
3895
],
[
3897,
3939,
3984,
3984,
4117
],
[
4119,
4209,
4251,
4251,
4384
],
[
4386,
4541,
4629,
4629,
5005
],
[
5007,
5235,
... | // Cast a ray from a surface toward the scene's directional light
// source and determine how much in shadow the surface is.
// Considers opacity, but not refraction.
| float cast_shadow_ray(vec3 ray_origin, vec3 ray_target) { |
float shadow_amount = 0.0;
for(int tri_index = 0; tri_index < NUM_TRIANGLES; tri_index++) {
vec3 tri_a = vertices[triangles[tri_index].x];
vec3 tri_b = vertices[triangles[tri_index].y];
vec3 tri_c = vertices[triangles[tri_index].z];
vec3 intersection = line_intersects_tri(
... | // Cast a ray from a surface toward the scene's directional light
// source and determine how much in shadow the surface is.
// Considers opacity, but not refraction.
float cast_shadow_ray(vec3 ray_origin, vec3 ray_target) { | 1 | 1 |
Wt2XzK | iq | 2019-09-13T08:10:46 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2023,
2091,
2154,
2154,
2559
] | [
[
2023,
2091,
2154,
2154,
2559
],
[
2561,
2561,
2608,
2608,
3011
],
[
3013,
3013,
3070,
3070,
4240
]
] | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| vec4 iBox( in vec3 ro, in vec3 rd, in mat4 tx, in vec3 rad )
{ |
vec3 rdd = (tx*vec4(rd,0.0)).xyz;
vec3 roo = (tx*vec4(ro,1.0)).xyz;
vec3 m = 1.0/rdd;
vec3 n = m*roo;
vec3 k = abs(m)*rad;
vec3 t1 = -n - k;
vec3 t2 = -n + k;
float tN = max( max( t1.x, t1.y ), t1.z );
float tF = min( min( t2.x, t2.y ), t2.z );
if( tN > tF || tF < 0.0) return vec4(-1.0);
vec3... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
vec4 iBox( in vec3 ro, in vec3 rd, in mat4 tx, in vec3 rad )
{ | 1 | 1 |
3sd3Rs | iq | 2019-10-07T04:24:59 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2074,
2089,
2117,
2134,
2461
] | [
[
2074,
2089,
2117,
2134,
2461
],
[
2463,
2493,
2521,
2521,
2724
],
[
2764,
2764,
2789,
2789,
2970
],
[
2973,
2973,
3030,
3030,
3778
],
[
3780,
3780,
3803,
3844,
3966
]
] | // Basic noise
| float bnoise( in float x )
{ |
float i = floor(x);
float f = fract(x);
float s = sign(fract(x/2.0)-0.5);
// use some hash to create a random value k in [0..1] from i
//float k = hash(uint(i));
//float k = 0.5+0.5*sin(i);
float k = fract(i*.1731);
// quartic polynomial
return s*f*(f-1.0)*((16.0*k-4.0)*f*(f-1.0)-... | // Basic noise
float bnoise( in float x )
{ | 2 | 4 |
3sd3Rs | iq | 2019-10-07T04:24:59 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2463,
2493,
2521,
2521,
2724
] | [
[
2074,
2089,
2117,
2134,
2461
],
[
2463,
2493,
2521,
2521,
2724
],
[
2764,
2764,
2789,
2789,
2970
],
[
2973,
2973,
3030,
3030,
3778
],
[
3780,
3780,
3803,
3844,
3966
]
] | // Traditional gradient noise
| float gnoise( in float p )
{ |
uint i = uint(floor(p));
float f = fract(p);
float u = f*f*(3.0-2.0*f);
float g0 = hash(i+0u)*2.0-1.0;
float g1 = hash(i+1u)*2.0-1.0;
return 2.4*mix( g0*(f-0.0), g1*(f-1.0), u);
} | // Traditional gradient noise
float gnoise( in float p )
{ | 1 | 2 |
WsV3zz | iq | 2019-10-01T00:21:04 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1950,
1989,
2011,
2011,
2153
] | [
[
1950,
1989,
2011,
2011,
2153
],
[
2155,
2173,
2201,
2201,
2359
],
[
2361,
2368,
2405,
2405,
2660
],
[
2662,
2662,
2698,
2698,
4074
]
] | // integer hash copied from Hugo Elias
| float hash( int n )
{ |
n = (n << 13) ^ n;
n = n * (n * n * 15731 + 789221) + 1376312589;
return -1.0+2.0*float( n & ivec3(0x0fffffff))/float(0x0fffffff);
} | // integer hash copied from Hugo Elias
float hash( int n )
{ | 1 | 1 |
WsV3zz | iq | 2019-10-01T00:21:04 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2155,
2173,
2201,
2201,
2359
] | [
[
1950,
1989,
2011,
2011,
2153
],
[
2155,
2173,
2201,
2201,
2359
],
[
2361,
2368,
2405,
2405,
2660
],
[
2662,
2662,
2698,
2698,
4074
]
] | // gradient noise
| float gnoise( in float p )
{ |
int i = int(floor(p));
float f = fract(p);
float u = f*f*(3.0-2.0*f);
return mix( hash(i+0)*(f-0.0),
hash(i+1)*(f-1.0), u);
} | // gradient noise
float gnoise( in float p )
{ | 1 | 2 |
WsV3zz | iq | 2019-10-01T00:21:04 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2361,
2368,
2405,
2405,
2660
] | [
[
1950,
1989,
2011,
2011,
2153
],
[
2155,
2173,
2201,
2201,
2359
],
[
2361,
2368,
2405,
2405,
2660
],
[
2662,
2662,
2698,
2698,
4074
]
] | // fbm
| float fbm( in float x, in float G )
{ |
x += 26.06;
float n = 0.0;
float s = 1.0;
float a = 0.0;
float f = 1.0;
for( int i=0; i<16; i++ )
{
n += s*gnoise(x*f);
a += s;
s *= G;
f *= 2.0;
x += 0.31;
}
return n;
} | // fbm
float fbm( in float x, in float G )
{ | 1 | 2 |
tdKSRR | iq | 2019-11-09T03:06:28 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1918,
2039,
2067,
2121,
3943
] | [
[
1918,
2039,
2067,
2121,
3943
],
[
4004,
4004,
4063,
4063,
4226
],
[
4228,
4228,
4300,
4300,
4495
],
[
4513,
4513,
4574,
4574,
4675
],
[
4677,
4677,
4721,
4721,
4758
],
[
4760,
4760,
... | // For a point in the sphere's surface p, return a color based on
// the solutions of the associate quadratic polynomial
| vec3 getColor( in vec3 p )
{ |
float an = 0.5*iTime;
float si = sin(an), co = cos(an);
p.xz = mat2(co,-si,si,co)*p.xz;
vec3 col = vec3(0.0);
float m = 11.0;
// solve quadratic
float h = p.y*p.y - 4.0*p.x*p.z;
if( h<0.0 )
{
// Complex solution. Make it blue
col = vec3(0.0,0.5,1.0);
... | // For a point in the sphere's surface p, return a color based on
// the solutions of the associate quadratic polynomial
vec3 getColor( in vec3 p )
{ | 1 | 1 |
tsVSRR | iq | 2019-11-09T03:06:40 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1136,
1417,
1463,
1463,
3245
] | [
[
1136,
1417,
1463,
1463,
3245
],
[
3306,
3374,
3446,
3446,
3844
],
[
3847,
3915,
3985,
3985,
4256
],
[
4258,
4258,
4296,
4296,
4378
],
[
4380,
4380,
4420,
4420,
4452
],
[
4511,
4511,
... | // For a point p in the unit box, return a color
// based on the solutions of the associated cubic
// polynomial. The point p is interprested as the
// 3 polar angles of a 4D point in a unit sphere,
// and that 4D point maps to a unique cubic
// polynomials a,b,c,d coefficients.
| vec3 getColor( in vec3 pb ) // p is in -1..1
{ |
vec3 col = vec3(0.0);
float m = 0.0;
//-------------------------------------------------------
// convert from box space to cannoincal 0..1
pb = 0.5 + 0.498*pb/vec3(1.0,1.0,2.0);
pb += vec3(0.5,0.5,0.5);
// convert to 4D polar coordinates with radius=1
pb *= vec3(3... | // For a point p in the unit box, return a color
// based on the solutions of the associated cubic
// polynomial. The point p is interprested as the
// 3 polar angles of a 4D point in a unit sphere,
// and that 4D point maps to a unique cubic
// polynomials a,b,c,d coefficients.
vec3 getColor( in vec3 pb ) // p is in ... | 1 | 1 |
tsVSRR | iq | 2019-11-09T03:06:40 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3306,
3374,
3446,
3446,
3844
] | [
[
1136,
1417,
1463,
1463,
3245
],
[
3306,
3374,
3446,
3446,
3844
],
[
3847,
3915,
3985,
3985,
4256
],
[
4258,
4258,
4296,
4296,
4378
],
[
4380,
4380,
4420,
4420,
4452
],
[
4511,
4511,
... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| vec4 boxIntersect( in vec3 ro, in vec3 rd, in vec3 cen, in vec3 rad )
{ |
ro -= cen;
// ray-box intersection in box space
vec3 m = 1.0/rd;
vec3 n = m*ro;
vec3 k = abs(m)*rad;
vec3 t1 = -n - k;
vec3 t2 = -n + k;
float tN = max( max( t1.x, t1.y ), t1.z );
float tF = min( min( t2.x, t2.y ), t2.z );
if( tN > tF || tF < 0.0) return vec4(-1.0);
vec3 nor = -... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
vec4 boxIntersect( in vec3 ro, in vec3 rd, in vec3 cen, in vec3 rad )
{ | 1 | 1 |
tsVSRR | iq | 2019-11-09T03:06:40 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3847,
3915,
3985,
3985,
4256
] | [
[
1136,
1417,
1463,
1463,
3245
],
[
3306,
3374,
3446,
3446,
3844
],
[
3847,
3915,
3985,
3985,
4256
],
[
4258,
4258,
4296,
4296,
4378
],
[
4380,
4380,
4420,
4420,
4452
],
[
4511,
4511,
... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| float boxShadow( in vec3 ro, in vec3 rd, in vec3 cen, in vec3 rad )
{ |
ro -= cen;
vec3 m = 1.0/rd;
vec3 n = m*ro;
vec3 k = abs(m)*rad;
vec3 t1 = -n - k;
vec3 t2 = -n + k;
float tN = max( max( t1.x, t1.y ), t1.z );
float tF = min( min( t2.x, t2.y ), t2.z );
if( tN > tF || tF < 0.0) return -1.0;
return tN;
} | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
float boxShadow( in vec3 ro, in vec3 rd, in vec3 cen, in vec3 rad )
{ | 1 | 1 |
WdVXRm | blackle | 2019-11-13T18:46:25 | //CC0 1.0 Universal https://creativecommons.org/publicdomain/zero/1.0/
//To the extent possible under law, Blackle Mori has waived all copyright and related or neighboring rights to this work.
#define FK(k) floatBitsToInt(cos(k))^floatBitsToInt(k)
float hash1(float k) {
int x = FK(k);int y = FK(cos(k));
return... | cc0-1.0 | [
488,
526,
566,
566,
632
] | [
[
249,
249,
271,
271,
355
],
[
357,
357,
378,
378,
486
],
[
488,
526,
566,
566,
632
],
[
634,
634,
669,
669,
797
],
[
799,
799,
842,
842,
883
],
[
885,
885,
937,
937,
1204
],... | //rotate P around axis AX by angle RO
| vec3 rotate(vec3 p, vec3 ax, float ro) { |
return mix(dot(p,ax)*ax, p, cos(ro)) + sin(ro)*cross(ax,p);
} | //rotate P around axis AX by angle RO
vec3 rotate(vec3 p, vec3 ax, float ro) { | 1 | 1 |
WdyXRD | iq | 2019-11-11T20:42:12 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
3622,
3892,
3965,
3965,
4295
] | [
[
1435,
1435,
1460,
1460,
1475
],
[
1477,
1477,
1508,
1508,
1599
],
[
1601,
1601,
1636,
1636,
1664
],
[
1666,
1666,
1710,
1710,
1827
],
[
1829,
1829,
1913,
1913,
2185
],
[
2187,
2187,
... | //------------------------------------------------------------------
//
// Approximated soft shadows, based on
//
// http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
//
// and
//
// https://www.shadertoy.com/view/tscSRS
//
// and further fixed and improved
//
| float apprSoftShadow(vec3 ro, vec3 rd, float mint, float tmax, float w)
{ |
float t = mint;
float res = 1.0;
for( int i=0; i<256; i++ )
{
float h = map(ro + t*rd);
res = min( res, h/(w*t) );
t += clamp(h, 0.005, 0.50);
if( res<-1.0 || t>tmax ) break;
}
res = max(res,-1.0); // clamp to [-1,1]
return 0.25*(1.0+res)*(1.0+res)*(2.0-res); // sm... | //------------------------------------------------------------------
//
// Approximated soft shadows, based on
//
// http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
//
// and
//
// https://www.shadertoy.com/view/tscSRS
//
// and further fixed and improved
//
float apprSoftShadow(vec3 ro, vec3 rd, float mint,... | 1 | 3 |
WdyXRD | iq | 2019-11-11T20:42:12 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
4298,
4366,
4384,
4384,
4424
] | [
[
1435,
1435,
1460,
1460,
1475
],
[
1477,
1477,
1508,
1508,
1599
],
[
1601,
1601,
1636,
1636,
1664
],
[
1666,
1666,
1710,
1710,
1827
],
[
1829,
1829,
1913,
1913,
2185
],
[
2187,
2187,
... | // montecarlo based shadow, for ground truth comparison
float seed; | float rand(void) { | return fract(sin(seed++)*768.475278); } | // montecarlo based shadow, for ground truth comparison
float seed; float rand(void) { | 1 | 1 |
Ws3XWl | iq | 2019-11-13T23:45:13 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1655,
1729,
1751,
1751,
1854
] | [
[
1655,
1729,
1751,
1751,
1854
],
[
1856,
1926,
1957,
1957,
2048
],
[
2050,
2102,
2143,
2143,
2215
],
[
2217,
2285,
2336,
2336,
2604
],
[
2801,
2801,
2828,
2828,
4022
],
[
4024,
4175,
... | // please, do not use in real projects - replace this by something better
| float hash(vec3 p)
{ |
p = 17.0*fract( p*0.3183099+vec3(.11,.17,.13) );
return fract( p.x*p.y*p.z*(p.x+p.y+p.z) );
} | // please, do not use in real projects - replace this by something better
float hash(vec3 p)
{ | 2 | 2 |
Ws3XWl | iq | 2019-11-13T23:45:13 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1856,
1926,
1957,
1957,
2048
] | [
[
1655,
1729,
1751,
1751,
1854
],
[
1856,
1926,
1957,
1957,
2048
],
[
2050,
2102,
2143,
2143,
2215
],
[
2217,
2285,
2336,
2336,
2604
],
[
2801,
2801,
2828,
2828,
4022
],
[
4024,
4175,
... | // http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
| 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));
} | // http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
float sdBox( vec3 p, vec3 b )
{ | 61 | 579 |
Ws3XWl | iq | 2019-11-13T23:45:13 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2050,
2102,
2143,
2143,
2215
] | [
[
1655,
1729,
1751,
1751,
1854
],
[
1856,
1926,
1957,
1957,
2048
],
[
2050,
2102,
2143,
2143,
2215
],
[
2217,
2285,
2336,
2336,
2604
],
[
2801,
2801,
2828,
2828,
4022
],
[
4024,
4175,
... | // http://iquilezles.org/www/articles/smin/smin.htm
| float smax( float a, float b, float k )
{ |
float h = max(k-abs(a-b),0.0);
return max(a, b) + h*h*0.25/k;
} | // http://iquilezles.org/www/articles/smin/smin.htm
float smax( float a, float b, float k )
{ | 21 | 42 |
Ws3XWl | iq | 2019-11-13T23:45:13 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2217,
2285,
2336,
2336,
2604
] | [
[
1655,
1729,
1751,
1751,
1854
],
[
1856,
1926,
1957,
1957,
2048
],
[
2050,
2102,
2143,
2143,
2215
],
[
2217,
2285,
2336,
2336,
2604
],
[
2801,
2801,
2828,
2828,
4022
],
[
4024,
4175,
... | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
| vec2 iBox( in vec3 ro, in vec3 rd, in vec3 rad )
{ |
vec3 m = 1.0/rd;
vec3 n = m*ro;
vec3 k = abs(m)*rad;
vec3 t1 = -n - k;
vec3 t2 = -n + k;
float tN = max( max( t1.x, t1.y ), t1.z );
float tF = min( min( t2.x, t2.y ), t2.z );
if( tN > tF || tF < 0.0) return vec2(-1.0);
return vec2( tN, tF );
} | // http://iquilezles.org/www/articles/boxfunctions/boxfunctions.htm
vec2 iBox( in vec3 ro, in vec3 rd, in vec3 rad )
{ | 4 | 24 |
Ws3XWl | iq | 2019-11-13T23:45:13 | // The MIT License
// Copyright © 2019 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
5533,
5595,
5668,
5695,
6167
] | [
[
1655,
1729,
1751,
1751,
1854
],
[
1856,
1926,
1957,
1957,
2048
],
[
2050,
2102,
2143,
2143,
2215
],
[
2217,
2285,
2336,
2336,
2604
],
[
2801,
2801,
2828,
2828,
4022
],
[
4024,
4175,
... | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
| float calcSoftShadow(vec3 ro, vec3 rd, float tmin, float tmax, float w)
{ |
vec2 dis = iBox( ro, rd, vec3(1.0) ) ;
if( dis.y<0.0 ) return 1.0;
tmin = max(tmin,dis.x);
tmax = min(tmax,dis.y);
float t = tmin;
float res = 1.0;
for( int i=0; i<128; i++ )
{
float h = map(ro + t*rd).x;
res = min( res, h/(w*t) );
t += clamp(h, 0.005, 0.50);
... | // http://iquilezles.org/www/articles/rmshadows/rmshadows.htm
float calcSoftShadow(vec3 ro, vec3 rd, float tmin, float tmax, float w)
{ | 1 | 1 |
Wl33RN | Codax | 2019-12-11T04:07:01 | // The MIT License
// Copyright © 2019 Miguel "Codax" Nieves
// Twitter: @GameDevMig
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights ... | mit | [
1138,
1212,
1280,
1280,
1323
] | [
[
1138,
1212,
1280,
1280,
1323
],
[
1325,
1325,
1382,
1432,
4255
]
] | //Inigo Quilez's Palette Function
//https://www.shadertoy.com/view/ll2GD3
| vec3 pal( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d )
{ |
return a + b*cos( 6.28318*(c*t+d) );
} | //Inigo Quilez's Palette Function
//https://www.shadertoy.com/view/ll2GD3
vec3 pal( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d )
{ | 68 | 75 |
tlVGDc | iq | 2020-01-27T12:22:54 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1347,
1387,
1451,
1451,
1709
] | [
[
1288,
1288,
1317,
1317,
1345
],
[
1347,
1387,
1451,
1451,
1709
],
[
1712,
1712,
1738,
1738,
1797
],
[
1799,
1863,
1895,
1895,
2134
]
] | // la,lb=semi axis, h=height, ra=corner
| float sdRhombus(vec3 p, float la, float lb, float h, float ra)
{ |
p = abs(p);
vec2 b = vec2(la,lb);
float f = clamp( (ndot(b,b-2.0*p.xz))/dot(b,b), -1.0, 1.0 );
vec2 q = vec2(length(p.xz-0.5*b*vec2(1.0-f,1.0+f))*sign(p.x*b.y+p.z*b.x-b.x*b.y)-ra, p.y-h);
return min(max(q.x,q.y),0.0) + length(max(q,0.0));
} | // la,lb=semi axis, h=height, ra=corner
float sdRhombus(vec3 p, float la, float lb, float h, float ra)
{ | 8 | 12 |
3ttSWX | iq | 2020-02-16T12:20:24 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1556,
1660,
1727,
1727,
2402
] | [
[
1450,
1450,
1475,
1475,
1494
],
[
1495,
1495,
1528,
1528,
1554
],
[
1556,
1660,
1727,
1727,
2402
],
[
2405,
2405,
2462,
2498,
3664
]
] | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
| vec4 paSegment( in vec2 p, vec2 a, vec2 b, float r, float band )
{ |
vec2 ba = b-a;
vec2 pa = p-a;
vec2 pb = p-b;
float f = dot(pa,ba)/dot(ba,ba);
float h = clamp(f, 0.0, 1.0 );
float d = length(pa-h*ba) - r;
float ra = band*round(d/band);
float lba = length(ba);
float l = 0.0;
if( f<0.0 )
{
l = (r+ra)*atan(dot(pa,b... | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
vec4 paSegment( in vec2 p, vec2 a, vec2 b, float r, float band )
{ | 1 | 1 |
tldSRj | iq | 2020-02-10T21:16:53 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2510,
2662,
2680,
2680,
2725
] | [
[
2510,
2662,
2680,
2680,
2725
],
[
2833,
2833,
2854,
2854,
3194
],
[
3196,
3196,
3253,
3253,
3857
]
] | // You should replace this hash by one that you like and meets
// your needs. This one is here just as example and should not
// be used in production.
| vec2 g( vec2 n ) { | return sin(n.x*n.y*vec2(12,17)+vec2(1,2)); } | // You should replace this hash by one that you like and meets
// your needs. This one is here just as example and should not
// be used in production.
vec2 g( vec2 n ) { | 2 | 3 |
ttcXWX | iq | 2020-02-16T12:20:31 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1315,
1419,
1505,
1505,
2016
] | [
[
1259,
1259,
1286,
1286,
1313
],
[
1315,
1419,
1505,
1505,
2016
],
[
2018,
2018,
2075,
2104,
3227
]
] | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
| vec4 paBox( in vec2 p,
in vec2 b, in float r,
in float s )
{ |
vec2 q = abs(p)-b;
float l = b.x+b.y + 1.570796*r;
float k1 = min(max(q.x,q.y),0.0) + length(max(q,0.0))-r;
float k2 = ((q.x>0.0)?atan(q.y,q.x):1.570796);
float k3 = 3.0 + 2.0*msign(min(p.x,-p.y)) - msign(p.x);
float k4 = msign(p.x*p.y);
float k5 = r*k2+max(-q.x,0.0);
... | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
vec4 paBox( in vec2 p,
in vec2 b, in float r,
in float s )
{ | 1 | 1 |
wlcXD2 | iq | 2020-02-15T06:10:55 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2583,
2678,
2715,
2715,
2976
] | [
[
2583,
2678,
2715,
2715,
2976
],
[
2979,
2979,
3036,
3036,
3709
]
] | // .x = f(p)
// .y = ∂f(p)/∂x
// .z = ∂f(p)/∂y
// .yz = ∇f(p) with ‖∇f(p)‖ = 1
| vec3 sdgBox( in vec2 p, in vec2 b )
{ |
vec2 w = abs(p)-b;
vec2 s = vec2(p.x<0.0?-1:1,p.y<0.0?-1:1);
float g = max(w.x,w.y);
vec2 q = max(w,0.0);
float l = length(q);
return vec3( (g>0.0)?l : g,
s*((g>0.0)?q/l : ((w.x>w.y)?vec2(1,0):vec2(0,1))));
} | // .x = f(p)
// .y = ∂f(p)/∂x
// .z = ∂f(p)/∂y
// .yz = ∇f(p) with ‖∇f(p)‖ = 1
vec3 sdgBox( in vec2 p, in vec2 b )
{ | 4 | 5 |
WldSWX | iq | 2020-02-16T12:20:17 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1504,
1608,
1658,
1658,
1820
] | [
[
1398,
1398,
1423,
1423,
1442
],
[
1443,
1443,
1476,
1476,
1502
],
[
1504,
1608,
1658,
1658,
1820
],
[
1822,
1822,
1879,
1915,
2896
]
] | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
| vec4 paCircle( in vec2 p, float r, float band )
{ |
float d = length(p) - r;
float ra = band*round(d/band);
float l = (r+ra)*(atan(p.x,p.y)+3.1415927);
return vec4( d-ra, l, 6.283185*(r+ra), d );
} | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
vec4 paCircle( in vec2 p, float r, float band )
{ | 1 | 1 |
wtcSDf | iq | 2020-02-16T12:20:37 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1595,
1636,
1691,
1691,
2194
] | [
[
1489,
1489,
1514,
1514,
1533
],
[
1534,
1534,
1567,
1567,
1593
],
[
1595,
1636,
1691,
1691,
2194
],
[
2196,
2196,
2233,
2233,
2316
],
[
2322,
2426,
2489,
2489,
3567
],
[
3574,
3574,
... | // https://www.shadertoy.com/view/wdBXRW
| float sdPoly( in vec2 p, vec2 verts[5], in float r )
{ |
const int num = verts.length();
float s = 1.0;
float d = length(p-verts[0]);
for( int i=0; i<num; i++ )
{
vec2 a = verts[i];
vec2 b = verts[(i+1)%num];
vec2 pa = p-a;
vec2 ba = b-a;
float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
d = min(d,l... | // https://www.shadertoy.com/view/wdBXRW
float sdPoly( in vec2 p, vec2 verts[5], in float r )
{ | 1 | 1 |
wtcSDf | iq | 2020-02-16T12:20:37 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
2322,
2426,
2489,
2489,
3567
] | [
[
1489,
1489,
1514,
1514,
1533
],
[
1534,
1534,
1567,
1567,
1593
],
[
1595,
1636,
1691,
1691,
2194
],
[
2196,
2196,
2233,
2233,
2316
],
[
2322,
2426,
2489,
2489,
3567
],
[
3574,
3574,
... | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
| vec4 paPoly( in vec2 p, vec2 verts[5], float r, float band )
{ |
const int num = verts.length();
float od = sdPoly( p, verts, r );
float ra = band*round(od/band);
float d = length(p-verts[0])-ra;
float l = 0.0;
float t = 0.0;
for( int i=0; i<num; i++ )
{
vec2 a = verts[ i ];
vec2 b = verts[(i+1)%num];
vec2 c =... | // x = local dist
// y = local perimeter dist
// z = total local perimeter
// w = global distance (sdf)
vec4 paPoly( in vec2 p, vec2 verts[5], float r, float band )
{ | 1 | 1 |
WtdSDj | iq | 2020-02-15T06:10:52 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1399,
1494,
1546,
1546,
1719
] | [
[
1399,
1494,
1546,
1546,
1719
]
] | // .x = f(p)
// .y = ∂f(p)/∂x
// .z = ∂f(p)/∂y
// .yz = ∇f(p) with ‖∇f(p)‖ = 1
| vec3 sdgSegment( in vec2 p, in vec2 a, in vec2 b )
{ |
vec2 ba = b-a;
vec2 pa = p-a;
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
vec2 q = pa-h*ba;
float d = length(q);
return vec3(d,q/d);
} | // .x = f(p)
// .y = ∂f(p)/∂x
// .z = ∂f(p)/∂y
// .yz = ∇f(p) with ‖∇f(p)‖ = 1
vec3 sdgSegment( in vec2 p, in vec2 a, in vec2 b )
{ | 1 | 3 |
WtySRc | iq | 2020-03-03T05:43:03 | // The MIT License
// Copyright © 2020 Inigo Quilez
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publ... | mit | [
1402,
1497,
1540,
1540,
1858
] | [
[
1402,
1497,
1540,
1540,
1858
],
[
1860,
1860,
1917,
1917,
2627
]
] | // .x = f(p)
// .y = ∂f(p)/∂x
// .z = ∂f(p)/∂y
// .yz = ∇f(p) with ‖∇f(p)‖ = 1
| vec3 sdgHexagon( in vec2 p, in float r )
{ |
const vec3 k = vec3(-0.866025404,0.5,0.577350269);
vec2 s = sign(p);
p = abs(p);
float w = dot(k.xy,p);
p -= 2.0*min(w,0.0)*k.xy;
p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);
float d = length(p)*sign(p.y);
vec2 g = (w<0.0) ? mat2(-k.y,-k.x,-k.x,k.y)*p : p;
return vec3( d, s*g/d );
} | // .x = f(p)
// .y = ∂f(p)/∂x
// .z = ∂f(p)/∂y
// .yz = ∇f(p) with ‖∇f(p)‖ = 1
vec3 sdgHexagon( in vec2 p, in float r )
{ | 2 | 2 |
td2cDd | blackle | 2020-04-22T13:51:28 | //CC0 1.0 Universal https://creativecommons.org/publicdomain/zero/1.0/
//To the extent possible under law, Blackle Mori has waived all copyright and related or neighboring rights to this work.
float smin(float a, float b, float k) {
float h = max(0., k-abs(a-b))/k;
return min(a,b)-h*h*h*k/6.;
}
//smooth triangle ... | cc0-1.0 | [
302,
399,
427,
427,
468
] | [
[
194,
194,
233,
233,
300
],
[
302,
399,
427,
427,
468
],
[
470,
470,
491,
491,
806
],
[
808,
808,
827,
827,
958
],
[
960,
960,
998,
998,
1060
],
[
1062,
1062,
1100,
1100,
1138... | //smooth triangle wave for smooth domain repetition https://www.desmos.com/calculator/ototv6tja8
| vec4 stri(vec4 p, float k) { |
return asin(sin(p*3.14)*k)/3.14+0.5;
} | //smooth triangle wave for smooth domain repetition https://www.desmos.com/calculator/ototv6tja8
vec4 stri(vec4 p, float k) { | 1 | 1 |
Ws2cRh | mla | 2020-04-05T15:23:23 | ////////////////////////////////////////////////////////////////////////////////
//
// Projective Conic Envelope
//
// Copyright (c) Matthew Arcus, 2020
// MIT License: https://opensource.org/licenses/MIT
//
// More projective magic - generate an ellipse as an envelope of lines.
// In fact, we start with the ellipse an... | mit | [
1104,
1226,
1287,
1287,
1926
] | [
[
879,
879,
906,
1004,
1027
],
[
1029,
1029,
1057,
1057,
1102
],
[
1104,
1226,
1287,
1287,
1926
],
[
1928,
1928,
1955,
1955,
2131
],
[
2133,
2133,
2186,
2186,
4385
]
] | // Set tan1 and tan2 to the two tangents to conic X from point p.
// Return false if no tangents (eg. inside an ellipse).
| bool tangents(vec3 p, mat3 X, out vec3 tan1, out vec3 tan2) { |
vec3 polar = X*p; // Line between tangents
float a = polar.x, b = polar.y, c = polar.z;
// Two points on the polar line. Q is the nearest point to origin,
// R is at infinity, ie. is direction vector.
vec3 Q = vec3(a,b,-(a*a+b*b)/c);
vec3 R = vec3(-b,a,0);
// Find intersection of QR with conic, ie. dot(... | // Set tan1 and tan2 to the two tangents to conic X from point p.
// Return false if no tangents (eg. inside an ellipse).
bool tangents(vec3 p, mat3 X, out vec3 tan1, out vec3 tan2) { | 1 | 1 |
wsByDh | andretugan | 2020-04-10T14:41:54 | // Author: https://www.shadertoy.com/user/andretugan
// Creative Commons Attribution-NonCommercial 3.0 Unported License
// https://creativecommons.org/licenses/by-nc/3.0
#define NUM_CHORDS 128
#define M_PI 3.14159265358
#define M_2_PI (2. * 3.14159265358)
#define FADE_INNER_RADIUS 0.8
#define FADE_OUTER_RADIUS 1.1
#... | cc-by-3.0 | [
342,
413,
440,
440,
618
] | [
[
342,
413,
440,
440,
618
],
[
620,
620,
676,
676,
2123
]
] | // Function from Inigo Quilez
// https://www.shadertoy.com/view/MsS3Wc
| vec3 hsv2rgb( in vec3 c )
{ |
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb); // cubic smoothing
return c.z * mix( vec3(1.0), rgb, c.y);
} | // Function from Inigo Quilez
// https://www.shadertoy.com/view/MsS3Wc
vec3 hsv2rgb( in vec3 c )
{ | 17 | 54 |
td2fRD | blackle | 2020-05-16T19:52:37 | //CC0 1.0 Universal https://creativecommons.org/publicdomain/zero/1.0/
//To the extent possible under law, Blackle Mori has waived all copyright and related or neighboring rights to this work.
//this shader is an experiment with mapping a 4 dimensional SDF onto a 3 dimensional one, by
//using the components of 3d spac... | cc0-1.0 | [
1180,
1264,
1317,
1317,
1533
] | [
[
1180,
1264,
1317,
1317,
1533
],
[
1590,
1590,
1620,
1620,
1700
],
[
1702,
1702,
1740,
1740,
1802
],
[
1804,
1804,
1843,
1843,
1914
],
[
1933,
1933,
1954,
1954,
3086
],
[
3088,
3088,
... | //return the SDF for a sphere, or the SDF for an empty region surrounded by spheres
| float gated_domain(vec4 p, float scale, bool gated) { |
if (!gated) {
p.yzw = abs(p.yzw);
if (p.y > p.z) p.yz = p.zy;
if (p.z > p.w) p.zw = p.wz;
if (p.y > p.z) p.yz = p.zy;
p.w -= scale;
}
return length(p)-scale/2.2;
} | //return the SDF for a sphere, or the SDF for an empty region surrounded by spheres
float gated_domain(vec4 p, float scale, bool gated) { | 1 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.