Selected Student Works
This is a small selection of student works from the 2021 class “Advanced Computer Graphics”. The objective was to create an image of an orchid using a single fragment shader. You can see the full homework description if interested.
// credit: TT // orchid: Lycaste uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float PI=3.1415926535897932384626433832795; float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); // can delay this sqrt by rewriting the comparison return ((p.y-b)*d > p.x*b) ? length(p-vec2(0.000,b))*sign(d) : length(p-vec2(-d,0.0))-r; } float sdCircle( in vec2 p, in float r ) { return length(p)-r; } 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; } 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)); } float sdBox( in vec2 p, in vec2 b ) { vec2 d = abs(p)-b; return length(max(d,0.0)) + min(max(d.x,d.y),0.0); } vec2 rotate(vec2 p, float degree){ float c = cos(degree*PI/180.); float s = sin(degree*PI/180.); mat3 H = mat3(c, s, 0, -s, c, 0, 0, 0, 1); return (inverse(H) * vec3(p,1.0)).xy; } vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i, 289.0); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } void main() { float mask = 1.000; vec2 p = (2.0*gl_FragCoord.xy-u_resolution.xy)/u_resolution.xy ; float ra1_a = 0.468; float ra2_a = 0.080; float wid_a = max(0.628,ra1_a); float ra1_b = 0.116; float ra2_b = -0.128; float wid_b = max(0.484,ra1_b); float ra1_c = 0.092; float ra2_c = -0.160; float wid_c = max(0.452,ra1_c); float d1 = sdVesica( rotate(p - vec2(0.380,-0.180),70.0), wid_a, ra1_a ) - ra2_a; float d2 = sdVesica( rotate(p - vec2(0.000,0.360),180.000), wid_a, ra1_a ) - ra2_a; float d3 = sdVesica( rotate(p - vec2(-0.380,-0.180),-70.0), wid_a, ra1_a ) - ra2_a; float d4 = sdVesica( rotate(p - vec2(-0.210,0.130),45.), wid_b, ra1_b ) - ra2_b; float d5 = sdVesica( rotate(p - vec2(0.210,0.130),-45.), wid_b, ra1_b ) - ra2_b; float d6 = sdVesica( rotate(p - vec2(0.000,-0.030),0.), wid_c, ra1_c ) - ra2_c; float d_c = sdCircle(p - vec2(0.000,0.070),0.052); float d_c2 = sdCircle(p - vec2(0.000,0.070),0.036); float ta = 4.732; float tb = 1.652; float rb = 0.022; float d_a = sdArc(p,vec2(sin(ta),cos(ta)),vec2(sin(tb),cos(tb)), 0.11, rb); float d_b = sdPie(rotate(p - vec2(0.000,-0.100),180.0),vec2(0.880,0.250), 0.12); float d_b2 = sdBox(rotate(p - vec2(0.270,-0.960),110.0),vec2(0.870,0.020)); vec3 colour = vec3( 1., 1., 1.); colour *= 1.0-mask; colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d1)) ); colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d2)) ); colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d3)) ); colour = mix( colour, vec3(0.317,0.735,0.040), 1.000-step(0.0, d_b2) ); colour = mix( colour, vec3(1.000,0.290,0.290), 1.000-step(0.0, d1) ); colour = mix( colour, vec3(1.000,0.290,0.290), 1.000-step(0.0, d2) ); colour = mix( colour, vec3(1.000,0.290,0.290), 1.000-step(0.0, d3) ); colour = mix( colour, vec3(1.000,0.944,0.179), 1.000-step(0.0, d6) ); colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d4)) ); colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d5)) ); colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d6)) ); colour = mix( colour, vec3(1.000,0.139,0.130), 1.000-step(0.0, d4) ); colour = mix( colour, vec3(1.000,0.139,0.130), 1.000-step(0.0, d5) ); colour = mix( colour, vec3(1.000,0.994,0.211), 1.000-step(0.0, d_c) ); colour = mix( colour, vec3(1.000,0.994,0.211), 1.000-smoothstep(0.0, 0.248, abs(d_c2)) ); colour = mix( colour, vec3(0.755,0.755,0.755), 1.000-smoothstep(0.0, 0.01, abs(d_c)) ); colour = mix( colour, vec3(0.705,0.026,0.074), 1.000-step(0.0, d_a) ); colour = mix( colour, vec3(0.805,0.030,0.084), 1.000-step(0.0, d_b) ); colour =(1.0-snoise(p*8.)*vec3(0.006,0.248,0.345))*colour; colour_out = vec4(colour,1.0); }
130
1
// credit: TT
2
// orchid: Lycaste
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
const float PI=3.1415926535897932384626433832795;
7
float sdVesica(vec2 p, float r, float d)
8
{
9
p = abs(p);
10
float b = sqrt(r*r-d*d); // can delay this sqrt by rewriting the comparison
11
return ((p.y-b)*d > p.x*b) ? length(p-vec2(0.000,b))*sign(d)
12
: length(p-vec2(-d,0.0))-r;
13
}
14
15
float sdCircle( in vec2 p, in float r )
16
{
17
return length(p)-r;
18
}
19
20
float sdArc( in vec2 p, in vec2 sca, in vec2 scb, in float ra, in float rb )
21
{
22
p *= mat2(sca.x,sca.y,-sca.y,sca.x);
23
p.x = abs(p.x);
24
float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p);
25
return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;
26
}
27
28
float sdPie( in vec2 p, in vec2 c, in float r )
29
{
30
p.x = abs(p.x);
31
float l = length(p) - r;
32
float m = length(p - c*clamp(dot(p,c),0.0,r) );
33
return max(l,m*sign(c.y*p.x-c.x*p.y));
34
}
35
36
float sdBox( in vec2 p, in vec2 b )
37
{
38
vec2 d = abs(p)-b;
39
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
40
}
41
42
vec2 rotate(vec2 p, float degree){
43
float c = cos(degree*PI/180.);
44
float s = sin(degree*PI/180.);
45
mat3 H = mat3(c, s, 0,
46
-s, c, 0,
47
0, 0, 1);
48
return (inverse(H) * vec3(p,1.0)).xy;
49
}
50
51
vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); }
52
53
float snoise(vec2 v){
54
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
55
-0.577350269189626, 0.024390243902439);
56
vec2 i = floor(v + dot(v, C.yy) );
57
vec2 x0 = v - i + dot(i, C.xx);
58
vec2 i1;
59
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
60
vec4 x12 = x0.xyxy + C.xxzz;
61
x12.xy -= i1;
62
i = mod(i, 289.0);
63
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
64
+ i.x + vec3(0.0, i1.x, 1.0 ));
65
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
66
dot(x12.zw,x12.zw)), 0.0);
67
m = m*m ;
68
m = m*m ;
69
vec3 x = 2.0 * fract(p * C.www) - 1.0;
70
vec3 h = abs(x) - 0.5;
71
vec3 ox = floor(x + 0.5);
72
vec3 a0 = x - ox;
73
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
74
vec3 g;
75
g.x = a0.x * x0.x + h.x * x0.y;
76
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
77
return 130.0 * dot(m, g);
78
}
79
80
void main() {
81
float mask = 1.000;
82
vec2 p = (2.0*gl_FragCoord.xy-u_resolution.xy)/u_resolution.xy ;
83
84
float ra1_a = 0.468;
85
float ra2_a = 0.080;
86
float wid_a = max(0.628,ra1_a);
87
float ra1_b = 0.116;
88
float ra2_b = -0.128;
89
float wid_b = max(0.484,ra1_b);
90
float ra1_c = 0.092;
91
float ra2_c = -0.160;
92
float wid_c = max(0.452,ra1_c);
93
float d1 = sdVesica( rotate(p - vec2(0.380,-0.180),70.0), wid_a, ra1_a ) - ra2_a;
94
float d2 = sdVesica( rotate(p - vec2(0.000,0.360),180.000), wid_a, ra1_a ) - ra2_a;
95
float d3 = sdVesica( rotate(p - vec2(-0.380,-0.180),-70.0), wid_a, ra1_a ) - ra2_a;
96
float d4 = sdVesica( rotate(p - vec2(-0.210,0.130),45.), wid_b, ra1_b ) - ra2_b;
97
float d5 = sdVesica( rotate(p - vec2(0.210,0.130),-45.), wid_b, ra1_b ) - ra2_b;
98
float d6 = sdVesica( rotate(p - vec2(0.000,-0.030),0.), wid_c, ra1_c ) - ra2_c;
99
float d_c = sdCircle(p - vec2(0.000,0.070),0.052);
100
float d_c2 = sdCircle(p - vec2(0.000,0.070),0.036);
101
float ta = 4.732;
102
float tb = 1.652;
103
float rb = 0.022;
104
float d_a = sdArc(p,vec2(sin(ta),cos(ta)),vec2(sin(tb),cos(tb)), 0.11, rb);
105
float d_b = sdPie(rotate(p - vec2(0.000,-0.100),180.0),vec2(0.880,0.250), 0.12);
106
float d_b2 = sdBox(rotate(p - vec2(0.270,-0.960),110.0),vec2(0.870,0.020));
107
vec3 colour = vec3( 1., 1., 1.);
108
colour *= 1.0-mask;
109
colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d1)) );
110
colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d2)) );
111
colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d3)) );
112
colour = mix( colour, vec3(0.317,0.735,0.040), 1.000-step(0.0, d_b2) );
113
colour = mix( colour, vec3(1.000,0.290,0.290), 1.000-step(0.0, d1) );
114
colour = mix( colour, vec3(1.000,0.290,0.290), 1.000-step(0.0, d2) );
115
colour = mix( colour, vec3(1.000,0.290,0.290), 1.000-step(0.0, d3) );
116
colour = mix( colour, vec3(1.000,0.944,0.179), 1.000-step(0.0, d6) );
117
colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d4)) );
118
colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d5)) );
119
colour = mix( colour, vec3(1.000), 1.000-smoothstep(0.0, 0.01, abs(d6)) );
120
colour = mix( colour, vec3(1.000,0.139,0.130), 1.000-step(0.0, d4) );
121
colour = mix( colour, vec3(1.000,0.139,0.130), 1.000-step(0.0, d5) );
122
colour = mix( colour, vec3(1.000,0.994,0.211), 1.000-step(0.0, d_c) );
123
colour = mix( colour, vec3(1.000,0.994,0.211), 1.000-smoothstep(0.0, 0.248, abs(d_c2)) );
124
colour = mix( colour, vec3(0.755,0.755,0.755), 1.000-smoothstep(0.0, 0.01, abs(d_c)) );
125
colour = mix( colour, vec3(0.705,0.026,0.074), 1.000-step(0.0, d_a) );
126
colour = mix( colour, vec3(0.805,0.030,0.084), 1.000-step(0.0, d_b) );
127
128
colour =(1.0-snoise(p*8.)*vec3(0.006,0.248,0.345))*colour;
129
colour_out = vec4(colour,1.0);
130
}
Lycaste by TT
// credit: jikihakase (will show up on website) // orchid: Coelogyne pandurata uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.000,b)) : length(p-vec2(-d,-0.008))-r; } 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.000,r)); // c=sin/cos of aperture return max(l,m*sign(c.y*p.x-c.x*p.y)); } float sdMoon(vec2 p, float d, float ra, float rb ) { p.y = abs(p.y); float a = (ra*ra - rb*rb + d*d)/(2.0*d); float b = sqrt(max(ra*ra-a*a,0.0)); if( d*(p.x*b-p.y*a) > d*d*max(b-p.y,0.0) ) return length(p-vec2(a,b)); return max( (length(p )-ra), -(length(p-vec2(d,0))-rb)); } mat2 rotate(float degree){ float c = cos(degree), s = sin(degree); return mat2( c, -s, s, c); } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy-0.5; float n = snoise(st * 30.0); vec4 color1 = vec4(0.985,0.929,0.971,1.000); vec4 color2 = vec4(0.815,0.281,0.423+n,1.000); vec4 color3 = vec4(0.645,0.083,0.404,1.000); vec4 color4 = vec4(0.879,0.915,0.701,1.000); float center =length(st-vec2(0.000,-0.020)) - 0.060; float moon1 = sdMoon(vec2(11.0,11.0) * (rotate(1.592)*st.xy)-vec2(-0.710,-0.030),0.424,1.184,0.896); float moon2 = sdVesica(vec2(3.0,7.0) * (rotate(0.000)*st.xy)-vec2(0.000,-0.570),1.272,1.168); float moon = min(moon1,moon2); float leaf1 = sdPie(vec2(2.0,1.5) * (rotate(-1.376)*st.xy)-vec2(0.040,-0.020),vec2(0.820,0.580),0.5); float leaf2 = sdPie(vec2(2.0,1.5) * (rotate(1.376)*st.xy)-vec2(-0.040,0.000),vec2(0.820,0.580),0.5); float leaf3 = sdVesica(vec2(2.6,4.2) * (rotate(0.000)*st.xy)-vec2(0.000,0.680),1.496,1.176); float leaf4 = sdVesica(vec2(3.0,4.5) * (rotate(-0.896)*st.xy)-vec2(0.070,-0.930),1.496,1.176); float leaf5 = sdVesica(vec2(3.0,4.5) * (rotate(0.896)*st.xy)-vec2(-0.070,-0.930),1.496,1.176); float leaves1 = min(leaf1,leaf2); float leaves2 = min(min(leaf3,leaf4),leaf5); if(center < 0.0){ colour_out = color4; } else{ if(moon < 0.0){ colour_out = color3; } else{ if(leaves1 < 0.0){ if(leaves1 < -0.015) colour_out = color2; else{ colour_out = color1; } } else{ if(leaves2 < 0.0){ if(leaves2 < -0.02) colour_out = color2; else colour_out = color1; } } } } }
153
1
// credit: jikihakase (will show up on website)
2
// orchid: Coelogyne pandurata
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
vec3 mod289(vec3 x) {
8
return x - floor(x * (1.0 / 289.0)) * 289.0;
9
}
10
11
vec2 mod289(vec2 x) {
12
return x - floor(x * (1.0 / 289.0)) * 289.0;
13
}
14
15
vec3 permute(vec3 x) {
16
return mod289(((x*34.0)+10.0)*x);
17
}
18
19
float snoise(vec2 v)
20
{
21
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
22
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
23
-0.577350269189626, // -1.0 + 2.0 * C.x
24
0.024390243902439); // 1.0 / 41.0
25
// First corner
26
vec2 i = floor(v + dot(v, C.yy) );
27
vec2 x0 = v - i + dot(i, C.xx);
28
29
// Other corners
30
vec2 i1;
31
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
32
//i1.y = 1.0 - i1.x;
33
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
34
// x0 = x0 - 0.0 + 0.0 * C.xx ;
35
// x1 = x0 - i1 + 1.0 * C.xx ;
36
// x2 = x0 - 1.0 + 2.0 * C.xx ;
37
vec4 x12 = x0.xyxy + C.xxzz;
38
x12.xy -= i1;
39
40
// Permutations
41
i = mod289(i); // Avoid truncation effects in permutation
42
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
43
+ i.x + vec3(0.0, i1.x, 1.0 ));
44
45
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
46
m = m*m ;
47
m = m*m ;
48
49
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
50
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
51
52
vec3 x = 2.0 * fract(p * C.www) - 1.0;
53
vec3 h = abs(x) - 0.5;
54
vec3 ox = floor(x + 0.5);
55
vec3 a0 = x - ox;
56
57
// Normalise gradients implicitly by scaling m
58
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
59
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
60
61
// Compute final noise value at P
62
vec3 g;
63
g.x = a0.x * x0.x + h.x * x0.y;
64
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
65
return 130.0 * dot(m, g);
66
}
67
68
float sdVesica(vec2 p, float r, float d)
69
{
70
p = abs(p);
71
float b = sqrt(r*r-d*d);
72
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.000,b))
73
: length(p-vec2(-d,-0.008))-r;
74
}
75
float sdPie( in vec2 p, in vec2 c, in float r )
76
{
77
p.x = abs(p.x);
78
float l = length(p) - r;
79
float m = length(p-c*clamp(dot(p,c),0.000,r)); // c=sin/cos of aperture
80
return max(l,m*sign(c.y*p.x-c.x*p.y));
81
}
82
float sdMoon(vec2 p, float d, float ra, float rb )
83
{
84
p.y = abs(p.y);
85
float a = (ra*ra - rb*rb + d*d)/(2.0*d);
86
float b = sqrt(max(ra*ra-a*a,0.0));
87
if( d*(p.x*b-p.y*a) > d*d*max(b-p.y,0.0) )
88
return length(p-vec2(a,b));
89
return max( (length(p )-ra),
90
-(length(p-vec2(d,0))-rb));
91
}
92
93
mat2 rotate(float degree){
94
float c = cos(degree), s = sin(degree);
95
return mat2( c, -s,
96
s, c);
97
}
98
99
void main() {
100
vec2 st = gl_FragCoord.xy/u_resolution.xy-0.5;
101
102
float n = snoise(st * 30.0);
103
104
vec4 color1 = vec4(0.985,0.929,0.971,1.000);
105
vec4 color2 = vec4(0.815,0.281,0.423+n,1.000);
106
vec4 color3 = vec4(0.645,0.083,0.404,1.000);
107
vec4 color4 = vec4(0.879,0.915,0.701,1.000);
108
109
float center =length(st-vec2(0.000,-0.020)) - 0.060;
110
111
float moon1 = sdMoon(vec2(11.0,11.0) * (rotate(1.592)*st.xy)-vec2(-0.710,-0.030),0.424,1.184,0.896);
112
float moon2 = sdVesica(vec2(3.0,7.0) * (rotate(0.000)*st.xy)-vec2(0.000,-0.570),1.272,1.168);
113
float moon = min(moon1,moon2);
114
115
float leaf1 = sdPie(vec2(2.0,1.5) * (rotate(-1.376)*st.xy)-vec2(0.040,-0.020),vec2(0.820,0.580),0.5);
116
float leaf2 = sdPie(vec2(2.0,1.5) * (rotate(1.376)*st.xy)-vec2(-0.040,0.000),vec2(0.820,0.580),0.5);
117
118
float leaf3 = sdVesica(vec2(2.6,4.2) * (rotate(0.000)*st.xy)-vec2(0.000,0.680),1.496,1.176);
119
float leaf4 = sdVesica(vec2(3.0,4.5) * (rotate(-0.896)*st.xy)-vec2(0.070,-0.930),1.496,1.176);
120
float leaf5 = sdVesica(vec2(3.0,4.5) * (rotate(0.896)*st.xy)-vec2(-0.070,-0.930),1.496,1.176);
121
122
123
float leaves1 = min(leaf1,leaf2);
124
float leaves2 = min(min(leaf3,leaf4),leaf5);
125
126
if(center < 0.0){
127
colour_out = color4;
128
}
129
else{
130
if(moon < 0.0){
131
colour_out = color3;
132
}
133
else{
134
if(leaves1 < 0.0){
135
if(leaves1 < -0.015)
136
colour_out = color2;
137
else{
138
colour_out = color1;
139
}
140
}
141
else{
142
if(leaves2 < 0.0){
143
if(leaves2 < -0.02)
144
colour_out = color2;
145
else
146
colour_out = color1;
147
}
148
}
149
}
150
}
151
152
153
}
unspecified by anonymous
// Name: Niku-Mochi // Orchid: eastern Queen of Sheba Orhicd (Scientific name: Thelymitra speciosa) // Description: Thelymitra speciosa, commonly called the eastern Queen of Sheba, is a species of orchid in the family Orchidaceae and endemic to the south-west of Western Australia. (https://en.wikipedia.org/wiki/Thelymitra_speciosa, accessed on 2021.12.05) // Reference photos: http://orchidswa.com.au/thelymitra-sun-orchids/queen-of-sheba/ uniform vec2 u_resolution; const float pi = 3.14159; // SDF function for the intersection of two mirror-symmetric circles // Input: p (position), r (radius), d (distance btw center of circle and axis of symmetry). float sdf_vesica(vec2 p, float r, float d){ p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d > p.x*b) ? (length(p-vec2(0.0,b)) * sign(d)) : (length(p-vec2(-d,0.0)) - r); } // SDF function for drawing circles float sdf_circle(vec2 p, float r){ return length(p) - r; } // Rotation and translation of sdf_vesica() // Input: p, r, d (as sdf_vesica()), theta (rotated angle), t (translation distance) float sdf_transform(vec2 p, float r, float d, float theta, vec2 t){ float c = cos(theta), s = sin(theta); t = mat2(c, s, -s, c) * t; mat3 H = mat3(vec3(c, s, 0.0), vec3(-s, c, 0.0), vec3(vec2(t), 1.0)); p = (inverse(H) * vec3(p,1.0)).xy; return sdf_vesica(p, r, d); } // SDF function for drawing petals // Input: p, r, d (as sdf_vesica()), theta (3 rotated angles), t (3 distances) float sdf_petals(vec2 p, float r, float d, vec3 theta, vec3 t){ float d1 = sdf_transform(p, r, d, theta.x, vec2(0.0,t.x)); float d2 = sdf_transform(p, r, d, theta.y, vec2(0.0,t.y)); float d3 = sdf_transform(p, r, d, theta.z, vec2(0.0,t.z)); return min(min(d1,d2),d3); } // SDF function for drawing stamens (or pistils?) float sdf_stamens(vec2 p){ float d1 = sdf_circle(p+vec2(0.00,-0.01), 0.04); float d2 = sdf_circle(p+vec2(-0.05,-0.055), 0.03); float d3 = sdf_circle(p+vec2(0.04,-0.05), 0.027); return min(min(d1,d2),d3); } // Function for differently colored edges of petals // Input: c (petal color), edge_c (edge color), sdf_d1, sdf_d2 (petals set 1 and set 2) vec3 petal_edge(vec3 c, vec3 edge_c, float sdf_d1, float sdf_d2){ vec3 out_c = c; if (sign(sdf_d1)<=0.0){ out_c = mix(c, edge_c, smoothstep(0.03,0.00,abs(sdf_d1))); } else if (sign(sdf_d1)>0.0 && sign(sdf_d2)<=0.0){ out_c = mix(c, edge_c, smoothstep(0.10,0.00,abs(sdf_d2))); } else{ out_c = out_c; } return out_c; } // Random 2D function vec2 rand_2(vec2 p) { const highp float seed = 12.9898; highp float a = seed, b = 78.233, c = 43758.5453, d = 269.5, e = 183.3; highp float dt_1 = dot(p, vec2(a,b)); return fract(sin(vec2(dt_1,dt_1)) * c); } // Reference: Cellular Noise. https://thebookofshaders.com/12/. Accessed on 2021.12.05. float noise(vec2 p){ // Tiling vec2 int_p = floor(p), frac_p = fract(p); // Minimum distance float min_dist = 0.425; for (int j=-1; j<=1; j++){ for (int i=-1; i<=1; i++ ){ // Random offset vec2 offset = rand_2(int_p + vec2(float(i),float(j))); offset = 0.6 + 0.45 * sin(0.98*offset+100.0); // Position of the cell vec2 pos = vec2(float(i),float(j)) + offset - frac_p; min_dist = min(min_dist, min_dist*length(pos)); } } return min_dist; } void main(){ // Define color vec3 dark_magenta = vec3(0.55,0.00,0.55); vec3 green_yellow = vec3(0.78,0.85,0.68); vec3 dark_orange = vec3(0.745,0.306,0.125); vec3 yellow = vec3(0.953,0.878,0.231); vec3 black_brown = vec3(0.271,0.196,0.176); vec3 purple = vec3(0.750,0.212,0.500); // Call sdf function to create petals and stamens vec2 p = gl_FragCoord.xy / u_resolution.xy; p -= vec2(0.5); float dist = 0.27; float ra = max(0.36, dist); // Two sets of petals. Each will be applied different patterns. // Adopt different rotation angles to make the orchid more 'natrual'. float d_petals_1 = sdf_petals(p, ra, dist, vec3(1.10, 3.05, 4.88)*pi/3.0, vec3(0.22,0.19,0.21)); float d_petals_2 = sdf_petals(p, ra, dist, vec3(-0.10, 2.05, 3.95)*pi/3.0, vec3(0.20,0.20,0.20)); // Stamens float d_stamens_1 = sdf_circle(p+vec2(0.000,0.025), 0.05); float d_stamens_2 = sdf_stamens(p); // Outline of the orchid float d_petals = min(d_petals_1,d_petals_2);//union of 2 petal sets vec3 col_orc = mix(dark_magenta, green_yellow, step(0.0,d_petals)); // Pattern 1 of petals (broad reddish edges) col_orc = petal_edge(col_orc, dark_orange, d_petals_1, d_petals_2); // Pattern 2 of petals (dark spots) by calling noise func p += vec2(0.5); p *= 15.0; float d_spots = max(noise(p)-0.06, d_petals);//intersection of spots and petals col_orc = mix(black_brown, col_orc, step(0.0,d_spots)); // Draw stamens col_orc = mix(purple, col_orc, step(0.0,d_stamens_1)); col_orc = mix(yellow, col_orc, step(0.0,d_stamens_2)); // Output colour_out = vec4(col_orc,1.0); }
130
1
// Name: Niku-Mochi
2
// Orchid: eastern Queen of Sheba Orhicd (Scientific name: Thelymitra speciosa)
3
// Description: Thelymitra speciosa, commonly called the eastern Queen of Sheba, is a species of orchid in the family Orchidaceae and endemic to the south-west of Western Australia. (https://en.wikipedia.org/wiki/Thelymitra_speciosa, accessed on 2021.12.05)
4
// Reference photos: http://orchidswa.com.au/thelymitra-sun-orchids/queen-of-sheba/
5
6
uniform vec2 u_resolution;
7
const float pi = 3.14159;
8
9
// SDF function for the intersection of two mirror-symmetric circles
10
// Input: p (position), r (radius), d (distance btw center of circle and axis of symmetry).
11
float sdf_vesica(vec2 p, float r, float d){
12
p = abs(p);
13
float b = sqrt(r*r-d*d);
14
return ((p.y-b)*d > p.x*b) ? (length(p-vec2(0.0,b)) * sign(d)) : (length(p-vec2(-d,0.0)) - r);
15
}
16
17
// SDF function for drawing circles
18
float sdf_circle(vec2 p, float r){
19
return length(p) - r;
20
}
21
22
// Rotation and translation of sdf_vesica()
23
// Input: p, r, d (as sdf_vesica()), theta (rotated angle), t (translation distance)
24
float sdf_transform(vec2 p, float r, float d, float theta, vec2 t){
25
float c = cos(theta), s = sin(theta);
26
t = mat2(c, s, -s, c) * t;
27
mat3 H = mat3(vec3(c, s, 0.0), vec3(-s, c, 0.0), vec3(vec2(t), 1.0));
28
p = (inverse(H) * vec3(p,1.0)).xy;
29
return sdf_vesica(p, r, d);
30
}
31
32
// SDF function for drawing petals
33
// Input: p, r, d (as sdf_vesica()), theta (3 rotated angles), t (3 distances)
34
float sdf_petals(vec2 p, float r, float d, vec3 theta, vec3 t){
35
float d1 = sdf_transform(p, r, d, theta.x, vec2(0.0,t.x));
36
float d2 = sdf_transform(p, r, d, theta.y, vec2(0.0,t.y));
37
float d3 = sdf_transform(p, r, d, theta.z, vec2(0.0,t.z));
38
return min(min(d1,d2),d3);
39
}
40
41
// SDF function for drawing stamens (or pistils?)
42
float sdf_stamens(vec2 p){
43
float d1 = sdf_circle(p+vec2(0.00,-0.01), 0.04);
44
float d2 = sdf_circle(p+vec2(-0.05,-0.055), 0.03);
45
float d3 = sdf_circle(p+vec2(0.04,-0.05), 0.027);
46
return min(min(d1,d2),d3);
47
}
48
49
// Function for differently colored edges of petals
50
// Input: c (petal color), edge_c (edge color), sdf_d1, sdf_d2 (petals set 1 and set 2)
51
vec3 petal_edge(vec3 c, vec3 edge_c, float sdf_d1, float sdf_d2){
52
vec3 out_c = c;
53
if (sign(sdf_d1)<=0.0){
54
out_c = mix(c, edge_c, smoothstep(0.03,0.00,abs(sdf_d1)));
55
}
56
else if (sign(sdf_d1)>0.0 && sign(sdf_d2)<=0.0){
57
out_c = mix(c, edge_c, smoothstep(0.10,0.00,abs(sdf_d2)));
58
}
59
else{
60
out_c = out_c;
61
}
62
return out_c;
63
}
64
65
// Random 2D function
66
vec2 rand_2(vec2 p) {
67
const highp float seed = 12.9898;
68
highp float a = seed, b = 78.233, c = 43758.5453, d = 269.5, e = 183.3;
69
highp float dt_1 = dot(p, vec2(a,b));
70
return fract(sin(vec2(dt_1,dt_1)) * c);
71
}
72
73
// Reference: Cellular Noise. https://thebookofshaders.com/12/. Accessed on 2021.12.05.
74
float noise(vec2 p){
75
// Tiling
76
vec2 int_p = floor(p), frac_p = fract(p);
77
// Minimum distance
78
float min_dist = 0.425;
79
for (int j=-1; j<=1; j++){
80
for (int i=-1; i<=1; i++ ){
81
// Random offset
82
vec2 offset = rand_2(int_p + vec2(float(i),float(j)));
83
offset = 0.6 + 0.45 * sin(0.98*offset+100.0);
84
// Position of the cell
85
vec2 pos = vec2(float(i),float(j)) + offset - frac_p;
86
min_dist = min(min_dist, min_dist*length(pos));
87
}
88
}
89
return min_dist;
90
}
91
92
void main(){
93
// Define color
94
vec3 dark_magenta = vec3(0.55,0.00,0.55);
95
vec3 green_yellow = vec3(0.78,0.85,0.68);
96
vec3 dark_orange = vec3(0.745,0.306,0.125);
97
vec3 yellow = vec3(0.953,0.878,0.231);
98
vec3 black_brown = vec3(0.271,0.196,0.176);
99
vec3 purple = vec3(0.750,0.212,0.500);
100
101
// Call sdf function to create petals and stamens
102
vec2 p = gl_FragCoord.xy / u_resolution.xy;
103
p -= vec2(0.5);
104
float dist = 0.27;
105
float ra = max(0.36, dist);
106
// Two sets of petals. Each will be applied different patterns.
107
// Adopt different rotation angles to make the orchid more 'natrual'.
108
float d_petals_1 = sdf_petals(p, ra, dist, vec3(1.10, 3.05, 4.88)*pi/3.0, vec3(0.22,0.19,0.21));
109
float d_petals_2 = sdf_petals(p, ra, dist, vec3(-0.10, 2.05, 3.95)*pi/3.0, vec3(0.20,0.20,0.20));
110
// Stamens
111
float d_stamens_1 = sdf_circle(p+vec2(0.000,0.025), 0.05);
112
float d_stamens_2 = sdf_stamens(p);
113
114
// Outline of the orchid
115
float d_petals = min(d_petals_1,d_petals_2);//union of 2 petal sets
116
vec3 col_orc = mix(dark_magenta, green_yellow, step(0.0,d_petals));
117
// Pattern 1 of petals (broad reddish edges)
118
col_orc = petal_edge(col_orc, dark_orange, d_petals_1, d_petals_2);
119
// Pattern 2 of petals (dark spots) by calling noise func
120
p += vec2(0.5);
121
p *= 15.0;
122
float d_spots = max(noise(p)-0.06, d_petals);//intersection of spots and petals
123
col_orc = mix(black_brown, col_orc, step(0.0,d_spots));
124
// Draw stamens
125
col_orc = mix(purple, col_orc, step(0.0,d_stamens_1));
126
col_orc = mix(yellow, col_orc, step(0.0,d_stamens_2));
127
128
// Output
129
colour_out = vec4(col_orc,1.0);
130
}
Thelymitra Speciosa (Eastern Queen of Sheba
Orchid) by Niku-Mochi
// credit: @amycqx // orchid: Cymbidium cv orchid @Geoff McKay // https://www.flickr.com/photos/129472387@N07/49368814152/in/photostream/ uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; float sdSegment( in vec2 p, in vec2 a, in vec2 b ) { vec2 pa = p-a, ba = b-a; float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 ); return length( pa - ba*h ); } float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,0.0))-r; } float sdVesica1(vec2 p,float r, float d,float rotate){ float s=sin(-rotate),c=cos(-rotate); vec2 q; q.x=p.x*c-p.y*s; q.y=p.y*c+p.x*s; q.y-=sqrt(r*r-d*d); return sdVesica(q,r,d); } float sdUnevenCapsule( vec2 p, float r1, float r2, float h ) { p.x = abs(p.x); float b = (r1-r2)/h; float a = sqrt(1.0-b*b); float k = dot(p,vec2(-b,a)); if( k < 0.0 ) return length(p) - r1; if( k > a*h ) return length(p-vec2(0.0,h)) - r2; return dot(p, vec2(a,b) ) - r1; } float sdUnevenCapsule1(vec2 p,vec2 pa, vec2 pb,float ra, float rb){ pb-=pa; float h=sqrt(dot(pb,pb)); p-=pa; vec2 q=vec2(dot(p,vec2(pb.y,-pb.x)),dot(p,pb))/h; return sdUnevenCapsule(q,ra,rb,h); } float sdRoundedBox( in vec2 p, in vec2 b, in vec4 r ) { r.xy = (p.x>0.0)?r.xy : r.zw; r.x = (p.y>0.0)?r.x : r.y; vec2 q = abs(p)-b+r.x; return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x; } float sdPolygon( in vec2[6] v, in vec2 p ) { float d = dot(p-v[0],p-v[0]); float s = 1.0; for( int i=0, j=6-1; i<6; j=i, i++ ) { vec2 e = v[j] - v[i]; vec2 w = p - v[i]; vec2 b = w - e*clamp( dot(w,e)/dot(e,e), 0.0, 1.0 ); d = min( d, dot(b,b) ); bvec3 c = bvec3(p.y>=v[i].y,p.y<v[j].y,e.x*w.y>e.y*w.x); if( all(c) || all(not(c)) ) s*=-1.0; } return s*sqrt(d); } // The following noise credits to: @patriciogv // Available on https://thebookofshaders.com // Permutation polynomial: (34x^2 + x) mod 289 vec4 permute(vec4 x) { return mod((34.0 * x + 1.0) * x, 289.0); } // Cellular noise, returning F1 and F2 in a vec2. // Speeded up by using 2x2 search window instead of 3x3, // at the expense of some strong pattern artifacts. // F2 is often wrong and has sharp discontinuities. // If you need a smooth F2, use the slower 3x3 version. // F1 is sometimes wrong, too, but OK for most purposes. vec2 cellular2x2(vec2 P) { const float K=0.142857142857; // 1/7 const float K2=0.0714285714285; // K/2 #define jitter 0.8 // jitter 1.0 makes F1 wrong more often vec2 Pi = mod(floor(P), 289.0); vec2 Pf = fract(P); vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5); vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5); vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0)); p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0)); vec4 ox = mod(p, 7.0)*K+K2; vec4 oy = mod(floor(p*K),7.0)*K+K2; vec4 dx = Pfx + jitter*ox; vec4 dy = Pfy + jitter*oy; vec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared // Sort out the two smallest distances #if 0 // Cheat and pick only F1 d.xy = min(d.xy, d.zw); d.x = min(d.x, d.y); return d.xx; // F1 duplicated, F2 not computed #else // Do it right and find both F1 and F2 d.xy = (d.x < d.y) ? d.xy : d.yx; // Swap if smaller d.xz = (d.x < d.z) ? d.xz : d.zx; d.xw = (d.x < d.w) ? d.xw : d.wx; d.y = min(d.y, d.z); d.y = min(d.y, d.w); return sqrt(d.xy); #endif } //The following background design credits to @del //Available at https://www.shadertoy.com/view/3dcyDj float wave(vec2 p) { float v = sin(p.x + sin(p.y) + sin(p.y * .43)); return v*v; } float get(vec2 p,float t) { mat2 rot = mat2(0.5, 0.86, -0.86, 0.5); float v = wave(p); p.y += t; p *= rot; v += wave(p.yx); p.y += t * .17; p *= rot; v += wave(p.xy); v = abs(1.5 - v); v+=pow(abs(sin(p.x+v)),18.0); return v; } void main() { const float PI=3.1415926535; vec2 fragCoord=gl_FragCoord.xy; vec2 iResolution=u_resolution; vec3 iMouse=vec3(u_mouse,0.); float iTime=0.; vec4 fragColor; //the background vec2 uv = (iResolution.xy - 2.0*fragCoord.xy)/iResolution.y; float t = iTime; float scale =14.0; float speed = .3; uv.y += sin(fract(t*0.1+uv.x)*6.28)*0.05; // wibble uv.xy += t*0.08; // scroll vec2 p = uv*scale; //p.y+= 1.0/p.y*p.y; float v = get(p,t*speed); v = smoothstep(-3.5,3.5,v); vec3 col = vec3(.29, 0.86, 0.4)*v*v; fragColor = vec4(col*v*v, 1.0); //the orchid p = (2.0*fragCoord-iResolution.xy)/iResolution.y; p *= 2.0; float theta=-PI*2./3.; float d=2.;//petal outline float s=2.;//lines on petal for (int i=0;i<5;i++){ vec2 vertex=2.*vec2(cos(theta+PI/2.),sin(theta+PI/2.)); //petal float d1=sdVesica1(p,2.01,1.8,theta); theta+=PI*1./3.; d=min(d,d1); float s1=sdSegment(p,vertex*1.2,vec2(0.,0.)); s=min(s,s1); } vec2[6] hexV=vec2[6](vec2(0.00,0.000), vec2(-0.30,0.150)*.8, vec2(-0.3,-0.25)*.8, vec2(0,-0.4)*.8, vec2(0.3,-0.25)*.8, vec2(0.3,0.15)*.8); float hex=sdPolygon(hexV,p); float tip=sdUnevenCapsule1(p,vec2(0.,0.35),vec2(0.,0.),.13,.13); float yellowCore=sdSegment(p,vec2(0.,1.3),vec2(0.,-0.1)); if (d<=0.02){//inside of the flower //petal color dark to light pink from center to the tips col=mix(vec3(220.,89.,92.),vec3(220.,170.,185.),dot(p,p)*0.4); //lines on the petal, darker in the middle vec3 veinCol=mix(vec3(198.,67.,96.),vec3(226.,155.,187.),s*4.); col=mix(col,veinCol,cos(75.*s)-.29); col/=255.; } if(tip<0.){ col=vec3(228.,193.,164.)/255.; } if(hex<0.16){//rounded outline of inside col=vec3(1.); if(hex>-0.2){//surrouding, rose red col=mix(col,vec3(188.,62.,127.)/255.,(hex+.041)*7.); //black dot noise vec2 st=p; st = (st-.5)*.75+.5; st/=.8; vec2 F = cellular2x2(st*15.); vec2 pos = st-.5; float a = dot(pos,pos)-3.8*0.1; float n = step(abs(sin(a*3.1415*5.)),F.x*2.5); if (n<0.3){ col=vec3(n+.2,n,n); } } if(yellowCore<.1){ col=mix(vec3(245.000,209.000,72.000)/255.,col-vec3(.2),yellowCore*4.); } } fragColor = vec4(col,1.0); colour_out=fragColor; }
224
1
// credit: @amycqx
2
// orchid: Cymbidium cv orchid @Geoff McKay
3
// https://www.flickr.com/photos/129472387@N07/49368814152/in/photostream/
4
uniform vec2 u_resolution;
5
uniform vec2 u_mouse;
6
uniform float u_time;
7
8
float sdSegment( in vec2 p, in vec2 a, in vec2 b )
9
{
10
vec2 pa = p-a, ba = b-a;
11
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
12
return length( pa - ba*h );
13
}
14
float sdVesica(vec2 p, float r, float d)
15
{
16
p = abs(p);
17
float b = sqrt(r*r-d*d);
18
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b))
19
: length(p-vec2(-d,0.0))-r;
20
}
21
float sdVesica1(vec2 p,float r, float d,float rotate){
22
23
float s=sin(-rotate),c=cos(-rotate);
24
vec2 q;
25
q.x=p.x*c-p.y*s;
26
q.y=p.y*c+p.x*s;
27
q.y-=sqrt(r*r-d*d);
28
return sdVesica(q,r,d);
29
}
30
float sdUnevenCapsule( vec2 p, float r1, float r2, float h )
31
{
32
p.x = abs(p.x);
33
float b = (r1-r2)/h;
34
float a = sqrt(1.0-b*b);
35
float k = dot(p,vec2(-b,a));
36
if( k < 0.0 ) return length(p) - r1;
37
if( k > a*h ) return length(p-vec2(0.0,h)) - r2;
38
return dot(p, vec2(a,b) ) - r1;
39
}
40
float sdUnevenCapsule1(vec2 p,vec2 pa, vec2 pb,float ra, float rb){
41
pb-=pa;
42
float h=sqrt(dot(pb,pb));
43
p-=pa;
44
vec2 q=vec2(dot(p,vec2(pb.y,-pb.x)),dot(p,pb))/h;
45
return sdUnevenCapsule(q,ra,rb,h);
46
}
47
float sdRoundedBox( in vec2 p, in vec2 b, in vec4 r )
48
{
49
r.xy = (p.x>0.0)?r.xy : r.zw;
50
r.x = (p.y>0.0)?r.x : r.y;
51
vec2 q = abs(p)-b+r.x;
52
return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x;
53
}
54
float sdPolygon( in vec2[6] v, in vec2 p )
55
{
56
float d = dot(p-v[0],p-v[0]);
57
float s = 1.0;
58
for( int i=0, j=6-1; i<6; j=i, i++ )
59
{
60
vec2 e = v[j] - v[i];
61
vec2 w = p - v[i];
62
vec2 b = w - e*clamp( dot(w,e)/dot(e,e), 0.0, 1.0 );
63
d = min( d, dot(b,b) );
64
bvec3 c = bvec3(p.y>=v[i].y,p.y<v[j].y,e.x*w.y>e.y*w.x);
65
if( all(c) || all(not(c)) ) s*=-1.0;
66
}
67
return s*sqrt(d);
68
}
69
// The following noise credits to: @patriciogv
70
// Available on https://thebookofshaders.com
71
72
// Permutation polynomial: (34x^2 + x) mod 289
73
vec4 permute(vec4 x) {
74
return mod((34.0 * x + 1.0) * x, 289.0);
75
}
76
// Cellular noise, returning F1 and F2 in a vec2.
77
// Speeded up by using 2x2 search window instead of 3x3,
78
// at the expense of some strong pattern artifacts.
79
// F2 is often wrong and has sharp discontinuities.
80
// If you need a smooth F2, use the slower 3x3 version.
81
// F1 is sometimes wrong, too, but OK for most purposes.
82
vec2 cellular2x2(vec2 P) {
83
const float K=0.142857142857; // 1/7
84
const float K2=0.0714285714285; // K/2
85
86
vec2 Pi = mod(floor(P), 289.0);
87
vec2 Pf = fract(P);
88
vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5);
89
vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5);
90
vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0));
91
p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0));
92
vec4 ox = mod(p, 7.0)*K+K2;
93
vec4 oy = mod(floor(p*K),7.0)*K+K2;
94
vec4 dx = Pfx + jitter*ox;
95
vec4 dy = Pfy + jitter*oy;
96
vec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared
97
// Sort out the two smallest distances
98
99
// Cheat and pick only F1
100
d.xy = min(d.xy, d.zw);
101
d.x = min(d.x, d.y);
102
return d.xx; // F1 duplicated, F2 not computed
103
104
// Do it right and find both F1 and F2
105
d.xy = (d.x < d.y) ? d.xy : d.yx; // Swap if smaller
106
d.xz = (d.x < d.z) ? d.xz : d.zx;
107
d.xw = (d.x < d.w) ? d.xw : d.wx;
108
d.y = min(d.y, d.z);
109
d.y = min(d.y, d.w);
110
return sqrt(d.xy);
111
112
}
113
114
//The following background design credits to @del
115
//Available at https://www.shadertoy.com/view/3dcyDj
116
float wave(vec2 p)
117
{
118
float v = sin(p.x + sin(p.y) + sin(p.y * .43));
119
return v*v;
120
}
121
122
float get(vec2 p,float t)
123
{
124
mat2 rot = mat2(0.5, 0.86, -0.86, 0.5);
125
float v = wave(p);
126
p.y += t;
127
p *= rot;
128
v += wave(p.yx);
129
p.y += t * .17;
130
p *= rot;
131
v += wave(p.xy);
132
v = abs(1.5 - v);
133
v+=pow(abs(sin(p.x+v)),18.0);
134
return v;
135
}
136
137
void main() {
138
const float PI=3.1415926535;
139
vec2 fragCoord=gl_FragCoord.xy;
140
vec2 iResolution=u_resolution;
141
vec3 iMouse=vec3(u_mouse,0.);
142
float iTime=0.;
143
vec4 fragColor;
144
145
//the background
146
vec2 uv = (iResolution.xy - 2.0*fragCoord.xy)/iResolution.y;
147
float t = iTime;
148
float scale =14.0;
149
float speed = .3;
150
uv.y += sin(fract(t*0.1+uv.x)*6.28)*0.05; // wibble
151
uv.xy += t*0.08; // scroll
152
vec2 p = uv*scale;
153
//p.y+= 1.0/p.y*p.y;
154
float v = get(p,t*speed);
155
v = smoothstep(-3.5,3.5,v);
156
vec3 col = vec3(.29, 0.86, 0.4)*v*v;
157
fragColor = vec4(col*v*v, 1.0);
158
159
//the orchid
160
p = (2.0*fragCoord-iResolution.xy)/iResolution.y;
161
p *= 2.0;
162
163
float theta=-PI*2./3.;
164
float d=2.;//petal outline
165
float s=2.;//lines on petal
166
for (int i=0;i<5;i++){
167
vec2 vertex=2.*vec2(cos(theta+PI/2.),sin(theta+PI/2.));
168
//petal
169
float d1=sdVesica1(p,2.01,1.8,theta);
170
theta+=PI*1./3.;
171
d=min(d,d1);
172
float s1=sdSegment(p,vertex*1.2,vec2(0.,0.));
173
s=min(s,s1);
174
}
175
vec2[6] hexV=vec2[6](vec2(0.00,0.000),
176
vec2(-0.30,0.150)*.8,
177
vec2(-0.3,-0.25)*.8,
178
vec2(0,-0.4)*.8,
179
vec2(0.3,-0.25)*.8,
180
vec2(0.3,0.15)*.8);
181
float hex=sdPolygon(hexV,p);
182
float tip=sdUnevenCapsule1(p,vec2(0.,0.35),vec2(0.,0.),.13,.13);
183
float yellowCore=sdSegment(p,vec2(0.,1.3),vec2(0.,-0.1));
184
185
if (d<=0.02){//inside of the flower
186
187
//petal color dark to light pink from center to the tips
188
col=mix(vec3(220.,89.,92.),vec3(220.,170.,185.),dot(p,p)*0.4);
189
//lines on the petal, darker in the middle
190
vec3 veinCol=mix(vec3(198.,67.,96.),vec3(226.,155.,187.),s*4.);
191
col=mix(col,veinCol,cos(75.*s)-.29);
192
193
194
col/=255.;
195
}
196
if(tip<0.){
197
col=vec3(228.,193.,164.)/255.;
198
}
199
if(hex<0.16){//rounded outline of inside
200
col=vec3(1.);
201
if(hex>-0.2){//surrouding, rose red
202
col=mix(col,vec3(188.,62.,127.)/255.,(hex+.041)*7.);
203
//black dot noise
204
vec2 st=p;
205
st = (st-.5)*.75+.5;
206
207
st/=.8;
208
vec2 F = cellular2x2(st*15.);
209
210
vec2 pos = st-.5;
211
float a = dot(pos,pos)-3.8*0.1;
212
float n = step(abs(sin(a*3.1415*5.)),F.x*2.5);
213
if (n<0.3){
214
col=vec3(n+.2,n,n);
215
}
216
}
217
if(yellowCore<.1){
218
col=mix(vec3(245.000,209.000,72.000)/255.,col-vec3(.2),yellowCore*4.);
219
}
220
}
221
222
fragColor = vec4(col,1.0);
223
colour_out=fragColor;
224
}
Cymbidium cv Orchid by @amycqx
// credit: Tsunehiko // orchid: Dendrobium kingianum uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float PI=3.1415926535897932384626433832795; float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,0.0))-r; } vec2 rotate(vec2 p, float degree){ float c = cos(degree * PI/180.); float s = sin(degree * PI/180.); mat3 H = mat3(c, s, 0, -s, c, 0, 0, 0, 1); return (inverse(H) * vec3(p,1.0)).xy; } float sdMoon(vec2 p, float d, float ra, float rb ) { p.y = abs(p.y); float a = (ra*ra - rb*rb + d*d)/(2.0*d); float b = sqrt(max(ra*ra-a*a,0.0)); if( d*(p.x*b-p.y*a) > d*d*max(b-p.y,0.0) ) return length(p-vec2(a,b)); return max( (length(p)-ra), -(length(p-vec2(d,0))-rb)); } float sdf( vec2 p ) { if(p.y < -0.7) return 1.0; float d = sdVesica(rotate(p - vec2(0.4,0.15),135.0), 0.6, 0.5) - 0.02; d = min(d, sdVesica(rotate(p - vec2(-0.4,0.15),-135.0), 0.6, 0.5) - 0.02); d = min(d, sdVesica(rotate(p - vec2(0.0,0.3),0.0), 0.7, 0.5) - 0.02); d = min(d, sdMoon(rotate(p-vec2(0.3, -0.5), -50.0), 0.25, 0.45, 0.37)); d = min(d, sdMoon(rotate(p-vec2(-0.3, -0.5), -130.0), 0.25, 0.45, 0.37)); return d; } 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)); } float sdf_2( vec2 p ) { float d = sdPie(rotate(p-vec2(-0.025, -0.2), 110.0), vec2(sin(75.0*PI/180.0), cos(75.0*PI/180.0)), 0.2); d = min(d, sdPie(rotate(p-vec2(0.025, -0.2), -110.0), vec2(sin(75.0*PI/180.0), cos(75.0*PI/180.0)), 0.2)); return d; } float sdCircle( vec2 p, float r ) { return length(p) - r; } float sdf_3(vec2 p) { float d = sdCircle(p+vec2(0.02, 0.1), 0.05); d = min(d, sdCircle(p+vec2(-0.02, 0.1), 0.05)); return d; } vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float fbm( vec2 p ) { float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += snoise( p * scale ) / scale; } return f; } void main() { vec2 p = (gl_FragCoord.xy / u_resolution.xy * 2.0 - 1.0) / 1.1; // distance float d = sdf(p); float d_2 = sdf_2(p); float d_3 = sdf_3(p); // color vec3 lavender = mix(vec3(0.644, 0.422, 0.625), vec3(0.95, 0.95, 0.95), exp(-length(p)+0.35)-0.1); float n = fbm( gl_FragCoord.xy / 60.0 ); vec3 purple = mix(vec3(0.690,0.276,0.690), vec3(1.0), n); vec3 col = vec3(0.0); if(sign(d) < 0.0){ if(sign(d_3) < 0.0){ col = mix(vec3(0.98, 0.96, 0.87), vec3(0.8), abs(d_3)); col = mix(col, vec3(0.95), 1.0 - smoothstep(0.0,0.02,abs(d_3))); } else if(sign(d_2) < 0.0) { col = mix( purple, vec3(0.95), 1.0 - smoothstep(0.0,0.02,abs(d_2))); } else { col = lavender; } } col = mix( col, vec3(0.644, 0.422, 0.625), 1.0 - smoothstep(0.0,0.02,abs(d))); colour_out = vec4( col, 1.0 ); }
167
1
// credit: Tsunehiko
2
// orchid: Dendrobium kingianum
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
const float PI=3.1415926535897932384626433832795;
7
8
float sdVesica(vec2 p, float r, float d)
9
{
10
p = abs(p);
11
float b = sqrt(r*r-d*d);
12
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,0.0))-r;
13
}
14
15
vec2 rotate(vec2 p, float degree){
16
float c = cos(degree * PI/180.);
17
float s = sin(degree * PI/180.);
18
mat3 H = mat3(c, s, 0, -s, c, 0, 0, 0, 1);
19
return (inverse(H) * vec3(p,1.0)).xy;
20
}
21
22
float sdMoon(vec2 p, float d, float ra, float rb )
23
{
24
p.y = abs(p.y);
25
float a = (ra*ra - rb*rb + d*d)/(2.0*d);
26
float b = sqrt(max(ra*ra-a*a,0.0));
27
if( d*(p.x*b-p.y*a) > d*d*max(b-p.y,0.0) ) return length(p-vec2(a,b));
28
return max( (length(p)-ra), -(length(p-vec2(d,0))-rb));
29
}
30
31
float sdf( vec2 p )
32
{
33
if(p.y < -0.7) return 1.0;
34
float d = sdVesica(rotate(p - vec2(0.4,0.15),135.0), 0.6, 0.5) - 0.02;
35
d = min(d, sdVesica(rotate(p - vec2(-0.4,0.15),-135.0), 0.6, 0.5) - 0.02);
36
d = min(d, sdVesica(rotate(p - vec2(0.0,0.3),0.0), 0.7, 0.5) - 0.02);
37
d = min(d, sdMoon(rotate(p-vec2(0.3, -0.5), -50.0), 0.25, 0.45, 0.37));
38
d = min(d, sdMoon(rotate(p-vec2(-0.3, -0.5), -130.0), 0.25, 0.45, 0.37));
39
return d;
40
}
41
42
float sdPie( in vec2 p, in vec2 c, in float r )
43
{
44
p.x = abs(p.x);
45
float l = length(p) - r;
46
float m = length(p-c*clamp(dot(p,c),0.0,r));
47
return max(l,m*sign(c.y*p.x-c.x*p.y));
48
}
49
50
float sdf_2( vec2 p )
51
{
52
float d = sdPie(rotate(p-vec2(-0.025, -0.2), 110.0), vec2(sin(75.0*PI/180.0), cos(75.0*PI/180.0)), 0.2);
53
d = min(d, sdPie(rotate(p-vec2(0.025, -0.2), -110.0), vec2(sin(75.0*PI/180.0), cos(75.0*PI/180.0)), 0.2));
54
return d;
55
}
56
57
float sdCircle( vec2 p, float r )
58
{
59
return length(p) - r;
60
}
61
62
float sdf_3(vec2 p)
63
{
64
float d = sdCircle(p+vec2(0.02, 0.1), 0.05);
65
d = min(d, sdCircle(p+vec2(-0.02, 0.1), 0.05));
66
return d;
67
}
68
69
vec3 mod289(vec3 x) {
70
return x - floor(x * (1.0 / 289.0)) * 289.0;
71
}
72
73
vec2 mod289(vec2 x) {
74
return x - floor(x * (1.0 / 289.0)) * 289.0;
75
}
76
77
vec3 permute(vec3 x) {
78
return mod289(((x*34.0)+10.0)*x);
79
}
80
81
float snoise(vec2 v)
82
{
83
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
84
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
85
-0.577350269189626, // -1.0 + 2.0 * C.x
86
0.024390243902439); // 1.0 / 41.0
87
// First corner
88
vec2 i = floor(v + dot(v, C.yy) );
89
vec2 x0 = v - i + dot(i, C.xx);
90
91
// Other corners
92
vec2 i1;
93
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
94
//i1.y = 1.0 - i1.x;
95
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
96
// x0 = x0 - 0.0 + 0.0 * C.xx ;
97
// x1 = x0 - i1 + 1.0 * C.xx ;
98
// x2 = x0 - 1.0 + 2.0 * C.xx ;
99
vec4 x12 = x0.xyxy + C.xxzz;
100
x12.xy -= i1;
101
102
// Permutations
103
i = mod289(i); // Avoid truncation effects in permutation
104
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
105
+ i.x + vec3(0.0, i1.x, 1.0 ));
106
107
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
108
m = m*m ;
109
m = m*m ;
110
111
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
112
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
113
114
vec3 x = 2.0 * fract(p * C.www) - 1.0;
115
vec3 h = abs(x) - 0.5;
116
vec3 ox = floor(x + 0.5);
117
vec3 a0 = x - ox;
118
119
// Normalise gradients implicitly by scaling m
120
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
121
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
122
123
// Compute final noise value at P
124
vec3 g;
125
g.x = a0.x * x0.x + h.x * x0.y;
126
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
127
return 130.0 * dot(m, g);
128
}
129
130
float fbm( vec2 p )
131
{
132
float f = 0.0, scale;
133
for (int i=0; i<4; i++) {
134
scale = pow( pow(2.0, 4.0/3.0), float(i) );
135
f += snoise( p * scale ) / scale;
136
}
137
return f;
138
}
139
140
void main() {
141
vec2 p = (gl_FragCoord.xy / u_resolution.xy * 2.0 - 1.0) / 1.1;
142
143
144
// distance
145
float d = sdf(p);
146
float d_2 = sdf_2(p);
147
float d_3 = sdf_3(p);
148
149
// color
150
vec3 lavender = mix(vec3(0.644, 0.422, 0.625), vec3(0.95, 0.95, 0.95), exp(-length(p)+0.35)-0.1);
151
float n = fbm( gl_FragCoord.xy / 60.0 );
152
vec3 purple = mix(vec3(0.690,0.276,0.690), vec3(1.0), n);
153
vec3 col = vec3(0.0);
154
if(sign(d) < 0.0){
155
if(sign(d_3) < 0.0){
156
col = mix(vec3(0.98, 0.96, 0.87), vec3(0.8), abs(d_3));
157
col = mix(col, vec3(0.95), 1.0 - smoothstep(0.0,0.02,abs(d_3)));
158
} else if(sign(d_2) < 0.0) {
159
col = mix( purple, vec3(0.95), 1.0 - smoothstep(0.0,0.02,abs(d_2)));
160
} else {
161
col = lavender;
162
}
163
}
164
col = mix( col, vec3(0.644, 0.422, 0.625), 1.0 - smoothstep(0.0,0.02,abs(d)));
165
166
colour_out = vec4( col, 1.0 );
167
}
Dendrobium Kingianum by Tsunehiko
// credit: Jyhwind // orchid: dendrobium_kingianum uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; float mask = 1.0; mask *= step( 0.110, distance( st.xy, vec2(0.5,0.55) ) ); mask *= step( 0.190, distance( st.xy, vec2(0.5,0.4) ) + distance( st.xy, vec2(0.5,0.5) ) ); mask *= step( 0.342, distance( st.xy, vec2(0.5,0.9) ) + distance( st.xy, vec2(0.5,0.590) ) ); mask *= step( 0.230, distance( st.xy, vec2(0.240,0.710) ) + distance( st.xy, vec2(0.400,0.590) ) ); mask *= step( 0.402, distance( st.xy, vec2(0.130,0.270) ) + distance( st.xy, vec2(0.420,0.500) ) ); mask *= step( 0.230, distance( st.xy, vec2(1.0-0.240,0.710) ) + distance( st.xy, vec2(1.0-0.400,0.590) ) ); mask *= step( 0.402, distance( st.xy, vec2(1.0-0.130,0.270) ) + distance( st.xy, vec2(1.0-0.420,0.500) ) ); colour_out = vec4( 1.0, 1.136*(1.0-distance( st.xy, vec2(0.5, 0.5) )), 1.0, 1.0 ); colour_out *= 1.0-mask; if (distance(st.xy, vec2(0.5, 0.55)) < 0.112 && distance(st.xy, vec2(0.5, 0.55)) > 0.092 && st.y < 0.596) { colour_out = vec4(0.725,0.123,1.000,1.000); } }
1
// credit: Jyhwind
2
// orchid: dendrobium_kingianum
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
void main() {
7
vec2 st = gl_FragCoord.xy/u_resolution.xy;
8
float mask = 1.0;
9
mask *= step( 0.110, distance( st.xy, vec2(0.5,0.55) ) );
10
mask *= step( 0.190, distance( st.xy, vec2(0.5,0.4) ) + distance( st.xy, vec2(0.5,0.5) ) );
11
mask *= step( 0.342, distance( st.xy, vec2(0.5,0.9) ) + distance( st.xy, vec2(0.5,0.590) ) );
12
mask *= step( 0.230, distance( st.xy, vec2(0.240,0.710) ) + distance( st.xy, vec2(0.400,0.590) ) );
13
mask *= step( 0.402, distance( st.xy, vec2(0.130,0.270) ) + distance( st.xy, vec2(0.420,0.500) ) );
14
mask *= step( 0.230, distance( st.xy, vec2(1.0-0.240,0.710) ) + distance( st.xy, vec2(1.0-0.400,0.590) ) );
15
mask *= step( 0.402, distance( st.xy, vec2(1.0-0.130,0.270) ) + distance( st.xy, vec2(1.0-0.420,0.500) ) );
16
colour_out = vec4( 1.0, 1.136*(1.0-distance( st.xy, vec2(0.5, 0.5) )), 1.0, 1.0 );
17
18
colour_out *= 1.0-mask;
19
if (distance(st.xy, vec2(0.5, 0.55)) < 0.112 && distance(st.xy, vec2(0.5, 0.55)) > 0.092 && st.y < 0.596)
20
{
21
colour_out = vec4(0.725,0.123,1.000,1.000);
22
}
23
}
Dendrobium Kingianum by Jyhwind
// credit: aoi (will show up on website) // orchid: Phalaenopsis lindenii uniform vec2 u_resolution; float petalDown(in vec2 pos) { pos = pos + vec2(0.0, -0.05); float a = atan(pos.x * 1.4, pos.y + 0.2) / 3.14159 * 1.65; float d = length(pos) - mix(0.15, 1.5, abs(fract(a) - 0.5)); return d; } float petalMiddle(in vec2 pos) { pos = abs(pos) * 2.0; pos = vec2(abs(pos.x - pos.y), 1.0 - pos.x - pos.y) / sqrt(2.0); float he = sin(1.0); he = (0.001 + abs(he)) * ((he >= 0.0) ? 1.0 : -1.0); float p = (he - pos.y - 0.25 / he) / (6.0 * he); float q = pos.x / (he * he * 16.0); float h = q * q - p * p * p; float x; if (h > 0.0) { float r = sqrt(h); x = pow(q + r, 1.0 / 3.0) - pow(abs(q - r), 1.0 / 3.0) * sign(r - q); } else { float r = sqrt(p); x = 2.0 * r * cos(acos(q / (p * r)) / 3.0); } x = min(x, sqrt(2.0) / 2.0); vec2 z = vec2(x, he * (1.0 - 2.0 * x * x)) - pos; return length(z) * sign(z.y) - 0.4; } float petalUp(in vec2 p) { const float k = sqrt(3.0); p.x = abs(p.x); p.y += 0.45; float ra = 0.3; float rb = ra * (0.1); float r = ra - rb; return ((p.y<0.0) ? length(vec2(p.x, p.y)) - r: (k * (p.x + r) <p.y) ? length(vec2(p.x, p.y - k * r)): length(vec2(p.x + r, p.y)) - 2.0 * r) - rb; } float star(in vec2 p) { p.y += 0.1; float r = 0.15; float n = 3.0 + mod(floor(2.0), 9.0); float m = 3.0 + fract(2.0) * fract(2.0) * (n - 2.0); float an = 3.141593 / float(n); float en = 3.141593 / m; vec2 acs = vec2(cos(an), sin(an)); vec2 ecs = vec2(cos(en), sin(en)); float bn = mod(atan(p.x, p.y), 2.0 * an) - an; p = length(p) * vec2(cos(bn), abs(sin(bn))); p -= r * acs; p += ecs * clamp(-dot(p, ecs), 0.0, r * acs.y / ecs.y); return length(p) * sign(p.x); } float sdUnion(float d1, float d2, float d3) { return min(min(d1, d2), d3); } float sdDifference(float d1, float d2) { return max(d1, -d2); } void main() { vec2 p = (gl_FragCoord.xy * 2.0 - u_resolution.xy) / u_resolution.y; float p1 = petalDown(p); float p2 = petalMiddle(p); float p3 = petalUp(p); float p4 = star(p); float d = sdDifference(sdUnion(p1, p2, p3), p4); vec3 col = vec3(0.7, p.y * 0.47, 1.0) - sign(d); col *= 1.1 - exp(-2.0 * abs(d)); col *= 0.8 + 0.2 * cos(120.0 * abs(d)); col = mix(col, vec3(0.79, 0.67, 0.82), 1.0 - smoothstep(0.0, 0.01, abs(d))); colour_out = vec4(col, 0.9); }
1
// credit: aoi (will show up on website)
2
// orchid: Phalaenopsis lindenii
3
uniform vec2 u_resolution;
4
5
float petalDown(in vec2 pos)
6
{
7
pos = pos + vec2(0.0, -0.05);
8
float a = atan(pos.x * 1.4, pos.y + 0.2) / 3.14159 * 1.65;
9
float d = length(pos) - mix(0.15, 1.5, abs(fract(a) - 0.5));
10
return d;
11
}
12
13
float petalMiddle(in vec2 pos)
14
{
15
pos = abs(pos) * 2.0;
16
pos = vec2(abs(pos.x - pos.y), 1.0 - pos.x - pos.y) / sqrt(2.0);
17
18
float he = sin(1.0);
19
he = (0.001 + abs(he)) * ((he >= 0.0) ? 1.0 : -1.0);
20
21
float p = (he - pos.y - 0.25 / he) / (6.0 * he);
22
float q = pos.x / (he * he * 16.0);
23
float h = q * q - p * p * p;
24
25
float x;
26
if (h > 0.0) {
27
float r = sqrt(h);
28
x = pow(q + r, 1.0 / 3.0) - pow(abs(q - r), 1.0 / 3.0) * sign(r - q);
29
}
30
else {
31
float r = sqrt(p);
32
x = 2.0 * r * cos(acos(q / (p * r)) / 3.0);
33
}
34
x = min(x, sqrt(2.0) / 2.0);
35
36
vec2 z = vec2(x, he * (1.0 - 2.0 * x * x)) - pos;
37
return length(z) * sign(z.y) - 0.4;
38
}
39
40
float petalUp(in vec2 p)
41
{
42
const float k = sqrt(3.0);
43
p.x = abs(p.x);
44
p.y += 0.45;
45
float ra = 0.3;
46
float rb = ra * (0.1);
47
float r = ra - rb;
48
49
return ((p.y<0.0) ? length(vec2(p.x, p.y)) - r:
50
(k * (p.x + r) <p.y) ? length(vec2(p.x, p.y - k * r)):
51
length(vec2(p.x + r, p.y)) - 2.0 * r) - rb;
52
}
53
54
float star(in vec2 p)
55
{
56
p.y += 0.1;
57
float r = 0.15;
58
float n = 3.0 + mod(floor(2.0), 9.0);
59
float m = 3.0 + fract(2.0) * fract(2.0) * (n - 2.0);
60
float an = 3.141593 / float(n);
61
float en = 3.141593 / m;
62
vec2 acs = vec2(cos(an), sin(an));
63
vec2 ecs = vec2(cos(en), sin(en));
64
65
float bn = mod(atan(p.x, p.y), 2.0 * an) - an;
66
p = length(p) * vec2(cos(bn), abs(sin(bn)));
67
68
p -= r * acs;
69
p += ecs * clamp(-dot(p, ecs), 0.0, r * acs.y / ecs.y);
70
return length(p) * sign(p.x);
71
}
72
73
74
float sdUnion(float d1, float d2, float d3) {
75
return min(min(d1, d2), d3);
76
}
77
78
float sdDifference(float d1, float d2) {
79
return max(d1, -d2);
80
}
81
82
void main() {
83
vec2 p = (gl_FragCoord.xy * 2.0 - u_resolution.xy) / u_resolution.y;
84
float p1 = petalDown(p);
85
float p2 = petalMiddle(p);
86
float p3 = petalUp(p);
87
float p4 = star(p);
88
float d = sdDifference(sdUnion(p1, p2, p3), p4);
89
90
vec3 col = vec3(0.7, p.y * 0.47, 1.0) - sign(d);
91
col *= 1.1 - exp(-2.0 * abs(d));
92
col *= 0.8 + 0.2 * cos(120.0 * abs(d));
93
col = mix(col, vec3(0.79, 0.67, 0.82), 1.0 - smoothstep(0.0, 0.01, abs(d)));
94
95
colour_out = vec4(col, 0.9);
96
}
Phalaenopsis Lindenii by aoi
// credit: s.l uniform vec2 u_resolution; vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } vec4 permute(vec4 x) { return mod289(((x*34.0)+10.0)*x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float snoise(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); // First corner vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; // Other corners vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); // x0 = x0 - 0.0 + 0.0 * C.xxx; // x1 = x0 - i1 + 1.0 * C.xxx; // x2 = x0 - i2 + 2.0 * C.xxx; // x3 = x0 - 1.0 + 3.0 * C.xxx; vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y // Permutations i = mod289(i); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); // Gradients: 7x7 points over a square, mapped onto an octahedron. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) float n_ = 0.142857142857; // 1.0/7.0 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); //Normalise gradients vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; // Mix final noise value vec4 m = max(0.5 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 105.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); } float turbulence( vec3 p ) { float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += abs( snoise( p * scale ) ) / scale; } return f; } // Blends a pre-multiplied src onto a dst color (without alpha) vec3 premulMix(vec4 src, vec3 dst) { return dst.rgb * (1.0 - src.a) + src.rgb; } // Blends a pre-multiplied src onto a dst color (with alpha) vec4 premulMix(vec4 src, vec4 dst) { vec4 res; res.rgb = premulMix(src, dst.rgb); res.a = 1.0 - (1.0 - src.a) * (1.0 - dst.a); return res; } float sdUnevenCapsule( vec2 p, float r1, float r2, float h ) { p.x = abs(p.x); float b = (r1 - r2) / h; float a = sqrt(1.0 - b * b); float k = dot(p, vec2(-b, a)); if(k < 0.0) return length(p) - r1; if(k > a * h) return length(p - vec2(0.0, h)) - r2; return dot(p, vec2(a, b)) - r1; } float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r * r - d * d); return ((p.y - b) * d > p.x * b) ? length(p - vec2(0.0, b)) : length(p - vec2(-d, 0.0)) - r; } float sdDifference(float d1, float d2) { return max(-d1, d2); } 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; } float sdSmoothDifference(float d1, float d2, float k) { return smax(-d1, d2, k); } // The outline of a petal float petalOutline(vec2 p, float s) { vec2 centerLine = vec2(0.5, p.y); // Top if (p.y > 0.6 && p.y < 1.0) return length(p - centerLine) - 0.57 * pow(1.0 - p.y, 0.35) + s; // Middle else if (p.y < 0.6 && p.y > 0.3) return length(p - centerLine) - 0.46 * pow(0.75 - p.y, 0.06) + s; // Bottom else if (p.y < 0.3 && p.y > -0.1) return length(p - centerLine) - 0.3 / (0.832 + exp(- 16.0 * p.y + 2.0)) - 0.1 + s; // Outside else return 1.0; } // Texture of a petal float petalTexture(vec2 p) { p = (p - 0.5) * 30.0; // Strips float n = snoise(p); float strips = smoothstep(0.0, 0.3, sin(p.x * 7.2 * (pow(-0.05 * p.y, 4.0) + 0.25)) + n * 0.25); // Spots n = snoise(p * 0.4); float spots = smoothstep(0.0, 0.1, n); return clamp(strips + spots, 0.0, 1.0); } // Draw a petal with texture vec4 drawPetal(vec2 p) { // White part vec4 whitePart = vec4(1.0 - smoothstep(0.0, 0.01, petalOutline(p, 0.0))); // Pink part vec4 inside = vec4(1.0 - smoothstep(0.0, 0.01, petalOutline(p, 0.033))); inside.rgb *= vec3(0.740,0.132,0.464); // Calculate texture vec4 tex = vec4(petalTexture(p)) * inside; return premulMix(tex, whitePart);; } // Draw the pistil vec4 drawPistil(vec2 p) { vec4 color = vec4(1.0 - sign(sdUnevenCapsule(p, 0.168, 0.124, 0.312))); color.rgb *= vec3(0.983,1.000,0.848); return color; } // Draw small petals vec4 drawSmallPetals(vec2 p) { // A big versica float rad = 1.6; float c = cos(rad), s = sin(rad); float x = 0.3, y = -0.46; mat3 H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; vec2 newP = (H * vec3(p, 1.0)).xy * 5.5; float v = sdVesica(newP, 1.36, 0.2); // Part to be removed 1 rad = 2.96; c = cos(rad), s = sin(rad); x = 0.59, y = 0.13; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; newP = (H * vec3(p, 1.0)).xy * 5.5; float part1 = sdVesica(newP, 1.25, 1.0); // Part to be removed 2 rad = 0.104; c = cos(rad), s = sin(rad); x = -0.360, y = -0.272; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; newP = (H * vec3(p, 1.0)).xy * 5.5; float part2 = sdVesica(newP, 1.25, 1.0); // Part to be removed 3 rad = 1.6; c = cos(rad), s = sin(rad); x = 0.416, y = -0.456; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; newP = (H * vec3(p, 1.0)).xy * 5.5; float part3 = sdVesica(newP, 1.28, 0.62); // Get small petals by removing the three unwanted parts of the big versica float smallPetals = sdSmoothDifference(part3, sdDifference(part2, sdDifference(part1, v)), 0.2); // Calculate and return the color (The edges are white) vec4 color_inside = vec4(1.0 - smoothstep(0.0, 0.04, smallPetals)); color_inside.rgb *= vec3(0.73 ,0.13,0.46) * (p.y + 0.75); vec4 color_outside = vec4(1.0 - smoothstep(0.02, 0.04, smallPetals)); return premulMix(color_inside, color_outside); } // uniform float u_time; vec4 drawBackground(vec2 p) { // vec3 uv = vec3(p.xy, 0.04 * u_time); vec3 uv = vec3(p.xy, 0.04); float noise = 0.50 * turbulence(uv) + 0.5; return vec4( vec3(0.507,0.800,0.183), noise); } void main() { vec2 st = gl_FragCoord.xy / u_resolution.xy; vec4 background = drawBackground(st); // Adjust the center of the orchid st += vec2(0.0, 0.05); // Draw petal 1 float rad = 0.0; float c = cos(rad), s = sin(rad); float x = -0.352, y = -0.568; mat3 H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; vec2 p = (H * vec3(st, 1.0)).xy * 3.3; vec4 petal1 = drawPetal(p); petal1.rgb *= 1.070 * pow(1.0 - p.y, 0.1); colour_out = premulMix(petal1, background); // Draw petal 2 rad = -2.416; c = cos(rad), s = sin(rad); x = 0.144, y = 0.692; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; p = (H * vec3(st, 1.0)).xy * vec2(3.5, 3.3); vec4 petal2 = drawPetal(p); petal2.rgb *= 0.9; colour_out = premulMix(petal2, colour_out); // Draw petal 3 rad = 2.360; c = cos(rad), s = sin(rad); x = 0.848, y = -0.016; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; p = (H * vec3(st, 1.0)).xy * vec2(4.0, 3.3); vec4 petal3 = drawPetal(p); petal3.rgb *= 1.1; colour_out = premulMix(petal3, colour_out); // Draw petal 4 colour_out -= vec4(vec3(0.05), 0.0); rad = 1.640; c = cos(rad), s = sin(rad); x = 0.744, y = -0.504; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; p = (H * vec3(st, 1.0)).xy * 3.0; vec4 petal4 = drawPetal(p); petal4.rgb *= 0.9 * (abs(p.x - 0.5) + 1.0); colour_out = premulMix(petal4, colour_out); // Draw petal 5 rad = -1.464; c = cos(rad), s = sin(rad); x = -0.416, y = 0.408; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; p = (H * vec3(st, 1.0)).xy * 3.0; vec4 petal5 = drawPetal(p); petal5.rgb *= 0.9 * (abs(p.x - 0.5) + 1.0); colour_out = premulMix(petal5, colour_out); // Draw pistil rad = 0.112; c = cos(rad), s = sin(rad); x = -0.432, y = -0.592; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; p = (H * vec3(st, 1.0)).xy * 5.488; vec4 pistil = drawPistil(p); colour_out = premulMix(pistil, colour_out); // Draw small petals rad = 0.112; c = cos(rad), s = sin(rad); x = -0.200, y = -0.448; H = mat3( c, s, 0, -s, c, 0, x, y, 1 ); // vec2 p = (inverse(H) * vec3(st, 1.0)).xy; p = (H * vec3(st, 1.0)).xy * 2.0; vec4 smallPetals = drawSmallPetals(p); colour_out = premulMix(smallPetals, colour_out); // Add some light from the top right corner colour_out += 0.1 * st.x * st.y; }
415
1
// credit: s.l
2
3
uniform vec2 u_resolution;
4
5
vec2 mod289(vec2 x) {
6
return x - floor(x * (1.0 / 289.0)) * 289.0;
7
}
8
9
vec3 mod289(vec3 x) {
10
return x - floor(x * (1.0 / 289.0)) * 289.0;
11
}
12
13
vec4 mod289(vec4 x) {
14
return x - floor(x * (1.0 / 289.0)) * 289.0;
15
}
16
17
vec3 permute(vec3 x) {
18
return mod289(((x*34.0)+10.0)*x);
19
}
20
21
vec4 permute(vec4 x) {
22
return mod289(((x*34.0)+10.0)*x);
23
}
24
25
vec4 taylorInvSqrt(vec4 r) {
26
return 1.79284291400159 - 0.85373472095314 * r;
27
}
28
29
float snoise(vec2 v) {
30
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
31
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
32
-0.577350269189626, // -1.0 + 2.0 * C.x
33
0.024390243902439); // 1.0 / 41.0
34
// First corner
35
vec2 i = floor(v + dot(v, C.yy) );
36
vec2 x0 = v - i + dot(i, C.xx);
37
38
// Other corners
39
vec2 i1;
40
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
41
//i1.y = 1.0 - i1.x;
42
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
43
// x0 = x0 - 0.0 + 0.0 * C.xx ;
44
// x1 = x0 - i1 + 1.0 * C.xx ;
45
// x2 = x0 - 1.0 + 2.0 * C.xx ;
46
vec4 x12 = x0.xyxy + C.xxzz;
47
x12.xy -= i1;
48
49
// Permutations
50
i = mod289(i); // Avoid truncation effects in permutation
51
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
52
+ i.x + vec3(0.0, i1.x, 1.0 ));
53
54
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
55
m = m*m ;
56
m = m*m ;
57
58
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
59
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
60
61
vec3 x = 2.0 * fract(p * C.www) - 1.0;
62
vec3 h = abs(x) - 0.5;
63
vec3 ox = floor(x + 0.5);
64
vec3 a0 = x - ox;
65
66
// Normalise gradients implicitly by scaling m
67
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
68
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
69
70
// Compute final noise value at P
71
vec3 g;
72
g.x = a0.x * x0.x + h.x * x0.y;
73
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
74
return 130.0 * dot(m, g);
75
}
76
77
float snoise(vec3 v) {
78
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
79
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
80
81
// First corner
82
vec3 i = floor(v + dot(v, C.yyy) );
83
vec3 x0 = v - i + dot(i, C.xxx) ;
84
85
// Other corners
86
vec3 g = step(x0.yzx, x0.xyz);
87
vec3 l = 1.0 - g;
88
vec3 i1 = min( g.xyz, l.zxy );
89
vec3 i2 = max( g.xyz, l.zxy );
90
91
// x0 = x0 - 0.0 + 0.0 * C.xxx;
92
// x1 = x0 - i1 + 1.0 * C.xxx;
93
// x2 = x0 - i2 + 2.0 * C.xxx;
94
// x3 = x0 - 1.0 + 3.0 * C.xxx;
95
vec3 x1 = x0 - i1 + C.xxx;
96
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
97
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
98
99
// Permutations
100
i = mod289(i);
101
vec4 p = permute( permute( permute(
102
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
103
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
104
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
105
106
// Gradients: 7x7 points over a square, mapped onto an octahedron.
107
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
108
float n_ = 0.142857142857; // 1.0/7.0
109
vec3 ns = n_ * D.wyz - D.xzx;
110
111
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
112
113
vec4 x_ = floor(j * ns.z);
114
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
115
116
vec4 x = x_ *ns.x + ns.yyyy;
117
vec4 y = y_ *ns.x + ns.yyyy;
118
vec4 h = 1.0 - abs(x) - abs(y);
119
120
vec4 b0 = vec4( x.xy, y.xy );
121
vec4 b1 = vec4( x.zw, y.zw );
122
123
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
124
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
125
vec4 s0 = floor(b0)*2.0 + 1.0;
126
vec4 s1 = floor(b1)*2.0 + 1.0;
127
vec4 sh = -step(h, vec4(0.0));
128
129
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
130
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
131
132
vec3 p0 = vec3(a0.xy,h.x);
133
vec3 p1 = vec3(a0.zw,h.y);
134
vec3 p2 = vec3(a1.xy,h.z);
135
vec3 p3 = vec3(a1.zw,h.w);
136
137
//Normalise gradients
138
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
139
p0 *= norm.x;
140
p1 *= norm.y;
141
p2 *= norm.z;
142
p3 *= norm.w;
143
144
// Mix final noise value
145
vec4 m = max(0.5 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
146
m = m * m;
147
return 105.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
148
dot(p2,x2), dot(p3,x3) ) );
149
}
150
151
float turbulence( vec3 p ) {
152
float f = 0.0, scale;
153
for (int i=0; i<4; i++) {
154
scale = pow( pow(2.0, 4.0/3.0), float(i) );
155
f += abs( snoise( p * scale ) ) / scale; }
156
return f;
157
}
158
159
// Blends a pre-multiplied src onto a dst color (without alpha)
160
vec3 premulMix(vec4 src, vec3 dst) {
161
return dst.rgb * (1.0 - src.a) + src.rgb;
162
}
163
164
// Blends a pre-multiplied src onto a dst color (with alpha)
165
vec4 premulMix(vec4 src, vec4 dst) {
166
vec4 res;
167
res.rgb = premulMix(src, dst.rgb);
168
res.a = 1.0 - (1.0 - src.a) * (1.0 - dst.a);
169
return res;
170
}
171
172
float sdUnevenCapsule( vec2 p, float r1, float r2, float h ) {
173
p.x = abs(p.x);
174
float b = (r1 - r2) / h;
175
float a = sqrt(1.0 - b * b);
176
float k = dot(p, vec2(-b, a));
177
if(k < 0.0)
178
return length(p) - r1;
179
if(k > a * h)
180
return length(p - vec2(0.0, h)) - r2;
181
return dot(p, vec2(a, b)) - r1;
182
}
183
float sdVesica(vec2 p, float r, float d) {
184
p = abs(p);
185
float b = sqrt(r * r - d * d);
186
return ((p.y - b) * d > p.x * b) ? length(p - vec2(0.0, b)) : length(p - vec2(-d, 0.0)) - r;
187
}
188
float sdDifference(float d1, float d2) {
189
return max(-d1, d2);
190
}
191
float smax(float a, float b, float k) {
192
float h = max(k - abs(a - b), 0.0);
193
return max(a, b) + h * h * 0.25 / k;
194
}
195
float sdSmoothDifference(float d1, float d2, float k) {
196
return smax(-d1, d2, k);
197
}
198
199
// The outline of a petal
200
float petalOutline(vec2 p, float s) {
201
vec2 centerLine = vec2(0.5, p.y);
202
203
// Top
204
if (p.y > 0.6 && p.y < 1.0)
205
return length(p - centerLine) - 0.57 * pow(1.0 - p.y, 0.35) + s;
206
// Middle
207
else if (p.y < 0.6 && p.y > 0.3)
208
return length(p - centerLine) - 0.46 * pow(0.75 - p.y, 0.06) + s;
209
// Bottom
210
else if (p.y < 0.3 && p.y > -0.1)
211
return length(p - centerLine) - 0.3 / (0.832 + exp(- 16.0 * p.y + 2.0)) - 0.1 + s;
212
// Outside
213
else
214
return 1.0;
215
}
216
217
// Texture of a petal
218
float petalTexture(vec2 p) {
219
p = (p - 0.5) * 30.0;
220
221
// Strips
222
float n = snoise(p);
223
float strips = smoothstep(0.0, 0.3, sin(p.x * 7.2 * (pow(-0.05 * p.y, 4.0) + 0.25)) + n * 0.25);
224
// Spots
225
n = snoise(p * 0.4);
226
float spots = smoothstep(0.0, 0.1, n);
227
228
return clamp(strips + spots, 0.0, 1.0);
229
}
230
231
// Draw a petal with texture
232
vec4 drawPetal(vec2 p) {
233
// White part
234
vec4 whitePart = vec4(1.0 - smoothstep(0.0, 0.01, petalOutline(p, 0.0)));
235
// Pink part
236
vec4 inside = vec4(1.0 - smoothstep(0.0, 0.01, petalOutline(p, 0.033)));
237
inside.rgb *= vec3(0.740,0.132,0.464);
238
// Calculate texture
239
vec4 tex = vec4(petalTexture(p)) * inside;
240
241
return premulMix(tex, whitePart);;
242
}
243
244
// Draw the pistil
245
vec4 drawPistil(vec2 p) {
246
vec4 color = vec4(1.0 - sign(sdUnevenCapsule(p, 0.168, 0.124, 0.312)));
247
color.rgb *= vec3(0.983,1.000,0.848);
248
return color;
249
}
250
251
// Draw small petals
252
vec4 drawSmallPetals(vec2 p) {
253
// A big versica
254
float rad = 1.6;
255
float c = cos(rad), s = sin(rad);
256
float x = 0.3, y = -0.46;
257
mat3 H = mat3( c, s, 0,
258
-s, c, 0,
259
x, y, 1 );
260
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
261
vec2 newP = (H * vec3(p, 1.0)).xy * 5.5;
262
float v = sdVesica(newP, 1.36, 0.2);
263
264
// Part to be removed 1
265
rad = 2.96;
266
c = cos(rad), s = sin(rad);
267
x = 0.59, y = 0.13;
268
H = mat3( c, s, 0,
269
-s, c, 0,
270
x, y, 1 );
271
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
272
newP = (H * vec3(p, 1.0)).xy * 5.5;
273
float part1 = sdVesica(newP, 1.25, 1.0);
274
275
// Part to be removed 2
276
rad = 0.104;
277
c = cos(rad), s = sin(rad);
278
x = -0.360, y = -0.272;
279
H = mat3( c, s, 0,
280
-s, c, 0,
281
x, y, 1 );
282
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
283
newP = (H * vec3(p, 1.0)).xy * 5.5;
284
float part2 = sdVesica(newP, 1.25, 1.0);
285
286
// Part to be removed 3
287
rad = 1.6;
288
c = cos(rad), s = sin(rad);
289
x = 0.416, y = -0.456;
290
H = mat3( c, s, 0,
291
-s, c, 0,
292
x, y, 1 );
293
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
294
newP = (H * vec3(p, 1.0)).xy * 5.5;
295
float part3 = sdVesica(newP, 1.28, 0.62);
296
297
// Get small petals by removing the three unwanted parts of the big versica
298
float smallPetals = sdSmoothDifference(part3, sdDifference(part2, sdDifference(part1, v)), 0.2);
299
300
// Calculate and return the color (The edges are white)
301
vec4 color_inside = vec4(1.0 - smoothstep(0.0, 0.04, smallPetals));
302
color_inside.rgb *= vec3(0.73 ,0.13,0.46) * (p.y + 0.75);
303
vec4 color_outside = vec4(1.0 - smoothstep(0.02, 0.04, smallPetals));
304
return premulMix(color_inside, color_outside);
305
}
306
307
// uniform float u_time;
308
vec4 drawBackground(vec2 p) {
309
// vec3 uv = vec3(p.xy, 0.04 * u_time);
310
vec3 uv = vec3(p.xy, 0.04);
311
float noise = 0.50 * turbulence(uv) + 0.5;
312
return vec4( vec3(0.507,0.800,0.183), noise);
313
}
314
315
void main() {
316
vec2 st = gl_FragCoord.xy / u_resolution.xy;
317
318
vec4 background = drawBackground(st);
319
320
// Adjust the center of the orchid
321
st += vec2(0.0, 0.05);
322
323
// Draw petal 1
324
float rad = 0.0;
325
float c = cos(rad), s = sin(rad);
326
float x = -0.352, y = -0.568;
327
mat3 H = mat3( c, s, 0,
328
-s, c, 0,
329
x, y, 1 );
330
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
331
vec2 p = (H * vec3(st, 1.0)).xy * 3.3;
332
vec4 petal1 = drawPetal(p);
333
petal1.rgb *= 1.070 * pow(1.0 - p.y, 0.1);
334
colour_out = premulMix(petal1, background);
335
336
// Draw petal 2
337
rad = -2.416;
338
c = cos(rad), s = sin(rad);
339
x = 0.144, y = 0.692;
340
H = mat3( c, s, 0,
341
-s, c, 0,
342
x, y, 1 );
343
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
344
p = (H * vec3(st, 1.0)).xy * vec2(3.5, 3.3);
345
vec4 petal2 = drawPetal(p);
346
petal2.rgb *= 0.9;
347
colour_out = premulMix(petal2, colour_out);
348
349
// Draw petal 3
350
rad = 2.360;
351
c = cos(rad), s = sin(rad);
352
x = 0.848, y = -0.016;
353
H = mat3( c, s, 0,
354
-s, c, 0,
355
x, y, 1 );
356
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
357
p = (H * vec3(st, 1.0)).xy * vec2(4.0, 3.3);
358
vec4 petal3 = drawPetal(p);
359
petal3.rgb *= 1.1;
360
colour_out = premulMix(petal3, colour_out);
361
362
// Draw petal 4
363
colour_out -= vec4(vec3(0.05), 0.0);
364
rad = 1.640;
365
c = cos(rad), s = sin(rad);
366
x = 0.744, y = -0.504;
367
H = mat3( c, s, 0,
368
-s, c, 0,
369
x, y, 1 );
370
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
371
p = (H * vec3(st, 1.0)).xy * 3.0;
372
vec4 petal4 = drawPetal(p);
373
petal4.rgb *= 0.9 * (abs(p.x - 0.5) + 1.0);
374
colour_out = premulMix(petal4, colour_out);
375
376
// Draw petal 5
377
rad = -1.464;
378
c = cos(rad), s = sin(rad);
379
x = -0.416, y = 0.408;
380
H = mat3( c, s, 0,
381
-s, c, 0,
382
x, y, 1 );
383
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
384
p = (H * vec3(st, 1.0)).xy * 3.0;
385
vec4 petal5 = drawPetal(p);
386
petal5.rgb *= 0.9 * (abs(p.x - 0.5) + 1.0);
387
colour_out = premulMix(petal5, colour_out);
388
389
// Draw pistil
390
rad = 0.112;
391
c = cos(rad), s = sin(rad);
392
x = -0.432, y = -0.592;
393
H = mat3( c, s, 0,
394
-s, c, 0,
395
x, y, 1 );
396
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
397
p = (H * vec3(st, 1.0)).xy * 5.488;
398
vec4 pistil = drawPistil(p);
399
colour_out = premulMix(pistil, colour_out);
400
401
// Draw small petals
402
rad = 0.112;
403
c = cos(rad), s = sin(rad);
404
x = -0.200, y = -0.448;
405
H = mat3( c, s, 0,
406
-s, c, 0,
407
x, y, 1 );
408
// vec2 p = (inverse(H) * vec3(st, 1.0)).xy;
409
p = (H * vec3(st, 1.0)).xy * 2.0;
410
vec4 smallPetals = drawSmallPetals(p);
411
colour_out = premulMix(smallPetals, colour_out);
412
413
// Add some light from the top right corner
414
colour_out += 0.1 * st.x * st.y;
415
}
unknown by s.l
// credit: YoshieSuzuki // orchid: Dendrobium uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float M_PI = 3.14159265358979323846; float mix(float x,float y, float a){ return x*(1.0-a)+y*a; } float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,-0.008))-r; } float sdUnevenCapsule( vec2 p, float r1, float r2, float h ) { p.x = abs(p.x); float b = (r1-r2)/h; float a = sqrt(1.0-b*b); float k = dot(p,vec2(-b,a)); if( k < 0.0 ) return length(p) - r1; if( k > a*h ) return length(p-vec2(0.0,h)) - r2; return dot(p, vec2(a,b) ) - r1; } float sdOrientedBox( in vec2 p, in vec2 a, in vec2 b, float th ) { float l = length(b-a); vec2 d = (b-a)/l; vec2 q = (p-(a+b)*0.5); q = mat2(d.x,-d.y,d.y,d.x)*q; q = abs(q)-vec2(l,th)*0.5; return length(max(q,0.0)) + min(max(q.x,q.y),0.0); } 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)); } float sdCircle( vec2 p, float r ) { return length(p) - r; } vec3 flag(vec2 uv) { float r = length(uv)*3.0; float a = atan(uv.y,uv.x); float f = abs(cos(a * 3.0)); if(r<=f){ return vec3(0.3,0.0,0.4); }else{ return vec3(1.000,0.914,0.992); } } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; vec2 center = vec2(0.5,0.5); float theta = M_PI / 3.0; float mask = 1.0; mask *= step( 0.3, sdVesica( st.xy-vec2(0.50,0.70), 0.1, 0.3 )); mask *= step( 0.0, sdUnevenCapsule( st.xy-vec2(0.50,0.2), 0.1,0.02, 0.3 )); mask *= step( 0.0, sdOrientedBox( st.xy,vec2(0.5,0.0),vec2(0.5,0.1), 0.03 )); colour_out = vec4(mix(0.0, 0.7, exp(-1.0*length(center-st)+0.7)),mix(0.0,0.9, exp(-1.0*length(center-st)+0.25)),1.0,1.000); if(sdOrientedBox( st.xy,vec2(0.5,0.0),vec2(0.5,0.1), 0.03 ) <= 0.0){ colour_out = vec4(0.000,0.495,0.000,1.000); } mat2 rotate = mat2( cos(theta), (-1.0)*sin(theta), sin(theta), cos(theta) ); st = rotate * st; mask *= step( 0.33, sdVesica( st.xy-vec2(0.600,0.000), 0.1, 0.3 )); st = rotate * st; mask *= step( 0.33, sdVesica( st.xy-vec2(0.110,-0.840), 0.1, 0.3 )); theta = M_PI / 6.0; rotate = mat2( cos(theta), (-1.0)*sin(theta), sin(theta), cos(theta) ); st = rotate * st; mask *= step( 0.3, sdVesica( st.xy-vec2(-0.220,-0.900), 0.08, 0.3 )); theta = M_PI / 3.0; rotate = mat2( cos(theta), (-1.0)*sin(theta), sin(theta), cos(theta) ); st = rotate * st; mask *= step( 0.3, sdVesica( st.xy-vec2(-0.630,-0.400), 0.08, 0.3 )); st = gl_FragCoord.xy/u_resolution.xy; theta = M_PI / 1.5; rotate = mat2( cos(theta), (-1.0)*sin(theta), sin(theta), cos(theta) ); st = rotate * st; vec2 reset = gl_FragCoord.xy/u_resolution.xy; if(sdPie( st.xy+vec2(-0.20,0.70),vec2(0.50,0.20),0.15 ) <= 0.0){ st = gl_FragCoord.xy/u_resolution.xy - vec2(0.5,0.5); vec3 ci = flag(st); colour_out = vec4(ci, 1.0); } st = gl_FragCoord.xy/u_resolution.xy; theta = -1.0*M_PI / 1.5; rotate = mat2( cos(theta), (-1.0)*sin(theta), sin(theta), cos(theta) ); st = rotate * st; if(sdPie( st.xy+vec2(0.705,-0.175),vec2(0.5,0.2),0.15 ) <= 0.0){ st = gl_FragCoord.xy/u_resolution.xy - vec2(0.5,0.5); vec3 ci = flag(st); colour_out = vec4(ci, 1.0); } colour_out *= 1.0-mask; }
119
1
// credit: YoshieSuzuki
2
// orchid: Dendrobium
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
const float M_PI = 3.14159265358979323846;
7
float mix(float x,float y, float a){
8
return x*(1.0-a)+y*a;
9
}
10
11
float sdVesica(vec2 p, float r, float d)
12
{
13
p = abs(p);
14
float b = sqrt(r*r-d*d);
15
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b))
16
: length(p-vec2(-d,-0.008))-r;
17
}
18
float sdUnevenCapsule( vec2 p, float r1, float r2, float h )
19
{
20
p.x = abs(p.x);
21
float b = (r1-r2)/h;
22
float a = sqrt(1.0-b*b);
23
float k = dot(p,vec2(-b,a));
24
if( k < 0.0 ) return length(p) - r1;
25
if( k > a*h ) return length(p-vec2(0.0,h)) - r2;
26
return dot(p, vec2(a,b) ) - r1;
27
}
28
float sdOrientedBox( in vec2 p, in vec2 a, in vec2 b, float th )
29
{
30
float l = length(b-a);
31
vec2 d = (b-a)/l;
32
vec2 q = (p-(a+b)*0.5);
33
q = mat2(d.x,-d.y,d.y,d.x)*q;
34
q = abs(q)-vec2(l,th)*0.5;
35
return length(max(q,0.0)) + min(max(q.x,q.y),0.0);
36
}
37
float sdPie( in vec2 p, in vec2 c, in float r )
38
{
39
p.x = abs(p.x);
40
float l = length(p) - r;
41
float m = length(p-c*clamp(dot(p,c),0.0,r));
42
return max(l,m*sign(c.y*p.x-c.x*p.y));
43
}
44
float sdCircle( vec2 p, float r )
45
{
46
return length(p) - r;
47
}
48
vec3 flag(vec2 uv) {
49
float r = length(uv)*3.0;
50
float a = atan(uv.y,uv.x);
51
float f = abs(cos(a * 3.0));
52
if(r<=f){
53
return vec3(0.3,0.0,0.4);
54
}else{
55
return vec3(1.000,0.914,0.992);
56
}
57
}
58
59
void main() {
60
vec2 st = gl_FragCoord.xy/u_resolution.xy;
61
vec2 center = vec2(0.5,0.5);
62
float theta = M_PI / 3.0;
63
float mask = 1.0;
64
mask *= step( 0.3, sdVesica( st.xy-vec2(0.50,0.70), 0.1, 0.3 ));
65
mask *= step( 0.0, sdUnevenCapsule( st.xy-vec2(0.50,0.2), 0.1,0.02, 0.3 ));
66
mask *= step( 0.0, sdOrientedBox( st.xy,vec2(0.5,0.0),vec2(0.5,0.1), 0.03 ));
67
colour_out = vec4(mix(0.0, 0.7, exp(-1.0*length(center-st)+0.7)),mix(0.0,0.9, exp(-1.0*length(center-st)+0.25)),1.0,1.000);
68
if(sdOrientedBox( st.xy,vec2(0.5,0.0),vec2(0.5,0.1), 0.03 ) <= 0.0){
69
colour_out = vec4(0.000,0.495,0.000,1.000);
70
}
71
mat2 rotate = mat2(
72
cos(theta), (-1.0)*sin(theta),
73
sin(theta), cos(theta)
74
);
75
st = rotate * st;
76
mask *= step( 0.33, sdVesica( st.xy-vec2(0.600,0.000), 0.1, 0.3 ));
77
st = rotate * st;
78
mask *= step( 0.33, sdVesica( st.xy-vec2(0.110,-0.840), 0.1, 0.3 ));
79
theta = M_PI / 6.0;
80
rotate = mat2(
81
cos(theta), (-1.0)*sin(theta),
82
sin(theta), cos(theta)
83
);
84
st = rotate * st;
85
mask *= step( 0.3, sdVesica( st.xy-vec2(-0.220,-0.900), 0.08, 0.3 ));
86
theta = M_PI / 3.0;
87
rotate = mat2(
88
cos(theta), (-1.0)*sin(theta),
89
sin(theta), cos(theta)
90
);
91
st = rotate * st;
92
mask *= step( 0.3, sdVesica( st.xy-vec2(-0.630,-0.400), 0.08, 0.3 ));
93
st = gl_FragCoord.xy/u_resolution.xy;
94
theta = M_PI / 1.5;
95
rotate = mat2(
96
cos(theta), (-1.0)*sin(theta),
97
sin(theta), cos(theta)
98
);
99
st = rotate * st;
100
vec2 reset = gl_FragCoord.xy/u_resolution.xy;
101
if(sdPie( st.xy+vec2(-0.20,0.70),vec2(0.50,0.20),0.15 ) <= 0.0){
102
st = gl_FragCoord.xy/u_resolution.xy - vec2(0.5,0.5);
103
vec3 ci = flag(st);
104
colour_out = vec4(ci, 1.0);
105
}
106
st = gl_FragCoord.xy/u_resolution.xy;
107
theta = -1.0*M_PI / 1.5;
108
rotate = mat2(
109
cos(theta), (-1.0)*sin(theta),
110
sin(theta), cos(theta)
111
);
112
st = rotate * st;
113
if(sdPie( st.xy+vec2(0.705,-0.175),vec2(0.5,0.2),0.15 ) <= 0.0){
114
st = gl_FragCoord.xy/u_resolution.xy - vec2(0.5,0.5);
115
vec3 ci = flag(st);
116
colour_out = vec4(ci, 1.0);
117
}
118
colour_out *= 1.0-mask;
119
}
Dendrobium by YoshieSuzuki
// credit: Chen Chung An (will show up on website) // orchid: Paphiopedilum Purpuratum uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; float petal( in vec2 p, in float ra, in float rb, in float curve_x, in float curve_y, in float width_x, in float width_y ) { const float k = sqrt(6.448); p.x = abs(p.x); float r = ra - rb; return ((p.y<0.000) ? length(vec2(p.x, p.y)) - r : (k*(p.x+r)<p.y) ? length(vec2(p.x, p.y-k*r)) : length(vec2(width_x*pow(p.x,curve_x)+ r,width_y*pow(p.y,curve_y))) - 2.000*r) - rb; } float noise(vec2 p){ return fract(sin(dot(p.xy, vec2(12.988, 78.233))) * 43758.5453); } vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float turbulence(vec2 p){ float f = 0.0, scale; for (int i=0; i<4; i++){ scale = pow(pow(3.912,5.116/3.0), float(i)); f += abs(snoise(p * scale)) / scale; } return f; } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; vec2 bright_spot = vec2(0.430,0.500); vec2 bright_spot_2 = vec2(0.460,0.390); if(petal(vec2(st.x - 0.444, st.y - 0.596), 0.124, -0.268, 0.065, 1.320, 0.159, 1.012) + -0.016 < 0.0 ){ colour_out = vec4( 2.272, 1.584 - sin(sin(st.x*1.648 + -0.716)*sin(st.y*5.260 + -1.812)/0.011), 0.912 , distance(st.x, 2.280*st.y)) ; // top petal } if( max(max(-st.x + 0.392, st.x - 0.432), max(- st.y + -0.300, st.y - 0.428)) < 0.0){ colour_out = vec4(1.368 - st.y,1.432 - st.y,st.y ,0.784)*(st.x + st.y)+st.y*noise(st.xy); // stem } if(pow(((1.200 * (st.x + -0.528))/2.416),2.000) - -0.536 *st.x*st.y + pow(((st.y + -0.584)/1.040),2.000) < 0.724*length(vec2(-0.104*st.y, 0.384*st.x))){ colour_out = vec4(vec3(1.0, st.x > 0.96 - pow(st.y, 2.0) ? 1.008: 1.0 - pow(st.x, 1.960), st.x > 0.96 - pow(st.y, 2.0) ? 1.040: 0.528), st.x*(2.056 + sin((st.y*st.x)/0.002 ))) + (distance(st.xy, vec2(0.300,0.820)) < 0.55 ? -st.x*noise(st.xy):0.0) ; // right petal } if(pow(((2.864 * (st.x + -0.216))/2.120),2.000) - 1.224 *st.x*st.y + pow(((pow(st.y,1.000) + -0.184)/1.040),2.000) + 0.084 < 0.0){ colour_out = vec4(vec3(1.0, st.y < 0.350 ? 1.008: 1.0 - pow(1.0-st.y, 2.264), st.y < 0.35 ? 1.040: 1.0 - pow(1.0-st.y, 1.304)), st.y < 0.35 ? 1.0:st.x*(2.968 + sin(sin(st.x*1.408 + -0.804)*sin(st.y*2.756 + -0.492)/0.003))) + (distance(st.xy, vec2(0.670,0.880)) < 0.55 ? -st.y*noise(st.xy):0.0) ; // right petal } if(pow(((1.000 * (st.x + -0.528))/1.160),2.000) - -0.104 *st.x*st.y + pow(((0.552 * (st.y + -0.356))/1.040),2.000) - 0.024 < 0.0){ colour_out = vec4( vec3(1.25, 0.252+st.y, st.x)*turbulence(st.xy), 1.0 - pow(length(st.xy - vec2(0.550,0.290)),0.416)) ; // bot petal } colour_out += vec4( exp(-length(st.xy - bright_spot) * 45.600)); colour_out += vec4( exp(-length(st.xy - bright_spot_2) * 20.600)); }
111
1
// credit: Chen Chung An (will show up on website)
2
// orchid: Paphiopedilum Purpuratum
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
float petal( in vec2 p, in float ra, in float rb, in float curve_x, in float curve_y, in float width_x, in float width_y )
7
{
8
const float k = sqrt(6.448);
9
p.x = abs(p.x);
10
float r = ra - rb;
11
return ((p.y<0.000) ? length(vec2(p.x, p.y)) - r :
12
(k*(p.x+r)<p.y) ? length(vec2(p.x, p.y-k*r)) :
13
length(vec2(width_x*pow(p.x,curve_x)+ r,width_y*pow(p.y,curve_y))) - 2.000*r) - rb;
14
}
15
16
float noise(vec2 p){
17
return fract(sin(dot(p.xy, vec2(12.988, 78.233))) * 43758.5453);
18
}
19
20
vec3 mod289(vec3 x) {
21
return x - floor(x * (1.0 / 289.0)) * 289.0;
22
}
23
24
vec2 mod289(vec2 x) {
25
return x - floor(x * (1.0 / 289.0)) * 289.0;
26
}
27
28
vec3 permute(vec3 x) {
29
return mod289(((x*34.0)+10.0)*x);
30
}
31
32
float snoise(vec2 v)
33
{
34
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
35
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
36
-0.577350269189626, // -1.0 + 2.0 * C.x
37
0.024390243902439); // 1.0 / 41.0
38
// First corner
39
vec2 i = floor(v + dot(v, C.yy) );
40
vec2 x0 = v - i + dot(i, C.xx);
41
42
// Other corners
43
vec2 i1;
44
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
45
//i1.y = 1.0 - i1.x;
46
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
47
// x0 = x0 - 0.0 + 0.0 * C.xx ;
48
// x1 = x0 - i1 + 1.0 * C.xx ;
49
// x2 = x0 - 1.0 + 2.0 * C.xx ;
50
vec4 x12 = x0.xyxy + C.xxzz;
51
x12.xy -= i1;
52
53
// Permutations
54
i = mod289(i); // Avoid truncation effects in permutation
55
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
56
+ i.x + vec3(0.0, i1.x, 1.0 ));
57
58
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
59
m = m*m ;
60
m = m*m ;
61
62
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
63
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
64
65
vec3 x = 2.0 * fract(p * C.www) - 1.0;
66
vec3 h = abs(x) - 0.5;
67
vec3 ox = floor(x + 0.5);
68
vec3 a0 = x - ox;
69
70
// Normalise gradients implicitly by scaling m
71
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
72
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
73
74
// Compute final noise value at P
75
vec3 g;
76
g.x = a0.x * x0.x + h.x * x0.y;
77
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
78
return 130.0 * dot(m, g);
79
}
80
81
float turbulence(vec2 p){
82
float f = 0.0, scale;
83
for (int i=0; i<4; i++){
84
scale = pow(pow(3.912,5.116/3.0), float(i));
85
f += abs(snoise(p * scale)) / scale;
86
}
87
return f;
88
}
89
90
void main() {
91
vec2 st = gl_FragCoord.xy/u_resolution.xy;
92
vec2 bright_spot = vec2(0.430,0.500);
93
vec2 bright_spot_2 = vec2(0.460,0.390);
94
if(petal(vec2(st.x - 0.444, st.y - 0.596), 0.124, -0.268, 0.065, 1.320, 0.159, 1.012) + -0.016 < 0.0 ){
95
colour_out = vec4( 2.272, 1.584 - sin(sin(st.x*1.648 + -0.716)*sin(st.y*5.260 + -1.812)/0.011), 0.912 , distance(st.x, 2.280*st.y)) ; // top petal
96
}
97
if( max(max(-st.x + 0.392, st.x - 0.432), max(- st.y + -0.300, st.y - 0.428)) < 0.0){
98
colour_out = vec4(1.368 - st.y,1.432 - st.y,st.y ,0.784)*(st.x + st.y)+st.y*noise(st.xy); // stem
99
}
100
if(pow(((1.200 * (st.x + -0.528))/2.416),2.000) - -0.536 *st.x*st.y + pow(((st.y + -0.584)/1.040),2.000) < 0.724*length(vec2(-0.104*st.y, 0.384*st.x))){
101
colour_out = vec4(vec3(1.0, st.x > 0.96 - pow(st.y, 2.0) ? 1.008: 1.0 - pow(st.x, 1.960), st.x > 0.96 - pow(st.y, 2.0) ? 1.040: 0.528), st.x*(2.056 + sin((st.y*st.x)/0.002 ))) + (distance(st.xy, vec2(0.300,0.820)) < 0.55 ? -st.x*noise(st.xy):0.0) ; // right petal
102
}
103
if(pow(((2.864 * (st.x + -0.216))/2.120),2.000) - 1.224 *st.x*st.y + pow(((pow(st.y,1.000) + -0.184)/1.040),2.000) + 0.084 < 0.0){
104
colour_out = vec4(vec3(1.0, st.y < 0.350 ? 1.008: 1.0 - pow(1.0-st.y, 2.264), st.y < 0.35 ? 1.040: 1.0 - pow(1.0-st.y, 1.304)), st.y < 0.35 ? 1.0:st.x*(2.968 + sin(sin(st.x*1.408 + -0.804)*sin(st.y*2.756 + -0.492)/0.003))) + (distance(st.xy, vec2(0.670,0.880)) < 0.55 ? -st.y*noise(st.xy):0.0) ; // right petal
105
}
106
if(pow(((1.000 * (st.x + -0.528))/1.160),2.000) - -0.104 *st.x*st.y + pow(((0.552 * (st.y + -0.356))/1.040),2.000) - 0.024 < 0.0){
107
colour_out = vec4( vec3(1.25, 0.252+st.y, st.x)*turbulence(st.xy), 1.0 - pow(length(st.xy - vec2(0.550,0.290)),0.416)) ; // bot petal
108
}
109
colour_out += vec4( exp(-length(st.xy - bright_spot) * 45.600));
110
colour_out += vec4( exp(-length(st.xy - bright_spot_2) * 20.600));
111
}
Paphiopedilum Purpuratum by Chen Chung An
// credit: @yuuki // orchid: Phalaenopsis Hybrid uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; // Shady (get it? lol) declarations that I probably ripped off of somewhere (wait a minute...) vec4 mod289(vec4 x){return x-floor(x*(1./289.))*289.;} vec3 mod289(vec3 x){return x-floor(x*(1./289.))*289.;} vec2 mod289(vec2 x){return x-floor(x*(1./289.))*289.;} vec4 permute(vec4 x){return mod289((34.*x+10.)*x);} vec3 permute(vec3 x){return mod289((34.*x+10.)*x);} vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-.85373472095314*r;} float snoise(vec3 v) { const vec2 C=vec2(1./6.,1./3.); const vec4 D=vec4(0.,.5,1.,2.); // First corner vec3 i=floor(v+dot(v,C.yyy)); vec3 x0=v-i+dot(i,C.xxx); // Other corners vec3 g=step(x0.yzx,x0.xyz); vec3 l=1.-g; vec3 i1=min(g.xyz,l.zxy); vec3 i2=max(g.xyz,l.zxy); // x0 = x0 - 0.0 + 0.0 * C.xxx; // x1 = x0 - i1 + 1.0 * C.xxx; // x2 = x0 - i2 + 2.0 * C.xxx; // x3 = x0 - 1.0 + 3.0 * C.xxx; vec3 x1=x0-i1+C.xxx; vec3 x2=x0-i2+C.yyy;// 2.0*C.x = 1/3 = C.y vec3 x3=x0-D.yyy;// -1.0+3.0*C.x = -0.5 = -D.y // Permutations i=mod289(i); vec4 p=permute(permute(permute( i.z+vec4(0.,i1.z,i2.z,1.)) +i.y+vec4(0.,i1.y,i2.y,1.)) +i.x+vec4(0.,i1.x,i2.x,1.)); // Gradients: 7x7 points over a square, mapped onto an octahedron. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) float n_=.142857142857;// 1.0/7.0 vec3 ns=n_*D.wyz-D.xzx; vec4 j=p-49.*floor(p*ns.z*ns.z);// mod(p,7*7) vec4 x_=floor(j*ns.z); vec4 y_=floor(j-7.*x_);// mod(j,N) vec4 x=x_*ns.x+ns.yyyy; vec4 y=y_*ns.x+ns.yyyy; vec4 h=1.-abs(x)-abs(y); vec4 b0=vec4(x.xy,y.xy); vec4 b1=vec4(x.zw,y.zw); //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; vec4 s0=floor(b0)*2.+1.; vec4 s1=floor(b1)*2.+1.; vec4 sh=-step(h,vec4(0.)); vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy; vec4 a1=b1.xzyw+s1.xzyw*sh.zzww; vec3 p0=vec3(a0.xy,h.x); vec3 p1=vec3(a0.zw,h.y); vec3 p2=vec3(a1.xy,h.z); vec3 p3=vec3(a1.zw,h.w); //Normalise gradients vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3))); p0*=norm.x; p1*=norm.y; p2*=norm.z; p3*=norm.w; // Mix final noise value vec4 m=max(.5-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.); m=m*m; return 105.*dot(m*m,vec4(dot(p0,x0),dot(p1,x1), dot(p2,x2),dot(p3,x3))); } float snoise(vec2 v){ const vec4 C=vec4(.211324865405187,// (3.0-sqrt(3.0))/6.0 .366025403784439,// 0.5*(sqrt(3.0)-1.0) -.577350269189626,// -1.0 + 2.0 * C.x .024390243902439);// 1.0 / 41.0 // First corner vec2 i=floor(v+dot(v,C.yy)); vec2 x0=v-i+dot(i,C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1=(x0.x>x0.y)?vec2(1.,0.):vec2(0.,1.); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12=x0.xyxy+C.xxzz; x12.xy-=i1; // Permutations i=mod289(i);// Avoid truncation effects in permutation vec3 p=permute(permute(i.y+vec3(0.,i1.y,1.)) +i.x+vec3(0.,i1.x,1.)); vec3 m=max(.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.); m=m*m; m=m*m; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x=2.*fract(p*C.www)-1.; vec3 h=abs(x)-.5; vec3 ox=floor(x+.5); vec3 a0=x-ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m*=1.79284291400159-.85373472095314*(a0*a0+h*h); // Compute final noise value at P vec3 g; g.x=a0.x*x0.x+h.x*x0.y; g.yz=a0.yz*x12.xz+h.yz*x12.yw; return 130.*dot(m,g); } float fbm(vec2 p){ float f=0.,scale; for(int i=0;i<4;i++){ scale=pow(pow(2.,4./3.),float(i)); f+=snoise(p*scale)/scale; } return f; } float fbm(vec3 p){ float f=0.,scale; for(int i=0;i<4;i++){ scale=pow(pow(2.,4./3.),float(i)); f+=snoise(p*scale)/scale; } return f; } float turbulence(vec3 p){ float f=0.,scale; for(int i=0;i<4;i++){ scale=pow(pow(2.,4./3.),float(i)); f+=abs(snoise(p*scale))/scale;} return f; } // End of the god-knows-what declarations // Functions for calculation float noise(vec3 v){ v.xy+=vec2(fbm(v),fbm(vec3(v.xy,v.z+1000.))); return fbm(v)*.35+.45; } // SDs ripped from https://iquilezles.org/ (thanks Inigo Quilez!) float dot2(in vec2 v){return dot(v,v);} float sdEgg(in vec2 p,in float ra,in float rb) { const float k=sqrt(3.); p.x=abs(p.x); float r=ra-rb; return((p.y<0.)?length(vec2(p.x,p.y))-r: (k*(p.x+r)<p.y)?length(vec2(p.x,p.y-k*r)): length(vec2(p.x+r,p.y))-2.*r)-rb; } float sdUnevenCapsule(vec2 p,float r1,float r2,float h) { p.x=abs(p.x); float b=(r1-r2)/h; float a=sqrt(1.-b*b); float k=dot(p,vec2(-b,a)); if(k<0.)return length(p)-r1; if(k>a*h)return length(p-vec2(0.,h))-r2; return dot(p,vec2(a,b))-r1; } float sdEquilateralTriangle(in vec2 p) { const float k=sqrt(3.); p.x=abs(p.x)-1.; p.y=p.y+1./k; if(p.x+k*p.y>0.)p=vec2(p.x-k*p.y,-k*p.x-p.y)/2.; p.x-=clamp(p.x,-2.,0.); return-length(p)*sign(p.y); } 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.,r));// c=sin/cos of aperture return max(l,m*sign(c.y*p.x-c.x*p.y)); } float sdHeart(in vec2 p) { p.x=abs(p.x); if(p.y+p.x>1.) return sqrt(dot2(p-vec2(.25,.75)))-sqrt(2.)/4.; return sqrt(min(dot2(p-vec2(0.,1.)), dot2(p-.5*max(p.x+p.y,0.))))*sign(p.x-p.y); } float sdVesica(vec2 p,float r,float d) { p=abs(p); float b=sqrt(r*r-d*d); return((p.y-b)*d>p.x*b)?length(p-vec2(0.,b)) :length(p-vec2(-d,0.))-r; } float sdEllipse(in vec2 p,in vec2 ab) { p=abs(p);if(p.x>p.y){p=p.yx;ab=ab.yx;} float l=ab.y*ab.y-ab.x*ab.x; float m=ab.x*p.x/l;float m2=m*m; float n=ab.y*p.y/l;float n2=n*n; float c=(m2+n2-1.)/3.;float c3=c*c*c; float q=c3+m2*n2*2.; float d=c3+m2*n2; float g=m+m*n2; float co; if(d<0.) { float h=acos(q/c3)/3.; float s=cos(h); float t=sin(h)*sqrt(3.); float rx=sqrt(-c*(s+t+2.)+m2); float ry=sqrt(-c*(s-t+2.)+m2); co=(ry+sign(l)*rx+abs(g)/(rx*ry)-m)/2.; } else { float h=2.*m*n*sqrt(d); float s=sign(q+h)*pow(abs(q+h),1./3.); float u=sign(q-h)*pow(abs(q-h),1./3.); float rx=-s-u-c*4.+2.*m2; float ry=(s-u)*sqrt(3.); float rm=sqrt(rx*rx+ry*ry); co=(ry/sqrt(rm-rx)+2.*g/rm-m)/2.; } vec2 r=ab*vec2(co,sqrt(1.-co*co)); return length(r-p)*sign(p.y-r.y); } // Flower patterns adapted from http://verygoodshaderexamples.ga (← very useful website!) vec4 flower_pattern_light(){ vec3 uv=vec3(15.*gl_FragCoord.xy/u_resolution.x-.5,.1*u_time); float noise=1.*turbulence(uv)+.2; return mix(vec4(1.,.1725,1.,1.),vec4(1.),noise); } vec4 flower_pattern_light_center(){ vec3 uv=vec3(15.*gl_FragCoord.xy/u_resolution.x-.5,.1*u_time); float noise=1.*turbulence(uv)+.2; return mix(vec4(.9725,.8706,.8706,1.),vec4(1.),noise); } vec4 flower_pattern_light_center_pink(){ vec3 uv=vec3(20.*gl_FragCoord.xy/u_resolution.x-.5,.05*u_time); float noise=1.*turbulence(uv)+.2; return mix(vec4(.8157,.5216,.9059,1.),vec4(.9686,.8078,1.,1.),noise); } vec4 flower_pattern_dark(){ vec3 uv=vec3(8.*gl_FragCoord.xy/u_resolution.x-.5,.05*u_time); float noise=.8*turbulence(uv)+.2; return mix(vec4(.5255,0.,.5255,1.),vec4(.7608,.4824,.4824,1.),noise); } vec4 flower_pattern_dark_center(){ vec3 uv=vec3(8.*gl_FragCoord.xy/u_resolution.x-.5,.05*u_time); float noise=.8*turbulence(uv)+.2; return mix(vec4(.2784,.0745,.2784,1.),vec4(.4078,.2392,.2392,1.),noise); } vec4 flower_pattern_yellow(){ vec3 uv=vec3(20.*gl_FragCoord.xy/u_resolution.x-.5,.2*u_time); float noise=1.*turbulence(uv)+.2; return mix(vec4(.6353,.6588,.2784,1.),vec4(.5216,.1373,.1373,1.),noise); } vec4 flower_pattern_white(){ vec3 uv=vec3(20.*gl_FragCoord.xy/u_resolution.x-.5,.5*u_time); float noise=1.*turbulence(uv)+.2; return mix(vec4(.9843,.9451,1.,1.),vec4(1.,.9608,.7765,1.),noise); } // Background pattern (it's not very easy to give the colors a natural feel for some reason) vec4 background_pattern(){ vec3 uv=vec3(.5*gl_FragCoord.xy/u_resolution.y-.5,.01*u_time); float noise=pow(noise(uv),4.)*5.; return mix(vec4(.0941,.0353,.0745,.8),vec4(.3255,.0902,.3255,1.),noise); } void main(){ vec2 st=gl_FragCoord.xy/u_resolution.xy; float mask_flower=1.; float mask_flower_edge=0.; float mask_flower_dark=1.; float mask_flower_yellow=0.; float mask_flower_pink=1.; float mask_flower_white=1.; float c1=cos(.2);float s1=sin(.2); mat2 R1=mat2(c1,s1,-s1,c1); float c2=cos(-.2);float s2=sin(-.2); mat2 R2=mat2(c2,s2,-s2,c2); // Generate flower pedals float left_pedal=sdEgg((st.yx-vec2(.5,.3))*R1*2.,.2,.5); float left_pedal_lower=sdEgg((st.yx-vec2(.4,.3))*R1*2.5,.2,.5); float right_pedal=sdEgg((-st.yx+vec2(.5,.7))*R2*2.,.2,.5); float right_pedal_lower=sdEgg((-st.yx+vec2(.4,.7))*R2*2.5,.2,.5); float top_pedal=sdEgg((vec2(st.x,st.y*.7)-vec2(.5,.4))*9.,1.4,.5); mask_flower*=step(.3,left_pedal); mask_flower*=step(.3,left_pedal_lower); mask_flower*=step(.3,right_pedal); mask_flower*=step(.3,right_pedal_lower); mask_flower*=step(.3,top_pedal); // Generate white edges of flower pedals if(left_pedal<.3&&left_pedal>.23)mask_flower_edge+=(left_pedal-.23)*50.*distance(vec2(.5),st.xy); if(right_pedal<.3&&right_pedal>.23)mask_flower_edge+=(right_pedal-.23)*50.*distance(vec2(.5),st.xy); if(left_pedal>.3&&right_pedal>.3){ if(top_pedal<.3&&top_pedal>.23)mask_flower_edge+=(top_pedal-.23)*50.*distance(vec2(.5),st.xy); if(left_pedal_lower<.3&&left_pedal_lower>.23)mask_flower_edge+=(left_pedal_lower-.23)*30.*distance(vec2(.5),st.xy); if(right_pedal_lower<.3&&right_pedal_lower>.23)mask_flower_edge+=(right_pedal_lower-.23)*30.*distance(vec2(.5),st.xy); } // Generate under part of flower float left_rounded_triangle=sdEquilateralTriangle((st.xy/.05-vec2(8,7))*R1); float right_rounded_triangle=sdEquilateralTriangle((st.xy/.05-vec2(12,7))*R2); float lower_rounded_thing=sdPie((st.xy/.4-vec2(1.25,.4)),vec2(1.,.8),.2); float lower_lower_not_rounded_thing=sdVesica((st.xy-vec2(.5,.1))/.7,.1,.2); mask_flower_dark*=step(.4,left_rounded_triangle); mask_flower_dark*=step(.4,right_rounded_triangle); mask_flower_dark*=step(.2,lower_rounded_thing); mask_flower_dark*=step(.2,lower_lower_not_rounded_thing); // Generate center pieces of flower float center_yellow_thing=sdHeart(st.xy/.05-vec2(10,6)); float center_pink_thing=sdEllipse((st.xy-vec2(.5))/.2,vec2(.5,.1)); float center_white_thing=sdUnevenCapsule((st.xy-vec2(.5,.41))/.1,.2,.1,.5); mask_flower_yellow=step(.2,center_yellow_thing); mask_flower_white=step(.2,center_white_thing); if(center_pink_thing<.2) if(center_pink_thing<.0)mask_flower_pink=0.; else mask_flower_pink=(center_pink_thing)*5.; if(center_white_thing<.2)mask_flower_white=1.-distance(vec2(.5,.48),st.xy)*20.; // Draw the elegant flower if(mask_flower_yellow==0.)colour_out=flower_pattern_yellow(); else if(mask_flower_dark==0.)colour_out=mix(flower_pattern_dark(),flower_pattern_dark_center(),.5-distance(vec2(.5,.3),st.xy)*2.); else if(mask_flower==0.){ colour_out=mix(mix(flower_pattern_light(),vec4(1.),mask_flower_edge),flower_pattern_light_center(),distance(vec2(0.),vec2(.5,.4)-distance(vec2(.5),st.xy))/.8); colour_out=mix(flower_pattern_white(),colour_out,mask_flower_white); colour_out=mix(flower_pattern_light_center_pink(),colour_out,mask_flower_pink); } else colour_out=background_pattern(); }
355
1
// credit: @yuuki
2
// orchid: Phalaenopsis Hybrid
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
// Shady (get it? lol) declarations that I probably ripped off of somewhere (wait a minute...)
8
vec4 mod289(vec4 x){return x-floor(x*(1./289.))*289.;}
9
vec3 mod289(vec3 x){return x-floor(x*(1./289.))*289.;}
10
vec2 mod289(vec2 x){return x-floor(x*(1./289.))*289.;}
11
12
vec4 permute(vec4 x){return mod289((34.*x+10.)*x);}
13
vec3 permute(vec3 x){return mod289((34.*x+10.)*x);}
14
15
vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-.85373472095314*r;}
16
17
float snoise(vec3 v)
18
{
19
const vec2 C=vec2(1./6.,1./3.);
20
const vec4 D=vec4(0.,.5,1.,2.);
21
22
// First corner
23
vec3 i=floor(v+dot(v,C.yyy));
24
vec3 x0=v-i+dot(i,C.xxx);
25
26
// Other corners
27
vec3 g=step(x0.yzx,x0.xyz);
28
vec3 l=1.-g;
29
vec3 i1=min(g.xyz,l.zxy);
30
vec3 i2=max(g.xyz,l.zxy);
31
32
// x0 = x0 - 0.0 + 0.0 * C.xxx;
33
// x1 = x0 - i1 + 1.0 * C.xxx;
34
// x2 = x0 - i2 + 2.0 * C.xxx;
35
// x3 = x0 - 1.0 + 3.0 * C.xxx;
36
vec3 x1=x0-i1+C.xxx;
37
vec3 x2=x0-i2+C.yyy;// 2.0*C.x = 1/3 = C.y
38
vec3 x3=x0-D.yyy;// -1.0+3.0*C.x = -0.5 = -D.y
39
40
// Permutations
41
i=mod289(i);
42
vec4 p=permute(permute(permute(
43
i.z+vec4(0.,i1.z,i2.z,1.))
44
+i.y+vec4(0.,i1.y,i2.y,1.))
45
+i.x+vec4(0.,i1.x,i2.x,1.));
46
47
// Gradients: 7x7 points over a square, mapped onto an octahedron.
48
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
49
float n_=.142857142857;// 1.0/7.0
50
vec3 ns=n_*D.wyz-D.xzx;
51
52
vec4 j=p-49.*floor(p*ns.z*ns.z);// mod(p,7*7)
53
54
vec4 x_=floor(j*ns.z);
55
vec4 y_=floor(j-7.*x_);// mod(j,N)
56
57
vec4 x=x_*ns.x+ns.yyyy;
58
vec4 y=y_*ns.x+ns.yyyy;
59
vec4 h=1.-abs(x)-abs(y);
60
61
vec4 b0=vec4(x.xy,y.xy);
62
vec4 b1=vec4(x.zw,y.zw);
63
64
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
65
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
66
vec4 s0=floor(b0)*2.+1.;
67
vec4 s1=floor(b1)*2.+1.;
68
vec4 sh=-step(h,vec4(0.));
69
70
vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;
71
vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;
72
73
vec3 p0=vec3(a0.xy,h.x);
74
vec3 p1=vec3(a0.zw,h.y);
75
vec3 p2=vec3(a1.xy,h.z);
76
vec3 p3=vec3(a1.zw,h.w);
77
78
//Normalise gradients
79
vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));
80
p0*=norm.x;
81
p1*=norm.y;
82
p2*=norm.z;
83
p3*=norm.w;
84
85
// Mix final noise value
86
vec4 m=max(.5-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.);
87
m=m*m;
88
return 105.*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),
89
dot(p2,x2),dot(p3,x3)));
90
}
91
float snoise(vec2 v){
92
const vec4 C=vec4(.211324865405187,// (3.0-sqrt(3.0))/6.0
93
.366025403784439,// 0.5*(sqrt(3.0)-1.0)
94
-.577350269189626,// -1.0 + 2.0 * C.x
95
.024390243902439);// 1.0 / 41.0
96
// First corner
97
vec2 i=floor(v+dot(v,C.yy));
98
vec2 x0=v-i+dot(i,C.xx);
99
100
// Other corners
101
vec2 i1;
102
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
103
//i1.y = 1.0 - i1.x;
104
i1=(x0.x>x0.y)?vec2(1.,0.):vec2(0.,1.);
105
// x0 = x0 - 0.0 + 0.0 * C.xx ;
106
// x1 = x0 - i1 + 1.0 * C.xx ;
107
// x2 = x0 - 1.0 + 2.0 * C.xx ;
108
vec4 x12=x0.xyxy+C.xxzz;
109
x12.xy-=i1;
110
111
// Permutations
112
i=mod289(i);// Avoid truncation effects in permutation
113
vec3 p=permute(permute(i.y+vec3(0.,i1.y,1.))
114
+i.x+vec3(0.,i1.x,1.));
115
116
vec3 m=max(.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.);
117
m=m*m;
118
m=m*m;
119
120
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
121
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
122
123
vec3 x=2.*fract(p*C.www)-1.;
124
vec3 h=abs(x)-.5;
125
vec3 ox=floor(x+.5);
126
vec3 a0=x-ox;
127
128
// Normalise gradients implicitly by scaling m
129
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
130
m*=1.79284291400159-.85373472095314*(a0*a0+h*h);
131
132
// Compute final noise value at P
133
vec3 g;
134
g.x=a0.x*x0.x+h.x*x0.y;
135
g.yz=a0.yz*x12.xz+h.yz*x12.yw;
136
return 130.*dot(m,g);
137
}
138
float fbm(vec2 p){
139
float f=0.,scale;
140
for(int i=0;i<4;i++){
141
scale=pow(pow(2.,4./3.),float(i));
142
f+=snoise(p*scale)/scale;
143
}
144
return f;
145
}
146
float fbm(vec3 p){
147
float f=0.,scale;
148
for(int i=0;i<4;i++){
149
scale=pow(pow(2.,4./3.),float(i));
150
f+=snoise(p*scale)/scale;
151
}
152
return f;
153
}
154
float turbulence(vec3 p){
155
float f=0.,scale;
156
for(int i=0;i<4;i++){
157
scale=pow(pow(2.,4./3.),float(i));
158
f+=abs(snoise(p*scale))/scale;}
159
return f;
160
}
161
// End of the god-knows-what declarations
162
163
// Functions for calculation
164
float noise(vec3 v){
165
v.xy+=vec2(fbm(v),fbm(vec3(v.xy,v.z+1000.)));
166
return fbm(v)*.35+.45;
167
}
168
// SDs ripped from https://iquilezles.org/ (thanks Inigo Quilez!)
169
float dot2(in vec2 v){return dot(v,v);}
170
float sdEgg(in vec2 p,in float ra,in float rb)
171
{
172
const float k=sqrt(3.);
173
p.x=abs(p.x);
174
float r=ra-rb;
175
return((p.y<0.)?length(vec2(p.x,p.y))-r:
176
(k*(p.x+r)<p.y)?length(vec2(p.x,p.y-k*r)):
177
length(vec2(p.x+r,p.y))-2.*r)-rb;
178
}
179
float sdUnevenCapsule(vec2 p,float r1,float r2,float h)
180
{
181
p.x=abs(p.x);
182
float b=(r1-r2)/h;
183
float a=sqrt(1.-b*b);
184
float k=dot(p,vec2(-b,a));
185
if(k<0.)return length(p)-r1;
186
if(k>a*h)return length(p-vec2(0.,h))-r2;
187
return dot(p,vec2(a,b))-r1;
188
}
189
float sdEquilateralTriangle(in vec2 p)
190
{
191
const float k=sqrt(3.);
192
p.x=abs(p.x)-1.;
193
p.y=p.y+1./k;
194
if(p.x+k*p.y>0.)p=vec2(p.x-k*p.y,-k*p.x-p.y)/2.;
195
p.x-=clamp(p.x,-2.,0.);
196
return-length(p)*sign(p.y);
197
}
198
float sdPie(in vec2 p,in vec2 c,in float r)
199
{
200
p.x=abs(p.x);
201
float l=length(p)-r;
202
float m=length(p-c*clamp(dot(p,c),0.,r));// c=sin/cos of aperture
203
return max(l,m*sign(c.y*p.x-c.x*p.y));
204
}
205
float sdHeart(in vec2 p)
206
{
207
p.x=abs(p.x);
208
209
if(p.y+p.x>1.)
210
return sqrt(dot2(p-vec2(.25,.75)))-sqrt(2.)/4.;
211
return sqrt(min(dot2(p-vec2(0.,1.)),
212
dot2(p-.5*max(p.x+p.y,0.))))*sign(p.x-p.y);
213
}
214
float sdVesica(vec2 p,float r,float d)
215
{
216
p=abs(p);
217
float b=sqrt(r*r-d*d);
218
return((p.y-b)*d>p.x*b)?length(p-vec2(0.,b))
219
:length(p-vec2(-d,0.))-r;
220
}
221
float sdEllipse(in vec2 p,in vec2 ab)
222
{
223
p=abs(p);if(p.x>p.y){p=p.yx;ab=ab.yx;}
224
float l=ab.y*ab.y-ab.x*ab.x;
225
float m=ab.x*p.x/l;float m2=m*m;
226
float n=ab.y*p.y/l;float n2=n*n;
227
float c=(m2+n2-1.)/3.;float c3=c*c*c;
228
float q=c3+m2*n2*2.;
229
float d=c3+m2*n2;
230
float g=m+m*n2;
231
float co;
232
if(d<0.)
233
{
234
float h=acos(q/c3)/3.;
235
float s=cos(h);
236
float t=sin(h)*sqrt(3.);
237
float rx=sqrt(-c*(s+t+2.)+m2);
238
float ry=sqrt(-c*(s-t+2.)+m2);
239
co=(ry+sign(l)*rx+abs(g)/(rx*ry)-m)/2.;
240
}
241
else
242
{
243
float h=2.*m*n*sqrt(d);
244
float s=sign(q+h)*pow(abs(q+h),1./3.);
245
float u=sign(q-h)*pow(abs(q-h),1./3.);
246
float rx=-s-u-c*4.+2.*m2;
247
float ry=(s-u)*sqrt(3.);
248
float rm=sqrt(rx*rx+ry*ry);
249
co=(ry/sqrt(rm-rx)+2.*g/rm-m)/2.;
250
}
251
vec2 r=ab*vec2(co,sqrt(1.-co*co));
252
return length(r-p)*sign(p.y-r.y);
253
}
254
// Flower patterns adapted from http://verygoodshaderexamples.ga (← very useful website!)
255
vec4 flower_pattern_light(){
256
vec3 uv=vec3(15.*gl_FragCoord.xy/u_resolution.x-.5,.1*u_time);
257
float noise=1.*turbulence(uv)+.2;
258
return mix(vec4(1.,.1725,1.,1.),vec4(1.),noise);
259
}
260
vec4 flower_pattern_light_center(){
261
vec3 uv=vec3(15.*gl_FragCoord.xy/u_resolution.x-.5,.1*u_time);
262
float noise=1.*turbulence(uv)+.2;
263
return mix(vec4(.9725,.8706,.8706,1.),vec4(1.),noise);
264
}
265
vec4 flower_pattern_light_center_pink(){
266
vec3 uv=vec3(20.*gl_FragCoord.xy/u_resolution.x-.5,.05*u_time);
267
float noise=1.*turbulence(uv)+.2;
268
return mix(vec4(.8157,.5216,.9059,1.),vec4(.9686,.8078,1.,1.),noise);
269
}
270
vec4 flower_pattern_dark(){
271
vec3 uv=vec3(8.*gl_FragCoord.xy/u_resolution.x-.5,.05*u_time);
272
float noise=.8*turbulence(uv)+.2;
273
return mix(vec4(.5255,0.,.5255,1.),vec4(.7608,.4824,.4824,1.),noise);
274
}
275
vec4 flower_pattern_dark_center(){
276
vec3 uv=vec3(8.*gl_FragCoord.xy/u_resolution.x-.5,.05*u_time);
277
float noise=.8*turbulence(uv)+.2;
278
return mix(vec4(.2784,.0745,.2784,1.),vec4(.4078,.2392,.2392,1.),noise);
279
}
280
vec4 flower_pattern_yellow(){
281
vec3 uv=vec3(20.*gl_FragCoord.xy/u_resolution.x-.5,.2*u_time);
282
float noise=1.*turbulence(uv)+.2;
283
return mix(vec4(.6353,.6588,.2784,1.),vec4(.5216,.1373,.1373,1.),noise);
284
}
285
vec4 flower_pattern_white(){
286
vec3 uv=vec3(20.*gl_FragCoord.xy/u_resolution.x-.5,.5*u_time);
287
float noise=1.*turbulence(uv)+.2;
288
return mix(vec4(.9843,.9451,1.,1.),vec4(1.,.9608,.7765,1.),noise);
289
}
290
// Background pattern (it's not very easy to give the colors a natural feel for some reason)
291
vec4 background_pattern(){
292
vec3 uv=vec3(.5*gl_FragCoord.xy/u_resolution.y-.5,.01*u_time);
293
float noise=pow(noise(uv),4.)*5.;
294
return mix(vec4(.0941,.0353,.0745,.8),vec4(.3255,.0902,.3255,1.),noise);
295
}
296
void main(){
297
vec2 st=gl_FragCoord.xy/u_resolution.xy;
298
float mask_flower=1.;
299
float mask_flower_edge=0.;
300
float mask_flower_dark=1.;
301
float mask_flower_yellow=0.;
302
float mask_flower_pink=1.;
303
float mask_flower_white=1.;
304
float c1=cos(.2);float s1=sin(.2);
305
mat2 R1=mat2(c1,s1,-s1,c1);
306
float c2=cos(-.2);float s2=sin(-.2);
307
mat2 R2=mat2(c2,s2,-s2,c2);
308
// Generate flower pedals
309
float left_pedal=sdEgg((st.yx-vec2(.5,.3))*R1*2.,.2,.5);
310
float left_pedal_lower=sdEgg((st.yx-vec2(.4,.3))*R1*2.5,.2,.5);
311
float right_pedal=sdEgg((-st.yx+vec2(.5,.7))*R2*2.,.2,.5);
312
float right_pedal_lower=sdEgg((-st.yx+vec2(.4,.7))*R2*2.5,.2,.5);
313
float top_pedal=sdEgg((vec2(st.x,st.y*.7)-vec2(.5,.4))*9.,1.4,.5);
314
mask_flower*=step(.3,left_pedal);
315
mask_flower*=step(.3,left_pedal_lower);
316
mask_flower*=step(.3,right_pedal);
317
mask_flower*=step(.3,right_pedal_lower);
318
mask_flower*=step(.3,top_pedal);
319
// Generate white edges of flower pedals
320
if(left_pedal<.3&&left_pedal>.23)mask_flower_edge+=(left_pedal-.23)*50.*distance(vec2(.5),st.xy);
321
if(right_pedal<.3&&right_pedal>.23)mask_flower_edge+=(right_pedal-.23)*50.*distance(vec2(.5),st.xy);
322
if(left_pedal>.3&&right_pedal>.3){
323
if(top_pedal<.3&&top_pedal>.23)mask_flower_edge+=(top_pedal-.23)*50.*distance(vec2(.5),st.xy);
324
if(left_pedal_lower<.3&&left_pedal_lower>.23)mask_flower_edge+=(left_pedal_lower-.23)*30.*distance(vec2(.5),st.xy);
325
if(right_pedal_lower<.3&&right_pedal_lower>.23)mask_flower_edge+=(right_pedal_lower-.23)*30.*distance(vec2(.5),st.xy);
326
}
327
// Generate under part of flower
328
float left_rounded_triangle=sdEquilateralTriangle((st.xy/.05-vec2(8,7))*R1);
329
float right_rounded_triangle=sdEquilateralTriangle((st.xy/.05-vec2(12,7))*R2);
330
float lower_rounded_thing=sdPie((st.xy/.4-vec2(1.25,.4)),vec2(1.,.8),.2);
331
float lower_lower_not_rounded_thing=sdVesica((st.xy-vec2(.5,.1))/.7,.1,.2);
332
mask_flower_dark*=step(.4,left_rounded_triangle);
333
mask_flower_dark*=step(.4,right_rounded_triangle);
334
mask_flower_dark*=step(.2,lower_rounded_thing);
335
mask_flower_dark*=step(.2,lower_lower_not_rounded_thing);
336
// Generate center pieces of flower
337
float center_yellow_thing=sdHeart(st.xy/.05-vec2(10,6));
338
float center_pink_thing=sdEllipse((st.xy-vec2(.5))/.2,vec2(.5,.1));
339
float center_white_thing=sdUnevenCapsule((st.xy-vec2(.5,.41))/.1,.2,.1,.5);
340
mask_flower_yellow=step(.2,center_yellow_thing);
341
mask_flower_white=step(.2,center_white_thing);
342
if(center_pink_thing<.2)
343
if(center_pink_thing<.0)mask_flower_pink=0.;
344
else mask_flower_pink=(center_pink_thing)*5.;
345
if(center_white_thing<.2)mask_flower_white=1.-distance(vec2(.5,.48),st.xy)*20.;
346
// Draw the elegant flower
347
if(mask_flower_yellow==0.)colour_out=flower_pattern_yellow();
348
else if(mask_flower_dark==0.)colour_out=mix(flower_pattern_dark(),flower_pattern_dark_center(),.5-distance(vec2(.5,.3),st.xy)*2.);
349
else if(mask_flower==0.){
350
colour_out=mix(mix(flower_pattern_light(),vec4(1.),mask_flower_edge),flower_pattern_light_center(),distance(vec2(0.),vec2(.5,.4)-distance(vec2(.5),st.xy))/.8);
351
colour_out=mix(flower_pattern_white(),colour_out,mask_flower_white);
352
colour_out=mix(flower_pattern_light_center_pink(),colour_out,mask_flower_pink);
353
}
354
else colour_out=background_pattern();
355
}
Phalaenopsis Hybrid by @yuuki
// credit: CGbaby // orchid: Phalaenopsis aphrodite uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float PI = 3.14159265358979324; vec2 rotate(vec2 p, float theta) { return mat2(cos(theta), -sin(theta), sin(theta), cos(theta)) * p; } float dot2(vec2 p) { return dot(p, p); } float add(float d1, float d2) { return min(d1, d2); } // d1 + d2 float diff(float d1, float d2) { return max(d1, -d2); } // d1 - d2 float random(vec2 co) { const highp float seed = 13.9898; highp float a = seed; highp float b = 78.233, c = 43758.5453; highp float dt= dot(co.xy, vec2(a,b)); highp float sn= mod(dt,PI); return fract(sin(sn) * c); } vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float fbm( vec2 p ) { float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += snoise( p * scale ) / scale; } return f; } float sdBezier( in vec2 pos, in vec2 A, in vec2 B, in vec2 C, in float r ) { 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 p = ky - kx*kx; float p3 = p*p*p; float q = kx*(2.0*kx*kx-3.0*ky) + kz; float h = q*q + 4.0*p3; if( h >= 0.0) { h = sqrt(h); vec2 x = (vec2(h,-h)-q)/2.0; vec2 uv = sign(x)*pow(abs(x), vec2(1.0/3.0)); float t = clamp( uv.x+uv.y-kx, 0.0, 1.0 ); res = dot2(d + (c + b*t)*t); } else { float z = sqrt(-p); float v = acos( q/(p*z*2.0) ) / 3.0; float m = cos(v); float n = sin(v)*1.732050808; vec3 t = clamp(vec3(m+m,-n-m,n-m)*z-kx,0.0,1.0); res = min( dot2(d+(c+b*t.x)*t.x), dot2(d+(c+b*t.y)*t.y) ); // the third root cannot be the closest // res = min(res,dot2(d+(c+b*t.z)*t.z)); } return sqrt( res ) - r; } float sdBox( in vec2 p, in vec2 b ) { vec2 d = abs(p)-b; return length(max(d,0.0)) + min(max(d.x,d.y),0.0); } float sdPieY( in vec2 p, float t, in float r ) { vec2 c = vec2(sin(t), cos(t)); p.y = abs(p.y); float l = length(p) - r; float m = length(p-c*clamp(dot(p,c),0.0,r)); // c=sin/cos of aperture return max(l,m*sign(c.y*p.x-c.x*p.y)); } float sdCircle( vec2 p, float r ) { return length(p) - r; } float sdParabola( in vec2 pos, in float k, bool inv ) { pos.x = abs(pos.x); float ik = 1.0/k; float p = ik*(pos.y - 0.5*ik)/3.0; float q = 0.25*ik*ik*pos.x; float h = q*q - p*p*p; float r = sqrt(abs(h)); float x = (h>0.0) ? pow(q+r,1.0/3.0) - pow(abs(q-r),1.0/3.0)*sign(r-q) : 2.0*cos(atan(r,q)/3.0)*sqrt(p); float sgn = inv ? -1.0 : 1.0; return sgn * length(pos-vec2(x,k*x*x)) * sign(pos.x-x); } float sdHorseshoe( in vec2 p, in float t, in float r, in vec2 w ) { vec2 c = vec2(sin(t), cos(t)); p.x = abs(p.x); float l = length(p); p = mat2(-c.x, c.y, c.y, c.x)*p; p = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x), (p.x>0.0)?p.y:l ); p = vec2(p.x,abs(p.y-r))-w; return length(max(p,0.0)) + min(0.0,max(p.x,p.y)); } const int N = 4; float sdRoundedPolygon( in vec2[N] v, in vec2 p, in float r ) { float d = dot(p-v[0],p-v[0]); float s = 1.0; for( int i=0, j=N-1; i<N; j=i, i++ ) { vec2 e = v[j] - v[i]; vec2 w = p - v[i]; vec2 b = w - e*clamp( dot(w,e)/dot(e,e), 0.0, 1.0 ); d = min( d, dot(b,b) ); bvec3 c = bvec3(p.y>=v[i].y,p.y<v[j].y,e.x*w.y>e.y*w.x); if( all(c) || all(not(c)) ) s*=-1.0; } return s*sqrt(d) - r; } float petal(vec2 p) { p.x = abs(p.x - sign(p.x) * 0.005); float d1; d1 = sdPieY(p, 0.97 * PI, 0.5); d1 = diff(d1, sdCircle(p - vec2(-0.2, 0.25), 0.3)); d1 = diff(d1, sdCircle(p - vec2(-0.2, -0.25), 0.3)); float d2; d2 = sdParabola(rotate(p, 0.21 * PI) - vec2(0.364, 0.325), -15.9, true); d2 = diff(d2, sdBox(p - vec2(0, -1.15), vec2(1, 1.5))); float d3; d3 = sdParabola(rotate(p, 0.79 * PI) - vec2(-0.364, 0.325), -15.9, true); d3 = diff(d3, sdBox(p - vec2(0, 1.15), vec2(1, 1.5))); float d; d = diff(d1, d2); d = diff(d, d3); return d; } float petalLine(vec2 p) { p.x = abs(p.x - sign(p.x) * 0.005); float d1; d1 = sdBezier(p, vec2(0.2, 0), vec2(0.3, 0.0001), vec2(0.35, 0), 0.0025); float d2; d2 = sdBezier(p, vec2(0.16, 0.04), vec2(0.16, 0.0401), vec2(0.32, 0.05), 0.002); float d3; d3 = sdBezier(p, vec2(0.16, 0.07), vec2(0.25, 0.10), vec2(0.35, 0.1), 0.002); float d4; d4 = sdBezier(p, vec2(0.18, -0.04), vec2(0.25, -0.07), vec2(0.32, -0.05), 0.002); float d; d = add(d1, d2); d = add(d, d3); d = add(d, d4); return d; } float lip(vec2 p) { float d1; d1 = sdHorseshoe(p - vec2(0, -0.16), 0.1 * PI, 0.07, vec2(0.06, 0.025)); float d2; d2 = sdBox(p - vec2(0, -0.3), vec2(0.07, 0.07)); d2 = diff(d2, sdCircle(p - vec2(0.15, -0.33), 0.12)); d2 = diff(d2, sdCircle(p - vec2(-0.15, -0.33), 0.12)); float d; d = add(d1, d2); return d; } float lipLine(vec2 p) { p.x = abs(p.x); float d1; d1 = sdBezier(p, vec2(0.04, -0.20), vec2(0.055, -0.20), vec2(0.07, -0.18), 0.004); float d2; d2 = sdBezier(p, vec2(0.04, -0.22), vec2(0.055, -0.23), vec2(0.08, -0.21), 0.004); float d; d = add(d1, d2); return d; } float lipProtrusion(vec2 p) { p.x = abs(p.x); float d1; vec2[] v = vec2[]( vec2(0, 0), vec2(0.02, 0.01), vec2(0.01, -0.06), vec2(0, -0.05) ); d1 = sdRoundedPolygon(v, p - vec2(0.01, -0.18), 0.01); float d; d = d1; return d; } float dorsalSepal(vec2 p) { float d1; d1 = sdParabola(p - vec2(0, 0.7), -5.0, false); d1 = diff(d1, sdBox(p - vec2(0, -1.5), vec2(1, 1.5))); float d; //d = d1; d = diff(d1, petal(p)); return d; } float dorsalSepalLine(vec2 p) { float d1; d1 = sdBezier(p, vec2(-0.03, 0.06), vec2(-0.07, 0.18), vec2(-0.08, 0.3), 0.0025); float d2; d2 = sdBezier(p, vec2(-0.01, 0.06), vec2(-0.04, 0.15), vec2(-0.03, 0.3), 0.0025); float d3; d3 = sdBezier(p, vec2(0.01, 0.07), vec2(0.01, 0.15), vec2(0.01, 0.32), 0.0025); float d; d = add(d1, d2); d = add(d, d3); return d; } float lowerSepal(vec2 p) { float d1; d1 = sdParabola(rotate(p, 0.95 * PI) - vec2(0.21, 0.6), -6.9, false); d1 = diff(d1, sdBox(p - vec2(0, 1.48), vec2(1, 1.5))); float d2; d2 = sdParabola(rotate(p, 1.05 * PI) - vec2(-0.21, 0.6), -6.9, false); d2 = diff(d2, sdBox(p - vec2(0, 1.48), vec2(1, 1.5))); float d; d = add(d1, d2); d = diff(d, petal(p)); return d; } void main(){ vec3 color; vec2 coord = (gl_FragCoord.xy / u_resolution.xy * 2.0 - 1.0) / 1.3; float fbmVal = fbm(coord); float dLowerSepal = lowerSepal(coord); float dDorsalSepal = dorsalSepal(coord); float dDorsalSepalLine = dorsalSepalLine(coord); float dPetal = petal(coord); float dPetalLine = petalLine(coord); float dLip = lip(coord); float dLipLine = lipLine(coord); float dLipProtrusion = lipProtrusion(coord); if (dLowerSepal <= .0) { color = vec3(0.88, 0.92, 0.96); float coef = 0.08 * (1.0 - smoothstep(0.0, 0.04, dPetal)); color *= coef * fbmVal + (1.0 - coef); } if (dDorsalSepal <= .0) { color = vec3(0.88, 0.92, 0.96); float coef = 0.08 * (1.0 - smoothstep(0.0, 0.04, dPetal)); color *= coef * fbmVal + (1.0 - coef); } if (dDorsalSepalLine <= .0) { color = vec3(0.87, 0.87, 0.87); } if (dPetal <= .0) { color = vec3(0.93, 0.97, 0.98); if (abs(coord.x) >= 0.2) { color *= 1.0 - 0.03 * smoothstep(-0.10, 0.0, dPetal) * fbm(coord * 30.0); } } if (dPetalLine <= .0) { color = vec3(0.87, 0.87, 0.87); } if (dLip <= .0) { color = mix( mix(vec3(0.80, 0.67, 0), vec3(0.92, 0.96, 0.97), smoothstep(0.05, 0.08, abs(coord.x))), vec3(0.92, 0.96, 0.97), smoothstep(0.00, 0.07, abs(coord.y + 0.21)) ); } if (dLipLine <= .0) { color = vec3(0.55, 0.15, 0.14); } if (dLipProtrusion <= .0) { if (random(coord) >= 0.7) { color = vec3(0); } else { color = vec3(0.80, 0.67, 0); } } colour_out = vec4(color, 1); }
388
1
// credit: CGbaby
2
// orchid: Phalaenopsis aphrodite
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
const float PI = 3.14159265358979324;
8
9
vec2 rotate(vec2 p, float theta) { return mat2(cos(theta), -sin(theta), sin(theta), cos(theta)) * p; }
10
float dot2(vec2 p) { return dot(p, p); }
11
float add(float d1, float d2) { return min(d1, d2); } // d1 + d2
12
float diff(float d1, float d2) { return max(d1, -d2); } // d1 - d2
13
14
float random(vec2 co) {
15
const highp float seed = 13.9898;
16
highp float a = seed;
17
highp float b = 78.233, c = 43758.5453;
18
highp float dt= dot(co.xy, vec2(a,b));
19
highp float sn= mod(dt,PI);
20
return fract(sin(sn) * c);
21
}
22
23
vec3 mod289(vec3 x) {
24
return x - floor(x * (1.0 / 289.0)) * 289.0;
25
}
26
27
vec2 mod289(vec2 x) {
28
return x - floor(x * (1.0 / 289.0)) * 289.0;
29
}
30
31
vec3 permute(vec3 x) {
32
return mod289(((x*34.0)+10.0)*x);
33
}
34
35
float snoise(vec2 v)
36
{
37
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
38
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
39
-0.577350269189626, // -1.0 + 2.0 * C.x
40
0.024390243902439); // 1.0 / 41.0
41
// First corner
42
vec2 i = floor(v + dot(v, C.yy) );
43
vec2 x0 = v - i + dot(i, C.xx);
44
45
// Other corners
46
vec2 i1;
47
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
48
//i1.y = 1.0 - i1.x;
49
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
50
// x0 = x0 - 0.0 + 0.0 * C.xx ;
51
// x1 = x0 - i1 + 1.0 * C.xx ;
52
// x2 = x0 - 1.0 + 2.0 * C.xx ;
53
vec4 x12 = x0.xyxy + C.xxzz;
54
x12.xy -= i1;
55
56
// Permutations
57
i = mod289(i); // Avoid truncation effects in permutation
58
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
59
+ i.x + vec3(0.0, i1.x, 1.0 ));
60
61
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
62
m = m*m ;
63
m = m*m ;
64
65
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
66
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
67
68
vec3 x = 2.0 * fract(p * C.www) - 1.0;
69
vec3 h = abs(x) - 0.5;
70
vec3 ox = floor(x + 0.5);
71
vec3 a0 = x - ox;
72
73
// Normalise gradients implicitly by scaling m
74
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
75
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
76
77
// Compute final noise value at P
78
vec3 g;
79
g.x = a0.x * x0.x + h.x * x0.y;
80
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
81
return 130.0 * dot(m, g);
82
}
83
84
float fbm( vec2 p ) {
85
float f = 0.0, scale;
86
for (int i=0; i<4; i++) {
87
scale = pow( pow(2.0, 4.0/3.0), float(i) );
88
f += snoise( p * scale ) / scale;
89
}
90
return f; }
91
92
float sdBezier( in vec2 pos, in vec2 A, in vec2 B, in vec2 C, in float r )
93
{
94
vec2 a = B - A;
95
vec2 b = A - 2.0*B + C;
96
vec2 c = a * 2.0;
97
vec2 d = A - pos;
98
float kk = 1.0/dot(b,b);
99
float kx = kk * dot(a,b);
100
float ky = kk * (2.0*dot(a,a)+dot(d,b)) / 3.0;
101
float kz = kk * dot(d,a);
102
float res = 0.0;
103
float p = ky - kx*kx;
104
float p3 = p*p*p;
105
float q = kx*(2.0*kx*kx-3.0*ky) + kz;
106
float h = q*q + 4.0*p3;
107
if( h >= 0.0)
108
{
109
h = sqrt(h);
110
vec2 x = (vec2(h,-h)-q)/2.0;
111
vec2 uv = sign(x)*pow(abs(x), vec2(1.0/3.0));
112
float t = clamp( uv.x+uv.y-kx, 0.0, 1.0 );
113
res = dot2(d + (c + b*t)*t);
114
}
115
else
116
{
117
float z = sqrt(-p);
118
float v = acos( q/(p*z*2.0) ) / 3.0;
119
float m = cos(v);
120
float n = sin(v)*1.732050808;
121
vec3 t = clamp(vec3(m+m,-n-m,n-m)*z-kx,0.0,1.0);
122
res = min( dot2(d+(c+b*t.x)*t.x),
123
dot2(d+(c+b*t.y)*t.y) );
124
// the third root cannot be the closest
125
// res = min(res,dot2(d+(c+b*t.z)*t.z));
126
}
127
return sqrt( res ) - r;
128
}
129
130
float sdBox( in vec2 p, in vec2 b )
131
{
132
vec2 d = abs(p)-b;
133
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
134
}
135
136
float sdPieY( in vec2 p, float t, in float r )
137
{
138
vec2 c = vec2(sin(t), cos(t));
139
p.y = abs(p.y);
140
float l = length(p) - r;
141
float m = length(p-c*clamp(dot(p,c),0.0,r)); // c=sin/cos of aperture
142
return max(l,m*sign(c.y*p.x-c.x*p.y));
143
}
144
145
float sdCircle( vec2 p, float r )
146
{
147
return length(p) - r;
148
}
149
150
float sdParabola( in vec2 pos, in float k, bool inv )
151
{
152
pos.x = abs(pos.x);
153
float ik = 1.0/k;
154
float p = ik*(pos.y - 0.5*ik)/3.0;
155
float q = 0.25*ik*ik*pos.x;
156
float h = q*q - p*p*p;
157
float r = sqrt(abs(h));
158
float x = (h>0.0) ?
159
pow(q+r,1.0/3.0) - pow(abs(q-r),1.0/3.0)*sign(r-q) :
160
2.0*cos(atan(r,q)/3.0)*sqrt(p);
161
float sgn = inv ? -1.0 : 1.0;
162
return sgn * length(pos-vec2(x,k*x*x)) * sign(pos.x-x);
163
}
164
165
float sdHorseshoe( in vec2 p, in float t, in float r, in vec2 w )
166
{
167
vec2 c = vec2(sin(t), cos(t));
168
p.x = abs(p.x);
169
float l = length(p);
170
p = mat2(-c.x, c.y, c.y, c.x)*p;
171
p = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
172
(p.x>0.0)?p.y:l );
173
p = vec2(p.x,abs(p.y-r))-w;
174
return length(max(p,0.0)) + min(0.0,max(p.x,p.y));
175
}
176
177
const int N = 4;
178
float sdRoundedPolygon( in vec2[N] v, in vec2 p, in float r )
179
{
180
float d = dot(p-v[0],p-v[0]);
181
float s = 1.0;
182
for( int i=0, j=N-1; i<N; j=i, i++ )
183
{
184
vec2 e = v[j] - v[i];
185
vec2 w = p - v[i];
186
vec2 b = w - e*clamp( dot(w,e)/dot(e,e), 0.0, 1.0 );
187
d = min( d, dot(b,b) );
188
bvec3 c = bvec3(p.y>=v[i].y,p.y<v[j].y,e.x*w.y>e.y*w.x);
189
if( all(c) || all(not(c)) ) s*=-1.0;
190
}
191
return s*sqrt(d) - r;
192
}
193
194
float petal(vec2 p) {
195
p.x = abs(p.x - sign(p.x) * 0.005);
196
197
float d1;
198
d1 = sdPieY(p, 0.97 * PI, 0.5);
199
d1 = diff(d1, sdCircle(p - vec2(-0.2, 0.25), 0.3));
200
d1 = diff(d1, sdCircle(p - vec2(-0.2, -0.25), 0.3));
201
202
float d2;
203
d2 = sdParabola(rotate(p, 0.21 * PI) - vec2(0.364, 0.325), -15.9, true);
204
d2 = diff(d2, sdBox(p - vec2(0, -1.15), vec2(1, 1.5)));
205
206
float d3;
207
d3 = sdParabola(rotate(p, 0.79 * PI) - vec2(-0.364, 0.325), -15.9, true);
208
d3 = diff(d3, sdBox(p - vec2(0, 1.15), vec2(1, 1.5)));
209
210
float d;
211
d = diff(d1, d2);
212
d = diff(d, d3);
213
return d;
214
}
215
216
float petalLine(vec2 p) {
217
p.x = abs(p.x - sign(p.x) * 0.005);
218
219
float d1;
220
d1 = sdBezier(p, vec2(0.2, 0), vec2(0.3, 0.0001), vec2(0.35, 0), 0.0025);
221
222
float d2;
223
d2 = sdBezier(p, vec2(0.16, 0.04), vec2(0.16, 0.0401), vec2(0.32, 0.05), 0.002);
224
225
float d3;
226
d3 = sdBezier(p, vec2(0.16, 0.07), vec2(0.25, 0.10), vec2(0.35, 0.1), 0.002);
227
228
float d4;
229
d4 = sdBezier(p, vec2(0.18, -0.04), vec2(0.25, -0.07), vec2(0.32, -0.05), 0.002);
230
231
float d;
232
d = add(d1, d2);
233
d = add(d, d3);
234
d = add(d, d4);
235
return d;
236
}
237
238
float lip(vec2 p) {
239
float d1;
240
d1 = sdHorseshoe(p - vec2(0, -0.16), 0.1 * PI, 0.07, vec2(0.06, 0.025));
241
242
float d2;
243
d2 = sdBox(p - vec2(0, -0.3), vec2(0.07, 0.07));
244
d2 = diff(d2, sdCircle(p - vec2(0.15, -0.33), 0.12));
245
d2 = diff(d2, sdCircle(p - vec2(-0.15, -0.33), 0.12));
246
247
float d;
248
d = add(d1, d2);
249
return d;
250
}
251
252
float lipLine(vec2 p) {
253
p.x = abs(p.x);
254
255
float d1;
256
d1 = sdBezier(p, vec2(0.04, -0.20), vec2(0.055, -0.20), vec2(0.07, -0.18), 0.004);
257
258
float d2;
259
d2 = sdBezier(p, vec2(0.04, -0.22), vec2(0.055, -0.23), vec2(0.08, -0.21), 0.004);
260
261
float d;
262
d = add(d1, d2);
263
return d;
264
}
265
266
float lipProtrusion(vec2 p) {
267
p.x = abs(p.x);
268
269
float d1;
270
vec2[] v = vec2[](
271
vec2(0, 0), vec2(0.02, 0.01), vec2(0.01, -0.06), vec2(0, -0.05)
272
);
273
d1 = sdRoundedPolygon(v, p - vec2(0.01, -0.18), 0.01);
274
275
float d;
276
d = d1;
277
return d;
278
}
279
280
float dorsalSepal(vec2 p) {
281
float d1;
282
d1 = sdParabola(p - vec2(0, 0.7), -5.0, false);
283
d1 = diff(d1, sdBox(p - vec2(0, -1.5), vec2(1, 1.5)));
284
285
float d;
286
//d = d1;
287
d = diff(d1, petal(p));
288
return d;
289
}
290
291
float dorsalSepalLine(vec2 p) {
292
float d1;
293
d1 = sdBezier(p, vec2(-0.03, 0.06), vec2(-0.07, 0.18), vec2(-0.08, 0.3), 0.0025);
294
295
float d2;
296
d2 = sdBezier(p, vec2(-0.01, 0.06), vec2(-0.04, 0.15), vec2(-0.03, 0.3), 0.0025);
297
298
float d3;
299
d3 = sdBezier(p, vec2(0.01, 0.07), vec2(0.01, 0.15), vec2(0.01, 0.32), 0.0025);
300
301
float d;
302
d = add(d1, d2);
303
d = add(d, d3);
304
return d;
305
}
306
307
float lowerSepal(vec2 p) {
308
float d1;
309
d1 = sdParabola(rotate(p, 0.95 * PI) - vec2(0.21, 0.6), -6.9, false);
310
d1 = diff(d1, sdBox(p - vec2(0, 1.48), vec2(1, 1.5)));
311
312
float d2;
313
d2 = sdParabola(rotate(p, 1.05 * PI) - vec2(-0.21, 0.6), -6.9, false);
314
d2 = diff(d2, sdBox(p - vec2(0, 1.48), vec2(1, 1.5)));
315
316
float d;
317
d = add(d1, d2);
318
d = diff(d, petal(p));
319
return d;
320
}
321
322
void main(){
323
vec3 color;
324
vec2 coord = (gl_FragCoord.xy / u_resolution.xy * 2.0 - 1.0) / 1.3;
325
326
float fbmVal = fbm(coord);
327
328
float dLowerSepal = lowerSepal(coord);
329
float dDorsalSepal = dorsalSepal(coord);
330
float dDorsalSepalLine = dorsalSepalLine(coord);
331
float dPetal = petal(coord);
332
float dPetalLine = petalLine(coord);
333
float dLip = lip(coord);
334
float dLipLine = lipLine(coord);
335
float dLipProtrusion = lipProtrusion(coord);
336
337
if (dLowerSepal <= .0) {
338
color = vec3(0.88, 0.92, 0.96);
339
340
float coef = 0.08 * (1.0 - smoothstep(0.0, 0.04, dPetal));
341
color *= coef * fbmVal + (1.0 - coef);
342
}
343
344
if (dDorsalSepal <= .0) {
345
color = vec3(0.88, 0.92, 0.96);
346
347
float coef = 0.08 * (1.0 - smoothstep(0.0, 0.04, dPetal));
348
color *= coef * fbmVal + (1.0 - coef);
349
}
350
351
if (dDorsalSepalLine <= .0) {
352
color = vec3(0.87, 0.87, 0.87);
353
}
354
355
if (dPetal <= .0) {
356
color = vec3(0.93, 0.97, 0.98);
357
if (abs(coord.x) >= 0.2) {
358
color *= 1.0 - 0.03 * smoothstep(-0.10, 0.0, dPetal) * fbm(coord * 30.0);
359
}
360
}
361
362
if (dPetalLine <= .0) {
363
color = vec3(0.87, 0.87, 0.87);
364
}
365
366
if (dLip <= .0) {
367
color = mix(
368
mix(vec3(0.80, 0.67, 0), vec3(0.92, 0.96, 0.97), smoothstep(0.05, 0.08, abs(coord.x))),
369
vec3(0.92, 0.96, 0.97),
370
smoothstep(0.00, 0.07, abs(coord.y + 0.21))
371
);
372
}
373
374
if (dLipLine <= .0) {
375
color = vec3(0.55, 0.15, 0.14);
376
}
377
378
if (dLipProtrusion <= .0) {
379
if (random(coord) >= 0.7) {
380
color = vec3(0);
381
}
382
else {
383
color = vec3(0.80, 0.67, 0);
384
}
385
}
386
387
colour_out = vec4(color, 1);
388
}
Phalaenopsis Aphrodite by CGbaby
More Student Works
The rest of the student works from 2021 are shown below. Note that some are very computationally expensive and may potentially cause issues with your browser. Show Other Student Works
// credit: Chen Kaishang // orchid: calanthe_discolor_lindl_sert_orchid // ref image: https://esslab.jp/~ess/images/teaching/acg/orchids/calanthe_discolor_lindl_sert_orchid_0.jpg uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float PI=3.1415926535897932384626433832795; /* SDFs */ float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); // can delay this sqrt by rewriting the comparison return ((p.y-b)*d > p.x*b) ? length(p-vec2(0.000,b))*sign(d) : length(p-vec2(-d,0.0))-r; } float sdCircle( in vec2 p, in float r ) { return length(p)-r; } 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; } 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)); } float sdBox( in vec2 p, in vec2 b ) { vec2 d = abs(p)-b; return length(max(d,0.0)) + min(max(d.x,d.y),0.0); } vec2 rotate(vec2 p, float degree){ float c = cos(degree*PI/180.); float s = sin(degree*PI/180.); mat3 H = mat3(c, s, 0, -s, c, 0, 0, 0, 1); return (inverse(H) * vec3(p,1.0)).xy; } float intersectSDF(float distA, float distB) { return max(distA, distB); } float unionSDF(float distA, float distB) { return min(distA, distB); } float differenceSDF(float distA, float distB) { return max(distA, -distB); } /* helper func for noise */ vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } /* noise */ float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i, 289.0); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float woodfbm( vec2 p ) { /* Same as the fbm before. */ float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += snoise( p * scale ) / scale; } return f; } void main() { float mask = 1.000; vec2 p = (2.0*gl_FragCoord.xy-u_resolution.xy)/u_resolution.xy ; //right leaf float ra1_a = 0.468; float ra2_a = 0.020; float wid_a = max(0.628,ra1_a); float d1 = sdVesica( rotate(p - vec2(0.480,-0.180),80.0), wid_a, ra1_a ) - ra2_a; //top leaf float ra1_b = 0.126; float ra2_b = -0.138; float wid_b = max(0.500,ra1_b); float d2 = sdVesica( rotate(p - vec2(0.,0.30),0.), wid_b, ra1_b ) - ra2_b; // top-right leaf float ra1_c = 0.468; float ra2_c = 0.020; float wid_c = max(0.628,ra1_c); float d3 = sdVesica( rotate(p - vec2(0.50,0.20),120.0), wid_c, ra1_c ) - ra2_c; // top-left leaf float ra1_d = 0.468; float ra2_d = 0.020; float wid_d = max(0.628,ra1_d); float d4 = sdVesica( rotate(p - vec2(-0.50,0.20),240.0), wid_d, ra1_d ) - ra2_d; //left leaf float ra1_e = 0.468; float ra2_e = 0.020; float wid_e = max(0.628,ra1_e); float d5 = sdVesica( rotate(p - vec2(-0.480,-0.180),-80.0), wid_e, ra1_e ) - ra2_e; // bar float d_b2 = sdBox(rotate(p - vec2(0.04,-0.200),100.0),vec2(0.20,0.10)); // union all the leaves float d = unionSDF(d1, d2); d = unionSDF(d, d3); d = unionSDF(d, d4); d = unionSDF(d, d5); vec3 f_colour = vec3(0.3,0.054,0.054); vec3 colour = f_colour; if (d<0.0){ float dist = length(p); float cof = exp(-dist * 5.0 + 1.0) ; colour = mix(f_colour, vec3(1.0), cof); } else{ colour = vec3(0.0); } if (d_b2 < 0.0){ colour = vec3(1.0); } float pattern = sin(10000.0 * -d * PI/180.0 + 10.0*u_time); colour = colour * pattern; //output colour_out = vec4(colour,1.0); }
173
1
// credit: Chen Kaishang
2
// orchid: calanthe_discolor_lindl_sert_orchid
3
// ref image: https://esslab.jp/~ess/images/teaching/acg/orchids/calanthe_discolor_lindl_sert_orchid_0.jpg
4
5
uniform vec2 u_resolution;
6
uniform vec2 u_mouse;
7
uniform float u_time;
8
9
const float PI=3.1415926535897932384626433832795;
10
11
/* SDFs */
12
float sdVesica(vec2 p, float r, float d)
13
{
14
p = abs(p);
15
float b = sqrt(r*r-d*d); // can delay this sqrt by rewriting the comparison
16
return ((p.y-b)*d > p.x*b) ? length(p-vec2(0.000,b))*sign(d)
17
: length(p-vec2(-d,0.0))-r;
18
}
19
20
float sdCircle( in vec2 p, in float r )
21
{
22
return length(p)-r;
23
}
24
25
float sdArc( in vec2 p, in vec2 sca, in vec2 scb, in float ra, in float rb )
26
{
27
p *= mat2(sca.x,sca.y,-sca.y,sca.x);
28
p.x = abs(p.x);
29
float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p);
30
return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;
31
}
32
33
float sdPie( in vec2 p, in vec2 c, in float r )
34
{
35
p.x = abs(p.x);
36
float l = length(p) - r;
37
float m = length(p - c*clamp(dot(p,c),0.0,r) );
38
return max(l,m*sign(c.y*p.x-c.x*p.y));
39
}
40
41
float sdBox( in vec2 p, in vec2 b )
42
{
43
vec2 d = abs(p)-b;
44
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
45
}
46
47
vec2 rotate(vec2 p, float degree){
48
float c = cos(degree*PI/180.);
49
float s = sin(degree*PI/180.);
50
mat3 H = mat3(c, s, 0,
51
-s, c, 0,
52
0, 0, 1);
53
return (inverse(H) * vec3(p,1.0)).xy;
54
}
55
56
float intersectSDF(float distA, float distB) {
57
return max(distA, distB);
58
}
59
60
float unionSDF(float distA, float distB) {
61
return min(distA, distB);
62
}
63
64
float differenceSDF(float distA, float distB) {
65
return max(distA, -distB);
66
}
67
68
/* helper func for noise */
69
vec3 permute(vec3 x) {
70
return mod(((x*34.0)+1.0)*x, 289.0);
71
}
72
73
/* noise */
74
float snoise(vec2 v){
75
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
76
-0.577350269189626, 0.024390243902439);
77
vec2 i = floor(v + dot(v, C.yy) );
78
vec2 x0 = v - i + dot(i, C.xx);
79
vec2 i1;
80
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
81
vec4 x12 = x0.xyxy + C.xxzz;
82
x12.xy -= i1;
83
i = mod(i, 289.0);
84
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
85
+ i.x + vec3(0.0, i1.x, 1.0 ));
86
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
87
dot(x12.zw,x12.zw)), 0.0);
88
m = m*m ;
89
m = m*m ;
90
vec3 x = 2.0 * fract(p * C.www) - 1.0;
91
vec3 h = abs(x) - 0.5;
92
vec3 ox = floor(x + 0.5);
93
vec3 a0 = x - ox;
94
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
95
vec3 g;
96
g.x = a0.x * x0.x + h.x * x0.y;
97
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
98
return 130.0 * dot(m, g);
99
}
100
101
float woodfbm( vec2 p ) { /* Same as the fbm before. */
102
float f = 0.0, scale;
103
for (int i=0; i<4; i++) {
104
scale = pow( pow(2.0, 4.0/3.0), float(i) );
105
f += snoise( p * scale ) / scale; }
106
107
return f; }
108
109
void main() {
110
float mask = 1.000;
111
vec2 p = (2.0*gl_FragCoord.xy-u_resolution.xy)/u_resolution.xy ;
112
113
//right leaf
114
float ra1_a = 0.468;
115
float ra2_a = 0.020;
116
float wid_a = max(0.628,ra1_a);
117
float d1 = sdVesica( rotate(p - vec2(0.480,-0.180),80.0), wid_a, ra1_a ) - ra2_a;
118
119
//top leaf
120
float ra1_b = 0.126;
121
float ra2_b = -0.138;
122
float wid_b = max(0.500,ra1_b);
123
float d2 = sdVesica( rotate(p - vec2(0.,0.30),0.), wid_b, ra1_b ) - ra2_b;
124
125
// top-right leaf
126
float ra1_c = 0.468;
127
float ra2_c = 0.020;
128
float wid_c = max(0.628,ra1_c);
129
float d3 = sdVesica( rotate(p - vec2(0.50,0.20),120.0), wid_c, ra1_c ) - ra2_c;
130
131
// top-left leaf
132
float ra1_d = 0.468;
133
float ra2_d = 0.020;
134
float wid_d = max(0.628,ra1_d);
135
float d4 = sdVesica( rotate(p - vec2(-0.50,0.20),240.0), wid_d, ra1_d ) - ra2_d;
136
137
//left leaf
138
float ra1_e = 0.468;
139
float ra2_e = 0.020;
140
float wid_e = max(0.628,ra1_e);
141
float d5 = sdVesica( rotate(p - vec2(-0.480,-0.180),-80.0), wid_e, ra1_e ) - ra2_e;
142
143
// bar
144
float d_b2 = sdBox(rotate(p - vec2(0.04,-0.200),100.0),vec2(0.20,0.10));
145
146
// union all the leaves
147
float d = unionSDF(d1, d2);
148
d = unionSDF(d, d3);
149
d = unionSDF(d, d4);
150
d = unionSDF(d, d5);
151
152
vec3 f_colour = vec3(0.3,0.054,0.054);
153
vec3 colour = f_colour;
154
155
if (d<0.0){
156
float dist = length(p);
157
float cof = exp(-dist * 5.0 + 1.0) ;
158
colour = mix(f_colour, vec3(1.0), cof);
159
}
160
else{
161
colour = vec3(0.0);
162
}
163
164
if (d_b2 < 0.0){
165
colour = vec3(1.0);
166
}
167
168
float pattern = sin(10000.0 * -d * PI/180.0 + 10.0*u_time);
169
colour = colour * pattern;
170
171
//output
172
colour_out = vec4(colour,1.0);
173
}
Calanthe Discolor Lindl Sert by Chen Kaishang
// credit: jikihakase (will show up on website) // orchid: Coelogyne pandurata uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; //precision mediump float; //out vec4 color_out; vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 mod7(vec3 x) { return x - floor(x * (1.0 / 7.0)) * 7.0; } vec3 permute(vec3 x) { return mod289((34.0 * x + 10.0) * x); } vec2 cellular(vec2 P) { #define K 0.142857142857 // 1/7 #define Ko 0.428571428571 // 3/7 #define jitter 1.0 // Less gives more regular pattern vec2 Pi = mod289(floor(P)); vec2 Pf = fract(P); vec3 oi = vec3(-1.0, 0.0, 1.0); vec3 of = vec3(-0.5, 0.5, 1.5); vec3 px = permute(Pi.x + oi); vec3 p = permute(px.x + Pi.y + oi); // p11, p12, p13 vec3 ox = fract(p*K) - Ko; vec3 oy = mod7(floor(p*K))*K - Ko; vec3 dx = Pf.x + 0.5 + jitter*ox; vec3 dy = Pf.y - of + jitter*oy; vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared p = permute(px.y + Pi.y + oi); // p21, p22, p23 ox = fract(p*K) - Ko; oy = mod7(floor(p*K))*K - Ko; dx = Pf.x - 0.5 + jitter*ox; dy = Pf.y - of + jitter*oy; vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared p = permute(px.z + Pi.y + oi); // p31, p32, p33 ox = fract(p*K) - Ko; oy = mod7(floor(p*K))*K - Ko; dx = Pf.x - 1.5 + jitter*ox; dy = Pf.y - of + jitter*oy; vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared // Sort out the two smallest distances (F1, F2) vec3 d1a = min(d1, d2); d2 = max(d1, d2); // Swap to keep candidates for F2 d2 = min(d2, d3); // neither F1 nor F2 are now in d3 d1 = min(d1a, d2); // F1 is now in d1 d2 = max(d1a, d2); // Swap to keep candidates for F2 d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz d1.y = min(d1.y, d1.z); // nor in d1.z d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done. return sqrt(d1.xy); } float sdBox( in vec2 p, in vec2 b ){ vec2 d = abs(p) - b; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); } float sdCircle( vec2 p, float r ){ return length(p) - r; } float sdIntersection( float d1, float d2 ) { return max( d1, d2 ); } float sdDifference( float d1, float d2 ) { return max( d1, -d2 ); /* Remove d2 from d1 */ } float sdUnion( float d1, float d2 ) { return min( d1, d2 ); } float sdVesica(vec2 p, float r, float d){ p = abs(p); float b = sqrt(r * r - d * d); return ((p.y - b) * d > p.x * b) ? length(p - vec2(0.0, b)) : length(p - vec2(-d, 0.0)) - r; } void main() { vec2 p = gl_FragCoord.xy/u_resolution.xy * 2.0 - 1.0; vec2 p5 = vec2(p.x, p.y - 0.35); float A = sdVesica(p5, 0.8, 0.5); float disA = distance(vec2(0.0, -0.15), p); vec4 a = vec4(1.0, 0.0, 1.0, 1.0); vec4 a1 = vec4(1.0, 0.0, 1.0, 0.7); vec4 b = vec4(1.0, 0.0, 1.0, 0.3); vec4 c = vec4(1.0, 1.0, 1.0, 1.0); vec2 f = cellular( p.xy * 50.0 ); vec4 a2 = vec4(f.x, 0.0, 1.0, 0.8); vec2 leaf2 = vec2(p.x + 0.3 - 0.45, p.y - 0.3 - 0.2); vec2 leaf3 = vec2(p.x - 0.3 - 0.45, p.y + 0.3 - 0.2); float B = sdIntersection(sdCircle(leaf2, 0.65), sdCircle(leaf3, 0.65)); float disB = distance(vec2(0.2, -0.1), p); vec2 leaf1 = vec2(p.x - 0.3 + 0.45, p.y - 0.3 - 0.2); vec2 leaf4 = vec2(p.x + 0.3 + 0.45, p.y + 0.3 - 0.2); float C = sdIntersection(sdCircle(leaf1, 0.65), sdCircle(leaf4, 0.65)); float disC = distance(vec2(-0.2, -0.1), p); vec2 p1 = vec2(p.x + 0.2 + 0.5, p.y + 0.3 + 0.7); vec2 p2 = vec2(p.x + 0.4, p.y + 0.6); float D = sdDifference(sdCircle(p2, 0.6), sdCircle(p1, 0.6)); float disD = distance(vec2(0.0, 0.0), p); vec2 p3 = vec2(p.x - 0.2 - 0.5, p.y + 0.3 + 0.7); vec2 p4 = vec2(p.x - 0.4, p.y + 0.6); float E = sdDifference(sdCircle(p4, 0.6), sdCircle(p3, 0.6)); float disE = distance(vec2(0.0, 0.0), p); vec2 Cir1 = vec2(p.x + 0.07, p.y + 0.1); vec2 Cir2 = vec2(p.x - 0.07, p.y + 0.1); float Seed = sdUnion(sdCircle(Cir1, 0.1), sdCircle(Cir2, 0.1)); vec2 leafa = vec2(p.x + 0.4 - 0.25, p.y - 0.4 + 0.2); vec2 leafb = vec2(p.x - 0.4 - 0.25, p.y + 0.4 + 0.2); float L1 = sdIntersection(sdCircle(leafa, 0.7), sdCircle(leafb, 0.7)); float disL1 = distance(vec2(0.1, -0.1), p); vec2 leafc = vec2(p.x - 0.4 + 0.25, p.y - 0.4 + 0.2); vec2 leafd = vec2(p.x + 0.4 + 0.25, p.y + 0.4 + 0.2); float L2 = sdIntersection(sdCircle(leafc, 0.7), sdCircle(leafd, 0.7)); float disL2 = distance(vec2(-0.1, -0.1), p); if( L1 < 0.0 ) colour_out = mix(a1, c, disL1/0.45); else if ( L2 < 0.0 ) colour_out = mix(a1, c, disL2/0.45); else if( Seed < 0.0 ) colour_out = vec4(0.0, 1.0, 0.0, 0.4); else if ( D < 0.0 ) colour_out = mix(b, a2, disD/1.4); else if ( E < 0.0 ) colour_out = mix(b, a2, disE/1.4); else if ( A < 0.0 ) colour_out = mix(b, a2, disA/1.7); else if ( B < 0.0 ) colour_out = mix(b, a2, disB/1.2); else if ( C < 0.0 ) colour_out = mix(b, a2, disC/1.2); else colour_out = vec4(1.0, 1.0, 1.0, 1.0); //colour_out = vec4(0.0, 0.0, 0.0, 1.0); }
145
1
// credit: jikihakase (will show up on website)
2
// orchid: Coelogyne pandurata
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
//precision mediump float;
8
//out vec4 color_out;
9
10
vec3 mod289(vec3 x) {
11
return x - floor(x * (1.0 / 289.0)) * 289.0;
12
}
13
vec2 mod289(vec2 x) {
14
return x - floor(x * (1.0 / 289.0)) * 289.0;
15
}
16
vec3 mod7(vec3 x) {
17
return x - floor(x * (1.0 / 7.0)) * 7.0;
18
}
19
vec3 permute(vec3 x) {
20
return mod289((34.0 * x + 10.0) * x);
21
}
22
vec2 cellular(vec2 P) {
23
24
25
26
vec2 Pi = mod289(floor(P));
27
vec2 Pf = fract(P);
28
vec3 oi = vec3(-1.0, 0.0, 1.0);
29
vec3 of = vec3(-0.5, 0.5, 1.5);
30
vec3 px = permute(Pi.x + oi);
31
vec3 p = permute(px.x + Pi.y + oi); // p11, p12, p13
32
vec3 ox = fract(p*K) - Ko;
33
vec3 oy = mod7(floor(p*K))*K - Ko;
34
vec3 dx = Pf.x + 0.5 + jitter*ox;
35
vec3 dy = Pf.y - of + jitter*oy;
36
vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared
37
p = permute(px.y + Pi.y + oi); // p21, p22, p23
38
ox = fract(p*K) - Ko;
39
oy = mod7(floor(p*K))*K - Ko;
40
dx = Pf.x - 0.5 + jitter*ox;
41
dy = Pf.y - of + jitter*oy;
42
vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared
43
p = permute(px.z + Pi.y + oi); // p31, p32, p33
44
ox = fract(p*K) - Ko;
45
oy = mod7(floor(p*K))*K - Ko;
46
dx = Pf.x - 1.5 + jitter*ox;
47
dy = Pf.y - of + jitter*oy;
48
vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared
49
// Sort out the two smallest distances (F1, F2)
50
vec3 d1a = min(d1, d2);
51
d2 = max(d1, d2); // Swap to keep candidates for F2
52
d2 = min(d2, d3); // neither F1 nor F2 are now in d3
53
d1 = min(d1a, d2); // F1 is now in d1
54
d2 = max(d1a, d2); // Swap to keep candidates for F2
55
d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller
56
d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x
57
d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz
58
d1.y = min(d1.y, d1.z); // nor in d1.z
59
d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done.
60
return sqrt(d1.xy);
61
}
62
63
64
float sdBox( in vec2 p, in vec2 b ){
65
vec2 d = abs(p) - b;
66
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
67
}
68
float sdCircle( vec2 p, float r ){
69
return length(p) - r;
70
}
71
float sdIntersection( float d1, float d2 ) {
72
return max( d1, d2 );
73
}
74
float sdDifference( float d1, float d2 ) {
75
return max( d1, -d2 ); /* Remove d2 from d1 */
76
}
77
float sdUnion( float d1, float d2 ) {
78
return min( d1, d2 );
79
}
80
float sdVesica(vec2 p, float r, float d){
81
p = abs(p);
82
float b = sqrt(r * r - d * d);
83
return ((p.y - b) * d > p.x * b) ? length(p - vec2(0.0, b)) : length(p - vec2(-d, 0.0)) - r;
84
}
85
86
void main() {
87
vec2 p = gl_FragCoord.xy/u_resolution.xy * 2.0 - 1.0;
88
89
vec2 p5 = vec2(p.x, p.y - 0.35);
90
float A = sdVesica(p5, 0.8, 0.5);
91
float disA = distance(vec2(0.0, -0.15), p);
92
93
vec4 a = vec4(1.0, 0.0, 1.0, 1.0);
94
vec4 a1 = vec4(1.0, 0.0, 1.0, 0.7);
95
vec4 b = vec4(1.0, 0.0, 1.0, 0.3);
96
vec4 c = vec4(1.0, 1.0, 1.0, 1.0);
97
vec2 f = cellular( p.xy * 50.0 );
98
vec4 a2 = vec4(f.x, 0.0, 1.0, 0.8);
99
100
vec2 leaf2 = vec2(p.x + 0.3 - 0.45, p.y - 0.3 - 0.2);
101
vec2 leaf3 = vec2(p.x - 0.3 - 0.45, p.y + 0.3 - 0.2);
102
float B = sdIntersection(sdCircle(leaf2, 0.65), sdCircle(leaf3, 0.65));
103
float disB = distance(vec2(0.2, -0.1), p);
104
105
vec2 leaf1 = vec2(p.x - 0.3 + 0.45, p.y - 0.3 - 0.2);
106
vec2 leaf4 = vec2(p.x + 0.3 + 0.45, p.y + 0.3 - 0.2);
107
float C = sdIntersection(sdCircle(leaf1, 0.65), sdCircle(leaf4, 0.65));
108
float disC = distance(vec2(-0.2, -0.1), p);
109
110
vec2 p1 = vec2(p.x + 0.2 + 0.5, p.y + 0.3 + 0.7);
111
vec2 p2 = vec2(p.x + 0.4, p.y + 0.6);
112
float D = sdDifference(sdCircle(p2, 0.6), sdCircle(p1, 0.6));
113
float disD = distance(vec2(0.0, 0.0), p);
114
115
vec2 p3 = vec2(p.x - 0.2 - 0.5, p.y + 0.3 + 0.7);
116
vec2 p4 = vec2(p.x - 0.4, p.y + 0.6);
117
float E = sdDifference(sdCircle(p4, 0.6), sdCircle(p3, 0.6));
118
float disE = distance(vec2(0.0, 0.0), p);
119
120
vec2 Cir1 = vec2(p.x + 0.07, p.y + 0.1);
121
vec2 Cir2 = vec2(p.x - 0.07, p.y + 0.1);
122
float Seed = sdUnion(sdCircle(Cir1, 0.1), sdCircle(Cir2, 0.1));
123
124
vec2 leafa = vec2(p.x + 0.4 - 0.25, p.y - 0.4 + 0.2);
125
vec2 leafb = vec2(p.x - 0.4 - 0.25, p.y + 0.4 + 0.2);
126
float L1 = sdIntersection(sdCircle(leafa, 0.7), sdCircle(leafb, 0.7));
127
float disL1 = distance(vec2(0.1, -0.1), p);
128
129
vec2 leafc = vec2(p.x - 0.4 + 0.25, p.y - 0.4 + 0.2);
130
vec2 leafd = vec2(p.x + 0.4 + 0.25, p.y + 0.4 + 0.2);
131
float L2 = sdIntersection(sdCircle(leafc, 0.7), sdCircle(leafd, 0.7));
132
float disL2 = distance(vec2(-0.1, -0.1), p);
133
134
if( L1 < 0.0 ) colour_out = mix(a1, c, disL1/0.45);
135
else if ( L2 < 0.0 ) colour_out = mix(a1, c, disL2/0.45);
136
else if( Seed < 0.0 ) colour_out = vec4(0.0, 1.0, 0.0, 0.4);
137
else if ( D < 0.0 ) colour_out = mix(b, a2, disD/1.4);
138
else if ( E < 0.0 ) colour_out = mix(b, a2, disE/1.4);
139
else if ( A < 0.0 ) colour_out = mix(b, a2, disA/1.7);
140
else if ( B < 0.0 ) colour_out = mix(b, a2, disB/1.2);
141
else if ( C < 0.0 ) colour_out = mix(b, a2, disC/1.2);
142
else
143
colour_out = vec4(1.0, 1.0, 1.0, 1.0);
144
//colour_out = vec4(0.0, 0.0, 0.0, 1.0);
145
}
unknown by anonymous
// credit: Big RUI(will show up on website) // orchid: phalaenopsis_hybrid_0 uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; vec2 random( vec2 p ) { p = vec2( dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3))); return -1.0 + 2.0*fract(sin(p)*43758.5453123); } float noise( in vec2 p ) { vec2 i = floor(p); vec2 f = fract(p); float F1 = 1.; for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { vec2 neighbor = vec2(float(j), float(k)); vec2 point = random(i + neighbor); float d = length(point + neighbor - f); F1 = min(F1,d); } } return F1; } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; vec2 pos=vec2 (st.x-0.5,st.y-0.5); float d=pos.x*pos.x+pos.y*pos.y; float mask = 1.0; float mask2 = 1.0; float mask3 = 1.0; float anti_mask = 0.0; float anti_mask2 = 0.0; float noise1 = noise( 20.944*vec2(1.808*sqrt(pos.x*pos.x)*pos.x,5.040*sqrt(pos.y*pos.y)*pos.x )); mask *= step( 0.3, distance( st.xy*vec2(0.900,0.190)*2.0, vec2(0.900,0.090) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.290,0.420) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.700,0.420) ) ); mask2 *= step( 0.25, distance( st.xy*vec2(0.50,1.00)*2.0, vec2(0.320,0.170) ) ); mask2 *= step( 0.25, distance( st.xy*vec2(0.50,1.00)*2.0, vec2(0.670,0.160) ) ); mask3 *= (log2(distance( st.xy*vec2(1.00,1.00), vec2(0.500,0.270) ))*13.264+36.216) ; anti_mask += step( 1.0, distance( st.xy*vec2(0.630,0.760)*4.440, vec2(1.370,0.100) ) ); anti_mask2 += (log2(distance( st.xy*vec2(1.00,1.00), vec2(0.510,0.290) ))*0.376+1.672) ; vec4 noise_out1 = vec4(vec3(pow(noise1, 1.664)), 1.0); colour_out = vec4( mix( vec3(0.981,0.745,1.000),vec3(0.880,0.245,0.811),d*3.378),1.0); colour_out +=0.580* noise_out1; colour_out *= (1.0-mask)*(anti_mask ); vec2 pos2=vec2 (st.x-0.5,st.y-0.5); float noise2 = noise( 159.144*vec2(0.240*sqrt(pos2.x*pos2.x)*pos2.x,0.344*sqrt(pos2.y*pos2.y)*pos2.x )); vec4 noise_out2 = vec4(vec3(pow(noise2, 1.664)), 1.0); float noise3 = noise( 21.408*vec2(25.632*sqrt(pos2.x*pos2.x)*pos2.x,3.400*sqrt(pos2.y*pos2.y)*pos2.y )); colour_out += vec4( mix( vec3(0.981,0.745,1.000),vec3(0.880,0.245,0.811),0.378),4.280*d*sqrt(d))*1.252*( noise_out2 +1.0)*(1.0-mask2); colour_out *=anti_mask2*1.168; vec4 noise_out3 = vec4(vec3(pow(noise3, 1.664)), 1.0); colour_out+=0.072*(1.0-step(1.856,mask3))*(1.992-mask3)*(vec4( mix( vec3(0.970,0.815,0.639),vec3(0.880,0.411,0.100),0.634),0.968)*noise_out3*(2.872)+-0.580)+0.328; colour_out *=0.496; }
1
// credit: Big RUI(will show up on website)
2
// orchid: phalaenopsis_hybrid_0
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
vec2 random( vec2 p )
7
{
8
p = vec2( dot(p,vec2(127.1,311.7)),
9
dot(p,vec2(269.5,183.3)));
10
11
return -1.0 + 2.0*fract(sin(p)*43758.5453123);
12
}
13
14
float noise( in vec2 p )
15
{
16
vec2 i = floor(p);
17
vec2 f = fract(p);
18
float F1 = 1.;
19
for (int j = -1; j <= 1; j++) {
20
for (int k = -1; k <= 1; k++) {
21
vec2 neighbor = vec2(float(j), float(k));
22
vec2 point = random(i + neighbor);
23
float d = length(point + neighbor - f);
24
F1 = min(F1,d);
25
}
26
}
27
return F1;
28
}
29
void main() {
30
vec2 st = gl_FragCoord.xy/u_resolution.xy;
31
vec2 pos=vec2 (st.x-0.5,st.y-0.5);
32
float d=pos.x*pos.x+pos.y*pos.y;
33
float mask = 1.0;
34
float mask2 = 1.0;
35
float mask3 = 1.0;
36
float anti_mask = 0.0; float anti_mask2 = 0.0;
37
38
float noise1 = noise( 20.944*vec2(1.808*sqrt(pos.x*pos.x)*pos.x,5.040*sqrt(pos.y*pos.y)*pos.x ));
39
mask *= step( 0.3, distance( st.xy*vec2(0.900,0.190)*2.0, vec2(0.900,0.090) ) );
40
mask *= step( 0.25, distance( st.xy, vec2(0.290,0.420) ) );
41
mask *= step( 0.25, distance( st.xy, vec2(0.700,0.420) ) );
42
mask2 *= step( 0.25, distance( st.xy*vec2(0.50,1.00)*2.0, vec2(0.320,0.170) ) );
43
mask2 *= step( 0.25, distance( st.xy*vec2(0.50,1.00)*2.0, vec2(0.670,0.160) ) );
44
mask3 *= (log2(distance( st.xy*vec2(1.00,1.00), vec2(0.500,0.270) ))*13.264+36.216) ;
45
anti_mask += step( 1.0, distance( st.xy*vec2(0.630,0.760)*4.440, vec2(1.370,0.100) ) );
46
anti_mask2 += (log2(distance( st.xy*vec2(1.00,1.00), vec2(0.510,0.290) ))*0.376+1.672) ;
47
vec4 noise_out1 = vec4(vec3(pow(noise1, 1.664)), 1.0);
48
colour_out = vec4( mix( vec3(0.981,0.745,1.000),vec3(0.880,0.245,0.811),d*3.378),1.0);
49
colour_out +=0.580* noise_out1;
50
colour_out *= (1.0-mask)*(anti_mask );
51
vec2 pos2=vec2 (st.x-0.5,st.y-0.5);
52
float noise2 = noise( 159.144*vec2(0.240*sqrt(pos2.x*pos2.x)*pos2.x,0.344*sqrt(pos2.y*pos2.y)*pos2.x ));
53
vec4 noise_out2 = vec4(vec3(pow(noise2, 1.664)), 1.0);
54
float noise3 = noise( 21.408*vec2(25.632*sqrt(pos2.x*pos2.x)*pos2.x,3.400*sqrt(pos2.y*pos2.y)*pos2.y ));
55
56
colour_out += vec4( mix(
57
vec3(0.981,0.745,1.000),vec3(0.880,0.245,0.811),0.378),4.280*d*sqrt(d))*1.252*( noise_out2 +1.0)*(1.0-mask2);
58
colour_out *=anti_mask2*1.168;
59
vec4 noise_out3 = vec4(vec3(pow(noise3, 1.664)), 1.0);
60
colour_out+=0.072*(1.0-step(1.856,mask3))*(1.992-mask3)*(vec4( mix(
61
vec3(0.970,0.815,0.639),vec3(0.880,0.411,0.100),0.634),0.968)*noise_out3*(2.872)+-0.580)+0.328;
62
colour_out *=0.496;
63
64
65
66
}
Phalaenopsis Hybrid by Big RUI
uniform vec2 u_resolution; uniform float u_time; #define TWO_PI 6.28318530718 #define PI 3.1415926535 // credit: oneAAAIaDayKeepsHairAway // orchid: Phalaenopsis Orchid Stem Green // cloud source code is from ShaderToy vec2 mod289(vec2 x) { return x - floor(x * (1. / 289.)) * 289.; } vec4 mod289(vec4 x) { return x - floor(x * (1. / 289.)) * 289.; } vec4 mod7(vec4 x) { return x - floor(x * (1. / 7.)) * 7.; } vec4 permute(vec4 x) { return mod289((34. * x + 10.) * x); } vec2 cellular2x2(vec2 P) { #define K.142857142857// 1/7 #define K2.0714285714285// K/2 #define jitter.8// jitter 1.0 makes F1 wrong more often vec2 Pi = mod289(floor(P)); vec2 Pf = fract(P); vec4 Pfx = Pf.x + vec4(-.5, -1.5, -.5, -1.5); vec4 Pfy = Pf.y + vec4(-.5, -.5, -1.5, -1.5); vec4 p = permute(Pi.x + vec4(0., 1., 0., 1.)); p = permute(p + Pi.y + vec4(0., 0., 1., 1.)); vec4 ox = mod7(p) * K + K2; vec4 oy = mod7(floor(p * K)) * K + K2; vec4 dx = Pfx + jitter * ox; vec4 dy = Pfy + jitter * oy; vec4 d = dx * dx + dy * dy;// d11, d12, d21 and d22, squared // Sort out the two smallest distances #if 0 // Cheat and pick only F1 d.xy = min(d.xy, d.zw); d.x = min(d.x, d.y); return vec2(sqrt(d.x));// F1 duplicated, F2 not computed #else // Do it right and find both F1 and F2 d.xy = (d.x < d.y) ? d.xy : d.yx;// Swap if smaller d.xz = (d.x < d.z) ? d.xz : d.zx; d.xw = (d.x < d.w) ? d.xw : d.wx; d.y = min(d.y, d.z); d.y = min(d.y, d.w); return sqrt(d.xy); #endif } float color(vec2 xy) { return cellular2x2(xy).x * 2. - 1.; } vec4 mainImage(vec2 fragcoord, vec2 uresolution) { vec2 p = (fragcoord.xy / uresolution.y) * 2. - 1.; vec3 xyz = vec3(p, 0); float n = color(xyz.xy * 3.); vec4 fragColor = vec4(2. + .2 * vec3(n, n, n), 1.); return fragColor; } //orchid mat2 rotate2d(float _angle) { return mat2(cos(_angle), -sin(_angle), sin(_angle), cos(_angle)); } float orchidSides(vec2 toCenter, float resize, float defX, float defY, float grow, float nPetals, float smoothness, float xfactor) { float angle = atan(toCenter.y, toCenter.x / xfactor); float deformOnY = abs(toCenter.y) * defY; float deformOnX = abs(toCenter.x) * defX; float radius = length(toCenter) * resize * (grow + deformOnY + deformOnX) / 1.3; float f = cos(angle * nPetals); return smoothstep(f, f + smoothness, radius); } const float timeScale = 10.; const float cloudScale = .2; const float softness = .2; const float brightness = 1.; const int noiseOctaves = 8; const float curlStrain = 3.; float saturate(float num) { return clamp(num, 0., 1.); } float noise(vec2 uv) { return color(uv); } float sdSegment(vec2 p, vec2 a, vec2 b) { vec2 ap = p - a; vec2 ab = b - a; float h = clamp(dot(ap, ab) / dot(ab, ab), 0., 1.); return length(ap - ab * h); } float random(vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); } vec2 rotate(vec2 uv) { uv = uv + noise(uv * .2) * .005; float rot = curlStrain; float sinRot = sin(rot); float cosRot = cos(rot); mat2 rotMat = mat2(cosRot, -sinRot, sinRot, cosRot); return uv * rotMat; } float fbm(vec2 uv) { float rot = 1.57; float f = 0.; float total = 0.; float mul = .5; for(int i = 0; i < noiseOctaves; i++) { f += noise(uv + u_time * .00015 * timeScale * (1. - mul)) * mul; total += mul; uv *= 3.; uv = rotate(uv); mul *= .5; } return f / total; } float easeOutCubic(float number) { return 1. - pow(1. - number, 3.); } void main() { vec2 st = gl_FragCoord.xy / u_resolution.xy; vec2 uv = gl_FragCoord.xy / (4000. * cloudScale); vec2 stTrans = (st * 2. - 1.); float angle = atan(stTrans.y / stTrans.x); vec2 a = vec2(0., 0.); vec2 b = vec2(.35, .35) * random(stTrans); vec2 rotateSt1 = vec2(rotate2d(angle * 100. * random(stTrans))); float cover = 1.1 + .1; float bright = brightness * (1.8 - cover); float color1 = fbm(uv - .5 + u_time * .004 * timeScale); float color2 = fbm(uv - 10.5 + u_time * .002 * timeScale); float clouds1 = smoothstep(1. - cover, min((1. - cover) + softness * 2., 1.), color1); float clouds2 = smoothstep(1. - cover, min((1. - cover) + softness, 1.), color2); float cloudsFormComb = saturate(clouds1 + clouds2); vec4 skyCol = vec4(.6, .8, 1., 1.); float cloudCol = saturate(saturate(1. - pow(color1, 1.) * .2) * bright); vec4 clouds1Color = vec4(cloudCol, cloudCol, cloudCol, 1.); vec4 clouds2Color = mix(clouds1Color, skyCol, .25); vec4 cloudColComb = 1.5 * mix(clouds1Color, clouds2Color, saturate(clouds2 - clouds1)); vec4 cloud_colour = mix(skyCol, cloudColComb, cloudsFormComb); //orchid float mask = 1.; mask *= orchidSides(st - .5, 1., 0., 0., 3., 2., .1, .5); mask *= orchidSides(rotate2d(PI / 2.) * (st - .5), 1., 0., 3., 3., 1., .05, 1.); mask *= orchidSides(rotate2d(PI * 6. / 4.) * (st - .5), 1.2, 1., 3., 3., 1., .05, 1.); float fun = 1. * exp(-1. * sqrt(pow(st.x - .5, 2.) + pow(st.y - .5, 2.))); vec4 objcolor = mix(vec4(1.), vec4(.478, .568, .176, 1.), fun); colour_out = mainImage(gl_FragCoord.xy, u_resolution.xy) * objcolor; if(1. - mask == 1.) { colour_out *= (1. - mask); if(distance(0., rotateSt1.x) <= .03) { colour_out *= vec4(0.4431, 1., 0.1941, 1.0); } float t = 0.; for(int i = 0; i <= 55; i++) { t += 1.; b.y += pow(-1., t) * .1 * abs(cos(t)); b *= rotate2d(PI / 27.); if(sdSegment(stTrans.xy, a, b) <= .01) { if(i > 12 && i < 28) colour_out = vec4(.478, .768, .176, .9) * (2. - distance(stTrans, vec2(0.))); else if(i > 38 && i < 55) colour_out = vec4(.478, .768, .176, .9) * (2. - distance(stTrans, vec2(0.))); // else // colour_out = vec4(0.4431, 1., 0.1941, 1.0) * (2. - distance(stTrans, vec2(0.0))); } } if(distance(vec2(0.), stTrans) < .05 * cos(stTrans.y * 15. * PI)) { colour_out = vec4(.9608, .8902, .2627, 1.); } } else colour_out = cloud_colour; // colour_out = objcolor*orchids; }
218
1
uniform vec2 u_resolution;
2
uniform float u_time;
3
4
5
// credit: oneAAAIaDayKeepsHairAway
6
// orchid: Phalaenopsis Orchid Stem Green
7
8
// cloud source code is from ShaderToy
9
10
vec2 mod289(vec2 x) {
11
return x - floor(x * (1. / 289.)) * 289.;
12
}
13
14
vec4 mod289(vec4 x) {
15
return x - floor(x * (1. / 289.)) * 289.;
16
}
17
18
vec4 mod7(vec4 x) {
19
return x - floor(x * (1. / 7.)) * 7.;
20
}
21
22
vec4 permute(vec4 x) {
23
return mod289((34. * x + 10.) * x);
24
}
25
26
vec2 cellular2x2(vec2 P) {
27
28
29
30
vec2 Pi = mod289(floor(P));
31
vec2 Pf = fract(P);
32
vec4 Pfx = Pf.x + vec4(-.5, -1.5, -.5, -1.5);
33
vec4 Pfy = Pf.y + vec4(-.5, -.5, -1.5, -1.5);
34
vec4 p = permute(Pi.x + vec4(0., 1., 0., 1.));
35
p = permute(p + Pi.y + vec4(0., 0., 1., 1.));
36
vec4 ox = mod7(p) * K + K2;
37
vec4 oy = mod7(floor(p * K)) * K + K2;
38
vec4 dx = Pfx + jitter * ox;
39
vec4 dy = Pfy + jitter * oy;
40
vec4 d = dx * dx + dy * dy;// d11, d12, d21 and d22, squared
41
// Sort out the two smallest distances
42
43
// Cheat and pick only F1
44
d.xy = min(d.xy, d.zw);
45
d.x = min(d.x, d.y);
46
return vec2(sqrt(d.x));// F1 duplicated, F2 not computed
47
48
// Do it right and find both F1 and F2
49
d.xy = (d.x < d.y) ? d.xy : d.yx;// Swap if smaller
50
d.xz = (d.x < d.z) ? d.xz : d.zx;
51
d.xw = (d.x < d.w) ? d.xw : d.wx;
52
d.y = min(d.y, d.z);
53
d.y = min(d.y, d.w);
54
return sqrt(d.xy);
55
56
}
57
58
float color(vec2 xy) {
59
return cellular2x2(xy).x * 2. - 1.;
60
}
61
vec4 mainImage(vec2 fragcoord, vec2 uresolution) {
62
vec2 p = (fragcoord.xy / uresolution.y) * 2. - 1.;
63
64
vec3 xyz = vec3(p, 0);
65
66
float n = color(xyz.xy * 3.);
67
68
vec4 fragColor = vec4(2. + .2 * vec3(n, n, n), 1.);
69
70
return fragColor;
71
72
}
73
74
//orchid
75
76
mat2 rotate2d(float _angle) {
77
return mat2(cos(_angle), -sin(_angle), sin(_angle), cos(_angle));
78
}
79
float orchidSides(vec2 toCenter, float resize, float defX, float defY, float grow, float nPetals, float smoothness, float xfactor) {
80
81
float angle = atan(toCenter.y, toCenter.x / xfactor);
82
float deformOnY = abs(toCenter.y) * defY;
83
float deformOnX = abs(toCenter.x) * defX;
84
float radius = length(toCenter) * resize * (grow + deformOnY + deformOnX) / 1.3;
85
86
float f = cos(angle * nPetals);
87
return smoothstep(f, f + smoothness, radius);
88
}
89
90
const float timeScale = 10.;
91
const float cloudScale = .2;
92
const float softness = .2;
93
const float brightness = 1.;
94
const int noiseOctaves = 8;
95
const float curlStrain = 3.;
96
97
float saturate(float num) {
98
return clamp(num, 0., 1.);
99
}
100
101
float noise(vec2 uv) {
102
return color(uv);
103
}
104
105
float sdSegment(vec2 p, vec2 a, vec2 b) {
106
vec2 ap = p - a;
107
vec2 ab = b - a;
108
float h = clamp(dot(ap, ab) / dot(ab, ab), 0., 1.);
109
return length(ap - ab * h);
110
}
111
float random(vec2 st) {
112
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) *
113
43758.5453123);
114
}
115
116
vec2 rotate(vec2 uv) {
117
uv = uv + noise(uv * .2) * .005;
118
float rot = curlStrain;
119
float sinRot = sin(rot);
120
float cosRot = cos(rot);
121
mat2 rotMat = mat2(cosRot, -sinRot, sinRot, cosRot);
122
return uv * rotMat;
123
}
124
125
float fbm(vec2 uv) {
126
float rot = 1.57;
127
float f = 0.;
128
float total = 0.;
129
float mul = .5;
130
131
for(int i = 0; i < noiseOctaves; i++) {
132
f += noise(uv + u_time * .00015 * timeScale * (1. - mul)) * mul;
133
total += mul;
134
uv *= 3.;
135
uv = rotate(uv);
136
mul *= .5;
137
}
138
return f / total;
139
}
140
141
float easeOutCubic(float number) {
142
return 1. - pow(1. - number, 3.);
143
}
144
145
void main() {
146
147
vec2 st = gl_FragCoord.xy / u_resolution.xy;
148
149
vec2 uv = gl_FragCoord.xy / (4000. * cloudScale);
150
151
vec2 stTrans = (st * 2. - 1.);
152
float angle = atan(stTrans.y / stTrans.x);
153
vec2 a = vec2(0., 0.);
154
vec2 b = vec2(.35, .35) * random(stTrans);
155
156
vec2 rotateSt1 = vec2(rotate2d(angle * 100. * random(stTrans)));
157
158
float cover = 1.1 + .1;
159
160
float bright = brightness * (1.8 - cover);
161
162
float color1 = fbm(uv - .5 + u_time * .004 * timeScale);
163
float color2 = fbm(uv - 10.5 + u_time * .002 * timeScale);
164
165
float clouds1 = smoothstep(1. - cover, min((1. - cover) + softness * 2., 1.), color1);
166
float clouds2 = smoothstep(1. - cover, min((1. - cover) + softness, 1.), color2);
167
168
float cloudsFormComb = saturate(clouds1 + clouds2);
169
170
vec4 skyCol = vec4(.6, .8, 1., 1.);
171
float cloudCol = saturate(saturate(1. - pow(color1, 1.) * .2) * bright);
172
vec4 clouds1Color = vec4(cloudCol, cloudCol, cloudCol, 1.);
173
vec4 clouds2Color = mix(clouds1Color, skyCol, .25);
174
vec4 cloudColComb = 1.5 * mix(clouds1Color, clouds2Color, saturate(clouds2 - clouds1));
175
176
vec4 cloud_colour = mix(skyCol, cloudColComb, cloudsFormComb);
177
178
//orchid
179
float mask = 1.;
180
mask *= orchidSides(st - .5, 1., 0., 0., 3., 2., .1, .5);
181
mask *= orchidSides(rotate2d(PI / 2.) * (st - .5), 1., 0., 3., 3., 1., .05, 1.);
182
mask *= orchidSides(rotate2d(PI * 6. / 4.) * (st - .5), 1.2, 1., 3., 3., 1., .05, 1.);
183
float fun = 1. * exp(-1. * sqrt(pow(st.x - .5, 2.) + pow(st.y - .5, 2.)));
184
185
vec4 objcolor = mix(vec4(1.), vec4(.478, .568, .176, 1.), fun);
186
187
colour_out = mainImage(gl_FragCoord.xy, u_resolution.xy) * objcolor;
188
189
if(1. - mask == 1.) {
190
colour_out *= (1. - mask);
191
if(distance(0., rotateSt1.x) <= .03) {
192
colour_out *= vec4(0.4431, 1., 0.1941, 1.0);
193
}
194
float t = 0.;
195
for(int i = 0; i <= 55; i++) {
196
t += 1.;
197
b.y += pow(-1., t) * .1 * abs(cos(t));
198
b *= rotate2d(PI / 27.);
199
if(sdSegment(stTrans.xy, a, b) <= .01) {
200
if(i > 12 && i < 28)
201
colour_out = vec4(.478, .768, .176, .9) * (2. - distance(stTrans, vec2(0.)));
202
else if(i > 38 && i < 55)
203
colour_out = vec4(.478, .768, .176, .9) * (2. - distance(stTrans, vec2(0.)));
204
// else
205
// colour_out = vec4(0.4431, 1., 0.1941, 1.0) * (2. - distance(stTrans, vec2(0.0)));
206
}
207
208
}
209
if(distance(vec2(0.), stTrans) < .05 * cos(stTrans.y * 15. * PI)) {
210
colour_out = vec4(.9608, .8902, .2627, 1.);
211
}
212
213
} else
214
colour_out = cloud_colour;
215
216
// colour_out = objcolor*orchids;
217
218
}
Phalaenopsis Orchid Stem Green by
oneAAAIaDayKeepsHairAway
// credit: yhoriuchi // orchid: Phalaenopsis orchid uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float PI = 3.141592653589; #define CUMSUM(T,S) { S[0]=0.0; for(int i=0;i<T.length();i++) S[i+1] =S[i]+T[i]; } #define NORMALIZE(T,S,L) { for(int i=1;i<T.length();i++) S[i] = S[i]/S[T.length()]*L; } #define GETIDX(S,ID,N) { ID=-1; for(int i=0;i<S.length();i++)ID+=int(step(S[i],N)); } #define INITIALIZE(T,S,L,ID,N) { CUMSUM(T,S); NORMALIZE(T,S,L); GETIDX(S,ID,N); } float ease_in_ease_out(float p, float n){ return (sign(p-0.5)+1.0)*0.5 + sign(0.5-p) * pow( 1.0-abs(p*2.0-1.0), n ) *0.5; } // アルファブレンド vec4 alpha_blend(vec4 back, vec4 fore){ float outA = fore.w + back.w * (1.0-fore.w); if(outA==0.0){ return vec4(0.0); }else{ return vec4( mix( back.xyz*back.w, fore.xyz, fore.w ), outA); } } // 線分 float lineseg(vec2 se, vec2 start, vec2 end, float thickness){ vec2 _se = end-start; float scale = length(_se); //長さ vec2 pos = mat2( _se.x, _se.y, _se.y, -_se.x )*(se-start)/scale/vec2(scale,1.0); pos.y = abs(pos.y); if( pos.x>0.0 && pos.x<1.0 && pos.y<thickness ) return 1.0; else return 0.0; } vec4 logo(vec2 st, vec2 lt, vec2 rb){ float W = rb.x - lt.x; float H = lt.y - rb.y; vec2 pos = vec2( (st.x-lt.x)/W, (st.y-rb.y)/H ); float v = 0.0; v += lineseg( pos, vec2( 0.00, 0.00 ), vec2( 0.26, 0.74 ), 0.015 ); // 左部分 v += lineseg( pos, vec2( 0.00, 1.00 ), vec2( 0.26, 0.26 ), 0.015 ); // 左部分 v += lineseg( pos, vec2( 0.02, 0.50 ), vec2( 0.26, 0.26 ), 0.015 ); // 左部分 v += lineseg( pos, vec2( 0.02, 0.50 ), vec2( 0.26, 0.74 ), 0.015 ); // 左部分 v += lineseg( pos, vec2( 1.00, 0.00 ), vec2( 0.74, 0.74 ), 0.015 ); // 右部分 v += lineseg( pos, vec2( 1.00, 1.00 ), vec2( 0.74, 0.26 ), 0.015 ); // 右部分 v += lineseg( pos, vec2( 0.93, 0.50 ), vec2( 0.74, 0.26 ), 0.015 ); // 右部分 v += lineseg( pos, vec2( 0.93, 0.50 ), vec2( 0.74, 0.74 ), 0.015 ); // 右部分 v += lineseg( pos, vec2( 0.26, 0.74 ), vec2( 0.74, 0.74 ), 0.015 ); // 中部分 v += lineseg( pos, vec2( 0.26, 0.26 ), vec2( 0.74, 0.26 ), 0.015 ); // 中部分 v += lineseg( pos, vec2( 0.50, 0.50 ), vec2( 1.00, 0.00 ), 0.015 ); // 中部分 v += lineseg( pos, vec2( 0.26, 0.26 ), vec2( 0.74, 0.74 ), 0.030 ); // 中部分y v += lineseg( pos, vec2( 0.26, 0.74 ), vec2( 0.50, 0.50 ), 0.030 ); // 中部分y v += lineseg( pos, vec2( 0.00, 1.00 ), vec2( 0.26, 0.74 ), 0.050 ); // en 左上 v += lineseg( pos, vec2( 0.00, 0.00 ), vec2( 0.26, 0.26 ), 0.050 ); // en 左下 v += lineseg( pos, vec2( 1.00, 1.00 ), vec2( 0.74, 0.74 ), 0.050 ); // en 右上 v += lineseg( pos, vec2( 0.02, 0.50 ), vec2( 0.18, 0.50 ), 0.040 ); // bar 左 v += lineseg( pos, vec2( 0.98, 0.50 ), vec2( 0.82, 0.50 ), 0.040 ); // bar 右 return vec4(1.0, 0.0, 1.0, 1.0) * clamp(v, 0.0, 1.0); } vec4 thankyou(vec2 st, vec2 lt, vec2 rb){ float W = rb.x - lt.x; float H = lt.y - rb.y; vec2 pos = vec2( (st.x-lt.x)/W, (st.y-rb.y)/H );/// * vec2(1.1,1.0); float v = 0.0; float b = 0.015; float B = 0.05; pos -= vec2(0.01,0.0); v += lineseg( pos, vec2( 0.02, 0.95), vec2( 0.08, 0.95), B ); // T v += lineseg( pos, vec2( 0.05, 1.0 ), vec2( 0.05, 0.0 ), b ); // T pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 0.5 ), vec2( 0.08, 0.5 ), B ); // H v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.02, 0.0 ), b ); // H v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // H pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.08, 1.0 ), b ); // A v += lineseg( pos, vec2( 0.05, 0.5 ), vec2( 0.08, 0.5 ), B ); // A v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // A pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.02, 1.0 ), b ); // N v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.08, 0.0 ), b ); // N v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // N pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.02, 1.0 ), b ); // K v += lineseg( pos, vec2( 0.02, 0.5 ), vec2( 0.08, 1.0 ), b ); // K v += lineseg( pos, vec2( 0.02, 0.5 ), vec2( 0.08, 0.0 ), b ); // K pos -= vec2(0.11,0.0); pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.05, 0.5 ), b ); // Y v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.05, 0.5 ), b ); // Y v += lineseg( pos, vec2( 0.05, 0.5 ), vec2( 0.05, 0.0 ), b ); // Y pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.08, 1.0 ), B ); // O v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.08, 0.0 ), B ); // O v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.02, 0.0 ), b ); // O v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // O pos -= vec2(0.11,0.0); v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.08, 0.0 ), B ); // U v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.02, 0.0 ), b ); // U v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // U return vec4(1.0, 1.0, 1.0, 1.0) * clamp(v, 0.0, 1.0); } //////////////////////////////////////////////////////////////////////////////// vec4 mainScene(vec2 st, float time, float duration){ st = (st-vec2(0.5,0.5))*1.1 +vec2(0.5,0.5); float ts = 1.0; float cts = 2.0; vec2 d = vec2( sin(time*ts), cos(time*ts) ); float mask0 = 1.0; float mask1 = 1.0; float mask2 = 1.0; float mask3 = 1.0; float mask4 = 1.0; mask0 *= step( abs(st.x-0.5), 0.1 )*step(st.y, 0.5); // 上 st -= d*vec2(0.02,0.03); mask1 *= step( 0.1, distance( (st.xy-vec2(0.50, 0.8))/vec2(2.0,4.0), vec2(0.0) ) ); // 上 st += d*vec2(0.07,0.03); mask2 *= step( 0.1, distance( (st.xy-vec2(0.25, 0.6))/vec2(3.0,3.0), vec2(0.0) ) ); // 左 mask2 *= step( 0.1, distance( (st.xy-vec2(0.75, 0.6))/vec2(3.0,3.0), vec2(0.0) ) ); // 右 st -= d*vec2(0.03,0.04); mask3 *= step( 0.1, distance( (st.xy-vec2(0.35, 0.3))/vec2(2.0,1.5), vec2(0.0) ) ); // 左下 mask3 *= step( 0.1, distance( (st.xy-vec2(0.65, 0.3))/vec2(2.0,1.5), vec2(0.0) ) ); // 右下 st += d*vec2(0.04,0.02); mask4 *= step( 0.1, distance( (st.xy-vec2(0.40, 0.4))/vec2(1.0,1.0), vec2(0.0) ) ); // 左 mask4 *= step( 0.1, distance( (st.xy-vec2(0.60, 0.4))/vec2(1.0,1.0), vec2(0.0) ) ); // 右 vec4 result = vec4(0.0); result = alpha_blend( result, vec4( 0.0, 0.8-st.y, 0.1*abs(sin(cts*time+0.0)), mask0 ) ); result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.0)), (1.0-mask1)*0.9 ) ); result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.3)), (1.0-mask2)*0.9 ) ); result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.6)), (1.0-mask3)*0.9 ) ); result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.9)), (1.0-mask4)*0.9 ) ); vec4[] flowerModel = vec4[]( vec4(0.0), vec4(1.0), vec4(2.0) ); return vec4(result.xyz, 1.0); } vec4 title(vec2 st, float time, float duration){ return vec4(0.8, 0.0, 0.0, 1.0); } vec4 ending(vec2 st, float time, float duration){ float[] timeschedule = float[]( 0.5, // black 1.0, // fade in 2.0, // white 1.3, // fade out 0.7); // black float start_times[ timeschedule.length()+1 ]; // 各ステップ開始時刻 int stepID; // ステップ番号 INITIALIZE( timeschedule, start_times, duration, stepID, time ); float p; switch(stepID){ case 0: p = 0.0; break; case 1: p = (time-start_times[stepID])/(start_times[stepID+1]-start_times[stepID]); break; case 2: p = 1.0; break; case 3: p = 1.0 - (time-start_times[stepID])/(start_times[stepID+1]-start_times[stepID]); break; case 4: p = 0.0; break; } float mask = ease_in_ease_out( p, 2.0 ); return alpha_blend( alpha_blend( alpha_blend( vec4(0.0,0.0,0.0,1.0), logo( st, vec2(0.8,0.2), vec2(0.9,0.1) ) ), thankyou( st, vec2(0.2,0.55), vec2(0.8,0.45) ) ), vec4(vec3(0.0),1.0-mask) ); //return vec4( logo(st, vec2(0.8,0.2), vec2(0.9,0.1) ).xyz*vec3(mask), 1.0); } // シークバー vec4 seek_bar(vec2 st, float time, float duration, float alpha){ vec4 c; if( st.y<0.015 ){ if( st.x<time/duration ){ c = vec4(1.0, 0.0, 0.0, alpha); }else{ c = vec4(0.4, 0.4, 0.4, alpha); } }else{ c = vec4(0.0); } return c; } void main() { ///// 初期設定 //// // 座標 vec2 st = gl_FragCoord.xy/u_resolution.xy; // 各シーンの時間 float[] timeschedule = float[]( 0.0, // title 30.0, // 通常 5.0 ); // ending 5.0 float start_times[ timeschedule.length()+1 ]; // 各シーンの開始時刻 ( +[シーン終了時刻] ) CUMSUM(timeschedule,start_times); float time = mod(u_time, start_times[timeschedule.length()]); // 現在時刻 float timeMax = start_times[timeschedule.length()]; // 時刻最大 int sceneID; GETIDX(start_times, sceneID, time); // シーンの特定 ///// レンダリング ///// // シーン毎にレンダリング float sceneTime = time-start_times[sceneID]; float sceneDuration = timeschedule[sceneID]; switch(sceneID){ case 0: colour_out = title( st, sceneTime, sceneDuration); break; case 1: colour_out = mainScene(st, sceneTime, sceneDuration); break; case 2: colour_out = ending( st, sceneTime, sceneDuration); break; } ///// シークバー ///// colour_out = alpha_blend( colour_out, seek_bar(st,time,timeMax, 0.8) ); }
250
1
// credit: yhoriuchi
2
// orchid: Phalaenopsis orchid
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
const float PI = 3.141592653589;
8
9
10
11
12
13
14
15
float ease_in_ease_out(float p, float n){
16
return (sign(p-0.5)+1.0)*0.5 + sign(0.5-p) * pow( 1.0-abs(p*2.0-1.0), n ) *0.5;
17
}
18
// アルファブレンド
19
vec4 alpha_blend(vec4 back, vec4 fore){
20
float outA = fore.w + back.w * (1.0-fore.w);
21
if(outA==0.0){
22
return vec4(0.0);
23
}else{
24
return vec4( mix( back.xyz*back.w, fore.xyz, fore.w ), outA);
25
}
26
}
27
28
// 線分
29
float lineseg(vec2 se, vec2 start, vec2 end, float thickness){
30
vec2 _se = end-start;
31
float scale = length(_se); //長さ
32
vec2 pos = mat2( _se.x, _se.y,
33
_se.y, -_se.x )*(se-start)/scale/vec2(scale,1.0);
34
pos.y = abs(pos.y);
35
if( pos.x>0.0 && pos.x<1.0 && pos.y<thickness ) return 1.0;
36
else return 0.0;
37
}
38
39
vec4 logo(vec2 st, vec2 lt, vec2 rb){
40
float W = rb.x - lt.x;
41
float H = lt.y - rb.y;
42
vec2 pos = vec2( (st.x-lt.x)/W, (st.y-rb.y)/H );
43
44
float v = 0.0;
45
v += lineseg( pos, vec2( 0.00, 0.00 ), vec2( 0.26, 0.74 ), 0.015 ); // 左部分
46
v += lineseg( pos, vec2( 0.00, 1.00 ), vec2( 0.26, 0.26 ), 0.015 ); // 左部分
47
v += lineseg( pos, vec2( 0.02, 0.50 ), vec2( 0.26, 0.26 ), 0.015 ); // 左部分
48
v += lineseg( pos, vec2( 0.02, 0.50 ), vec2( 0.26, 0.74 ), 0.015 ); // 左部分
49
50
v += lineseg( pos, vec2( 1.00, 0.00 ), vec2( 0.74, 0.74 ), 0.015 ); // 右部分
51
v += lineseg( pos, vec2( 1.00, 1.00 ), vec2( 0.74, 0.26 ), 0.015 ); // 右部分
52
v += lineseg( pos, vec2( 0.93, 0.50 ), vec2( 0.74, 0.26 ), 0.015 ); // 右部分
53
v += lineseg( pos, vec2( 0.93, 0.50 ), vec2( 0.74, 0.74 ), 0.015 ); // 右部分
54
55
v += lineseg( pos, vec2( 0.26, 0.74 ), vec2( 0.74, 0.74 ), 0.015 ); // 中部分
56
v += lineseg( pos, vec2( 0.26, 0.26 ), vec2( 0.74, 0.26 ), 0.015 ); // 中部分
57
v += lineseg( pos, vec2( 0.50, 0.50 ), vec2( 1.00, 0.00 ), 0.015 ); // 中部分
58
59
v += lineseg( pos, vec2( 0.26, 0.26 ), vec2( 0.74, 0.74 ), 0.030 ); // 中部分y
60
v += lineseg( pos, vec2( 0.26, 0.74 ), vec2( 0.50, 0.50 ), 0.030 ); // 中部分y
61
62
v += lineseg( pos, vec2( 0.00, 1.00 ), vec2( 0.26, 0.74 ), 0.050 ); // en 左上
63
v += lineseg( pos, vec2( 0.00, 0.00 ), vec2( 0.26, 0.26 ), 0.050 ); // en 左下
64
v += lineseg( pos, vec2( 1.00, 1.00 ), vec2( 0.74, 0.74 ), 0.050 ); // en 右上
65
66
v += lineseg( pos, vec2( 0.02, 0.50 ), vec2( 0.18, 0.50 ), 0.040 ); // bar 左
67
v += lineseg( pos, vec2( 0.98, 0.50 ), vec2( 0.82, 0.50 ), 0.040 ); // bar 右
68
69
return vec4(1.0, 0.0, 1.0, 1.0) * clamp(v, 0.0, 1.0);
70
}
71
72
vec4 thankyou(vec2 st, vec2 lt, vec2 rb){
73
float W = rb.x - lt.x;
74
float H = lt.y - rb.y;
75
vec2 pos = vec2( (st.x-lt.x)/W, (st.y-rb.y)/H );/// * vec2(1.1,1.0);
76
77
float v = 0.0;
78
float b = 0.015; float B = 0.05;
79
80
pos -= vec2(0.01,0.0);
81
v += lineseg( pos, vec2( 0.02, 0.95), vec2( 0.08, 0.95), B ); // T
82
v += lineseg( pos, vec2( 0.05, 1.0 ), vec2( 0.05, 0.0 ), b ); // T
83
pos -= vec2(0.11,0.0);
84
v += lineseg( pos, vec2( 0.02, 0.5 ), vec2( 0.08, 0.5 ), B ); // H
85
v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.02, 0.0 ), b ); // H
86
v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // H
87
pos -= vec2(0.11,0.0);
88
v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.08, 1.0 ), b ); // A
89
v += lineseg( pos, vec2( 0.05, 0.5 ), vec2( 0.08, 0.5 ), B ); // A
90
v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // A
91
pos -= vec2(0.11,0.0);
92
v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.02, 1.0 ), b ); // N
93
v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.08, 0.0 ), b ); // N
94
v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // N
95
pos -= vec2(0.11,0.0);
96
v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.02, 1.0 ), b ); // K
97
v += lineseg( pos, vec2( 0.02, 0.5 ), vec2( 0.08, 1.0 ), b ); // K
98
v += lineseg( pos, vec2( 0.02, 0.5 ), vec2( 0.08, 0.0 ), b ); // K
99
pos -= vec2(0.11,0.0);
100
pos -= vec2(0.11,0.0);
101
v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.05, 0.5 ), b ); // Y
102
v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.05, 0.5 ), b ); // Y
103
v += lineseg( pos, vec2( 0.05, 0.5 ), vec2( 0.05, 0.0 ), b ); // Y
104
pos -= vec2(0.11,0.0);
105
v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.08, 1.0 ), B ); // O
106
v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.08, 0.0 ), B ); // O
107
v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.02, 0.0 ), b ); // O
108
v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // O
109
pos -= vec2(0.11,0.0);
110
v += lineseg( pos, vec2( 0.02, 0.0 ), vec2( 0.08, 0.0 ), B ); // U
111
v += lineseg( pos, vec2( 0.02, 1.0 ), vec2( 0.02, 0.0 ), b ); // U
112
v += lineseg( pos, vec2( 0.08, 1.0 ), vec2( 0.08, 0.0 ), b ); // U
113
114
return vec4(1.0, 1.0, 1.0, 1.0) * clamp(v, 0.0, 1.0);
115
}
116
117
118
////////////////////////////////////////////////////////////////////////////////
119
120
vec4 mainScene(vec2 st, float time, float duration){
121
122
st = (st-vec2(0.5,0.5))*1.1 +vec2(0.5,0.5);
123
124
float ts = 1.0; float cts = 2.0;
125
vec2 d = vec2( sin(time*ts), cos(time*ts) );
126
127
float mask0 = 1.0;
128
float mask1 = 1.0;
129
float mask2 = 1.0;
130
float mask3 = 1.0;
131
float mask4 = 1.0;
132
mask0 *= step( abs(st.x-0.5), 0.1 )*step(st.y, 0.5); // 上
133
134
st -= d*vec2(0.02,0.03);
135
mask1 *= step( 0.1, distance( (st.xy-vec2(0.50, 0.8))/vec2(2.0,4.0), vec2(0.0) ) ); // 上
136
st += d*vec2(0.07,0.03);
137
mask2 *= step( 0.1, distance( (st.xy-vec2(0.25, 0.6))/vec2(3.0,3.0), vec2(0.0) ) ); // 左
138
mask2 *= step( 0.1, distance( (st.xy-vec2(0.75, 0.6))/vec2(3.0,3.0), vec2(0.0) ) ); // 右
139
st -= d*vec2(0.03,0.04);
140
mask3 *= step( 0.1, distance( (st.xy-vec2(0.35, 0.3))/vec2(2.0,1.5), vec2(0.0) ) ); // 左下
141
mask3 *= step( 0.1, distance( (st.xy-vec2(0.65, 0.3))/vec2(2.0,1.5), vec2(0.0) ) ); // 右下
142
st += d*vec2(0.04,0.02);
143
mask4 *= step( 0.1, distance( (st.xy-vec2(0.40, 0.4))/vec2(1.0,1.0), vec2(0.0) ) ); // 左
144
mask4 *= step( 0.1, distance( (st.xy-vec2(0.60, 0.4))/vec2(1.0,1.0), vec2(0.0) ) ); // 右
145
146
vec4 result = vec4(0.0);
147
result = alpha_blend( result, vec4( 0.0, 0.8-st.y, 0.1*abs(sin(cts*time+0.0)), mask0 ) );
148
result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.0)), (1.0-mask1)*0.9 ) );
149
result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.3)), (1.0-mask2)*0.9 ) );
150
result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.6)), (1.0-mask3)*0.9 ) );
151
result = alpha_blend( result, vec4( st.x, st.y, abs(sin(cts*time+0.9)), (1.0-mask4)*0.9 ) );
152
153
vec4[] flowerModel = vec4[]( vec4(0.0), vec4(1.0), vec4(2.0) );
154
155
return vec4(result.xyz, 1.0);
156
157
}
158
vec4 title(vec2 st, float time, float duration){
159
return vec4(0.8, 0.0, 0.0, 1.0);
160
}
161
vec4 ending(vec2 st, float time, float duration){
162
float[] timeschedule = float[]( 0.5, // black
163
1.0, // fade in
164
2.0, // white
165
1.3, // fade out
166
0.7); // black
167
float start_times[ timeschedule.length()+1 ]; // 各ステップ開始時刻
168
int stepID; // ステップ番号
169
INITIALIZE( timeschedule, start_times, duration, stepID, time );
170
171
float p;
172
switch(stepID){
173
case 0:
174
p = 0.0;
175
break;
176
case 1:
177
p = (time-start_times[stepID])/(start_times[stepID+1]-start_times[stepID]);
178
break;
179
case 2:
180
p = 1.0;
181
break;
182
case 3:
183
p = 1.0 - (time-start_times[stepID])/(start_times[stepID+1]-start_times[stepID]);
184
break;
185
case 4:
186
p = 0.0;
187
break;
188
}
189
190
float mask = ease_in_ease_out( p, 2.0 );
191
192
return alpha_blend( alpha_blend( alpha_blend( vec4(0.0,0.0,0.0,1.0),
193
logo( st, vec2(0.8,0.2), vec2(0.9,0.1) ) ),
194
thankyou( st, vec2(0.2,0.55), vec2(0.8,0.45) ) ),
195
vec4(vec3(0.0),1.0-mask) );
196
197
198
//return vec4( logo(st, vec2(0.8,0.2), vec2(0.9,0.1) ).xyz*vec3(mask), 1.0);
199
}
200
201
// シークバー
202
vec4 seek_bar(vec2 st, float time, float duration, float alpha){
203
vec4 c;
204
if( st.y<0.015 ){
205
if( st.x<time/duration ){
206
c = vec4(1.0, 0.0, 0.0, alpha);
207
}else{
208
c = vec4(0.4, 0.4, 0.4, alpha);
209
}
210
}else{
211
c = vec4(0.0);
212
}
213
return c;
214
}
215
216
217
218
void main() {
219
///// 初期設定 ////
220
221
// 座標
222
vec2 st = gl_FragCoord.xy/u_resolution.xy;
223
224
// 各シーンの時間
225
float[] timeschedule = float[]( 0.0, // title
226
30.0, // 通常
227
5.0 ); // ending 5.0
228
float start_times[ timeschedule.length()+1 ]; // 各シーンの開始時刻 ( +[シーン終了時刻] )
229
CUMSUM(timeschedule,start_times);
230
float time = mod(u_time, start_times[timeschedule.length()]); // 現在時刻
231
float timeMax = start_times[timeschedule.length()]; // 時刻最大
232
int sceneID; GETIDX(start_times, sceneID, time); // シーンの特定
233
234
235
///// レンダリング /////
236
237
// シーン毎にレンダリング
238
float sceneTime = time-start_times[sceneID];
239
float sceneDuration = timeschedule[sceneID];
240
switch(sceneID){
241
case 0: colour_out = title( st, sceneTime, sceneDuration); break;
242
case 1: colour_out = mainScene(st, sceneTime, sceneDuration); break;
243
case 2: colour_out = ending( st, sceneTime, sceneDuration); break;
244
}
245
246
247
///// シークバー /////
248
249
colour_out = alpha_blend( colour_out, seek_bar(st,time,timeMax, 0.8) );
250
}
Phalaenopsis orchid by yhoriuchi
// credit: Liu Yang (will show up on website) // orchid: phalaenopsis_hybrid_0 uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; #define PI 3.14159265358979323846 float smoothMerge(float d1, float d2, float k){ float h = clamp(0.5 + 0.5*(d2 - d1)/k, 0.0, 1.0); return mix(d2, d1, h) - k * h * (1.0-h); } float substract(float d1, float d2){ return max(-d1, d2); } float intersect(float d1, float d2){ return max(d1, d2); } float ellipseDist(vec2 p, float radius, vec2 dim){ vec2 pos = p; pos.x = p.x / dim.x; pos.y = p.y / dim.y; return length(pos) - radius; } float circleDist(vec2 p, float radius){ return length(p) - radius; } mat2 rotate2dm(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } float when_eq(float x, float y) { return 1.0 - abs(sign(x - y)); } vec2 tile (vec2 _st, float _zoom) { _st *= _zoom; return fract(_st); } float orcSepals(vec2 toCenter, float resize, float defX, float defY, float grow, float nPetals, float smoothness){ float angle = atan(toCenter.y,toCenter.x) + 0.5; float deformOnY = toCenter.y * defY; float deformOnX = abs(toCenter.x) * defX; float radius = length(toCenter)*resize * (grow+deformOnY+deformOnX); float f = cos(angle*nPetals); return smoothstep(f, f+smoothness,radius); } float lip(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){ float A = ellipseDist(pos, radius, oval); vec2 posB = pos; posB.y += offset; float B = ellipseDist(posB, radius, ovalSub); float p = smoothMerge(B, A, 0.5); return p; } float orcColumn(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){ float A = ellipseDist(pos, radius, ovalSub); vec2 posB = pos; posB.y -= offset; float B = ellipseDist(posB, radius, oval); float p = substract(B,A); posB.y += 0.035; float cone = ellipseDist(posB, radius, vec2(0.055, 0.30)); p = smoothMerge(cone,p, 0.4); float s = ellipseDist(posB, radius, vec2(0.2, 0.20)); return p; } float flip(float v, float pct){ return mix(v, 1. - v, pct); } float fillSmooth(float sdfVal, float size, float smoothness){ return smoothstep(size, size+smoothness,sdfVal); } float strokeSmoot(float x, float pos, float width, float smtness){ return smoothstep(pos, pos+smtness,x+ width*0.5) - smoothstep(pos, pos+smtness,x- width*0.5); } float rand(vec2 uv){ return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453); } void main(){ float smoothness = 0.03; vec2 st = gl_FragCoord.xy/u_resolution.xy; st.x *= u_resolution.x / u_resolution.y; vec2 orcSt = tile(st,1.0); // Orchid parameters. The orchid is composed by sepals, petals, lip and column orcSt+=vec2(-0.5, -0.5); //column parameters float colResize = 0.45; vec2 posCol = orcSt; posCol.y += 0.035; float colYoffset = -0.051; float powerCol = 2.; vec2 colRatio = vec2(0.7*colResize, 0.7*colResize); vec2 colSubRatio = vec2(0.9*colResize, 0.9*colResize); float colRadius = 0.52*colResize; // sepals parameters float addSmoothnessToSetals = 2.9; float deformX = 0.; float deformY = 0.; float resizePetals = 11.9; float powerSepals = 2.0; float nPetals = 3.; float growSepals = exp2(length(orcSt)) * 0.19; float nPetalsLat = 2.; float deformXLat = 0.0; float deformYLat = -0.0; float resizePetalsLat = 21.9; float powerLat = 2.3; vec2 latPos = orcSt*rotate2dm(PI*2.0/2.4); float growLaterals = pow(length(orcSt), powerLat); // lip parameter vec2 posLip = orcSt; posLip.y += 0.18; float lipResize = 0.6; float lipYoffset = 0.05; vec2 lipRatio = vec2(0.19*lipResize, 0.45*lipResize); vec2 smallLipRatio = vec2(0.3*lipResize, 0.15*lipResize); float lipRadius = 1.*lipResize; float column = orcColumn(posCol*rotate2dm(PI), colRatio, colSubRatio, colRadius, colYoffset); float sepals = orcSepals(orcSt, resizePetals, deformX, deformY, growSepals, nPetals, smoothness+addSmoothnessToSetals); float latPetals = orcSepals(latPos, resizePetalsLat, deformXLat, deformYLat, growLaterals, nPetalsLat, smoothness+addSmoothnessToSetals); float lip = lip(posLip, lipRatio, smallLipRatio, lipRadius, lipYoffset); float orchids = min(latPetals, sepals); orchids = min(orchids, lip); orchids = substract(column, orchids); float angle = atan(orcSt.y,orcSt.x) + 0.5; // this angle is using while creating the colors vec3 lip_Color = vec3(0.843,0.125,0.101);//花中间和花屁股 vec3 sepals_Texture_Color = vec3(0.898,0.229,0.394); //纹路 vec3 sepals_Color = vec3(0.387,0.033,0.500);//1 vec3 petals_Color = vec3(0.772,0.324,0.946);//花朵 vec3 points_Color = vec3(0.832,0.081,0.843); vec3 line_Color = vec3(0.603,0.077,0.545); // Background vec3 bgCol = vec3(0,0,0); // Sepals color: sepals = fillSmooth(sepals,0.09,smoothness+0.005); vec3 sepalsColor = mix(sepals_Texture_Color, sepals_Color, rand(orcSt)); vec3 orcColor = mix(sepalsColor, bgCol, sepals); // Lip color: // 1 create the space coord for the points vec2 lipSt = orcSt; lipSt = fract(lipSt *= 20.); lipSt -=vec2(0.5,0.5); // 2 create the color points float points = circleDist(lipSt, 0.1); points = smoothstep(points, points+0.05, 0.2); vec3 colorPoints = mix(lip_Color, points_Color, points); // 3 mix the color with the orchid lip = fillSmooth(lip,0.09,smoothness+0.005); orcColor = mix(colorPoints, orcColor, lip); // Petals color latPetals = fillSmooth(latPetals,0.09,smoothness+0.005); vec3 latPetalsColor = mix(line_Color, petals_Color, sin(angle * 40.0)); latPetalsColor = mix(latPetalsColor, petals_Color, abs(orcSt.x)*2.7); orcColor = mix(latPetalsColor,orcColor,latPetals); //column color column = fillSmooth(column,0.01,0.02); vec3 columnColor = lip_Color - petals_Color * (orcSt.y *2.); orcColor = mix(columnColor, orcColor, column); colour_out = vec4(vec3(orcColor),1.0); }
208
1
// credit: Liu Yang (will show up on website)
2
// orchid: phalaenopsis_hybrid_0
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
8
9
float smoothMerge(float d1, float d2, float k){
10
float h = clamp(0.5 + 0.5*(d2 - d1)/k, 0.0, 1.0);
11
return mix(d2, d1, h) - k * h * (1.0-h);
12
}
13
14
float substract(float d1, float d2){
15
return max(-d1, d2);
16
}
17
18
float intersect(float d1, float d2){
19
return max(d1, d2);
20
}
21
22
23
float ellipseDist(vec2 p, float radius, vec2 dim){
24
vec2 pos = p;
25
pos.x = p.x / dim.x;
26
pos.y = p.y / dim.y;
27
return length(pos) - radius;
28
}
29
30
float circleDist(vec2 p, float radius){
31
return length(p) - radius;
32
}
33
34
mat2 rotate2dm(float _angle){
35
return mat2(cos(_angle),-sin(_angle),
36
sin(_angle),cos(_angle));
37
}
38
39
float when_eq(float x, float y) {
40
return 1.0 - abs(sign(x - y));
41
}
42
43
vec2 tile (vec2 _st, float _zoom) {
44
_st *= _zoom;
45
return fract(_st);
46
}
47
48
float orcSepals(vec2 toCenter, float resize, float defX, float defY,
49
float grow, float nPetals, float smoothness){
50
float angle = atan(toCenter.y,toCenter.x) + 0.5;
51
float deformOnY = toCenter.y * defY;
52
float deformOnX = abs(toCenter.x) * defX;
53
float radius = length(toCenter)*resize * (grow+deformOnY+deformOnX);
54
55
float f = cos(angle*nPetals);
56
return smoothstep(f, f+smoothness,radius);
57
}
58
59
float lip(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){
60
float A = ellipseDist(pos, radius, oval);
61
vec2 posB = pos;
62
posB.y += offset;
63
float B = ellipseDist(posB, radius, ovalSub);
64
float p = smoothMerge(B, A, 0.5);
65
return p;
66
}
67
68
float orcColumn(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){
69
float A = ellipseDist(pos, radius, ovalSub);
70
vec2 posB = pos;
71
posB.y -= offset;
72
float B = ellipseDist(posB, radius, oval);
73
float p = substract(B,A);
74
posB.y += 0.035;
75
float cone = ellipseDist(posB, radius, vec2(0.055, 0.30));
76
p = smoothMerge(cone,p, 0.4);
77
float s = ellipseDist(posB, radius, vec2(0.2, 0.20));
78
return p;
79
}
80
81
82
float flip(float v, float pct){
83
return mix(v, 1. - v, pct);
84
}
85
86
float fillSmooth(float sdfVal, float size, float smoothness){
87
return smoothstep(size, size+smoothness,sdfVal);
88
}
89
90
float strokeSmoot(float x, float pos, float width, float smtness){
91
return smoothstep(pos, pos+smtness,x+ width*0.5) -
92
smoothstep(pos, pos+smtness,x- width*0.5);
93
}
94
95
float rand(vec2 uv){
96
return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453);
97
}
98
99
100
void main(){
101
102
float smoothness = 0.03;
103
104
vec2 st = gl_FragCoord.xy/u_resolution.xy;
105
st.x *= u_resolution.x / u_resolution.y;
106
vec2 orcSt = tile(st,1.0);
107
108
// Orchid parameters. The orchid is composed by sepals, petals, lip and column
109
orcSt+=vec2(-0.5, -0.5);
110
//column parameters
111
float colResize = 0.45;
112
vec2 posCol = orcSt;
113
posCol.y += 0.035;
114
float colYoffset = -0.051;
115
float powerCol = 2.;
116
vec2 colRatio = vec2(0.7*colResize, 0.7*colResize);
117
vec2 colSubRatio = vec2(0.9*colResize, 0.9*colResize);
118
float colRadius = 0.52*colResize;
119
// sepals parameters
120
float addSmoothnessToSetals = 2.9;
121
float deformX = 0.;
122
float deformY = 0.;
123
float resizePetals = 11.9;
124
float powerSepals = 2.0;
125
float nPetals = 3.;
126
float growSepals = exp2(length(orcSt)) * 0.19;
127
float nPetalsLat = 2.;
128
float deformXLat = 0.0;
129
float deformYLat = -0.0;
130
float resizePetalsLat = 21.9;
131
float powerLat = 2.3;
132
vec2 latPos = orcSt*rotate2dm(PI*2.0/2.4);
133
float growLaterals = pow(length(orcSt), powerLat);
134
// lip parameter
135
vec2 posLip = orcSt;
136
posLip.y += 0.18;
137
float lipResize = 0.6;
138
float lipYoffset = 0.05;
139
vec2 lipRatio = vec2(0.19*lipResize, 0.45*lipResize);
140
vec2 smallLipRatio = vec2(0.3*lipResize, 0.15*lipResize);
141
float lipRadius = 1.*lipResize;
142
143
float column = orcColumn(posCol*rotate2dm(PI),
144
colRatio,
145
colSubRatio,
146
colRadius, colYoffset);
147
float sepals = orcSepals(orcSt,
148
resizePetals,
149
deformX,
150
deformY, growSepals, nPetals,
151
smoothness+addSmoothnessToSetals);
152
float latPetals = orcSepals(latPos,
153
resizePetalsLat,
154
deformXLat,
155
deformYLat, growLaterals, nPetalsLat,
156
smoothness+addSmoothnessToSetals);
157
float lip = lip(posLip,
158
lipRatio,
159
smallLipRatio,
160
lipRadius, lipYoffset);
161
162
float orchids = min(latPetals, sepals);
163
orchids = min(orchids, lip);
164
orchids = substract(column, orchids);
165
float angle = atan(orcSt.y,orcSt.x) + 0.5; // this angle is using while creating the colors
166
167
168
169
vec3 lip_Color = vec3(0.843,0.125,0.101);//花中间和花屁股
170
vec3 sepals_Texture_Color = vec3(0.898,0.229,0.394); //纹路
171
vec3 sepals_Color = vec3(0.387,0.033,0.500);//1
172
vec3 petals_Color = vec3(0.772,0.324,0.946);//花朵
173
vec3 points_Color = vec3(0.832,0.081,0.843);
174
vec3 line_Color = vec3(0.603,0.077,0.545);
175
// Background
176
vec3 bgCol = vec3(0,0,0);
177
178
// Sepals color:
179
sepals = fillSmooth(sepals,0.09,smoothness+0.005);
180
vec3 sepalsColor = mix(sepals_Texture_Color, sepals_Color, rand(orcSt));
181
vec3 orcColor = mix(sepalsColor, bgCol, sepals);
182
183
// Lip color:
184
// 1 create the space coord for the points
185
vec2 lipSt = orcSt;
186
lipSt = fract(lipSt *= 20.);
187
lipSt -=vec2(0.5,0.5);
188
// 2 create the color points
189
float points = circleDist(lipSt, 0.1);
190
points = smoothstep(points, points+0.05, 0.2);
191
vec3 colorPoints = mix(lip_Color, points_Color, points);
192
// 3 mix the color with the orchid
193
lip = fillSmooth(lip,0.09,smoothness+0.005);
194
orcColor = mix(colorPoints, orcColor, lip);
195
196
// Petals color
197
latPetals = fillSmooth(latPetals,0.09,smoothness+0.005);
198
vec3 latPetalsColor = mix(line_Color, petals_Color, sin(angle * 40.0));
199
latPetalsColor = mix(latPetalsColor, petals_Color, abs(orcSt.x)*2.7);
200
orcColor = mix(latPetalsColor,orcColor,latPetals);
201
202
//column color
203
column = fillSmooth(column,0.01,0.02);
204
vec3 columnColor = lip_Color - petals_Color * (orcSt.y *2.);
205
orcColor = mix(columnColor, orcColor, column);
206
207
colour_out = vec4(vec3(orcColor),1.0);
208
}
Phalaenopsis Hybrid by Liu Yang
// credit: maopao (will show up on website) // orchid: Blue Vanda Orchid uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 mod7(vec3 x) { return x - floor(x * (1.0 / 7.0)) * 7.0; } // Permutation polynomial: (34x^2 + 6x) mod 289 vec3 permute(vec3 x) { return mod289((34.0 * x + 10.0) * x); } vec2 cellular(vec2 P) { #define K 0.142857142857 // 1/7 #define Ko 0.428571428571 // 3/7 #define jitter 1.0 // Less gives more regular pattern vec2 Pi = mod289(floor(P)); vec2 Pf = fract(P); vec3 oi = vec3(-1.0, 0.0, 1.0); vec3 of = vec3(-0.5, 0.5, 1.5); vec3 px = permute(Pi.x + oi); vec3 p = permute(px.x + Pi.y + oi); // p11, p12, p13 vec3 ox = fract(p*K) - Ko; vec3 oy = mod7(floor(p*K))*K - Ko; vec3 dx = Pf.x + 0.5 + jitter*ox; vec3 dy = Pf.y - of + jitter*oy; vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared p = permute(px.y + Pi.y + oi); // p21, p22, p23 ox = fract(p*K) - Ko; oy = mod7(floor(p*K))*K - Ko; dx = Pf.x - 0.5 + jitter*ox; dy = Pf.y - of + jitter*oy; vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared p = permute(px.z + Pi.y + oi); // p31, p32, p33 ox = fract(p*K) - Ko; oy = mod7(floor(p*K))*K - Ko; dx = Pf.x - 1.5 + jitter*ox; dy = Pf.y - of + jitter*oy; vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared // Sort out the two smallest distances (F1, F2) vec3 d1a = min(d1, d2); d2 = max(d1, d2); // Swap to keep candidates for F2 d2 = min(d2, d3); // neither F1 nor F2 are now in d3 d1 = min(d1a, d2); // F1 is now in d1 d2 = max(d1a, d2); // Swap to keep candidates for F2 d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz d1.y = min(d1.y, d1.z); // nor in d1.z d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done. return sqrt(d1.xy); } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; float mask = 1.0; mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.6, 0.7) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.4, 0.7) ) ); vec4 cc = vec4(0.093,0.090,0.100,0.500); float outx = cellular(st.xy*10.0).x-0.5; float sig_x = 1.0/(exp(outx/-0.15)+1.0); //sigmoid function colour_out = vec4(vec3(0.6-0.3*pow(sig_x,1.0),0.6-0.55*sig_x,1.0-0.1*sig_x),1.0-sig_x/6.0); colour_out *= 1.0-mask; }
1
// credit: maopao (will show up on website)
2
// orchid: Blue Vanda Orchid
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
vec3 mod289(vec3 x) {
7
return x - floor(x * (1.0 / 289.0)) * 289.0;
8
}
9
vec2 mod289(vec2 x) {
10
return x - floor(x * (1.0 / 289.0)) * 289.0;
11
}
12
vec3 mod7(vec3 x) {
13
return x - floor(x * (1.0 / 7.0)) * 7.0;
14
}
15
16
// Permutation polynomial: (34x^2 + 6x) mod 289
17
vec3 permute(vec3 x) {
18
return mod289((34.0 * x + 10.0) * x);
19
}
20
vec2 cellular(vec2 P) {
21
22
23
24
vec2 Pi = mod289(floor(P));
25
vec2 Pf = fract(P);
26
vec3 oi = vec3(-1.0, 0.0, 1.0);
27
vec3 of = vec3(-0.5, 0.5, 1.5);
28
vec3 px = permute(Pi.x + oi);
29
vec3 p = permute(px.x + Pi.y + oi); // p11, p12, p13
30
vec3 ox = fract(p*K) - Ko;
31
vec3 oy = mod7(floor(p*K))*K - Ko;
32
vec3 dx = Pf.x + 0.5 + jitter*ox;
33
vec3 dy = Pf.y - of + jitter*oy;
34
vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared
35
p = permute(px.y + Pi.y + oi); // p21, p22, p23
36
ox = fract(p*K) - Ko;
37
oy = mod7(floor(p*K))*K - Ko;
38
dx = Pf.x - 0.5 + jitter*ox;
39
dy = Pf.y - of + jitter*oy;
40
vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared
41
p = permute(px.z + Pi.y + oi); // p31, p32, p33
42
ox = fract(p*K) - Ko;
43
oy = mod7(floor(p*K))*K - Ko;
44
dx = Pf.x - 1.5 + jitter*ox;
45
dy = Pf.y - of + jitter*oy;
46
vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared
47
// Sort out the two smallest distances (F1, F2)
48
vec3 d1a = min(d1, d2);
49
d2 = max(d1, d2); // Swap to keep candidates for F2
50
d2 = min(d2, d3); // neither F1 nor F2 are now in d3
51
d1 = min(d1a, d2); // F1 is now in d1
52
d2 = max(d1a, d2); // Swap to keep candidates for F2
53
d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller
54
d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x
55
d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz
56
d1.y = min(d1.y, d1.z); // nor in d1.z
57
d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done.
58
return sqrt(d1.xy);
59
}
60
void main() {
61
62
63
vec2 st = gl_FragCoord.xy/u_resolution.xy;
64
float mask = 1.0;
65
mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) );
66
mask *= step( 0.25, distance( st.xy, vec2(0.6, 0.7) ) );
67
mask *= step( 0.25, distance( st.xy, vec2(0.4, 0.7) ) );
68
vec4 cc = vec4(0.093,0.090,0.100,0.500);
69
float outx = cellular(st.xy*10.0).x-0.5;
70
float sig_x = 1.0/(exp(outx/-0.15)+1.0);
71
//sigmoid function
72
colour_out = vec4(vec3(0.6-0.3*pow(sig_x,1.0),0.6-0.55*sig_x,1.0-0.1*sig_x),1.0-sig_x/6.0);
73
74
colour_out *= 1.0-mask;
75
}
Blue Vanda Orchid by maopao
// ACG 04 homework: yanagida precision highp float; //out vec4 color_out; uniform float u_time; uniform vec2 u_resolution; const float PI = 3.14159265359; float opSmoothUnion( float d1, float d2, float k ) { float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 ); return mix( d2, d1, h ) - k*h*(1.0-h); } float opSmoothSubtraction( float d1, float d2, float k ) { float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 ); return mix( d2, -d1, h ) + k*h*(1.0-h); } float opSmoothIntersection( float d1, float d2, float k ) { float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 ); return mix( d2, d1, h ) + k*h*(1.0-h); } float opUnion( float d1, float d2 ) { return min(d1,d2); } float opSubtraction( float d1, float d2 ) { return max(-d1,d2); } float opIntersection( float d1, float d2 ) { return max(d1,d2); } vec4 qConjugate(vec4 q) { return vec4(-q.x, -q.y, -q.z, q.w); } vec4 qMul(vec4 q1, vec4 q2) { vec3 qv1 = vec3(q1.x, q1.y, q1.z); vec3 qv2 = vec3(q2.x, q2.y, q2.z); return vec4(vec3(cross(qv1, qv2) + q2.w * qv1 + q1.w * qv2), q1.w * q2.w - dot(qv1, qv2)); } vec3 rotate3d(vec3 v, vec4 q) { vec4 vq = vec4(v, 0.0); vec4 cq = qConjugate(q); vec4 qOut = qMul(qMul(cq, vq), q); return vec3(qOut.x, qOut.y, qOut.z); } vec4 makeQuatFromAxisAngle(vec3 axis, float angle) { vec4 quat = vec4(vec3(axis.x * sin(angle / 2.0), axis.y * sin(angle / 2.0), axis.z * sin(angle / 2.0)), cos(angle / 2.0)); return normalize(quat); } float sdEllipsoid( vec3 p, vec3 r ){ float k0 = length(p/r); float k1 = length(p/(r*r)); return k0*(k0-1.0)/k1; } float sdSphere( vec3 p, float s ) { return length(p)-s; } float deg2rad(float deg){ return (PI/180.0)*deg; } float ue(vec3 p){ float ue_fin = 0.0; float ue = sdEllipsoid(p - vec3(0.0, 0.5, 0.0), vec3(0.5,0.9,0.3)); float ue_sub1_r = sdEllipsoid(p - vec3(0.7, 0.0, 0.25), vec3(0.9,1.2,0.4)*0.7); float ue_sub1_l = sdEllipsoid(p - vec3(-0.7, 0.0, 0.25), vec3(0.9,1.2,0.4)*0.7); float ue_sub2 = sdEllipsoid(p - vec3(0.0, 0.6, 0.4), vec3(0.5,0.9,0.2)*1.2); ue_fin = opSmoothSubtraction(ue_sub1_r, ue,0.25); ue_fin = opSmoothSubtraction(ue_sub1_l, ue_fin,0.25); ue_fin = opSmoothSubtraction(ue_sub2, ue_fin,0.1); return ue_fin; } float temae(vec3 p){ float temae = sdEllipsoid(p - vec3(0.0, 0.0, 0.3), vec3(1.2,0.7,0.3)); float temae_sub_1 = sdEllipsoid(p - vec3(0.0, 0.4, 0.3), vec3(0.22,0.4,0.3)); float temae_sub_2 = sdEllipsoid(p - vec3(0.0, -0.4, 0.3), vec3(0.35,0.4,0.3)); vec4 q = makeQuatFromAxisAngle(vec3(0.0,0.0,1.0),deg2rad(150.0)); vec3 tmp = rotate3d(p - vec3(0.6,-0.35, 0.5), q); float temae_r_1 = sdEllipsoid(tmp, vec3(0.3,0.2,0.08)); q = makeQuatFromAxisAngle(vec3(0.0,0.0,1.0),deg2rad(30.0)); tmp = rotate3d(p - vec3(-0.6,-0.35, 0.5), q); float temae_r_2 = sdEllipsoid(tmp, vec3(-0.3,0.2,0.08)); float temae_fin = opSmoothSubtraction(temae_sub_1, temae, 0.2); temae_fin = opSmoothSubtraction(temae_sub_2, temae_fin,0.2); temae_fin = opSmoothSubtraction(temae_r_1, temae_fin, 0.3); temae_fin = opSmoothSubtraction(temae_r_2, temae_fin, 0.3); return temae_fin; } float sdfRep(vec3 p_org, vec3 c){ vec3 p = mod(p_org+0.5*c,c)-0.5*c; float obj = 0.0; float ue_fin = ue(p); float temae_fin = temae(p); vec4 q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0), deg2rad(140.0)); float sita = ue(rotate3d(p,q)); q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0),deg2rad(220.0)); float sita2 = ue(rotate3d(p,q)); obj = opUnion(ue_fin, temae_fin); obj = opUnion(sita, obj); obj = opUnion(sita2, obj); return obj; } float mannaka(vec3 p){ float mannaka = sdSphere(p-vec3(0.0,-0.4,0.4), 0.3); float sub = sdSphere(p-vec3(0.0,-0.4,0.5), 0.25); float fin = opSubtraction(sub, mannaka); return fin; } float orchid(vec3 p){ float obj = 0.0; float ue_fin = ue(p); float temae_fin = temae(p); vec4 q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0), deg2rad(140.0)); float sita = ue(rotate3d(p,q)); q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0),deg2rad(220.0)); float sita2 = ue(rotate3d(p,q)); float mannnaka = mannaka(p); obj = opUnion(ue_fin, temae_fin); obj = opUnion(sita, obj); obj = opUnion(sita2, obj); obj = opUnion(mannnaka, obj); return obj; } float rand(){ return fract(sin(dot(gl_FragCoord.xy ,vec2(12.9898,78.233))) * 43758.5453); } float distanceFunc(vec3 p){ float obj = sdSphere(p,0.0001 ); //return obj; for(int i=0; i<4; i++){ obj = opUnion(orchid((p- vec3(0.6,-0.9+1.5*float(i),0.0))*1.6), obj); } for(int i=0; i<4; i++){ obj = opUnion(orchid((p- vec3(-0.6,-1.7+1.5*float(i),0.0))*1.8), obj); } for(int i=0; i<4; i++){ obj = opUnion(orchid((p- vec3(1.8,-1.7+1.5*float(i),0.0))*1.6), obj); } for(int i=0; i<4; i++){ obj = opUnion(orchid((p- vec3(-1.8,-0.9+1.5*float(i),0.0))*1.8), obj); } return obj; } vec3 calcNormal(vec3 p){ const float h = 0.0001; const vec2 k = vec2(1,-1); return normalize( k.xyy*distanceFunc( p + k.xyy*h) + \ k.yyx*distanceFunc( p + k.yyx*h) + \ k.yxy*distanceFunc( p + k.yxy*h) + \ k.xxx*distanceFunc( p + k.xxx*h) ); } const vec3 lightDir = vec3(0.0, 0.1, 1.0); void main(void){ // fragment position vec2 p =gl_FragCoord.xy/u_resolution.xy + vec2(-0.5,-0.5); //coord;//(coord * 4.0 - u_resolution) / min(u_resolution.x, u_resolution.y); // camera vec3 cPos = vec3(0.0, 0.0, 2.0); //vec3 cPos = vec3(0.9, 1.0, 5.0); //vec3 cDir = normalize(vec3(-0.5, -0.4, -1.0)); vec3 cDir = normalize(vec3(0.0, 0.0, -1.0)); vec3 cUp = vec3(0.0, 1.0, 0.0); vec3 cSide = cross(cDir, cUp); float targetDepth = 0.3; // ray vec3 ray = normalize(cSide * p.x + cUp * p.y + cDir * targetDepth); // marching loop float distance = 0.0; float rLen = 0.0; vec3 rPos = cPos; for(int i = 0; i < 100; i++){ distance = distanceFunc(rPos); rLen += distance; rPos = cPos + ray * rLen; } // hit check float fog = smoothstep(0.0, 6.0, length(rPos - cPos)); if(abs(distance) < 0.001){ vec3 normal = calcNormal(rPos); vec3 shade = vec3(dot(lightDir, normal)); vec3 layer = mix(shade, normal, 0.2); vec3 mix_temp = mix(vec3(dot(normal, -ray)), layer, 0.8); colour_out = vec4(mix_temp * vec3(1.0,0.6,1.2) + vec3(fog), 1.0); }else{ colour_out = vec4(vec3(0.0), 1.0); } }
223
1
// ACG 04 homework: yanagida
2
precision highp float;
3
4
//out vec4 color_out;
5
uniform float u_time;
6
uniform vec2 u_resolution;
7
8
const float PI = 3.14159265359;
9
10
11
float opSmoothUnion( float d1, float d2, float k ) {
12
float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );
13
return mix( d2, d1, h ) - k*h*(1.0-h);
14
}
15
16
float opSmoothSubtraction( float d1, float d2, float k ) {
17
float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 );
18
return mix( d2, -d1, h ) + k*h*(1.0-h);
19
}
20
21
float opSmoothIntersection( float d1, float d2, float k ) {
22
float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 );
23
return mix( d2, d1, h ) + k*h*(1.0-h);
24
}
25
26
27
float opUnion( float d1, float d2 ) {
28
return min(d1,d2);
29
}
30
31
float opSubtraction( float d1, float d2 ) {
32
return max(-d1,d2);
33
}
34
35
float opIntersection( float d1, float d2 ) {
36
return max(d1,d2);
37
}
38
39
vec4 qConjugate(vec4 q) {
40
return vec4(-q.x, -q.y, -q.z, q.w);
41
}
42
43
vec4 qMul(vec4 q1, vec4 q2) {
44
vec3 qv1 = vec3(q1.x, q1.y, q1.z);
45
vec3 qv2 = vec3(q2.x, q2.y, q2.z);
46
return vec4(vec3(cross(qv1, qv2) + q2.w * qv1 + q1.w * qv2), q1.w * q2.w - dot(qv1, qv2));
47
}
48
49
vec3 rotate3d(vec3 v, vec4 q) {
50
vec4 vq = vec4(v, 0.0);
51
vec4 cq = qConjugate(q);
52
vec4 qOut = qMul(qMul(cq, vq), q);
53
return vec3(qOut.x, qOut.y, qOut.z);
54
}
55
56
vec4 makeQuatFromAxisAngle(vec3 axis, float angle) {
57
vec4 quat = vec4(vec3(axis.x * sin(angle / 2.0), axis.y * sin(angle / 2.0), axis.z * sin(angle / 2.0)), cos(angle / 2.0));
58
return normalize(quat);
59
}
60
61
float sdEllipsoid( vec3 p, vec3 r ){
62
float k0 = length(p/r);
63
float k1 = length(p/(r*r));
64
return k0*(k0-1.0)/k1;
65
}
66
float sdSphere( vec3 p, float s )
67
{
68
return length(p)-s;
69
}
70
float deg2rad(float deg){
71
return (PI/180.0)*deg;
72
}
73
74
float ue(vec3 p){
75
float ue_fin = 0.0;
76
float ue = sdEllipsoid(p - vec3(0.0, 0.5, 0.0), vec3(0.5,0.9,0.3));
77
float ue_sub1_r = sdEllipsoid(p - vec3(0.7, 0.0, 0.25), vec3(0.9,1.2,0.4)*0.7);
78
float ue_sub1_l = sdEllipsoid(p - vec3(-0.7, 0.0, 0.25), vec3(0.9,1.2,0.4)*0.7);
79
float ue_sub2 = sdEllipsoid(p - vec3(0.0, 0.6, 0.4), vec3(0.5,0.9,0.2)*1.2);
80
ue_fin = opSmoothSubtraction(ue_sub1_r, ue,0.25);
81
ue_fin = opSmoothSubtraction(ue_sub1_l, ue_fin,0.25);
82
ue_fin = opSmoothSubtraction(ue_sub2, ue_fin,0.1);
83
return ue_fin;
84
}
85
86
float temae(vec3 p){
87
float temae = sdEllipsoid(p - vec3(0.0, 0.0, 0.3), vec3(1.2,0.7,0.3));
88
float temae_sub_1 = sdEllipsoid(p - vec3(0.0, 0.4, 0.3), vec3(0.22,0.4,0.3));
89
float temae_sub_2 = sdEllipsoid(p - vec3(0.0, -0.4, 0.3), vec3(0.35,0.4,0.3));
90
vec4 q = makeQuatFromAxisAngle(vec3(0.0,0.0,1.0),deg2rad(150.0));
91
vec3 tmp = rotate3d(p - vec3(0.6,-0.35, 0.5), q);
92
float temae_r_1 = sdEllipsoid(tmp, vec3(0.3,0.2,0.08));
93
q = makeQuatFromAxisAngle(vec3(0.0,0.0,1.0),deg2rad(30.0));
94
tmp = rotate3d(p - vec3(-0.6,-0.35, 0.5), q);
95
float temae_r_2 = sdEllipsoid(tmp, vec3(-0.3,0.2,0.08));
96
float temae_fin = opSmoothSubtraction(temae_sub_1, temae, 0.2);
97
temae_fin = opSmoothSubtraction(temae_sub_2, temae_fin,0.2);
98
temae_fin = opSmoothSubtraction(temae_r_1, temae_fin, 0.3);
99
temae_fin = opSmoothSubtraction(temae_r_2, temae_fin, 0.3);
100
return temae_fin;
101
}
102
103
104
float sdfRep(vec3 p_org, vec3 c){
105
vec3 p = mod(p_org+0.5*c,c)-0.5*c;
106
107
float obj = 0.0;
108
float ue_fin = ue(p);
109
float temae_fin = temae(p);
110
111
vec4 q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0), deg2rad(140.0));
112
float sita = ue(rotate3d(p,q));
113
q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0),deg2rad(220.0));
114
float sita2 = ue(rotate3d(p,q));
115
116
obj = opUnion(ue_fin, temae_fin);
117
obj = opUnion(sita, obj);
118
obj = opUnion(sita2, obj);
119
120
return obj;
121
}
122
123
float mannaka(vec3 p){
124
float mannaka = sdSphere(p-vec3(0.0,-0.4,0.4), 0.3);
125
float sub = sdSphere(p-vec3(0.0,-0.4,0.5), 0.25);
126
float fin = opSubtraction(sub, mannaka);
127
return fin;
128
}
129
130
float orchid(vec3 p){
131
float obj = 0.0;
132
float ue_fin = ue(p);
133
float temae_fin = temae(p);
134
135
vec4 q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0), deg2rad(140.0));
136
float sita = ue(rotate3d(p,q));
137
q = makeQuatFromAxisAngle(vec3(0.0,0.1,1.0),deg2rad(220.0));
138
float sita2 = ue(rotate3d(p,q));
139
140
float mannnaka = mannaka(p);
141
142
obj = opUnion(ue_fin, temae_fin);
143
obj = opUnion(sita, obj);
144
obj = opUnion(sita2, obj);
145
obj = opUnion(mannnaka, obj);
146
147
return obj;
148
}
149
150
float rand(){
151
return fract(sin(dot(gl_FragCoord.xy ,vec2(12.9898,78.233))) * 43758.5453);
152
}
153
154
float distanceFunc(vec3 p){
155
156
float obj = sdSphere(p,0.0001 );
157
//return obj;
158
for(int i=0; i<4; i++){
159
obj = opUnion(orchid((p- vec3(0.6,-0.9+1.5*float(i),0.0))*1.6), obj);
160
}
161
162
for(int i=0; i<4; i++){
163
obj = opUnion(orchid((p- vec3(-0.6,-1.7+1.5*float(i),0.0))*1.8), obj);
164
}
165
for(int i=0; i<4; i++){
166
obj = opUnion(orchid((p- vec3(1.8,-1.7+1.5*float(i),0.0))*1.6), obj);
167
}
168
for(int i=0; i<4; i++){
169
obj = opUnion(orchid((p- vec3(-1.8,-0.9+1.5*float(i),0.0))*1.8), obj);
170
}
171
return obj;
172
}
173
174
175
vec3 calcNormal(vec3 p){
176
const float h = 0.0001;
177
const vec2 k = vec2(1,-1);
178
return normalize( k.xyy*distanceFunc( p + k.xyy*h) + \
179
k.yyx*distanceFunc( p + k.yyx*h) + \
180
k.yxy*distanceFunc( p + k.yxy*h) + \
181
k.xxx*distanceFunc( p + k.xxx*h) );
182
}
183
184
const vec3 lightDir = vec3(0.0, 0.1, 1.0);
185
void main(void){
186
// fragment position
187
vec2 p =gl_FragCoord.xy/u_resolution.xy + vec2(-0.5,-0.5); //coord;//(coord * 4.0 - u_resolution) / min(u_resolution.x, u_resolution.y);
188
189
190
// camera
191
vec3 cPos = vec3(0.0, 0.0, 2.0);
192
//vec3 cPos = vec3(0.9, 1.0, 5.0);
193
//vec3 cDir = normalize(vec3(-0.5, -0.4, -1.0));
194
vec3 cDir = normalize(vec3(0.0, 0.0, -1.0));
195
vec3 cUp = vec3(0.0, 1.0, 0.0);
196
vec3 cSide = cross(cDir, cUp);
197
float targetDepth = 0.3;
198
199
// ray
200
vec3 ray = normalize(cSide * p.x + cUp * p.y + cDir * targetDepth);
201
202
// marching loop
203
float distance = 0.0;
204
float rLen = 0.0;
205
vec3 rPos = cPos;
206
for(int i = 0; i < 100; i++){
207
distance = distanceFunc(rPos);
208
rLen += distance;
209
rPos = cPos + ray * rLen;
210
}
211
// hit check
212
float fog = smoothstep(0.0, 6.0, length(rPos - cPos));
213
if(abs(distance) < 0.001){
214
vec3 normal = calcNormal(rPos);
215
vec3 shade = vec3(dot(lightDir, normal));
216
vec3 layer = mix(shade, normal, 0.2);
217
vec3 mix_temp = mix(vec3(dot(normal, -ray)), layer, 0.8);
218
219
colour_out = vec4(mix_temp * vec3(1.0,0.6,1.2) + vec3(fog), 1.0);
220
}else{
221
colour_out = vec4(vec3(0.0), 1.0);
222
}
223
}
Phalaenopsis by yanagida
// credit: wofwof (will show up on website) // orchid: pololei_flame_burrageara uniform vec2 u_resolution; vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i, 289.0); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } vec4 use_red_snoise(vec2 p,float deno){ float n = snoise( p / deno ); vec4 colour_out = vec4( vec3(mix(0.0,1.0,exp(n)),0.0,0.0), 1.0 ); return colour_out; } vec4 use_yellow_snoise(vec2 p){ float n = snoise( p / 0.0296 ); vec4 colour_out = vec4( vec3(mix(0.0,1.0,exp(n)),mix(0.0,1.0,exp(n)),0.0), 1.0 ); return colour_out; } float sdEllipse( in vec2 p, in vec2 ab ) { p = abs(p); if( p.x > p.y ) {p=p.yx;ab=ab.yx;} float l = ab.y*ab.y - ab.x*ab.x; float m = ab.x*p.x/l; float m2 = m*m; float n = ab.y*p.y/l; float n2 = n*n; float c = (m2+n2-1.0)/3.0; float c3 = c*c*c; float q = c3 + m2*n2*2.0; float d = c3 + m2*n2; float g = m + m*n2; float co; if( d<0.0 ) { float h = acos(q/c3)/3.0; float s = cos(h); float t = sin(h)*sqrt(3.0); float rx = sqrt( -c*(s + t + 2.0) + m2 ); float ry = sqrt( -c*(s - t + 2.0) + m2 ); co = (ry+sign(l)*rx+abs(g)/(rx*ry)- m)/2.0; } else { float h = 2.0*m*n*sqrt( d ); float s = sign(q+h)*pow(abs(q+h), 1.0/3.0); float u = sign(q-h)*pow(abs(q-h), 1.0/3.0); float rx = -s - u - c*4.0 + 2.0*m2; float ry = (s - u)*sqrt(3.0); float rm = sqrt( rx*rx + ry*ry ); co = (ry/sqrt(rm-rx)+2.0*g/rm-m)/2.0; } vec2 r = ab * vec2(co, sqrt(1.0-co*co)); return length(r-p) * sign(p.y-r.y); } float sdStar(in vec2 p, in float r, in int n, in float m){ // next 4 lines can be precomputed for a given shape float an = 3.141593/float(n); float en = 3.141593/m; // m is between 2 and n vec2 acs = vec2(cos(an),sin(an)); vec2 ecs = vec2(cos(en),sin(en)); // ecs=vec2(0,1) for regular polygon float bn = mod(atan(p.x,p.y),2.0*an) - an; p = length(p)*vec2(cos(bn),abs(sin(bn))); p -= r*acs; p += ecs*clamp( -dot(p,ecs), 0.0, r*acs.y/ecs.y); return length(p)*sign(p.x); } float sdEgg( in vec2 p, in float ra, in float rb ) { const float k = sqrt(2.0); p.x = abs(p.x); float r = ra - rb; return ((p.y<0.0) ? length(vec2(p.x, p.y )) - r : (k*(p.x+r)<p.y) ? length(vec2(p.x, p.y-k*r)) : length(vec2(p.x+r,p.y )) - 2.0*r) - rb; } float sdf1(vec2 p,vec2 ab,float angle,vec2 move){ mat4 spin= mat4(cos(angle),sin(angle),0,0, -sin(angle),cos(angle),0,0, 0,0,1,0, 0,0,0,1); return sdEllipse((vec4(p+move,0,0)*spin).xy,ab); } float sdf2(vec2 p,float r,int n,float m){ vec2 move = vec2(-0.520,-0.430); return sdStar(p+move,r,n,m); } float sdf3(vec2 p,float ra,float rb){ vec2 move = vec2(-0.530,-0.160); return sdEgg(p+move,ra,rb); } void main() { vec2 p = gl_FragCoord.xy/u_resolution.xy; // up 3 petals if (sdf2(p,0.100,8,4.768 )<=0.0) colour_out = use_yellow_snoise(p.xy); else if (sdf1(p,vec2(0.08,0.18),1.0,vec2(-0.380,-0.490)) <= 0.0 ) colour_out = vec4(1.0,0.0,0.0,0.700); else if (sdf1(p,vec2(0.10,0.20),1.0,vec2(-0.360,-0.510)) <= 0.0 ) colour_out = use_red_snoise(p.xy,0.0296); else if (sdf1(p,vec2(0.08,0.18),-1.0,vec2(-0.690,-0.510)) <= 0.0 ) colour_out = vec4(1.0,0.0,0.0,0.700); else if (sdf1(p,vec2(0.10,0.20),-1.0,vec2(-0.690,-0.510)) <= 0.0 ) colour_out = use_red_snoise(p.xy,0.0296); else if (sdf1(p,vec2(0.08,0.18),0.0,vec2(-0.530,-0.660)) <= 0.0) colour_out = vec4(1.0,0.0,0.0,0.700); else if (sdf1(p,vec2(0.10,0.20),0.0,vec2(-0.530,-0.680)) <= 0.0) colour_out = use_red_snoise(p.xy,0.0296); else if (sdf1(p,vec2(0.08,0.18),2.0,vec2(-0.360,-0.340)) <= 0.0) colour_out = vec4(1.0,0.0,0.0,0.700); else if (sdf1(p,vec2(0.10,0.20),2.0,vec2(-0.360,-0.340)) <= 0.0) colour_out = use_red_snoise(p.xy,0.0296); else if (sdf1(p,vec2(0.08,0.18),-2.0,vec2(-0.720,-0.300)) <= 0.0) colour_out = vec4(1.0,0.0,0.0,0.700); else if (sdf1(p,vec2(0.1,0.20),-2.0,vec2(-0.720,-0.300)) <= 0.0) colour_out = use_red_snoise(p.xy,0.0296); else if (sdf3(p,0.15,0.02) <= 0.0 ) colour_out = use_red_snoise(p.xy,0.035); else colour_out = vec4(vec3(0.0),1.0); }
147
1
// credit: wofwof (will show up on website)
2
// orchid: pololei_flame_burrageara
3
uniform vec2 u_resolution;
4
5
vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); }
6
float snoise(vec2 v){
7
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
8
-0.577350269189626, 0.024390243902439);
9
vec2 i = floor(v + dot(v, C.yy) );
10
vec2 x0 = v - i + dot(i, C.xx);
11
vec2 i1;
12
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
13
vec4 x12 = x0.xyxy + C.xxzz;
14
x12.xy -= i1;
15
i = mod(i, 289.0);
16
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
17
+ i.x + vec3(0.0, i1.x, 1.0 ));
18
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
19
dot(x12.zw,x12.zw)), 0.0);
20
m = m*m ;
21
m = m*m ;
22
vec3 x = 2.0 * fract(p * C.www) - 1.0;
23
vec3 h = abs(x) - 0.5;
24
vec3 ox = floor(x + 0.5);
25
vec3 a0 = x - ox;
26
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
27
vec3 g;
28
g.x = a0.x * x0.x + h.x * x0.y;
29
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
30
return 130.0 * dot(m, g);
31
}
32
vec4 use_red_snoise(vec2 p,float deno){
33
float n = snoise( p / deno );
34
vec4 colour_out = vec4( vec3(mix(0.0,1.0,exp(n)),0.0,0.0), 1.0 );
35
return colour_out;
36
}
37
vec4 use_yellow_snoise(vec2 p){
38
float n = snoise( p / 0.0296 );
39
vec4 colour_out = vec4( vec3(mix(0.0,1.0,exp(n)),mix(0.0,1.0,exp(n)),0.0), 1.0 );
40
return colour_out;
41
}
42
float sdEllipse( in vec2 p, in vec2 ab )
43
{
44
p = abs(p); if( p.x > p.y ) {p=p.yx;ab=ab.yx;}
45
float l = ab.y*ab.y - ab.x*ab.x;
46
float m = ab.x*p.x/l; float m2 = m*m;
47
float n = ab.y*p.y/l; float n2 = n*n;
48
float c = (m2+n2-1.0)/3.0; float c3 = c*c*c;
49
float q = c3 + m2*n2*2.0;
50
float d = c3 + m2*n2;
51
float g = m + m*n2;
52
float co;
53
if( d<0.0 )
54
{
55
float h = acos(q/c3)/3.0;
56
float s = cos(h);
57
float t = sin(h)*sqrt(3.0);
58
float rx = sqrt( -c*(s + t + 2.0) + m2 );
59
float ry = sqrt( -c*(s - t + 2.0) + m2 );
60
co = (ry+sign(l)*rx+abs(g)/(rx*ry)- m)/2.0;
61
}
62
else
63
{
64
float h = 2.0*m*n*sqrt( d );
65
float s = sign(q+h)*pow(abs(q+h), 1.0/3.0);
66
float u = sign(q-h)*pow(abs(q-h), 1.0/3.0);
67
float rx = -s - u - c*4.0 + 2.0*m2;
68
float ry = (s - u)*sqrt(3.0);
69
float rm = sqrt( rx*rx + ry*ry );
70
co = (ry/sqrt(rm-rx)+2.0*g/rm-m)/2.0;
71
}
72
vec2 r = ab * vec2(co, sqrt(1.0-co*co));
73
return length(r-p) * sign(p.y-r.y);
74
}
75
float sdStar(in vec2 p, in float r, in int n, in float m){
76
// next 4 lines can be precomputed for a given shape
77
float an = 3.141593/float(n);
78
float en = 3.141593/m; // m is between 2 and n
79
vec2 acs = vec2(cos(an),sin(an));
80
vec2 ecs = vec2(cos(en),sin(en)); // ecs=vec2(0,1) for regular polygon
81
82
float bn = mod(atan(p.x,p.y),2.0*an) - an;
83
p = length(p)*vec2(cos(bn),abs(sin(bn)));
84
p -= r*acs;
85
p += ecs*clamp( -dot(p,ecs), 0.0, r*acs.y/ecs.y);
86
return length(p)*sign(p.x);
87
}
88
float sdEgg( in vec2 p, in float ra, in float rb )
89
{
90
const float k = sqrt(2.0);
91
p.x = abs(p.x);
92
float r = ra - rb;
93
return ((p.y<0.0) ? length(vec2(p.x, p.y )) - r :
94
(k*(p.x+r)<p.y) ? length(vec2(p.x, p.y-k*r)) :
95
length(vec2(p.x+r,p.y )) - 2.0*r) - rb;
96
}
97
98
float sdf1(vec2 p,vec2 ab,float angle,vec2 move){
99
mat4 spin= mat4(cos(angle),sin(angle),0,0,
100
-sin(angle),cos(angle),0,0,
101
0,0,1,0,
102
0,0,0,1);
103
return sdEllipse((vec4(p+move,0,0)*spin).xy,ab);
104
}
105
float sdf2(vec2 p,float r,int n,float m){
106
vec2 move = vec2(-0.520,-0.430);
107
return sdStar(p+move,r,n,m);
108
}
109
float sdf3(vec2 p,float ra,float rb){
110
vec2 move = vec2(-0.530,-0.160);
111
return sdEgg(p+move,ra,rb);
112
}
113
114
115
void main() {
116
vec2 p = gl_FragCoord.xy/u_resolution.xy;
117
// up 3 petals
118
if (sdf2(p,0.100,8,4.768 )<=0.0)
119
colour_out = use_yellow_snoise(p.xy);
120
121
else if (sdf1(p,vec2(0.08,0.18),1.0,vec2(-0.380,-0.490)) <= 0.0 )
122
colour_out = vec4(1.0,0.0,0.0,0.700);
123
else if (sdf1(p,vec2(0.10,0.20),1.0,vec2(-0.360,-0.510)) <= 0.0 )
124
colour_out = use_red_snoise(p.xy,0.0296);
125
else if (sdf1(p,vec2(0.08,0.18),-1.0,vec2(-0.690,-0.510)) <= 0.0 )
126
colour_out = vec4(1.0,0.0,0.0,0.700);
127
else if (sdf1(p,vec2(0.10,0.20),-1.0,vec2(-0.690,-0.510)) <= 0.0 )
128
colour_out = use_red_snoise(p.xy,0.0296);
129
else if (sdf1(p,vec2(0.08,0.18),0.0,vec2(-0.530,-0.660)) <= 0.0)
130
colour_out = vec4(1.0,0.0,0.0,0.700);
131
else if (sdf1(p,vec2(0.10,0.20),0.0,vec2(-0.530,-0.680)) <= 0.0)
132
colour_out = use_red_snoise(p.xy,0.0296);
133
else if (sdf1(p,vec2(0.08,0.18),2.0,vec2(-0.360,-0.340)) <= 0.0)
134
colour_out = vec4(1.0,0.0,0.0,0.700);
135
else if (sdf1(p,vec2(0.10,0.20),2.0,vec2(-0.360,-0.340)) <= 0.0)
136
colour_out = use_red_snoise(p.xy,0.0296);
137
else if (sdf1(p,vec2(0.08,0.18),-2.0,vec2(-0.720,-0.300)) <= 0.0)
138
colour_out = vec4(1.0,0.0,0.0,0.700);
139
else if (sdf1(p,vec2(0.1,0.20),-2.0,vec2(-0.720,-0.300)) <= 0.0)
140
colour_out = use_red_snoise(p.xy,0.0296);
141
else if (sdf3(p,0.15,0.02) <= 0.0 )
142
colour_out = use_red_snoise(p.xy,0.035);
143
144
else
145
colour_out = vec4(vec3(0.0),1.0);
146
147
}
Pololei Flame Burrageara by wofwof
// credit: Zhongxi Fang // orchid: Phalaenopsis uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; // Modulo 289 without a division (only multiplications) vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } // Modulo 7 without a division vec3 mod7(vec3 x) { return x - floor(x * (1.0 / 7.0)) * 7.0; } // Permutation polynomial: (34x^2 + 6x) mod 289 vec3 permute(vec3 x) { return mod289((34.0 * x + 10.0) * x); } // Cellular noise, returning F1 and F2 in a vec2. // Standard 3x3 search window for good F1 and F2 values vec2 cellular(vec2 P) { #define K 0.142857142857 // 1/7 #define Ko 0.428571428571 // 3/7 #define jitter 1.0 // Less gives more regular pattern vec2 Pi = mod289(floor(P)); vec2 Pf = fract(P); vec3 oi = vec3(-1.0, 0.0, 1.0); vec3 of = vec3(-0.5, 0.5, 1.5); vec3 px = permute(Pi.x + oi); vec3 p = permute(px.x + Pi.y + oi); // p11, p12, p13 vec3 ox = fract(p*K) - Ko; vec3 oy = mod7(floor(p*K))*K - Ko; vec3 dx = Pf.x + 0.5 + jitter*ox; vec3 dy = Pf.y - of + jitter*oy; vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared p = permute(px.y + Pi.y + oi); // p21, p22, p23 ox = fract(p*K) - Ko; oy = mod7(floor(p*K))*K - Ko; dx = Pf.x - 0.5 + jitter*ox; dy = Pf.y - of + jitter*oy; vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared p = permute(px.z + Pi.y + oi); // p31, p32, p33 ox = fract(p*K) - Ko; oy = mod7(floor(p*K))*K - Ko; dx = Pf.x - 1.5 + jitter*ox; dy = Pf.y - of + jitter*oy; vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared // Sort out the two smallest distances (F1, F2) vec3 d1a = min(d1, d2); d2 = max(d1, d2); // Swap to keep candidates for F2 d2 = min(d2, d3); // neither F1 nor F2 are now in d3 d1 = min(d1a, d2); // F1 is now in d1 d2 = max(d1a, d2); // Swap to keep candidates for F2 d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz d1.y = min(d1.y, d1.z); // nor in d1.z d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done. return sqrt(d1.xy); } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; float mask = 1.0; mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.6, 0.7) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.4, 0.7) ) ); vec4 colour1 = vec4(0.890,0.856,0.801,1.000) * 1.5; vec4 colour2 = vec4(0.830,0.129,0.716,1.000) * 0.8; float noise = 1.0 / exp(cellular(st.xy*30.0).x); // float noise = 1.0 / exp(cellular(st.xy*20.0).x + cellular(st.xy*20.0).y); colour_out = colour2 * noise + colour1 * (1.0-noise); colour_out *= 1.0-mask; }
1
// credit: Zhongxi Fang
2
// orchid: Phalaenopsis
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
// Modulo 289 without a division (only multiplications)
8
vec3 mod289(vec3 x) {
9
return x - floor(x * (1.0 / 289.0)) * 289.0;
10
}
11
12
vec2 mod289(vec2 x) {
13
return x - floor(x * (1.0 / 289.0)) * 289.0;
14
}
15
16
// Modulo 7 without a division
17
vec3 mod7(vec3 x) {
18
return x - floor(x * (1.0 / 7.0)) * 7.0;
19
}
20
21
// Permutation polynomial: (34x^2 + 6x) mod 289
22
vec3 permute(vec3 x) {
23
return mod289((34.0 * x + 10.0) * x);
24
}
25
26
// Cellular noise, returning F1 and F2 in a vec2.
27
// Standard 3x3 search window for good F1 and F2 values
28
vec2 cellular(vec2 P) {
29
30
31
32
vec2 Pi = mod289(floor(P));
33
vec2 Pf = fract(P);
34
vec3 oi = vec3(-1.0, 0.0, 1.0);
35
vec3 of = vec3(-0.5, 0.5, 1.5);
36
vec3 px = permute(Pi.x + oi);
37
vec3 p = permute(px.x + Pi.y + oi); // p11, p12, p13
38
vec3 ox = fract(p*K) - Ko;
39
vec3 oy = mod7(floor(p*K))*K - Ko;
40
vec3 dx = Pf.x + 0.5 + jitter*ox;
41
vec3 dy = Pf.y - of + jitter*oy;
42
vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared
43
p = permute(px.y + Pi.y + oi); // p21, p22, p23
44
ox = fract(p*K) - Ko;
45
oy = mod7(floor(p*K))*K - Ko;
46
dx = Pf.x - 0.5 + jitter*ox;
47
dy = Pf.y - of + jitter*oy;
48
vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared
49
p = permute(px.z + Pi.y + oi); // p31, p32, p33
50
ox = fract(p*K) - Ko;
51
oy = mod7(floor(p*K))*K - Ko;
52
dx = Pf.x - 1.5 + jitter*ox;
53
dy = Pf.y - of + jitter*oy;
54
vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared
55
// Sort out the two smallest distances (F1, F2)
56
vec3 d1a = min(d1, d2);
57
d2 = max(d1, d2); // Swap to keep candidates for F2
58
d2 = min(d2, d3); // neither F1 nor F2 are now in d3
59
d1 = min(d1a, d2); // F1 is now in d1
60
d2 = max(d1a, d2); // Swap to keep candidates for F2
61
d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller
62
d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x
63
d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz
64
d1.y = min(d1.y, d1.z); // nor in d1.z
65
d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done.
66
return sqrt(d1.xy);
67
}
68
69
70
void main() {
71
vec2 st = gl_FragCoord.xy/u_resolution.xy;
72
float mask = 1.0;
73
mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) );
74
mask *= step( 0.25, distance( st.xy, vec2(0.6, 0.7) ) );
75
mask *= step( 0.25, distance( st.xy, vec2(0.4, 0.7) ) );
76
vec4 colour1 = vec4(0.890,0.856,0.801,1.000) * 1.5;
77
vec4 colour2 = vec4(0.830,0.129,0.716,1.000) * 0.8;
78
float noise = 1.0 / exp(cellular(st.xy*30.0).x);
79
// float noise = 1.0 / exp(cellular(st.xy*20.0).x + cellular(st.xy*20.0).y);
80
colour_out = colour2 * noise + colour1 * (1.0-noise);
81
colour_out *= 1.0-mask;
82
}
Phalaenopsis by Zhongxi Fang
// Name: Yuan Zong // orchid: Miltonia uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; const float PI = 3.14159; vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } 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)); // c=sin/cos of aperture return max(l,m*sign(c.y*p.x-c.x*p.y)); } float sdVesica(vec2 p, float r, float d) { p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,0.0))-r; } float rotationVesica(vec2 p, float deg){ float c = cos(deg*PI/180.); float s = sin(deg*PI/180.); mat3 H = mat3(c, s, 0, -s, c, 0, 0, 0, 1); p = (inverse(H)*vec3(p,1.0)).xy; return sdVesica(p, 0.388, 0.292); } float sdCircle( in vec2 p, in float r ) { return length(p)-r; } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; // distance float d1 = sdPie(st-vec2(0.510,0.140), vec2(0.950,0.320), 0.312); float d2 = rotationVesica(st-vec2(0.510,0.690), 0.); float d3 = rotationVesica(st-vec2(0.330,0.570), 60.); float d4 = rotationVesica(st-vec2(0.710,0.600), -60.); float d5 = rotationVesica(st-vec2(0.330,0.360), 120.); float d6 = rotationVesica(st-vec2(0.710,0.350), -120.); float d7 = sdCircle(st-vec2(0.510,0.480), 0.034); float d8 = sdCircle(st-vec2(0.510,0.430), 0.042); // coloring vec3 colour = vec3(0.0); float noise = snoise(30.*st); colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d2) ); colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d2)) ); colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d5) ); colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d5)) ); colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d6) ); colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d6)) ); colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d3) ); colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d3)) ); colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d4) ); colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d4)) ); colour = mix( colour, vec3(1.000,0.309,0.950), 1.0-step(0.0,d1) ); colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d1)) ); colour = (1.- noise * vec3(0.117,1.000,0.126)) *colour; colour = mix( colour, vec3(1.000,0.978,0.120), 1.0-step(0.0,d7) ); colour = mix( colour, vec3(0.958,1.000,0.721), 1.0-smoothstep(0.0,0.05,d8) ); colour_out = vec4( colour, 1.0 ); }
134
1
// Name: Yuan Zong
2
// orchid: Miltonia
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
const float PI = 3.14159;
7
8
9
vec3 mod289(vec3 x) {
10
return x - floor(x * (1.0 / 289.0)) * 289.0;
11
}
12
13
vec2 mod289(vec2 x) {
14
return x - floor(x * (1.0 / 289.0)) * 289.0;
15
}
16
17
vec3 permute(vec3 x) {
18
return mod289(((x*34.0)+10.0)*x);
19
}
20
21
float snoise(vec2 v)
22
{
23
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
24
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
25
-0.577350269189626, // -1.0 + 2.0 * C.x
26
0.024390243902439); // 1.0 / 41.0
27
// First corner
28
vec2 i = floor(v + dot(v, C.yy) );
29
vec2 x0 = v - i + dot(i, C.xx);
30
31
// Other corners
32
vec2 i1;
33
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
34
//i1.y = 1.0 - i1.x;
35
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
36
// x0 = x0 - 0.0 + 0.0 * C.xx ;
37
// x1 = x0 - i1 + 1.0 * C.xx ;
38
// x2 = x0 - 1.0 + 2.0 * C.xx ;
39
vec4 x12 = x0.xyxy + C.xxzz;
40
x12.xy -= i1;
41
42
// Permutations
43
i = mod289(i); // Avoid truncation effects in permutation
44
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
45
+ i.x + vec3(0.0, i1.x, 1.0 ));
46
47
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
48
m = m*m ;
49
m = m*m ;
50
51
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
52
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
53
54
vec3 x = 2.0 * fract(p * C.www) - 1.0;
55
vec3 h = abs(x) - 0.5;
56
vec3 ox = floor(x + 0.5);
57
vec3 a0 = x - ox;
58
59
// Normalise gradients implicitly by scaling m
60
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
61
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
62
63
// Compute final noise value at P
64
vec3 g;
65
g.x = a0.x * x0.x + h.x * x0.y;
66
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
67
return 130.0 * dot(m, g);
68
}
69
70
71
float sdPie( in vec2 p, in vec2 c, in float r )
72
{
73
p.x = abs(p.x);
74
float l = length(p) - r;
75
float m = length(p-c*clamp(dot(p,c),0.0,r)); // c=sin/cos of aperture
76
return max(l,m*sign(c.y*p.x-c.x*p.y));
77
}
78
79
float sdVesica(vec2 p, float r, float d)
80
{
81
p = abs(p);
82
float b = sqrt(r*r-d*d);
83
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b))
84
: length(p-vec2(-d,0.0))-r;
85
}
86
87
float rotationVesica(vec2 p, float deg){
88
float c = cos(deg*PI/180.);
89
float s = sin(deg*PI/180.);
90
mat3 H = mat3(c, s, 0,
91
-s, c, 0,
92
0, 0, 1);
93
p = (inverse(H)*vec3(p,1.0)).xy;
94
return sdVesica(p, 0.388, 0.292);
95
}
96
97
float sdCircle( in vec2 p, in float r )
98
{
99
return length(p)-r;
100
}
101
102
void main() {
103
vec2 st = gl_FragCoord.xy/u_resolution.xy;
104
105
// distance
106
float d1 = sdPie(st-vec2(0.510,0.140), vec2(0.950,0.320), 0.312);
107
float d2 = rotationVesica(st-vec2(0.510,0.690), 0.);
108
float d3 = rotationVesica(st-vec2(0.330,0.570), 60.);
109
float d4 = rotationVesica(st-vec2(0.710,0.600), -60.);
110
float d5 = rotationVesica(st-vec2(0.330,0.360), 120.);
111
float d6 = rotationVesica(st-vec2(0.710,0.350), -120.);
112
float d7 = sdCircle(st-vec2(0.510,0.480), 0.034);
113
float d8 = sdCircle(st-vec2(0.510,0.430), 0.042);
114
115
// coloring
116
vec3 colour = vec3(0.0);
117
float noise = snoise(30.*st);
118
colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d2) );
119
colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d2)) );
120
colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d5) );
121
colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d5)) );
122
colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d6) );
123
colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d6)) );
124
colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d3) );
125
colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d3)) );
126
colour = mix( colour, vec3(1.000,0.228,0.699), 1.0-step(0.0,d4) );
127
colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d4)) );
128
colour = mix( colour, vec3(1.000,0.309,0.950), 1.0-step(0.0,d1) );
129
colour = mix( colour, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d1)) );
130
colour = (1.- noise * vec3(0.117,1.000,0.126)) *colour;
131
colour = mix( colour, vec3(1.000,0.978,0.120), 1.0-step(0.0,d7) );
132
colour = mix( colour, vec3(0.958,1.000,0.721), 1.0-smoothstep(0.0,0.05,d8) );
133
colour_out = vec4( colour, 1.0 );
134
}
Miltonia by Yuan
Zong
// credit: Chispark777 // orchid: Phalaenopsis Blume uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; vec3 permute(vec3 x) { return mod(((x*34.0)+10.0)*x,289.); } vec4 permute(vec4 x) { return mod((34.0 * x + 1.0) * x, 289.0); } vec2 cellular2x2(vec2 P) { #define K 0.142857142857 // 1/7 #define K2 0.0714285714285 // K/2 #define jitter 0.8 // jitter 1.0 makes F1 wrong more often vec2 Pi = mod(floor(P), 289.0); vec2 Pf = fract(P); vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5); vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5); vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0)); p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0)); vec4 ox = mod(p, 7.0)*K+K2; vec4 oy = mod(floor(p*K),7.0)*K+K2; vec4 dx = Pfx + jitter*ox; vec4 dy = Pfy + jitter*oy; vec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared // Sort out the two smallest distances #if 0 // Cheat and pick only F1 d.xy = min(d.xy, d.zw); d.x = min(d.x, d.y); return d.xx; // F1 duplicated, F2 not computed #else // Do it right and find both F1 and F2 d.xy = (d.x < d.y) ? d.xy : d.yx; // Swap if smaller d.xz = (d.x < d.z) ? d.xz : d.zx; d.xw = (d.x < d.w) ? d.xw : d.wx; d.y = min(d.y, d.z); d.y = min(d.y, d.w); return sqrt(d.xy); #endif } float celllike(vec2 st){ st -= .5; st *= .7; vec2 F1 = cellular2x2(st*50.*(.1+1.0-dot(st,st)*5.)); float facets = 0.1+(F1.y-F1.x); float n3 = facets; n3 = step(.2,facets); return n3; } float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i,289.0); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float fbm( vec2 p ) { float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += snoise( p * scale ) / scale; } return f; } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; vec2 st1 = gl_FragCoord.xy; vec2 st2 = gl_FragCoord.xy/u_resolution.xy; st2 = (st2-.5)*1.+.5; if (u_resolution.y > u_resolution.x ) { st2.y *= u_resolution.y/u_resolution.x; st2.y -= (u_resolution.y*.5-u_resolution.x*.5)/u_resolution.x; } else { st2.x *= u_resolution.x/u_resolution.y; st2.x -= (u_resolution.x*.5-u_resolution.y*.5)/u_resolution.y; } //dots and fbm vec2 F = cellular2x2(st2*35.); vec2 pos = st-.5; float a = dot(pos,pos); float n1 = step(abs(cos(a*3.1415*4.)),F.x*2.9); float n = fbm(gl_FragCoord.xy/300.0); //cell like float n3 = celllike(st); float pct = distance(st,vec2(0.5)); float nmix1 = 0.7*n1 +0.5*n; float nmix2 = 0.5*n+0.7*n3; vec3 color = vec3(0.3,0.7,0.26); float mask = 1.0; mask *= step( 0.2, distance( st.xy, vec2(0.5,0.75) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.35,0.45) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.65,0.45) ) ); mask *= step(0.15, distance(st.xy, vec2(0.5,0.2))); if(pct <0.25){ colour_out.rgb = 1.-vec3(nmix1); } else{ colour_out.rgb = 1.-vec3(nmix2); } colour_out.rgb *= color; colour_out.a = 1.0; colour_out *= 1.-mask; colour_out = vec4(vec3(1.0) - colour_out.rgb,1.0); }
131
1
// credit: Chispark777
2
// orchid: Phalaenopsis Blume
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
vec3 permute(vec3 x) {
7
return mod(((x*34.0)+10.0)*x,289.);
8
}
9
vec4 permute(vec4 x) {
10
return mod((34.0 * x + 1.0) * x, 289.0);
11
}
12
vec2 cellular2x2(vec2 P) {
13
14
15
16
vec2 Pi = mod(floor(P), 289.0);
17
vec2 Pf = fract(P);
18
vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5);
19
vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5);
20
vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0));
21
p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0));
22
vec4 ox = mod(p, 7.0)*K+K2;
23
vec4 oy = mod(floor(p*K),7.0)*K+K2;
24
vec4 dx = Pfx + jitter*ox;
25
vec4 dy = Pfy + jitter*oy;
26
vec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared
27
// Sort out the two smallest distances
28
29
// Cheat and pick only F1
30
d.xy = min(d.xy, d.zw);
31
d.x = min(d.x, d.y);
32
return d.xx; // F1 duplicated, F2 not computed
33
34
// Do it right and find both F1 and F2
35
d.xy = (d.x < d.y) ? d.xy : d.yx; // Swap if smaller
36
d.xz = (d.x < d.z) ? d.xz : d.zx;
37
d.xw = (d.x < d.w) ? d.xw : d.wx;
38
d.y = min(d.y, d.z);
39
d.y = min(d.y, d.w);
40
return sqrt(d.xy);
41
42
}
43
float celllike(vec2 st){
44
st -= .5;
45
st *= .7;
46
vec2 F1 = cellular2x2(st*50.*(.1+1.0-dot(st,st)*5.));
47
float facets = 0.1+(F1.y-F1.x);
48
float n3 = facets;
49
n3 = step(.2,facets);
50
return n3;
51
}
52
float snoise(vec2 v){
53
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
54
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
55
-0.577350269189626, // -1.0 + 2.0 * C.x
56
0.024390243902439); // 1.0 / 41.0
57
// First corner
58
vec2 i = floor(v + dot(v, C.yy) );
59
vec2 x0 = v - i + dot(i, C.xx);
60
// Other corners
61
vec2 i1;
62
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
63
vec4 x12 = x0.xyxy + C.xxzz;
64
x12.xy -= i1;
65
i = mod(i,289.0); // Avoid truncation effects in permutation
66
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
67
+ i.x + vec3(0.0, i1.x, 1.0 ));
68
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
69
m = m*m ;
70
m = m*m ;
71
vec3 x = 2.0 * fract(p * C.www) - 1.0;
72
vec3 h = abs(x) - 0.5;
73
vec3 ox = floor(x + 0.5);
74
vec3 a0 = x - ox;
75
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
76
// Compute final noise value at P
77
vec3 g;
78
g.x = a0.x * x0.x + h.x * x0.y;
79
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
80
return 130.0 * dot(m, g);
81
}
82
83
float fbm( vec2 p ) {
84
float f = 0.0, scale;
85
for (int i=0; i<4; i++) {
86
scale = pow( pow(2.0, 4.0/3.0), float(i) );
87
f += snoise( p * scale ) / scale;
88
}
89
return f;
90
}
91
void main() {
92
vec2 st = gl_FragCoord.xy/u_resolution.xy;
93
vec2 st1 = gl_FragCoord.xy;
94
vec2 st2 = gl_FragCoord.xy/u_resolution.xy;
95
st2 = (st2-.5)*1.+.5;
96
if (u_resolution.y > u_resolution.x ) {
97
st2.y *= u_resolution.y/u_resolution.x;
98
st2.y -= (u_resolution.y*.5-u_resolution.x*.5)/u_resolution.x;
99
} else {
100
st2.x *= u_resolution.x/u_resolution.y;
101
st2.x -= (u_resolution.x*.5-u_resolution.y*.5)/u_resolution.y;
102
}
103
//dots and fbm
104
vec2 F = cellular2x2(st2*35.);
105
vec2 pos = st-.5;
106
float a = dot(pos,pos);
107
108
float n1 = step(abs(cos(a*3.1415*4.)),F.x*2.9);
109
float n = fbm(gl_FragCoord.xy/300.0);
110
//cell like
111
float n3 = celllike(st);
112
float pct = distance(st,vec2(0.5));
113
float nmix1 = 0.7*n1 +0.5*n;
114
float nmix2 = 0.5*n+0.7*n3;
115
vec3 color = vec3(0.3,0.7,0.26);
116
float mask = 1.0;
117
mask *= step( 0.2, distance( st.xy, vec2(0.5,0.75) ) );
118
mask *= step( 0.25, distance( st.xy, vec2(0.35,0.45) ) );
119
mask *= step( 0.25, distance( st.xy, vec2(0.65,0.45) ) );
120
mask *= step(0.15, distance(st.xy, vec2(0.5,0.2)));
121
if(pct <0.25){
122
colour_out.rgb = 1.-vec3(nmix1);
123
}
124
else{
125
colour_out.rgb = 1.-vec3(nmix2);
126
}
127
colour_out.rgb *= color;
128
colour_out.a = 1.0;
129
colour_out *= 1.-mask;
130
colour_out = vec4(vec3(1.0) - colour_out.rgb,1.0);
131
}
Phalaenopsis Blume by Chispark777
// credit: Doclaf.eth // orchid: Dracula simia uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; vec2 random3(vec2 st){ st = vec2( dot(st,vec2(127.1,311.7)), dot(st,vec2(269.5,183.3)) ); return -1.392 + 1.968*fract(sin(st)*43755.897); } vec2 random2(vec2 st){ st = vec2( dot(st,vec2(0.100,0.200)), dot(st,vec2(0.000,0.210)) ); return -1.464 + -0.160*fract(sin(st)*43763.681); } // Gradient Noise by Inigo Quilez - iq/2013 // https://www.shadertoy.com/view/XdXGW8 float noise(vec2 st) { vec2 i = floor(st); vec2 f = fract(st); vec2 u = f*f*(3.0-2.0*f); return mix( mix( dot( random2(i + vec2(0.0,0.0) ), f - vec2(0.0,0.0) ), dot( random2(i + vec2(1.0,0.0) ), f - vec2(1.0,0.0) ), u.x), mix( dot( random2(i + vec2(0.0,1.0) ), f - vec2(0.0,1.0) ), dot( random2(i + vec2(1.0,1.0) ), f - vec2(1.0,1.0) ), u.x), u.y); } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; float mask = 1.; mask *= step( 0.25, distance( st.xy, vec2(0.30,0.320) ) );//bottom left leaf mask *= step( 0.25, distance( st.xy, vec2(0.70,0.320) ) );//bottom right leaf mask *= step( 0.25, distance( st.xy, vec2(0.50,0.680) ) );//top leaf vec3 color = vec3(0.0); float t = 0.712; // Uncomment to animate //t = abs(1.0-sin(u_time*.1))*5.; // Comment and uncomment the following lines: // gradual color from center color = vec3(mix(0.280, 1.0, exp(-length(random3(st).xy)*-0.480)), 1.0, 0.560); st += noise(st*2.)*t; // Animate the coordinate space color -= vec3(1.) * smoothstep(0.844,-0.200,noise(st)); // lighting effects color += smoothstep(0.182,0.208,noise(st*1.520)); // inner structure color += smoothstep(0.206,0.344,noise(st*10.088)); // outer structure colour_out = vec4(color, 1.); //colour_out = vec4( 1, .05, .05, 0.5 ); colour_out *= 1.-mask; }
1
// credit: Doclaf.eth
2
// orchid: Dracula simia
3
4
uniform vec2 u_resolution;
5
uniform vec2 u_mouse;
6
uniform float u_time;
7
8
9
10
vec2 random3(vec2 st){
11
st = vec2( dot(st,vec2(127.1,311.7)),
12
dot(st,vec2(269.5,183.3)) );
13
return -1.392 + 1.968*fract(sin(st)*43755.897);
14
}
15
16
vec2 random2(vec2 st){
17
st = vec2( dot(st,vec2(0.100,0.200)),
18
dot(st,vec2(0.000,0.210)) );
19
return -1.464 + -0.160*fract(sin(st)*43763.681);
20
}
21
22
// Gradient Noise by Inigo Quilez - iq/2013
23
// https://www.shadertoy.com/view/XdXGW8
24
float noise(vec2 st) {
25
vec2 i = floor(st);
26
vec2 f = fract(st);
27
28
vec2 u = f*f*(3.0-2.0*f);
29
30
return mix( mix( dot( random2(i + vec2(0.0,0.0) ), f - vec2(0.0,0.0) ),
31
dot( random2(i + vec2(1.0,0.0) ), f - vec2(1.0,0.0) ), u.x),
32
mix( dot( random2(i + vec2(0.0,1.0) ), f - vec2(0.0,1.0) ),
33
dot( random2(i + vec2(1.0,1.0) ), f - vec2(1.0,1.0) ), u.x), u.y);
34
}
35
36
37
void main() {
38
vec2 st = gl_FragCoord.xy/u_resolution.xy;
39
float mask = 1.;
40
mask *= step( 0.25, distance( st.xy, vec2(0.30,0.320) ) );//bottom left leaf
41
mask *= step( 0.25, distance( st.xy, vec2(0.70,0.320) ) );//bottom right leaf
42
mask *= step( 0.25, distance( st.xy, vec2(0.50,0.680) ) );//top leaf
43
44
45
vec3 color = vec3(0.0);
46
47
float t = 0.712;
48
// Uncomment to animate
49
//t = abs(1.0-sin(u_time*.1))*5.;
50
// Comment and uncomment the following lines:
51
52
// gradual color from center
53
color = vec3(mix(0.280, 1.0, exp(-length(random3(st).xy)*-0.480)), 1.0, 0.560);
54
55
st += noise(st*2.)*t; // Animate the coordinate space
56
color -= vec3(1.) * smoothstep(0.844,-0.200,noise(st)); // lighting effects
57
color += smoothstep(0.182,0.208,noise(st*1.520)); // inner structure
58
color += smoothstep(0.206,0.344,noise(st*10.088)); // outer structure
59
60
61
62
colour_out = vec4(color, 1.);
63
//colour_out = vec4( 1, .05, .05, 0.5 );
64
colour_out *= 1.-mask;
65
}
Dracula Simia by Doclaf.eth
// Author name: barnacleboy // orchid: Cymbidium/boat orchid uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123); } float noise (in vec2 st) { vec2 i = floor(st); vec2 f = fract(st); float a = random(i); float b = random(i + vec2(1.0, 0.0)); float c = random(i + vec2(0.0, 1.0)); float d = random(i + vec2(1.0, 1.0)); vec2 u = f*f*(3.0-2.0*f); return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y; } vec4 permute(vec4 x) { return mod((34.0 * x + 1.0) * x, 289.0); } vec2 cellular2x2(vec2 P) { #define K 0.142857142857 // 1/7 #define K2 0.0714285714285 // K/2 #define jitter 0.8 // jitter 1.0 makes F1 wrong more often vec2 Pi = mod(floor(P), 289.0); vec2 Pf = fract(P); vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5); vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5); vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0)); p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0)); vec4 ox = mod(p, 7.0)*K+K2; vec4 oy = mod(floor(p*K),7.0)*K+K2; vec4 dx = Pfx + jitter*ox; vec4 dy = Pfy + jitter*oy; vec4 d = dx * dx + dy * dy; #if 0 d.xy = min(d.xy, d.zw); d.x = min(d.x, d.y); return d.xx; #else d.xy = (d.x < d.y) ? d.xy : d.yx; d.xz = (d.x < d.z) ? d.xz : d.zx; d.xw = (d.x < d.w) ? d.xw : d.wx; d.y = min(d.y, d.z); d.y = min(d.y, d.w); return sqrt(d.xy); #endif } float noise1(vec2 st) { vec2 i = floor(st); vec2 f = fract(st); vec2 u = f*f*(3.0-2.0*f); return mix( mix( random( i + vec2(0.0,0.0) ), random( i + vec2(1.0,0.0) ), u.x), mix( random( i + vec2(0.0,1.0) ), random( i + vec2(1.0,1.0) ), u.x), u.y); } mat2 rotate2d(float angle){ return mat2(cos(angle),-sin(angle), sin(angle),cos(angle)); } float lines(in vec2 pos, float b){ float scale = 50.880; pos *= scale; return smoothstep(0.0, .5+b*.5, abs((sin(pos.x*3.1415)+b*2.0))*.5); } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; vec2 pos = vec2(0.5,0.5)-st; vec2 pos1 = vec2(st*80.0); vec2 pos2 = vec2(st*150.0); vec2 pos3 = st.yx*vec2(10.,3.); float d1 =length(vec2(0.500,0.440)-st); float d2 =length(vec2(0.500,0.520)-st); float d3 =length(vec2(0.500,0.615)-st); float d4 =length(vec2(0.500,0.570)-st); float r = length(pos)*2.080; float a = atan(pos.y,pos.x); float f = abs(cos(a*3.0)); float n1 = -noise(pos1); float n2 = -noise(pos2); float pattern = pos3.x; st.y *= u_resolution.y/u_resolution.x; pos3 = rotate2d( noise(pos3) ) * pos3; pattern = lines(pos3,.5); vec2 st1 = (st-.5)*1.+.5; if (u_resolution.y > u_resolution.x ) { st1.y *= u_resolution.y/u_resolution.x; st1.y -= (u_resolution.y*.5-u_resolution.x*.5)/u_resolution.x; } else { st1.x *= u_resolution.x/u_resolution.y; st1.x -= (u_resolution.x*.5-u_resolution.y*.5)/u_resolution.y; } st1 -= .5; st1 *= .7; vec2 F = cellular2x2(st1*40.*(.1+1.0-dot(st1,st1)*5.)); float facets = 0.1+(F.y-F.x); float dots = smoothstep(-1.0, 0.1, F.x); float n4 = facets * dots; n4 = step(.2,facets)*dots; if(st.x>0.495&&st.x<0.505&&st.y>0.42&&st.y<0.52) colour_out = vec4(1.000,0.818,0.243,1.0); else if (d1>0.07&&d1<0.1&&d2>0.1||d2>0.07&&d2<0.1&&d3>0.075&&d1>0.05) colour_out = vec4(-vec3(n1)+vec3(0.291,0.149,0.425), 1.0); else if(d2<0.1&&d3>0.075||d1<0.1) colour_out=vec4(mix(vec4(1.0),vec4(0.995,0.826,0.050,1.000),exp((-25.600)*d2))); else if(d4<0.05) colour_out = vec4((vec3(pattern))+vec3(0.995,0.607,0.093), 1.0); else colour_out = vec4(vec3(1.0)-vec3(n4)+vec3(0.870,0.487,0.623),1.0-smoothstep(f,f+0.1,r) ); }
134
1
// Author name: barnacleboy
2
// orchid: Cymbidium/boat orchid
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
float random (in vec2 st) {
8
return fract(sin(dot(st.xy,
9
vec2(12.9898,78.233)))
10
* 43758.5453123);
11
}
12
13
float noise (in vec2 st) {
14
vec2 i = floor(st);
15
vec2 f = fract(st);
16
float a = random(i);
17
float b = random(i + vec2(1.0, 0.0));
18
float c = random(i + vec2(0.0, 1.0));
19
float d = random(i + vec2(1.0, 1.0));
20
vec2 u = f*f*(3.0-2.0*f);
21
return mix(a, b, u.x) +
22
(c - a)* u.y * (1.0 - u.x) +
23
(d - b) * u.x * u.y;
24
}
25
26
vec4 permute(vec4 x) {
27
return mod((34.0 * x + 1.0) * x, 289.0);
28
}
29
30
vec2 cellular2x2(vec2 P) {
31
32
33
34
vec2 Pi = mod(floor(P), 289.0);
35
vec2 Pf = fract(P);
36
vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5);
37
vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5);
38
vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0));
39
p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0));
40
vec4 ox = mod(p, 7.0)*K+K2;
41
vec4 oy = mod(floor(p*K),7.0)*K+K2;
42
vec4 dx = Pfx + jitter*ox;
43
vec4 dy = Pfy + jitter*oy;
44
vec4 d = dx * dx + dy * dy;
45
46
47
d.xy = min(d.xy, d.zw);
48
d.x = min(d.x, d.y);
49
return d.xx;
50
51
d.xy = (d.x < d.y) ? d.xy : d.yx;
52
d.xz = (d.x < d.z) ? d.xz : d.zx;
53
d.xw = (d.x < d.w) ? d.xw : d.wx;
54
d.y = min(d.y, d.z);
55
d.y = min(d.y, d.w);
56
return sqrt(d.xy);
57
58
}
59
60
float noise1(vec2 st) {
61
vec2 i = floor(st);
62
vec2 f = fract(st);
63
vec2 u = f*f*(3.0-2.0*f);
64
return mix( mix( random( i + vec2(0.0,0.0) ),
65
random( i + vec2(1.0,0.0) ), u.x),
66
mix( random( i + vec2(0.0,1.0) ),
67
random( i + vec2(1.0,1.0) ), u.x), u.y);
68
}
69
70
mat2 rotate2d(float angle){
71
return mat2(cos(angle),-sin(angle),
72
sin(angle),cos(angle));
73
}
74
75
float lines(in vec2 pos, float b){
76
float scale = 50.880;
77
pos *= scale;
78
return smoothstep(0.0,
79
.5+b*.5,
80
abs((sin(pos.x*3.1415)+b*2.0))*.5);
81
}
82
83
void main() {
84
vec2 st = gl_FragCoord.xy/u_resolution.xy;
85
vec2 pos = vec2(0.5,0.5)-st;
86
vec2 pos1 = vec2(st*80.0);
87
vec2 pos2 = vec2(st*150.0);
88
vec2 pos3 = st.yx*vec2(10.,3.);
89
float d1 =length(vec2(0.500,0.440)-st);
90
float d2 =length(vec2(0.500,0.520)-st);
91
float d3 =length(vec2(0.500,0.615)-st);
92
float d4 =length(vec2(0.500,0.570)-st);
93
float r = length(pos)*2.080;
94
float a = atan(pos.y,pos.x);
95
float f = abs(cos(a*3.0));
96
float n1 = -noise(pos1);
97
float n2 = -noise(pos2);
98
float pattern = pos3.x;
99
st.y *= u_resolution.y/u_resolution.x;
100
pos3 = rotate2d( noise(pos3) ) * pos3;
101
pattern = lines(pos3,.5);
102
103
104
vec2 st1 = (st-.5)*1.+.5;
105
if (u_resolution.y > u_resolution.x ) {
106
st1.y *= u_resolution.y/u_resolution.x;
107
st1.y -= (u_resolution.y*.5-u_resolution.x*.5)/u_resolution.x;
108
} else {
109
st1.x *= u_resolution.x/u_resolution.y;
110
st1.x -= (u_resolution.x*.5-u_resolution.y*.5)/u_resolution.y;
111
}
112
st1 -= .5;
113
st1 *= .7;
114
vec2 F = cellular2x2(st1*40.*(.1+1.0-dot(st1,st1)*5.));
115
116
float facets = 0.1+(F.y-F.x);
117
float dots = smoothstep(-1.0, 0.1, F.x);
118
float n4 = facets * dots;
119
n4 = step(.2,facets)*dots;
120
121
if(st.x>0.495&&st.x<0.505&&st.y>0.42&&st.y<0.52)
122
colour_out = vec4(1.000,0.818,0.243,1.0);
123
else if (d1>0.07&&d1<0.1&&d2>0.1||d2>0.07&&d2<0.1&&d3>0.075&&d1>0.05)
124
colour_out = vec4(-vec3(n1)+vec3(0.291,0.149,0.425), 1.0);
125
126
else if(d2<0.1&&d3>0.075||d1<0.1)
127
colour_out=vec4(mix(vec4(1.0),vec4(0.995,0.826,0.050,1.000),exp((-25.600)*d2)));
128
129
else if(d4<0.05)
130
colour_out = vec4((vec3(pattern))+vec3(0.995,0.607,0.093), 1.0);
131
else
132
133
colour_out = vec4(vec3(1.0)-vec3(n4)+vec3(0.870,0.487,0.623),1.0-smoothstep(f,f+0.1,r) );
134
}
Cybidium/boat orchid by barnacleboy
// credit: HUANG, Jianming // orchid: Orchid Cymbidium uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; float rand(vec2 n) { return fract( sin( dot( n, vec2(12.9898, 4.1414) ) ) * 43758.5453 ); } float noise(vec2 n) { const vec2 d = vec2( 0.0, 1.0 ); vec2 b = floor( n ), f = smoothstep( vec2(0.0), vec2(1.0), fract(n) ); return mix( mix( rand(b), rand(b + d.yx), f.x ), mix( rand(b + d.xy), rand(b + d.yy), f.x ), f.y ); } // Rotate to reduce axial bias const mat2 rot = mat2( 0.8, -0.6, 0.6, 0.8 ); float fbm( vec2 p ) { float f = 0.0; f += 0.5000 * noise( p ); p = rot * p * 2.02; f += 0.2500 * noise( p ); p = rot * p * 2.03; f += 0.1250 * noise( p ); p = rot * p * 2.01; f += 0.0625 * noise( p ); return f / 0.9375; } vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 permute(vec4 x) { return mod289(((x*34.0)+10.0)*x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } vec2 fade(vec2 t) { return t*t*t*(t*(t*6.0-15.0)+10.0); } // Classic Perlin noise float cnoise(vec2 P) { vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0); vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0); Pi = mod289(Pi); // To avoid truncation effects in permutation vec4 ix = Pi.xzxz; vec4 iy = Pi.yyww; vec4 fx = Pf.xzxz; vec4 fy = Pf.yyww; vec4 i = permute(permute(ix) + iy); vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ; vec4 gy = abs(gx) - 0.5 ; vec4 tx = floor(gx + 0.5); gx = gx - tx; vec2 g00 = vec2(gx.x,gy.x); vec2 g10 = vec2(gx.y,gy.y); vec2 g01 = vec2(gx.z,gy.z); vec2 g11 = vec2(gx.w,gy.w); vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); g00 *= norm.x; g01 *= norm.y; g10 *= norm.z; g11 *= norm.w; float n00 = dot(g00, vec2(fx.x, fy.x)); float n10 = dot(g10, vec2(fx.y, fy.y)); float n01 = dot(g01, vec2(fx.z, fy.z)); float n11 = dot(g11, vec2(fx.w, fy.w)); vec2 fade_xy = fade(Pf.xy); vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x); float n_xy = mix(n_x.x, n_x.y, fade_xy.y); return 2.3 * n_xy; } float sigmoid(float v){ return (1.0/(1.0+exp(v))); } void main() { vec2 st = gl_FragCoord.xy/u_resolution.xy; float mask = 1.0; mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.6, 0.7) ) ); mask *= step( 0.25, distance( st.xy, vec2(0.4, 0.7) ) ); //float noise_fbm = fbm(st.xy*10.); float center_dist = pow(distance( st.xy, vec2(0.5, 0.5) )/ 0.25, 2.0); float noise_classic = pow(sigmoid(cnoise(st.xy*30.)),2.)*center_dist; float noise2 = sigmoid(1.0/cnoise(st.xy*30.)); vec4 pink = vec4(0.725,0.094,0.562,1.); vec4 white = vec4(0.958,0.965,0.836,1.000); vec4 slight_yellow = vec4(0.945,0.945,0.738,1.000); vec4 mixed = white * center_dist + slight_yellow*(1.0-center_dist); vec4 spot = pink*noise_classic + mixed*(1.0-noise_classic); //vec4 smoo = pink*noise_fbm + white*(1.0-noise_fbm); //colour_out += vec4(slight_yellow,1.0); colour_out = spot*(1.0-mask); }
114
1
// credit: HUANG, Jianming
2
// orchid: Orchid Cymbidium
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
float rand(vec2 n)
8
{
9
return fract( sin( dot( n, vec2(12.9898, 4.1414) ) ) * 43758.5453 );
10
}
11
12
float noise(vec2 n)
13
{
14
const vec2 d = vec2( 0.0, 1.0 );
15
vec2 b = floor( n ), f = smoothstep( vec2(0.0), vec2(1.0), fract(n) );
16
return mix( mix( rand(b), rand(b + d.yx), f.x ), mix( rand(b + d.xy), rand(b + d.yy), f.x ), f.y );
17
}
18
19
// Rotate to reduce axial bias
20
const mat2 rot = mat2( 0.8, -0.6, 0.6, 0.8 );
21
22
float fbm( vec2 p )
23
{
24
float f = 0.0;
25
f += 0.5000 * noise( p ); p = rot * p * 2.02;
26
f += 0.2500 * noise( p ); p = rot * p * 2.03;
27
f += 0.1250 * noise( p ); p = rot * p * 2.01;
28
f += 0.0625 * noise( p );
29
30
return f / 0.9375;
31
}
32
33
vec4 mod289(vec4 x)
34
{
35
return x - floor(x * (1.0 / 289.0)) * 289.0;
36
}
37
38
vec4 permute(vec4 x)
39
{
40
return mod289(((x*34.0)+10.0)*x);
41
}
42
43
vec4 taylorInvSqrt(vec4 r)
44
{
45
return 1.79284291400159 - 0.85373472095314 * r;
46
}
47
48
vec2 fade(vec2 t) {
49
return t*t*t*(t*(t*6.0-15.0)+10.0);
50
}
51
52
// Classic Perlin noise
53
float cnoise(vec2 P)
54
{
55
vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);
56
vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);
57
Pi = mod289(Pi); // To avoid truncation effects in permutation
58
vec4 ix = Pi.xzxz;
59
vec4 iy = Pi.yyww;
60
vec4 fx = Pf.xzxz;
61
vec4 fy = Pf.yyww;
62
63
vec4 i = permute(permute(ix) + iy);
64
65
vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;
66
vec4 gy = abs(gx) - 0.5 ;
67
vec4 tx = floor(gx + 0.5);
68
gx = gx - tx;
69
70
vec2 g00 = vec2(gx.x,gy.x);
71
vec2 g10 = vec2(gx.y,gy.y);
72
vec2 g01 = vec2(gx.z,gy.z);
73
vec2 g11 = vec2(gx.w,gy.w);
74
75
vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
76
g00 *= norm.x;
77
g01 *= norm.y;
78
g10 *= norm.z;
79
g11 *= norm.w;
80
81
float n00 = dot(g00, vec2(fx.x, fy.x));
82
float n10 = dot(g10, vec2(fx.y, fy.y));
83
float n01 = dot(g01, vec2(fx.z, fy.z));
84
float n11 = dot(g11, vec2(fx.w, fy.w));
85
86
vec2 fade_xy = fade(Pf.xy);
87
vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);
88
float n_xy = mix(n_x.x, n_x.y, fade_xy.y);
89
return 2.3 * n_xy;
90
}
91
92
float sigmoid(float v){
93
return (1.0/(1.0+exp(v)));
94
}
95
96
void main() {
97
vec2 st = gl_FragCoord.xy/u_resolution.xy;
98
float mask = 1.0;
99
mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) );
100
mask *= step( 0.25, distance( st.xy, vec2(0.6, 0.7) ) );
101
mask *= step( 0.25, distance( st.xy, vec2(0.4, 0.7) ) );
102
//float noise_fbm = fbm(st.xy*10.);
103
float center_dist = pow(distance( st.xy, vec2(0.5, 0.5) )/ 0.25, 2.0);
104
float noise_classic = pow(sigmoid(cnoise(st.xy*30.)),2.)*center_dist;
105
float noise2 = sigmoid(1.0/cnoise(st.xy*30.));
106
vec4 pink = vec4(0.725,0.094,0.562,1.);
107
vec4 white = vec4(0.958,0.965,0.836,1.000);
108
vec4 slight_yellow = vec4(0.945,0.945,0.738,1.000);
109
vec4 mixed = white * center_dist + slight_yellow*(1.0-center_dist);
110
vec4 spot = pink*noise_classic + mixed*(1.0-noise_classic);
111
//vec4 smoo = pink*noise_fbm + white*(1.0-noise_fbm);
112
//colour_out += vec4(slight_yellow,1.0);
113
colour_out = spot*(1.0-mask);
114
}
Orchid Cymbidium by HUANG, Jianming
// credit: 5121DG04-3 // orchid: Cymbidium Cultivar uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; // define squared dot product float dot2(in vec2 v){return dot(v,v);} // Primitives____________________________ // Modified from https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm // Vesica float sdVesica(vec2 p, float r, float d){ p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,0.0))-r; } // Egg float sdEgg( in vec2 p, in float ra, in float rb ){ const float k = sqrt(0.5); p.x = abs(p.x); float r = ra - rb; return ((p.y<0.0) ? length(vec2(p.x, p.y )) - r : (k*(p.x+r)<p.y) ? length(vec2(p.x, p.y-k*r)) : length(vec2(p.x+r,p.y )) - 2.0*r) - rb; } // Uneven Capsule float sdUnevenCapsule( vec2 p, float r1, float r2, float h ){ p.x = abs(p.x); float b = (r1-r2)/h; float a = sqrt(1.0-b*b); float k = dot(p,vec2(-b,a)); if( k < 0.0 ) return length(p) - r1; if( k > a*h ) return length(p-vec2(0.0,h)) - r2; return dot(p, vec2(a,b) ) - r1; } // Structures____________________________ // Petals float petals(vec2 p, float offset){ // Dimensions float petal_length = 0.37; float petal_width_drop = 0.3; // Position vec2 coord = p.xy-offset; // Rotation Matrix float theta = 2.5; float c = cos(theta); float s = sin(theta); mat3 R = mat3(c, -s, 0, s, c, 0, 0, 0, 1.0); // Signed distance function float petals_sdf = sdVesica(coord.xy-vec2(0.0, offset/2.5), petal_length, petal_width_drop); for (int i=0; i<4; i++){ coord = (R*vec3(coord.xy, 1.0)).xy; petals_sdf = min(petals_sdf, sdVesica(coord.xy-vec2(0.0, offset/2.5), petal_length, petal_width_drop)); } return petals_sdf; } // Lip float lip(vec2 p, float offset){ // Dimensions float lip_length = 0.1; float lip_width = 0.05; float stem_bot_rad = 0.03; float stem_top_rad = 0.06; float stem_height = 0.15; // Position vec2 coord = p.xy-offset; // Signed distance function float lip_sdf = min(sdEgg( coord + vec2(0.0, offset/10.0), lip_length, lip_width ), sdUnevenCapsule(coord, stem_bot_rad, stem_top_rad, stem_height)); return lip_sdf; } // Noise___________________________________ // Modified from the lecture slides // Random number generator float rng(vec2 co) { const highp float seed = 12.9898; highp float a = seed; highp float b = 78.233, c = 43758.5453; highp float dt= dot(co.xy, vec2(a,b)); highp float sn= mod(dt,3.14159265358979323846); return fract(sin(sn) * c); } // Noise function float vnoise( vec2 st ) { vec2 i = floor(st), f = fract(st); float a = rng(i), b = rng(i + vec2(1.0, 0.0)), c = rng(i + vec2(0.0, 1.0)), d = rng(i + vec2(1.0, 1.0)); vec2 uv= smoothstep(0.0, 1.0, f); //uv = f; return mix( a, b, uv.x ) + (c-a)*uv.y * (1.0-uv.x) + (d-b)*uv.x*uv.y; } // Brownian motion float fbm( vec2 p ) { float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += vnoise( p * scale ) / scale; } return f; } // Marble Texture float marbleturbulence( vec2 p ) { /* Same as the turbulence before. */ float f = 0.0, scale; for (int i=0; i<4; i++) { scale = pow( pow(2.0, 4.0/3.0), float(i) ); f += abs( vnoise( p * scale ) ) / scale; } return f; } // Colouring__________________________________ void main() { // Coordinates vec2 st = gl_FragCoord.xy/u_resolution.xy; float offset = 0.5; // Brownian texture float b = fbm( gl_FragCoord.xy / 10.0 ); // Marble texture float n = marbleturbulence( gl_FragCoord.xy / 3.0 ); float t = 1.0 + sin( gl_FragCoord.x / 80.0 + 10.0 * n ) / 2.0; // Orchid outline float orchid_sdf = min(lip(st.xy, offset), petals(st.xy, offset)); // Mask float mask = 1.0; mask *= step(0.0, orchid_sdf); // Petal colour vec3 petal_col = mix(vec3(1.000,0.891,0.000),vec3(1.000,0.680,0.954)-sign(lip(st.xy, offset))*vec3(0.1, 0.4, 0.7), exp(length(st-0.5))); petal_col = mix( vec3(t,0.3,0.5), petal_col, exp(length(st-0.5))); // Lip colour vec3 lip_col = vec3(1.000,0.745,0.950)/b; // Output colour if(lip(st.xy, offset) < 0.0){ colour_out = vec4(lip_col, 1.0); } else{ colour_out = vec4(petal_col, 1.0); } colour_out *= 1.0-mask; }
155
1
// credit: 5121DG04-3
2
// orchid: Cymbidium Cultivar
3
uniform vec2 u_resolution;
4
uniform vec2 u_mouse;
5
uniform float u_time;
6
7
// define squared dot product
8
float dot2(in vec2 v){return dot(v,v);}
9
10
// Primitives____________________________
11
// Modified from https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
12
13
// Vesica
14
float sdVesica(vec2 p, float r, float d){
15
p = abs(p);
16
float b = sqrt(r*r-d*d);
17
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b))
18
: length(p-vec2(-d,0.0))-r;
19
}
20
21
// Egg
22
float sdEgg( in vec2 p, in float ra, in float rb ){
23
const float k = sqrt(0.5);
24
p.x = abs(p.x);
25
float r = ra - rb;
26
return ((p.y<0.0) ? length(vec2(p.x, p.y )) - r :
27
(k*(p.x+r)<p.y) ? length(vec2(p.x, p.y-k*r)) :
28
length(vec2(p.x+r,p.y )) - 2.0*r) - rb;
29
}
30
31
// Uneven Capsule
32
float sdUnevenCapsule( vec2 p, float r1, float r2, float h ){
33
p.x = abs(p.x);
34
float b = (r1-r2)/h;
35
float a = sqrt(1.0-b*b);
36
float k = dot(p,vec2(-b,a));
37
if( k < 0.0 ) return length(p) - r1;
38
if( k > a*h ) return length(p-vec2(0.0,h)) - r2;
39
return dot(p, vec2(a,b) ) - r1;
40
}
41
42
// Structures____________________________
43
44
// Petals
45
float petals(vec2 p, float offset){
46
// Dimensions
47
float petal_length = 0.37;
48
float petal_width_drop = 0.3;
49
// Position
50
vec2 coord = p.xy-offset;
51
// Rotation Matrix
52
float theta = 2.5;
53
float c = cos(theta);
54
float s = sin(theta);
55
mat3 R = mat3(c, -s, 0,
56
s, c, 0,
57
0, 0, 1.0);
58
// Signed distance function
59
float petals_sdf = sdVesica(coord.xy-vec2(0.0, offset/2.5), petal_length, petal_width_drop);
60
for (int i=0; i<4; i++){
61
coord = (R*vec3(coord.xy, 1.0)).xy;
62
petals_sdf = min(petals_sdf, sdVesica(coord.xy-vec2(0.0, offset/2.5), petal_length, petal_width_drop));
63
}
64
return petals_sdf;
65
}
66
67
// Lip
68
float lip(vec2 p, float offset){
69
// Dimensions
70
float lip_length = 0.1;
71
float lip_width = 0.05;
72
float stem_bot_rad = 0.03;
73
float stem_top_rad = 0.06;
74
float stem_height = 0.15;
75
// Position
76
vec2 coord = p.xy-offset;
77
// Signed distance function
78
float lip_sdf = min(sdEgg( coord + vec2(0.0, offset/10.0), lip_length, lip_width ), sdUnevenCapsule(coord, stem_bot_rad, stem_top_rad, stem_height));
79
return lip_sdf;
80
}
81
82
// Noise___________________________________
83
// Modified from the lecture slides
84
85
// Random number generator
86
float rng(vec2 co) {
87
const highp float seed = 12.9898;
88
highp float a = seed;
89
highp float b = 78.233, c = 43758.5453;
90
highp float dt= dot(co.xy, vec2(a,b));
91
highp float sn= mod(dt,3.14159265358979323846);
92
return fract(sin(sn) * c); }
93
94
// Noise function
95
float vnoise( vec2 st ) {
96
vec2 i = floor(st), f = fract(st);
97
float a = rng(i), b = rng(i + vec2(1.0, 0.0)),
98
c = rng(i + vec2(0.0, 1.0)), d = rng(i + vec2(1.0, 1.0));
99
vec2 uv= smoothstep(0.0, 1.0, f);
100
//uv = f;
101
return mix( a, b, uv.x ) + (c-a)*uv.y * (1.0-uv.x) + (d-b)*uv.x*uv.y; }
102
103
// Brownian motion
104
float fbm( vec2 p ) {
105
float f = 0.0, scale;
106
for (int i=0; i<4; i++) {
107
scale = pow( pow(2.0, 4.0/3.0), float(i) );
108
f += vnoise( p * scale ) / scale;
109
}
110
return f; }
111
112
// Marble Texture
113
float marbleturbulence( vec2 p ) { /* Same as the turbulence before. */
114
float f = 0.0, scale;
115
for (int i=0; i<4; i++) {
116
scale = pow( pow(2.0, 4.0/3.0), float(i) );
117
f += abs( vnoise( p * scale ) ) / scale; }
118
return f; }
119
120
// Colouring__________________________________
121
void main() {
122
// Coordinates
123
vec2 st = gl_FragCoord.xy/u_resolution.xy;
124
float offset = 0.5;
125
126
// Brownian texture
127
float b = fbm( gl_FragCoord.xy / 10.0 );
128
129
// Marble texture
130
float n = marbleturbulence( gl_FragCoord.xy / 3.0 );
131
float t = 1.0 + sin( gl_FragCoord.x / 80.0 + 10.0 * n ) / 2.0;
132
133
// Orchid outline
134
float orchid_sdf = min(lip(st.xy, offset), petals(st.xy, offset));
135
136
// Mask
137
float mask = 1.0;
138
mask *= step(0.0, orchid_sdf);
139
140
// Petal colour
141
vec3 petal_col = mix(vec3(1.000,0.891,0.000),vec3(1.000,0.680,0.954)-sign(lip(st.xy, offset))*vec3(0.1, 0.4, 0.7), exp(length(st-0.5)));
142
petal_col = mix( vec3(t,0.3,0.5), petal_col, exp(length(st-0.5)));
143
144
// Lip colour
145
vec3 lip_col = vec3(1.000,0.745,0.950)/b;
146
147
// Output colour
148
if(lip(st.xy, offset) < 0.0){
149
colour_out = vec4(lip_col, 1.0);
150
}
151
else{
152
colour_out = vec4(petal_col, 1.0);
153
}
154
colour_out *= 1.0-mask;
155
}
Cymbidium Cultivar by anonymous
//Student: Waseda 1 uniform vec2 u_resolution; uniform float u_time; vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+10.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) -0.577350269189626, // -1.0 + 2.0 * C.x 0.024390243902439); // 1.0 / 41.0 // First corner vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); // Other corners vec2 i1; //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 //i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); // x0 = x0 - 0.0 + 0.0 * C.xx ; // x1 = x0 - i1 + 1.0 * C.xx ; // x2 = x0 - 1.0 + 2.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; // Permutations i = mod289(i); // Avoid truncation effects in permutation vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; // Gradients: 41 points uniformly over a line, mapped onto a diamond. // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; // Normalise gradients implicitly by scaling m // Approximation of: m *= inversesqrt( a0*a0 + h*h ); m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); // Compute final noise value at P vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float sdVesica(vec2 p, float r, float d){ p = abs(p); float b = sqrt(r*r-d*d); return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b)) : length(p-vec2(-d,0.0))-r; } float sdf(vec2 p){ return sdVesica( 1.816*p-vec2(0.920,1.000), 0.080, 0.160); } void main() { vec2 st = gl_FragCoord.xy / u_resolution.xy; float mask = snoise(st); //mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) ); mask *= step( 0.202, distance( st.xy, vec2(0.680,0.370)) ); mask *= step( 0.202, distance( st.xy, vec2(0.340,0.380) ) ); mask *= step(0.346, sdf(st.xy)); colour_out = vec4( st.x, st.y, abs(sin(0.840)), 1.0 ); colour_out *= 1.0-mask; }
1
//Student: Waseda 1
2
uniform vec2 u_resolution;
3
uniform float u_time;
4
5
vec3 mod289(vec3 x) {
6
return x - floor(x * (1.0 / 289.0)) * 289.0;
7
}
8
9
vec2 mod289(vec2 x) {
10
return x - floor(x * (1.0 / 289.0)) * 289.0;
11
}
12
13
vec3 permute(vec3 x) {
14
return mod289(((x*34.0)+10.0)*x);
15
}
16
17
float snoise(vec2 v)
18
{
19
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
20
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
21
-0.577350269189626, // -1.0 + 2.0 * C.x
22
0.024390243902439); // 1.0 / 41.0
23
// First corner
24
vec2 i = floor(v + dot(v, C.yy) );
25
vec2 x0 = v - i + dot(i, C.xx);
26
27
// Other corners
28
vec2 i1;
29
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
30
//i1.y = 1.0 - i1.x;
31
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
32
// x0 = x0 - 0.0 + 0.0 * C.xx ;
33
// x1 = x0 - i1 + 1.0 * C.xx ;
34
// x2 = x0 - 1.0 + 2.0 * C.xx ;
35
vec4 x12 = x0.xyxy + C.xxzz;
36
x12.xy -= i1;
37
38
// Permutations
39
i = mod289(i); // Avoid truncation effects in permutation
40
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
41
+ i.x + vec3(0.0, i1.x, 1.0 ));
42
43
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
44
m = m*m ;
45
m = m*m ;
46
47
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
48
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
49
50
vec3 x = 2.0 * fract(p * C.www) - 1.0;
51
vec3 h = abs(x) - 0.5;
52
vec3 ox = floor(x + 0.5);
53
vec3 a0 = x - ox;
54
55
// Normalise gradients implicitly by scaling m
56
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
57
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
58
59
// Compute final noise value at P
60
vec3 g;
61
g.x = a0.x * x0.x + h.x * x0.y;
62
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
63
return 130.0 * dot(m, g);
64
}
65
float sdVesica(vec2 p, float r, float d){
66
p = abs(p);
67
float b = sqrt(r*r-d*d);
68
return ((p.y-b)*d>p.x*b) ? length(p-vec2(0.0,b))
69
: length(p-vec2(-d,0.0))-r;
70
}
71
72
float sdf(vec2 p){
73
return sdVesica( 1.816*p-vec2(0.920,1.000), 0.080, 0.160);
74
}
75
void main() {
76
vec2 st = gl_FragCoord.xy / u_resolution.xy;
77
float mask = snoise(st);
78
//mask *= step( 0.3, distance( st.xy, vec2(0.5, 0.4) ) );
79
mask *= step( 0.202, distance( st.xy, vec2(0.680,0.370)) );
80
mask *= step( 0.202, distance( st.xy, vec2(0.340,0.380) ) );
81
mask *= step(0.346, sdf(st.xy));
82
colour_out = vec4( st.x, st.y, abs(sin(0.840)), 1.0 );
83
colour_out *= 1.0-mask;
84
}
Phalaenopsis Hybrid by Waseda 1
// credit: takuto // orchid: Phalaenopsis #define PI 3.14159265358979323846 #define TAU (2.0*PI) uniform vec2 u_resolution; uniform float u_time; vec3 olive = vec3(0.482, 0.5, 0.29); vec3 red = vec3(0.952, 0.227, 0.152); vec3 orange = vec3(1.0, 1.0, 0.2); vec3 yellow = vec3(0.956, 0.898, 0.247); vec3 black = vec3(0.0); vec3 white = vec3(1.0); vec3 gray = vec3(0.147); vec3 pink = vec3(1.0, 0.69, 0.66); vec3 green = vec3(0.20, 0.52, 0.13); float merge(float d1, float d2){ return min(d1, d2); } float smoothMerge(float d1, float d2, float k){ float h = clamp(0.5 + 0.5*(d2 - d1)/k, 0.0, 1.0); return mix(d2, d1, h) - k * h * (1.0-h); } float substract(float d1, float d2){ return max(-d1, d2); } float ellipseDist(vec2 p, float radius, vec2 dim){ vec2 pos = p; pos.x = p.x / dim.x; pos.y = p.y / dim.y; return length(pos) - radius; } float circleDist(vec2 p, float radius){ return length(p) - radius; } mat2 rotate2dm(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } vec2 rotate2D (vec2 _st, float _angle) { _st = rotate2dm(_angle) * _st; return _st; } float when_eq(float x, float y) { return 1.0 - abs(sign(x - y)); } float orcSepals(vec2 toCenter, float resize, float defX, float defY, float grow, float nPetals, float smoothness){ float angle = atan(toCenter.y,toCenter.x) + 0.5; float deformOnY = toCenter.y * defY; float deformOnX = abs(toCenter.x) * defX; float radius = length(toCenter)*resize * (grow+deformOnY+deformOnX); float f = cos(angle*nPetals); return smoothstep(f, f+smoothness,radius); } float lip(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){ float A = ellipseDist(pos, radius, oval); vec2 posB = pos; posB.y += offset; float B = ellipseDist(posB, radius, ovalSub); float p = smoothMerge(B, A, 0.5); return p; } float orcColumn(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){ float A = ellipseDist(pos, radius, ovalSub); vec2 posB = pos; posB.y -= offset; float B = ellipseDist(posB, radius, oval); float p = substract(B,A); posB.y += 0.035; float cone = ellipseDist(posB, radius, vec2(0.055, 0.30)); p = smoothMerge(cone,p, 0.4); float s = ellipseDist(posB, radius, vec2(0.2, 0.20)); return p; } float fillSmooth(float sdfVal, float size, float smoothness){ return smoothstep(size, size+smoothness,sdfVal); } float rand(vec2 uv){ return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453); } float cW = 2.0; float cH = 1.5; float bool2sign(int x) { /* if (x == 0) return 1.0; */ /* else return -1.0; */ /* return 1.0; */ return float(-1 * x + (1 - x)); } float modfloat(float x, float a) { return x - floor(x / a) * a; } vec4 drawOrchid(vec3 bg_color) { float smoothness = 0.05; vec2 st = gl_FragCoord.xy / u_resolution.xy * 2.0 - 1.0; st.x *= u_resolution.x / u_resolution.y; float x = st.x + 0.5 * u_time; float y = st.y + 0.3 * u_time; x = bool2sign(int((x + cW / 2.0) / cW) % 2) * (modfloat(x + cW / 2.0, cW) - cW / 2.0); y = bool2sign(int((y + cH / 2.0) / cH) % 2) * (modfloat(y + cH / 2.0, cH) - cH / 2.0); st.xy = vec2(x, y); st = rotate2D(st,TAU*u_time*0.15); // Orchid parameters. The orchid is composed by sepals, petals, lip and column //column parameters float colResize = 0.45; vec2 posCol = st; posCol.y += 0.035; float colYoffset = -0.051; float powerCol = 2.0; vec2 colRatio = vec2(0.7*colResize, 0.7*colResize); vec2 colSubRatio = vec2(0.9*colResize, 0.9*colResize); float colRadius = 0.52*colResize; // sepals parameters float addSmoothnessToSetals = 2.9; float deformX = 0.0; float deformY = 0.0; float resizePetals = 11.9; float powerSepals = 2.0; float nPetals = 3.0; float growSepals = exp2(length(st)) * 0.19; float nPetalsLat = 2.0; float deformXLat = 0.0; float deformYLat = -0.0; float resizePetalsLat = 21.9; float powerLat = 2.3; vec2 latPos = st*rotate2dm(TAU/2.4); float growLaterals = pow(length(st), powerLat); // lip parameter vec2 posLip = st; posLip.y += 0.18; float lipResize = 0.6; float lipYoffset = 0.05; vec2 lipRatio = vec2(0.19*lipResize, 0.45*lipResize); vec2 smallLipRatio = vec2(0.3*lipResize, 0.15*lipResize); float lipRadius = 1.0*lipResize; float column = orcColumn(posCol*rotate2dm(TAU/2.0), colRatio, colSubRatio, colRadius, colYoffset); float sepals = orcSepals(st, resizePetals, deformX, deformY, growSepals, nPetals, smoothness+addSmoothnessToSetals); float latPetals = orcSepals(latPos, resizePetalsLat, deformXLat, deformYLat, growLaterals, nPetalsLat, smoothness+addSmoothnessToSetals); float lip = lip(posLip, lipRatio, smallLipRatio, lipRadius, lipYoffset); float orchids = merge(latPetals, sepals); orchids = merge(orchids, lip); orchids = substract(column, orchids); // this angle is using while creating the colors float angle = atan(st.y,st.x) + 0.5; // Sepals color: sepals = fillSmooth(sepals,0.09,smoothness+0.005); vec3 sepalsColor = mix(yellow, white, rand(st)); vec3 orcColor = mix(sepalsColor, bg_color, sepals); // Lip color: // 1) create the space coord for the dots vec2 lipSt = st; lipSt = fract(lipSt *= 20.0); lipSt -= vec2(0.5,0.5); // 2 create the color dots float dots = circleDist(lipSt, 0.1); dots = smoothstep(dots, dots+0.05, 0.2); vec3 colorPoints = mix(green, white, dots); // 3 mix the color with the orchid lip = fillSmooth(lip,0.09,smoothness+0.005); orcColor = mix(colorPoints, orcColor, lip); // Petals color latPetals = fillSmooth(latPetals,0.09,smoothness+0.005); vec3 latPetalsColor = mix(yellow, red, sin(angle * 40.0)); latPetalsColor = mix(latPetalsColor, red, abs(st.x)*2.7); orcColor = mix(latPetalsColor,orcColor,latPetals); // column color column = fillSmooth(column,0.01,0.02); vec3 columnColor = orange - red * (st.y *2.0); orcColor = mix(columnColor, orcColor, column); return vec4(vec3(orcColor),1.0); } #define fs(i) (fract(sin((i)*114.514)*1919.810)) #define lofi(i,j) (floor((i)/(j))*(j)) float seed; mat2 r2d(float t) { return mat2(cos(t),sin(t),-sin(t),cos(t)); } mat3 orthBas(vec3 z) { z = normalize(z); vec3 up = abs(z.y)>0.999?vec3(0,0,1):vec3(0,1,0); vec3 x = normalize(cross(up,z)); return mat3(x,cross(z,x),z); } float random() { seed++; return fs(seed); } vec3 uniformLambert(vec3 n) { float p = TAU*random(); float cost = sqrt(random()); float sint = sqrt(1.0-cost*cost); return orthBas(n)*vec3(cos(p)*sint,sin(p)*sint,cost); } vec4 tbox(vec3 ro,vec3 rd,vec3 s) { vec3 or = ro/rd; vec3 pl = abs(s/rd); vec3 f = -or-pl; vec3 b = -or+pl; float fl = max(f.x,max(f.y,f.z)); float bl = min(b.x,min(b.y,b.z)); if (bl<fl||fl<0.0) return vec4(1E2); vec3 n = -sign(rd)*step(f.yzx,f.xyz)*step(f.zxy,f.xyz); return vec4(n,fl); } struct QTR { vec3 cell; vec3 pos; float len; float size; bool hole; }; bool isHole(vec3 p) { if (abs(p.x)<0.5&&abs(p.y)<0.5) return true; float dice = fs(dot(p,vec3(-2.0,-5.0,7.0))); if (dice<0.3) return true; return false; } QTR qt(vec3 ro,vec3 rd){ vec3 haha = lofi(ro+rd*1E-2,0.5); float ha = fs(dot(haha,vec3(6.0,2.0,0.0))); ha = smoothstep(-0.2,0.2,sin(0.5*u_time+TAU*(ha-0.5))); ro.z += ha; QTR r; r.size = 1.0; for (int i= 0; i<4; i++) { r.size /= 2.0; r.cell = lofi(ro+rd*1E-2*r.size,r.size)+r.size/2.0; if(isHole(r.cell)) break; float dice = fs(dot(r.cell,vec3(5.0,6.0,7.0))); if(dice>r.size) break; } vec3 or = (ro-r.cell)/rd; vec3 pl = abs(r.size/2./rd); vec3 b = -or+pl; r.len = min(b.x,min(b.y,b.z)); r.pos = r.cell-vec3(0.0,0.0,ha); r.hole = isHole(r.cell); return r; } vec4 drawBackground() { vec2 uv = gl_FragCoord.xy/u_resolution.xy; vec2 p = uv*2.0-1.0; p.x *= u_resolution.x/u_resolution.y; /* seed = texture(iChannel0,p).x; */ seed = fract(u_time); float haha = u_time*62.0/60.0; float haha2 = floor(haha)-.2*exp(-fract(haha)); p = r2d(u_time*0.2+0.2*floor(haha))*p; vec3 ro0 = vec3(0.0,0.0,1.0); ro0.z -= haha2; ro0 += 0.02*vec3(sin(u_time*1.36),sin(u_time*1.78),0.0); vec3 rd0 = normalize(vec3(p,-1.0)); vec3 ro = ro0; vec3 rd = rd0; vec3 fp = ro+rd*2.0; ro += vec3(0.04*vec2(random(),random())*mat2(1.0,1.0,-1.0,1.0),0.0); rd = normalize(fp-ro); float rl = 0.01; vec3 rp = ro+rd*rl; vec3 col = vec3(0.0); vec3 colRem = vec3(1.0); float samples = 1.0; for (int i= 0; i<200; i++) { QTR qtr = qt(rp,rd); vec4 isect; if (qtr.hole) { isect = vec4(1E2); } else { float size = qtr.size*0.5; size -= 0.01; size -= 0.02*(0.5+0.5*sin(5.0*u_time+15.0*qtr.cell.z)); isect = tbox(rp-qtr.pos,rd,vec3(size)); } if (isect.w<1E2) { float fog = exp(-.2*rl); colRem *= fog; rl += isect.w; rp = ro+rd*rl; vec3 mtl = fs(cross(qtr.cell,vec3(4.0,8.0,1.0))); vec3 n = isect.xyz; if (mtl.x<0.1) { col += colRem*vec3(10.0,1.0,1.0); colRem *= 0.0; } else if (mtl.x<0.2) { col += colRem*vec3(6.0,8.0,11.0); colRem *= 0.0; } else { colRem *= 0.3; } ro = ro+rd*rl; rd = mix(uniformLambert(n),reflect(rd,n),pow(random(),0.3)); rl = 0.01; } else { rl += qtr.len; rp = ro+rd*rl; } if (colRem.x<0.01) { ro = ro0; rd = rd0; vec3 fp = ro+rd*2.0; ro += vec3(0.04*vec2(random(),random())*mat2(1.0,1.0,-1.0,1.0),0.0); rd = normalize(fp-ro); rl = 0.01; rp = ro+rd*rl; colRem = vec3(1.0); samples++; } } col = pow(col/samples,vec3(0.4545)); col *= 1.0-0.4*length(p); col = vec3( smoothstep(0.1,0.9,col.x), smoothstep(0.0,1.0,col.y), smoothstep(-0.1,1.1,col.z) ); vec4 prev = vec4(0.0); return mix(vec4(col,1.0),prev,0.5*prev.w); } void main() { vec4 bg_color = drawBackground(); /* vec4 bg_color = vec4(black, 1.0); */ colour_out = drawOrchid(bg_color.xyz); }
403
1
// credit: takuto
2
// orchid: Phalaenopsis
3
4
5
6
7
uniform vec2 u_resolution;
8
uniform float u_time;
9
10
vec3 olive = vec3(0.482, 0.5, 0.29);
11
vec3 red = vec3(0.952, 0.227, 0.152);
12
vec3 orange = vec3(1.0, 1.0, 0.2);
13
vec3 yellow = vec3(0.956, 0.898, 0.247);
14
vec3 black = vec3(0.0);
15
vec3 white = vec3(1.0);
16
vec3 gray = vec3(0.147);
17
vec3 pink = vec3(1.0, 0.69, 0.66);
18
vec3 green = vec3(0.20, 0.52, 0.13);
19
20
float merge(float d1, float d2){
21
return min(d1, d2);
22
}
23
24
float smoothMerge(float d1, float d2, float k){
25
float h = clamp(0.5 + 0.5*(d2 - d1)/k, 0.0, 1.0);
26
return mix(d2, d1, h) - k * h * (1.0-h);
27
}
28
29
float substract(float d1, float d2){
30
return max(-d1, d2);
31
}
32
33
float ellipseDist(vec2 p, float radius, vec2 dim){
34
vec2 pos = p;
35
pos.x = p.x / dim.x;
36
pos.y = p.y / dim.y;
37
return length(pos) - radius;
38
}
39
40
float circleDist(vec2 p, float radius){
41
return length(p) - radius;
42
}
43
44
mat2 rotate2dm(float _angle){
45
return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle));
46
}
47
48
49
vec2 rotate2D (vec2 _st, float _angle) {
50
_st = rotate2dm(_angle) * _st;
51
return _st;
52
}
53
54
float when_eq(float x, float y) {
55
return 1.0 - abs(sign(x - y));
56
}
57
58
float orcSepals(vec2 toCenter, float resize, float defX, float defY, float grow, float nPetals, float smoothness){
59
float angle = atan(toCenter.y,toCenter.x) + 0.5;
60
float deformOnY = toCenter.y * defY;
61
float deformOnX = abs(toCenter.x) * defX;
62
float radius = length(toCenter)*resize * (grow+deformOnY+deformOnX);
63
64
float f = cos(angle*nPetals);
65
return smoothstep(f, f+smoothness,radius);
66
}
67
68
float lip(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){
69
float A = ellipseDist(pos, radius, oval);
70
vec2 posB = pos;
71
posB.y += offset;
72
float B = ellipseDist(posB, radius, ovalSub);
73
float p = smoothMerge(B, A, 0.5);
74
return p;
75
}
76
77
float orcColumn(vec2 pos, vec2 oval, vec2 ovalSub,float radius, float offset){
78
float A = ellipseDist(pos, radius, ovalSub);
79
vec2 posB = pos;
80
posB.y -= offset;
81
float B = ellipseDist(posB, radius, oval);
82
float p = substract(B,A);
83
posB.y += 0.035;
84
float cone = ellipseDist(posB, radius, vec2(0.055, 0.30));
85
p = smoothMerge(cone,p, 0.4);
86
float s = ellipseDist(posB, radius, vec2(0.2, 0.20));
87
return p;
88
}
89
90
float fillSmooth(float sdfVal, float size, float smoothness){
91
return smoothstep(size, size+smoothness,sdfVal);
92
}
93
94
float rand(vec2 uv){
95
return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453);
96
}
97
98
float cW = 2.0;
99
float cH = 1.5;
100
101
float bool2sign(int x) {
102
/* if (x == 0) return 1.0; */
103
/* else return -1.0; */
104
/* return 1.0; */
105
return float(-1 * x + (1 - x));
106
}
107
108
float modfloat(float x, float a) {
109
return x - floor(x / a) * a;
110
}
111
112
vec4 drawOrchid(vec3 bg_color) {
113
float smoothness = 0.05;
114
115
vec2 st = gl_FragCoord.xy / u_resolution.xy * 2.0 - 1.0;
116
st.x *= u_resolution.x / u_resolution.y;
117
118
float x = st.x + 0.5 * u_time;
119
float y = st.y + 0.3 * u_time;
120
x = bool2sign(int((x + cW / 2.0) / cW) % 2) * (modfloat(x + cW / 2.0, cW) - cW / 2.0);
121
y = bool2sign(int((y + cH / 2.0) / cH) % 2) * (modfloat(y + cH / 2.0, cH) - cH / 2.0);
122
st.xy = vec2(x, y);
123
124
st = rotate2D(st,TAU*u_time*0.15);
125
// Orchid parameters. The orchid is composed by sepals, petals, lip and column
126
127
//column parameters
128
float colResize = 0.45;
129
vec2 posCol = st;
130
posCol.y += 0.035;
131
float colYoffset = -0.051;
132
float powerCol = 2.0;
133
vec2 colRatio = vec2(0.7*colResize, 0.7*colResize);
134
vec2 colSubRatio = vec2(0.9*colResize, 0.9*colResize);
135
float colRadius = 0.52*colResize;
136
// sepals parameters
137
float addSmoothnessToSetals = 2.9;
138
float deformX = 0.0;
139
float deformY = 0.0;
140
float resizePetals = 11.9;
141
float powerSepals = 2.0;
142
float nPetals = 3.0;
143
float growSepals = exp2(length(st)) * 0.19;
144
float nPetalsLat = 2.0;
145
float deformXLat = 0.0;
146
float deformYLat = -0.0;
147
float resizePetalsLat = 21.9;
148
float powerLat = 2.3;
149
vec2 latPos = st*rotate2dm(TAU/2.4);
150
float growLaterals = pow(length(st), powerLat);
151
// lip parameter
152
vec2 posLip = st;
153
posLip.y += 0.18;
154
float lipResize = 0.6;
155
float lipYoffset = 0.05;
156
vec2 lipRatio = vec2(0.19*lipResize, 0.45*lipResize);
157
vec2 smallLipRatio = vec2(0.3*lipResize, 0.15*lipResize);
158
float lipRadius = 1.0*lipResize;
159
160
float column = orcColumn(posCol*rotate2dm(TAU/2.0),
161
colRatio,
162
colSubRatio,
163
colRadius, colYoffset);
164
float sepals = orcSepals(st,
165
resizePetals,
166
deformX,
167
deformY, growSepals, nPetals,
168
smoothness+addSmoothnessToSetals);
169
float latPetals = orcSepals(latPos,
170
resizePetalsLat,
171
deformXLat,
172
deformYLat, growLaterals, nPetalsLat,
173
smoothness+addSmoothnessToSetals);
174
float lip = lip(posLip,
175
lipRatio,
176
smallLipRatio,
177
lipRadius, lipYoffset);
178
179
float orchids = merge(latPetals, sepals);
180
orchids = merge(orchids, lip);
181
orchids = substract(column, orchids);
182
// this angle is using while creating the colors
183
float angle = atan(st.y,st.x) + 0.5;
184
185
// Sepals color:
186
sepals = fillSmooth(sepals,0.09,smoothness+0.005);
187
vec3 sepalsColor = mix(yellow, white, rand(st));
188
vec3 orcColor = mix(sepalsColor, bg_color, sepals);
189
190
// Lip color:
191
// 1) create the space coord for the dots
192
vec2 lipSt = st;
193
lipSt = fract(lipSt *= 20.0);
194
lipSt -= vec2(0.5,0.5);
195
// 2 create the color dots
196
float dots = circleDist(lipSt, 0.1);
197
dots = smoothstep(dots, dots+0.05, 0.2);
198
vec3 colorPoints = mix(green, white, dots);
199
// 3 mix the color with the orchid
200
lip = fillSmooth(lip,0.09,smoothness+0.005);
201
orcColor = mix(colorPoints, orcColor, lip);
202
203
// Petals color
204
latPetals = fillSmooth(latPetals,0.09,smoothness+0.005);
205
vec3 latPetalsColor = mix(yellow, red, sin(angle * 40.0));
206
latPetalsColor = mix(latPetalsColor, red, abs(st.x)*2.7);
207
orcColor = mix(latPetalsColor,orcColor,latPetals);
208
209
// column color
210
column = fillSmooth(column,0.01,0.02);
211
vec3 columnColor = orange - red * (st.y *2.0);
212
orcColor = mix(columnColor, orcColor, column);
213
214
return vec4(vec3(orcColor),1.0);
215
}
216
217
218
219
220
float seed;
221
222
mat2 r2d(float t) {
223
return mat2(cos(t),sin(t),-sin(t),cos(t));
224
}
225
226
mat3 orthBas(vec3 z) {
227
z = normalize(z);
228
vec3 up = abs(z.y)>0.999?vec3(0,0,1):vec3(0,1,0);
229
vec3 x = normalize(cross(up,z));
230
return mat3(x,cross(z,x),z);
231
}
232
233
float random() {
234
seed++;
235
return fs(seed);
236
}
237
238
vec3 uniformLambert(vec3 n) {
239
float p = TAU*random();
240
float cost = sqrt(random());
241
float sint = sqrt(1.0-cost*cost);
242
return orthBas(n)*vec3(cos(p)*sint,sin(p)*sint,cost);
243
}
244
245
vec4 tbox(vec3 ro,vec3 rd,vec3 s) {
246
vec3 or = ro/rd;
247
vec3 pl = abs(s/rd);
248
vec3 f = -or-pl;
249
vec3 b = -or+pl;
250
float fl = max(f.x,max(f.y,f.z));
251
float bl = min(b.x,min(b.y,b.z));
252
if (bl<fl||fl<0.0) return vec4(1E2);
253
vec3 n = -sign(rd)*step(f.yzx,f.xyz)*step(f.zxy,f.xyz);
254
return vec4(n,fl);
255
}
256
257
struct QTR {
258
vec3 cell;
259
vec3 pos;
260
float len;
261
float size;
262
bool hole;
263
};
264
265
bool isHole(vec3 p) {
266
if (abs(p.x)<0.5&&abs(p.y)<0.5) return true;
267
float dice = fs(dot(p,vec3(-2.0,-5.0,7.0)));
268
if (dice<0.3) return true;
269
return false;
270
}
271
272
QTR qt(vec3 ro,vec3 rd){
273
vec3 haha = lofi(ro+rd*1E-2,0.5);
274
float ha = fs(dot(haha,vec3(6.0,2.0,0.0)));
275
ha = smoothstep(-0.2,0.2,sin(0.5*u_time+TAU*(ha-0.5)));
276
277
ro.z += ha;
278
279
QTR r;
280
r.size = 1.0;
281
for (int i= 0; i<4; i++) {
282
r.size /= 2.0;
283
r.cell = lofi(ro+rd*1E-2*r.size,r.size)+r.size/2.0;
284
if(isHole(r.cell)) break;
285
float dice = fs(dot(r.cell,vec3(5.0,6.0,7.0)));
286
if(dice>r.size) break;
287
}
288
289
vec3 or = (ro-r.cell)/rd;
290
vec3 pl = abs(r.size/2./rd);
291
vec3 b = -or+pl;
292
r.len = min(b.x,min(b.y,b.z));
293
294
r.pos = r.cell-vec3(0.0,0.0,ha);
295
r.hole = isHole(r.cell);
296
297
return r;
298
}
299
300
vec4 drawBackground() {
301
vec2 uv = gl_FragCoord.xy/u_resolution.xy;
302
vec2 p = uv*2.0-1.0;
303
p.x *= u_resolution.x/u_resolution.y;
304
305
/* seed = texture(iChannel0,p).x; */
306
seed = fract(u_time);
307
308
float haha = u_time*62.0/60.0;
309
float haha2 = floor(haha)-.2*exp(-fract(haha));
310
311
p = r2d(u_time*0.2+0.2*floor(haha))*p;
312
313
vec3 ro0 = vec3(0.0,0.0,1.0);
314
ro0.z -= haha2;
315
ro0 += 0.02*vec3(sin(u_time*1.36),sin(u_time*1.78),0.0);
316
317
vec3 rd0 = normalize(vec3(p,-1.0));
318
319
vec3 ro = ro0;
320
vec3 rd = rd0;
321
vec3 fp = ro+rd*2.0;
322
ro += vec3(0.04*vec2(random(),random())*mat2(1.0,1.0,-1.0,1.0),0.0);
323
rd = normalize(fp-ro);
324
325
float rl = 0.01;
326
vec3 rp = ro+rd*rl;
327
328
vec3 col = vec3(0.0);
329
vec3 colRem = vec3(1.0);
330
float samples = 1.0;
331
332
for (int i= 0; i<200; i++) {
333
QTR qtr = qt(rp,rd);
334
335
vec4 isect;
336
if (qtr.hole) {
337
isect = vec4(1E2);
338
} else {
339
float size = qtr.size*0.5;
340
size -= 0.01;
341
size -= 0.02*(0.5+0.5*sin(5.0*u_time+15.0*qtr.cell.z));
342
isect = tbox(rp-qtr.pos,rd,vec3(size));
343
}
344
345
if (isect.w<1E2) {
346
float fog = exp(-.2*rl);
347
colRem *= fog;
348
349
rl += isect.w;
350
rp = ro+rd*rl;
351
352
vec3 mtl = fs(cross(qtr.cell,vec3(4.0,8.0,1.0)));
353
354
vec3 n = isect.xyz;
355
356
if (mtl.x<0.1) {
357
col += colRem*vec3(10.0,1.0,1.0);
358
colRem *= 0.0;
359
} else if (mtl.x<0.2) {
360
col += colRem*vec3(6.0,8.0,11.0);
361
colRem *= 0.0;
362
} else {
363
colRem *= 0.3;
364
}
365
366
ro = ro+rd*rl;
367
rd = mix(uniformLambert(n),reflect(rd,n),pow(random(),0.3));
368
rl = 0.01;
369
} else {
370
rl += qtr.len;
371
rp = ro+rd*rl;
372
}
373
374
if (colRem.x<0.01) {
375
ro = ro0;
376
rd = rd0;
377
vec3 fp = ro+rd*2.0;
378
ro += vec3(0.04*vec2(random(),random())*mat2(1.0,1.0,-1.0,1.0),0.0);
379
rd = normalize(fp-ro);
380
rl = 0.01;
381
rp = ro+rd*rl;
382
colRem = vec3(1.0);
383
samples++;
384
}
385
}
386
387
col = pow(col/samples,vec3(0.4545));
388
col *= 1.0-0.4*length(p);
389
col = vec3(
390
smoothstep(0.1,0.9,col.x),
391
smoothstep(0.0,1.0,col.y),
392
smoothstep(-0.1,1.1,col.z)
393
);
394
395
vec4 prev = vec4(0.0);
396
return mix(vec4(col,1.0),prev,0.5*prev.w);
397
}
398
399
void main() {
400
vec4 bg_color = drawBackground();
401
/* vec4 bg_color = vec4(black, 1.0); */
402
colour_out = drawOrchid(bg_color.xyz);
403
}
Phalaenopsis Hybrid by takuto