text scroller

This commit is contained in:
2024-05-24 21:48:35 +03:00
parent acb50e1e15
commit 05de1acfc9
4 changed files with 152 additions and 134 deletions

View File

@ -12,5 +12,5 @@ CRINKLER_ORDERTRIES=4000
SHADER_FILE=shader_minified.h
TIME_UNIFORM_NAME='v'
RESOLUTION_UNIFORM_NAME='s'
TEXTS_UNIFORM_NAME='c'
TEXTS_UNIFORM_NAME='f'
USE_WIDECHAR_TEXTS=1

View File

@ -51,7 +51,7 @@ float map(in vec3 p) {
vec3 raymarch(in vec3 ro, vec3 rd, vec2 tminmax) {
float t = tminmax.x;
float dt = .02;
//float dt = .2 - .195*cos(iTime*.05);//animated
//float dt = .2 - .195*cos(time*.05);//animated
vec3 col = vec3(0.);
float c = 0.;
for(int i = 0; i < 64; i++) {
@ -187,19 +187,71 @@ void mainImage2(out vec4 fragColor, in vec2 fragCoord) {
fragColor = vec4(col, 1.0 - t * (0.02 + 0.02 * sin(time)));
}
void main(void) {
if (getBar() <= 8)
CoolSphere(gl_FragColor, gl_FragCoord.xy);
else
mainImage2(gl_FragColor, gl_FragCoord.xy);
vec3 l;
vec2 texttop = vec2(0., -.35), pt = (gl_FragCoord.xy / resolution) - texttop;
if(pt.y > 0.) {
l = gl_FragColor + texture2D(texts, pt);
}
gl_FragColor = vec4(l * (1.0), 1.0);
vec3 palette(float t) {
vec3 a = vec3(0.5, 0.5, 0.5);
vec3 b = vec3(1.0, 1.0, 1.0);
vec3 c = vec3(1.0, 1.0, 1.0);
vec3 d = vec3(0.0, 0.6666, 0.3333);
return a + b * cos(6.28318 * (c*t+d));
}
float rand(vec2 co) {
float a = 12.9898;
float b = 78.233;
float c = 43758.5453;
float dt= dot(co.xy ,vec2(a,b));
float sn= mod(dt,3.14);
return fract(sin(sn) * c);
}
vec3 random(vec2 coord) {
float rng = rand(vec2(coord.x+time, coord.y));
return vec3(0.05, 0.05, 0.05) * rng;
}
vec3 wave(vec2 uv, float phase, float _offset, float height, float waveLenght, float color) {
float val = -(sin(phase+uv.x*waveLenght+time) + (uv.y*6.+height)+_offset)*0.055;
val *= 1. + sin(phase + uv.x*waveLenght+time) + (uv.y*6.-height+_offset);
// return smoothstep(0.0, 32.0, val) * palette(color/360.);
return clamp(val, 0., 1.) * palette(color/360.);
}
vec2 waveTexture(vec2 uv) {
uv.y = clamp(sin(uv.x*7. + time)/10. + uv.y, 0., 1.)+0.4;
uv.x += sin(time);
return uv;
}
void TextScroller(out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from -1 to 1, origo at 0,0)
vec2 uv = (fragCoord*2. - resolution) / resolution;
vec2 uv2 = (fragCoord / resolution);
vec3 col = vec3(0., 0.3, 0.6);
col += texture2D(texts, waveTexture(uv2));
col += wave(uv, 0., 1., 3., 1., sin(time+0.3)*360.);
col += wave(uv, sin(time), 0., 3., -1., sin(time-1.2)*120.);
col += wave(uv, -3., 0., 3., 1., sin(time+0.5)*90.);
col += random(uv*2.);
// Output to screen
fragColor = vec4(col, 1.);
}
void main(void) {
if (getBar() <= 32)
TextScroller(gl_FragColor, gl_FragCoord.xy);
else
{
mainImage2(gl_FragColor, gl_FragCoord.xy);
vec3 l;
vec2 texttop = vec2(0., -.35), pt = (gl_FragCoord.xy / resolution) - texttop;
if(pt.y > 0.) {
l = gl_FragColor + texture2D(texts, pt);
}
gl_FragColor = vec4(l * (1.0), 1.0);
}
}

View File

@ -2,155 +2,121 @@
#ifndef SHADER_MINIFIED_H_
# define SHADER_MINIFIED_H_
# define VAR_resolution "s"
# define VAR_texts "c"
# define VAR_texts "f"
# define VAR_texture_sampler "m"
# define VAR_time "v"
const char *__temp_cleaned_shader_glsl =
"uniform float v;"
"uniform vec2 s;"
"uniform sampler2D m,c;"
"float f=0.;"
"vec2 n(vec2 v)"
"{"
"return vec2(v.x*v.x-v.y*v.y,2.*v.x*v.y);"
"}"
"mat2 t(float v)"
"uniform sampler2D m,f;"
"float y=0.;"
"mat2 n(float v)"
"{"
"return mat2(cos(v),sin(v),-sin(v),cos(v));"
"}"
"vec2 n(vec3 v,vec3 y)"
"{"
"vec4 s=vec4(0,0,0,2);"
"vec3 f=v-s.xyz;"
"float t=dot(f,y),m=t*t-dot(f,f)+s.w*s.w;"
"if(m<0.)"
"return vec2(-1);"
"m=sqrt(m);"
"return vec2(-t-m,-t+m);"
"}"
"float x(vec3 v)"
"{"
"float f=0.;"
"vec3 y=v;"
"for(int m=0;m<10;++m)"
"v=.7*abs(v)/dot(v,v)-.7,v.yz=n(v.yz),v=v.zxy,f+=exp(-19.*abs(dot(v,y)));"
"return f/2.;"
"vec3 s=abs(v)-vec3(.4,.4,.1);"
"return length(max(s,0.))+min(max(s.x,max(s.y,s.z)),0.);"
"}"
"vec3 n(vec3 v,vec3 y,vec2 s)"
"float n(vec3 v,float s)"
"{"
"float f=s.x;"
"vec3 m=vec3(0);"
"float r=0.;"
"for(int i=0;i<64;i++)"
"{"
"f+=.02*exp(-2.*r);"
"if(f>s.y)"
"break;"
"r=x(v+f*y);"
"m=.99*m+.08*vec3(r*r,r,r*r*r);"
"}"
"return m;"
"}"
"void t(out vec4 f,vec2 y)"
"{"
"float r=v;"
"vec2 i=-1.+2.*(y.xy/s.xy);"
"i.x*=s.x/s.y;"
"vec2 d=vec2(0);"
"d-=.5;"
"vec3 a=vec3(4);"
"a.yz*=t(d.y);"
"a.xz*=t(d.x+.1*r);"
"vec3 c=normalize(vec3(0)-a),g=normalize(cross(c,vec3(0,1,0))),z=normalize(i.x*g+i.y*normalize(cross(g,c))+4.*c);"
"vec2 o=n(a,z);"
"vec3 x=n(a,z,o);"
"if(o.x<0.)"
"x=texture2D(m,z).xyz;"
"else"
"{"
"vec3 e=(a+o.x*z)/2.;"
"e=reflect(z,e);"
"float l=pow(.5+clamp(dot(e,z),0.,1.),3.)*1.3;"
"x+=texture2D(m,e).xyz*l;"
"}"
"x=.5*log(1.+x);"
"x=clamp(x,0.,1.);"
"f=vec4(x,1);"
"}"
"float e(vec3 v)"
"{"
"vec3 f=abs(v)-vec3(.4,.4,.1);"
"return length(max(f,0.))+min(max(f.x,max(f.y,f.z)),0.);"
"}"
"float e(vec3 v,float y)"
"{"
"v*=y;"
"float f=e(v)/1.5;"
"v*=s;"
"float y=x(v)/1.5;"
"v.xy*=5.;"
"v.y-=3.5;"
"v.xy*=t(.75);"
"return-f;"
"v.xy*=n(.75);"
"return-y;"
"}"
"float x(vec3 v,float y)"
"float x(vec3 v,float s)"
"{"
"vec3 m=v;"
"v=m;"
"v.y+=sin(f*.4)*2.5;"
"v.xy*=t(.8);"
"float s=e(v,2.-abs(sin(f*.4))*1.5);"
"v.y+=sin(y*.4)*2.5;"
"v.xy*=n(.8);"
"float f=n(v,2.-abs(sin(y*.4))*1.5);"
"v=m;"
"v.y-=sin(f*.4)*2.5;"
"v.xy*=t(.8);"
"float z=e(v,2.-abs(sin(f*.4))*1.5);"
"v.y-=sin(y*.4)*2.5;"
"v.xy*=n(.8);"
"float c=n(v,2.-abs(sin(y*.4))*1.5);"
"v=m;"
"v.x+=sin(f*.4)*2.5;"
"v.xy*=t(.8);"
"float r=e(v,2.-abs(sin(f*.4))*1.5);"
"v.x+=sin(y*.4)*2.5;"
"v.xy*=n(.8);"
"float g=n(v,2.-abs(sin(y*.4))*1.5);"
"v=m;"
"v.x-=sin(f*.4)*2.5;"
"v.xy*=t(.8);"
"float c=e(v,2.-abs(sin(f*.4))*1.5);"
"v.x-=sin(y*.4)*2.5;"
"v.xy*=n(.8);"
"float p=n(v,2.-abs(sin(y*.4))*1.5);"
"v=m;"
"v.xy*=t(.8);"
"float x=e(v,.5)*6.;"
"v.xy*=n(.8);"
"float r=n(v,.5)*6.;"
"v=m;"
"float g=e(v,.5)*6.;"
"return max(max(max(max(max(s,z),r),c),x),g);"
"float z=n(v,.5)*6.;"
"return max(max(max(max(max(f,c),g),p),r),z);"
"}"
"void p(out vec4 m,vec2 y)"
"void r(out vec4 f,vec2 m)"
"{"
"vec3 r=vec3(0,-.2,v*4.),z=normalize(vec3((y.xy*2.-s.xy)/min(s.x,s.y),1.5));"
"z.xy=z.xy*t(sin(v*.03)*5.);"
"z.yz=z.yz*t(sin(v*.05)*.2);"
"vec3 r=vec3(0,-.2,v*4.),g=normalize(vec3((m.xy*2.-s.xy)/min(s.x,s.y),1.5));"
"g.xy=g.xy*n(sin(v*.03)*5.);"
"g.yz=g.yz*n(sin(v*.05)*.2);"
"float a=.1;"
"vec3 i=vec3(0);"
"float c=0.;"
"for(int e=0;e<99;e++)"
"vec3 c=vec3(0);"
"float z=0.;"
"for(int p=0;p<99;p++)"
"{"
"vec3 d=r+z*a;"
"d=mod(d-2.,4.)-2.;"
"f=v-float(e)*.01;"
"float g=x(d,v);"
"g=max(abs(g),.01);"
"c+=exp(-g*23.);"
"a+=g*.55;"
"vec3 i=r+g*a;"
"i=mod(i-2.,4.)-2.;"
"y=v-float(p)*.01;"
"float e=x(i,v);"
"e=max(abs(e),.01);"
"z+=exp(-e*23.);"
"a+=e*.55;"
"}"
"i=vec3(c*.02);"
"i+=vec3(0,.2*abs(sin(v)),.5+sin(v)*.2);"
"m=vec4(i,1.-a*(.02+.02*sin(v)));"
"c=vec3(z*.02);"
"c+=vec3(0,.2*abs(sin(v)),.5+sin(v)*.2);"
"f=vec4(c,1.-a*(.02+.02*sin(v)));"
"}"
"vec3 r(vec2 s)"
"{"
"return vec3(.05)*fract(sin(mod(dot(vec2(s.x+v,s.y).xy,vec2(12.9898,78.233)),3.14))*43758.5453);"
"}"
"vec3 n(vec2 s,float m,float y,float f,float c)"
"{"
"float r=(-s.y*6.-3.-sin(m+s.x*f+v)-y)*.055;"
"r*=1.+sin(m+s.x*f+v)+(s.y*6.-3.+y);"
"return clamp(r,0.,1.)*(vec3(.5)+vec3(1)*cos(6.28318*(vec3(1)*(c/360.)+vec3(0,.6666,.3333))));"
"}"
"vec2 p(vec2 s)"
"{"
"s.y=clamp(sin(s.x*7.+v)/10.+s.y,0.,1.)+.4;"
"s.x+=sin(v);"
"return s;"
"}"
"void p(out vec4 y,vec2 m)"
"{"
"vec2 c=(m*2.-s)/s;"
"vec3 i=vec3(0,.3,.6);"
"i+=texture2D(f,p(m/s));"
"i+=n(c,0.,1.,1.,sin(v+.3)*360.);"
"i+=n(c,sin(v),0.,-1.,sin(v-1.2)*120.);"
"i+=n(c,-3.,0.,1.,sin(v+.5)*90.);"
"i+=r(c*2.);"
"y=vec4(i,1);"
"}"
"void main()"
"{"
"if(floor(abs(v)/(60./133))<=8)"
"t(gl_FragColor,gl_FragCoord.xy);"
"if(floor(abs(v)/(60./133))<=32)"
"p(gl_FragColor,gl_FragCoord.xy);"
"else"
" p(gl_FragColor,gl_FragCoord.xy);"
"vec3 f;"
"vec2 m=gl_FragCoord.xy/s-vec2(0,-.35);"
"if(m.y>0.)"
"f=gl_FragColor+texture2D(c,m);"
"gl_FragColor=vec4(f,1);"
"{"
"r(gl_FragColor,gl_FragCoord.xy);"
"vec3 m;"
"vec2 y=gl_FragCoord.xy/s-vec2(0,-.35);"
"if(y.y>0.)"
"m=gl_FragColor+texture2D(f,y);"
"gl_FragColor=vec4(m,1);"
"}"
"}";
#endif // SHADER_MINIFIED_H_

View File

@ -45,7 +45,7 @@ TIMINGS_REC_STRING_PTR_FIELD_OFS equ (REC_TIMINGS_TIME_FIELD_SIZE + REC_TIMINGS_
section .textstr1 data
;______STRINGS_START______
_string0: DEFINE_STRING 32 END_STRING
_string0: DEFINE_STRING 65, 115, 115, 101, 109, 98, 108, 121, 32, 50, 48, 50, 52 END_STRING
_string1: DEFINE_STRING 65, 115, 115, 101, 109, 98, 108, 121, 13, 50, 48, 50, 52 END_STRING
_string2: DEFINE_STRING 71, 111, 111, 100, 98, 121, 101, 33 END_STRING
;______STRINGS_END______