hohkaminen alhaalta

This commit is contained in:
Teemu Järvisalo
2025-07-29 20:57:34 +03:00
parent 700d7caf6d
commit 2c03c51193
2 changed files with 38 additions and 17 deletions

View File

@ -13,6 +13,15 @@ layout(location = 700) uniform vec3 test; // shapes test
layout(binding = 0) uniform sampler2D u_ShapesTex; // uniform sampler2D shapes texture
// float u_time = syncs[0];
vec3 palette(float t){
vec3 a=vec3(0.46,0.2,0.94);
vec3 b=vec3(0.66,0.64,0.77);
vec3 c=vec3(0.91,0.62,0.97);
vec3 d=vec3(0.26,0.2,0.84);
return a+b*cos(6.28318*(c*t+d));
}
vec2 getUV() {
const vec2 scale = vec2(0.00104166667, 0.00185185185);
return gl_FragCoord.xy * scale - 1.0;
@ -105,7 +114,7 @@ vec2 opU(vec2 d1, vec2 d2) {
vec2 mapScene(in vec3 p) {
float res = 1e8;
float res = p.y;
float mat = 0.;
float hexRadius = 0.85;
@ -428,6 +437,16 @@ vec3 render(vec2 uv) {
col = shading(hitPos, nor, rayDir, t.y);
}
//glow from the bottom
vec3 bGlowColor = palette(syncs[0] * .5); // color change
float bGlowDistance = 0.3;
vec3 p = camPos + t.x * rayDir;
vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 9900.;
col += bGlowLevel;
col = clamp(mix(bGlowLevel, col, t.z), 0.0, 1.0);
// distance fog + bass thunder
float fogAmount = 0.01;
col = col * exp(-t.x * fogAmount) + applyFog(col, t.x, rayDir, vec3(0., -0.5, 1.8), fogAmount) * (1.0 - exp(-t.x * fogAmount));

View File

@ -6,7 +6,7 @@
# define VAR_shapes "n"
# define VAR_syncs "m"
# define VAR_test "k"
# define VAR_u_ShapesTex "x"
# define VAR_u_ShapesTex "y"
const char *fragment_frag =
"#version 460\n"
@ -17,7 +17,7 @@ const char *fragment_frag =
"layout(location=20)uniform float f[512];"
"layout(location=600)uniform vec3 n[15];"
"layout(location=700)uniform vec3 k;"
"layout(binding=0)uniform sampler2D x;"
"layout(binding=0)uniform sampler2D y;"
"mat2 s()"
"{"
"float v=sin(.5),m=cos(.5);"
@ -52,7 +52,7 @@ const char *fragment_frag =
"}"
"vec2 t(vec3 v)"
"{"
"float m=1e8;"
"float m=v.y;"
"HexData l=s(vec3(v.x,v.y-2.5,v.z));"
"vec3 i=l.local;"
"i.xz*=s();"
@ -98,12 +98,12 @@ const char *fragment_frag =
"i=max(i,-1.);"
"return.25*(1.+i)*(1.+i)*(2.-i);"
"}"
"vec3 p(vec3 v)"
"vec3 x(vec3 v)"
"{"
"vec2 m=vec2(.01,0);"
"return normalize(vec3(t(v+m.xyy).x-t(v-m.xyy).x,t(v+m.yxy).x-t(v-m.yxy).x,t(v+m.yyx).x-t(v-m.yyx).x));"
"}"
"vec3 p(vec3 v,vec3 m,vec3 i,vec3 l,vec3 x,float f)"
"vec3 s(vec3 v,vec3 m,vec3 i,vec3 l,vec3 x,float f)"
"{"
"v-=i;"
"float r=length(v);"
@ -115,7 +115,7 @@ const char *fragment_frag =
"r=s(i+x*.01,v,r);"
"return(m*y*n+m*pow(max(dot(x,l),0.),mix(128.,8.,f))*n*e)*r;"
"}"
"vec3 p(vec3 v,vec3 m,vec3 i,float l)"
"vec3 s(vec3 v,vec3 m,vec3 i,float l)"
"{"
"float f=.01;"
"vec3 n=vec3(0);"
@ -131,29 +131,31 @@ const char *fragment_frag =
"n=vec3(.9961,1,.9922),f=.1;"
"else if(l==5.)"
"n=vec3(.9961,1,.9922),f=.3;"
"v=vec3(0)+p(vec3(0,20,10),vec3(.77,.26,.73),v,i,m,f)+p(vec3(-10,20,-10),vec3(.18,.61,.86),v,i,m,f)+vec3(.08,.62,.75)*clamp(dot(m,normalize(vec3(0,2,3)*vec3(0,1,-2))),0.,1.)*.8;"
"v=vec3(0)+s(vec3(0,20,10),vec3(.77,.26,.73),v,i,m,f)+s(vec3(-10,20,-10),vec3(.18,.61,.86),v,i,m,f)+vec3(.08,.62,.75)*clamp(dot(m,normalize(vec3(0,2,3)*vec3(0,1,-2))),0.,1.)*.8;"
"return n*max(vec3(0),v);"
"}"
"vec3 p(vec2 v,vec3 m)"
"vec3 s(vec2 v,vec3 m)"
"{"
"m=normalize(vec3(0)-m);"
"vec3 l=normalize(cross(vec3(0,1,0),m));"
"return normalize(m+v.x*l+v.y*cross(m,l));"
"}"
"vec3 p(vec2 v)"
"vec3 t(vec2 v)"
"{"
"vec3 l=vec3(-20.+sin(m[0]*.25)*5,abs(sin(m[0]*.25)*10)+25.,-20),i=p(v,l),f=vec3(0),x=vec3(0);"
"l=s(l,i,x);"
"if(l.x>0.)"
"vec3 l=vec3(-20.+sin(m[0]*.25)*5,abs(sin(m[0]*.25)*10)+25.,-20),i=s(v,l),f=vec3(0),n=vec3(0),t=s(l,i,n);"
"if(t.x>0.)"
"{"
"vec3 v=p(x);"
"f=p(x,v,i,l.y);"
"vec3 v=x(n);"
"f=s(n,v,i,t.y);"
"}"
"return f*exp(-l.x*.01)+mix(f,mix(vec3(.2706,.2706,.2863),vec3(.2314),pow(max(dot(i,vec3(0,-.5,1.8)),0.),clamp(m[1]+m[2]+m[3],0.,1.))),1.-exp(-l.x*.01))*(1.-exp(-l.x*.01));"
"l=(vec3(.46,.2,.94)+vec3(.66,.64,.77)*cos(6.28318*(vec3(.91,.62,.97)*(m[0]*.5)+vec3(.26,.2,.84))))*exp(-(l+t.x*i).y/.3)*99e2;"
"f=clamp(mix(l,f+l,t.z),0.,1.);"
"return f*exp(-t.x*.01)+mix(f,mix(vec3(.2706,.2706,.2863),vec3(.2314),pow(max(dot(i,vec3(0,-.5,1.8)),0.),clamp(m[1]+m[2]+m[3],0.,1.))),1.-exp(-t.x*.01))*(1.-exp(-t.x*.01));"
"}"
"void main()"
"{"
"vec3 v=p(gl_FragCoord.xy*vec2(.00104166667,.00185185185)-1.);"
"vec3 v=t(gl_FragCoord.xy*vec2(.00104166667,.00185185185)-1.);"
"v=pow(mix(v,smoothstep(0.,1.,v),.75),vec3(.4545));"
"l=vec4(v,1);"
"}";