显示结果
相关图片:
image.pngimage.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
代码0601.frag
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.141592653589793
#define HALF_PI 1.5707963267948966
uniform vec2 u_resolution;
uniform float u_time;
float linear(float t) {
return t;
}
float exponentialIn(float t) {
return t == 0.0 ? t : pow(2.0, 10.0 * (t - 1.0));
}
float exponentialOut(float t) {
return t == 1.0 ? t : 1.0 - pow(2.0, -10.0 * t);
}
float exponentialInOut(float t) {
return t == 0.0 || t == 1.0
? t
: t < 0.5
? +0.5 * pow(2.0, (20.0 * t) - 10.0)
: -0.5 * pow(2.0, 10.0 - (t * 20.0)) + 1.0;
}
float sineIn(float t) {
return sin((t - 1.0) * HALF_PI) + 1.0;
}
float sineOut(float t) {
return sin(t * HALF_PI);
}
float sineInOut(float t) {
return -0.5 * (cos(PI * t) - 1.0);
}
float qinticIn(float t) {
return pow(t, 5.0);
}
float qinticOut(float t) {
return 1.0 - (pow(t - 1.0, 5.0));
}
float qinticInOut(float t) {
return t < 0.5
? +16.0 * pow(t, 5.0)
: -0.5 * pow(2.0 * t - 2.0, 5.0) + 1.0;
}
float quarticIn(float t) {
return pow(t, 4.0);
}
float quarticOut(float t) {
return pow(t - 1.0, 3.0) * (1.0 - t) + 1.0;
}
float quarticInOut(float t) {
return t < 0.5
? +8.0 * pow(t, 4.0)
: -8.0 * pow(t - 1.0, 4.0) + 1.0;
}
float quadraticInOut(float t) {
float p = 2.0 * t * t;
return t < 0.5 ? p : -p + (4.0 * t) - 1.0;
}
float quadraticIn(float t) {
return t * t;
}
float quadraticOut(float t) {
return -t * (t - 2.0);
}
float cubicIn(float t) {
return t * t * t;
}
float cubicOut(float t) {
float f = t - 1.0;
return f * f * f + 1.0;
}
float cubicInOut(float t) {
return t < 0.5
? 4.0 * t * t * t
: 0.5 * pow(2.0 * t - 2.0, 3.0) + 1.0;
}
float elasticIn(float t) {
return sin(13.0 * t * HALF_PI) * pow(2.0, 10.0 * (t - 1.0));
}
float elasticOut(float t) {
return sin(-13.0 * (t + 1.0) * HALF_PI) * pow(2.0, -10.0 * t) + 1.0;
}
float elasticInOut(float t) {
return t < 0.5
? 0.5 * sin(+13.0 * HALF_PI * 2.0 * t) * pow(2.0, 10.0 * (2.0 * t - 1.0))
: 0.5 * sin(-13.0 * HALF_PI * ((2.0 * t - 1.0) + 1.0)) * pow(2.0, -10.0 * (2.0 * t - 1.0)) + 1.0;
}
float circularIn(float t) {
return 1.0 - sqrt(1.0 - t * t);
}
float circularOut(float t) {
return sqrt((2.0 - t) * t);
}
float circularInOut(float t) {
return t < 0.5
? 0.5 * (1.0 - sqrt(1.0 - 4.0 * t * t))
: 0.5 * (sqrt((3.0 - 2.0 * t) * (2.0 * t - 1.0)) + 1.0);
}
float bounceOut(float t) {
const float a = 4.0 / 11.0;
const float b = 8.0 / 11.0;
const float c = 9.0 / 10.0;
const float ca = 4356.0 / 361.0;
const float cb = 35442.0 / 1805.0;
const float cc = 16061.0 / 1805.0;
float t2 = t * t;
return t < a
? 7.5625 * t2
: t < b
? 9.075 * t2 - 9.9 * t + 3.4
: t < c
? ca * t2 - cb * t + cc
: 10.8 * t * t - 20.52 * t + 10.72;
}
float bounceIn(float t) {
return 1.0 - bounceOut(1.0 - t);
}
float bounceInOut(float t) {
return t < 0.5
? 0.5 * (1.0 - bounceOut(1.0 - t * 2.0))
: 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5;
}
float backIn(float t) {
return pow(t, 3.0) - t * sin(t * PI);
}
float backOut(float t) {
float f = 1.0 - t;
return 1.0 - (pow(f, 3.0) - f * sin(f * PI));
}
float backInOut(float t) {
float f = t < 0.5
? 2.0 * t
: 1.0 - (2.0 * t - 1.0);
float g = pow(f, 3.0) - f * sin(f * PI);
return t < 0.5
? 0.5 * g
: 0.5 * (1.0 - g) + 0.5;
}
vec3 ColorA=vec3(0.4275, 0.3529, 0.7451);
vec3 ColorB=vec3(0.4588, 0.2275, 0.2275);
void main(){
vec3 color=vec3(0.0);
//float pct=linear(abs(sin(u_time)));
//float pct=exponentialIn(abs(sin(u_time)));
float pct=bounceOut(abs(sin(u_time)));
color=mix(ColorA,ColorB,pct);
gl_FragColor=vec4(color,1.0);
}
代码0602.frag
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
vec3 colorA=vec3(0.102, 0.098, 0.4118);
vec3 colorB = vec3(0.5216, 0.5137, 0.098);
float stroke=0.1;
float plot(vec2 st, float pct){
return step(pct-stroke,st.x)-
smoothstep(pct,pct+stroke,st.x);
}
float almostIdentity( float x, float n )
{
return sqrt(x*x+n);
}
float parabola( float x, float k )
{
return pow( 4.0*x*(1.0-x), k );
}
float expImpulse( float x, float k )
{
float h = k*x;
return h*exp(1.0-h);
}
void main(){
vec2 st=gl_FragCoord.xy/u_resolution;
vec3 color=vec3(0.0, 0.0, 0.0);
float magicTime=abs(sin(u_time))*10.-1.0;
float y=expImpulse(st.x,magicTime);
vec3 pct=vec3(y);
pct[0]=expImpulse(st.x,magicTime);
pct[1]=almostIdentity((st.x-0.5),magicTime);
pct[2]=parabola(st.x,magicTime);
color=mix(colorA,colorB,pct);
color=mix(color,vec3(0.7255, 0.2078, 0.2078),plot(st,pct.r));
color=mix(color,vec3(0.1255, 0.7451, 0.1255),plot(st,pct.g));
color=mix(color,vec3(0.1961, 0.2471, 0.2549),plot(st,pct.b));
color=mix(color,vec3(0.4824, 0.5608, 0.6549),pct);
gl_FragColor=vec4(color,1.0);
}
代码0603.frag
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.141592653589793
#define TWO_PI 6.28318530718
uniform vec2 u_resolution;
uniform float u_time;
vec3 rgb2hsb( in vec3 c ){
vec4 K = vec4(.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz),
vec4(c.gb, K.xy),
step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r),
vec4(c.r, p.yzx),
step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (1.0 * d + e)),
d / (q.x + e),
q.x);
}
vec3 hsb2rgb( in vec3 c ){
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0,
0.0,
1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb);
return c.z * mix(vec3(1.0), rgb, c.y);
}
float parabola( float x, float k )
{
return pow( 4.0*x*(1.0-x), k );
}
float sinc( float x, float k )
{
float a = PI*((k*x-.0))*20.;
return sin(a)/a+0.3;
}
float pcurve( float x, float a, float b )
{
float k = pow(a+b,a+b) / (pow(a,a)*pow(b,b));
return k * pow( x, a ) * pow( 1.0-x, b );
}
float gain(float x, float k)
{
float a = 0.5*pow(2.0*((x<0.5)?x:1.0-x), k);
return (x<0.5)?a:1.0-a;
}
void main(){
vec2 st=gl_FragCoord.xy/u_resolution;
vec3 colorHSB=vec3(0.0);
vec3 colorRGB=vec3(0.0,0.0,0.0);
vec3 colorPolar=vec3(0.0,0.0,0.0);
vec3 color=vec3(0.0,0.0,0.0);
float test=tan(u_time);
float magicTime=pcurve(st.x,abs(sin(u_time)),abs(test))*0.5;
//vec2 toCenter=vec2(0.5)-st;
vec2 toCenter=vec2(magicTime)-st;
//float angle=atan(toCenter.y, toCenter.x)*1.0;
float angle=atan(toCenter.y, toCenter.x)*magicTime*20.;
//float radius=length(toCenter)*2.0;
float radius=length(toCenter)*magicTime*10.;
colorRGB =rgb2hsb(vec3(st.x,magicTime*2.,st.y));
colorHSB =hsb2rgb(vec3(st.x,magicTime,st.y));
colorPolar = hsb2rgb(vec3((angle/TWO_PI)+0.5,radius,1.0));
color=mix(colorRGB,colorPolar,0.1);
//gl_FragColor=vec4(colorPolar,1.0);
//gl_FragColor=vec4(colorRGB,1.0);
}
网友评论