shaderiin muutoksia

This commit is contained in:
2025-07-29 19:14:56 +03:00
parent c6cccbcb0e
commit 700d7caf6d
2 changed files with 194 additions and 268 deletions

View File

@ -4,21 +4,14 @@ out vec4 o;
const float PI = 3.14159265;
const float TAU = (2. * PI);
const float PHI = sqrt(5.) * 0.5 + 0.5;
layout(location = 0) uniform float syncs[12];
layout(location = 0) uniform float syncs[11];
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
layout(location = 600) uniform vec3 shapes[15]; // shapes - x = horizontal position, y = vertical position, z = length
layout(location = 700) uniform vec3 test; // shapes test
//layout(binding = 1) uniform sampler2D u_hexGridTex; //uniform sampler2D u_fft_texture;
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));
}
layout(binding = 0) uniform sampler2D u_ShapesTex; // uniform sampler2D shapes texture
// float u_time = syncs[0];
vec2 getUV() {
const vec2 scale = vec2(0.00104166667, 0.00185185185);
@ -44,19 +37,6 @@ float fHexagonCircumcircle(vec3 p, vec2 h) {
return max(q.y - h.y, max(q.x * sqrt(3.) * 0.5 + q.z * 0.5, q.z) - h.x);
}
float hexPylon(vec3 p, vec2 h) {//float r, float ht){
//vec3 p = vec3(p.x, p.z, p2.y);
vec3 b = vec3(h.x, h.y, h.x);
// Hexagon.
p.xz = abs(p.xz);
p.xz = vec2(p.x*.866025 + p.z*.5, p.z);
// The ".015" is a subtle rounding factor. Zero gives sharp edges,
// and larger numbers give a more rounded look.
return length(max(abs(p) - b + .15, 0.)) - .15;
}
// Return local coordinates inside hex AND axial ID
struct HexData {
vec3 local; // Local position inside hex
@ -75,8 +55,10 @@ HexData hexTile(vec3 p, float radius) {
float dr = abs(rr - r);
float ds = abs(rs + q + r);
if (dq > dr && dq > ds) rq = -rr - rs;
else if (dr > ds) rr = -rq - rs;
if(dq > dr && dq > ds)
rq = -rr - rs;
else if(dr > ds)
rr = -rq - rs;
float hx = radius * sqrt(3.0) * (rq + rr * 0.5);
float hz = radius * 1.5 * rr;
@ -87,11 +69,6 @@ HexData hexTile(vec3 p, float radius) {
return outData;
}
struct HexData {
vec3 local;
vec2 axial;
};
float hexDistance(vec2 axial) {
float q = axial.x;
float r = axial.y;
@ -99,18 +76,28 @@ float hexDistance(vec2 axial) {
return max(abs(q), max(abs(r), abs(s)));
}
float sdSphere(vec3 p, float r) {
return length(p) - r;
}
float hexPylon(vec3 p, vec2 h) {
//vec3 p = vec3(p.x, p.z, p2.y);
vec3 b = vec3(h.x, h.y, h.x);
// Hexagon.
p.xz = abs(p.xz);
p.xz = vec2(p.x * .866025 + p.z * .5, p.z);
// The ".015" is a subtle rounding factor. Zero gives sharp edges,
// and larger numbers give a more rounded look.
return length(max(abs(p) - b + .15, 0.)) - .15;
}
//////////////
// SCENE //
//////////////
// instructions -> opU( { float to union with } , vec2( {put shape here}, {put material here} ) )
vec2 opU( vec2 d1, vec2 d2 )
{
vec2 opU(vec2 d1, vec2 d2) {
return (d1.x < d2.x) ? d1 : d2;
}
@ -118,49 +105,51 @@ vec2 opU( vec2 d1, vec2 d2 )
vec2 mapScene(in vec3 p) {
vec2 res = vec2( p.y, 0.0 );
float mat = 1.;
float d = 1e9;
float a = 0.;
float hexRadius = 0.83;
float res = 1e8;
float mat = 0.;
float hexRadius = 0.85;
vec3 hexpos = vec3(p.x, p.y - 2.5, p.z);
HexData hex = hexTile(hexpos, 1.0);
HexData hex = hexTile(hexpos, 1.5);
float distFromCenter = hexDistance(hex.axial);
int fftIndex = int(clamp(distFromCenter +1.0, 0.0, 511.0)); // tweak 15.0 to taste
int fftIndex = int(clamp(distFromCenter + 1.0, 0.0, 511.0));
float fftVal = fft_output[fftIndex];
float hexHeight = 1.0 + fftVal * 3.0;
float hexHeight = 1.0 + fftVal * 4.0;
// Rotate individual hex tiles if needed
vec3 r = hex.local;
//r.yz *= rot2D(1.0);
// r.yz *= rot2D(PI * 0.5);
r.xz *= rot2D(0.5);
float d1 = hexPylon(vec3(r.x,(r.y-hexHeight/2),r.z), vec2(hexRadius, hexHeight/2));
res = min(res, vec2(d1,0.));
//float d1 = hexPylon(vec3(r.x, (r.y + hexHeight / 2), r.z), vec2(hexRadius, hexHeight / 2));
float d1 = hexPylon(vec3(r.x, r.y, r.z), vec2(hexRadius, hexHeight));
float gridSize2 = 16.;
for(float j = 0.; j < gridSize2; j++) {
for(float i = 0.; i < gridSize2; i++) {
res = (d1 < res) ? d1 : res;
/* const float gridSize = 16.;
for(float j = 0.; j < gridSize; j++) {
for(float i = 0.; i < gridSize; i++) {
ivec2 texSize = textureSize(u_ShapesTex, 0);
vec2 texCoord = (vec2(i, j)) / vec2(texSize);
vec4 shapeData = texture(u_ShapesTex, texCoord); // RGBA: x, y, length, active
float shapeActive = shapeData.a;
if(shapeActive < 0.5) continue;
if(shapeActive < 0.5)
continue;
vec3 shapePos = p - vec3(-70.0 + (shapeData.x * 2.), 12. + (shapeData.y * 80.), 0.0);
float a = sdSphere(shapePos, 0.8);
res = min(res, vec2(a, 1.));
res = min(res, a);
if(res == a) {
mat = 1.0;
}
}
}*/
return res;
return vec2(res, mat);
}
////////////////
@ -170,64 +159,25 @@ vec2 mapScene(in vec3 p) {
vec3 castRay(vec3 ro, vec3 rd, inout vec3 pos) {
float mat = 0.;
float hit = 0.;
vec3 d;
float t = 0.,ad,tmax=400.; // total distance travelled
const float tolerance = 0.001;
const float Z_REPEAT_DIST = 2.;
float t = 0.;
vec2 res;
// Raymarching
for (int i = 0; i < 50; i++) {
for(int i = 0; i < 20; i++) {
pos = ro + rd * t;
res = mapScene(pos); // Get distance to objects
ad = abs(res.x);
res = mapScene(pos); // Get distance to objects, x = dist, y = material
mat = res.y;
if (t > tmax) break;
if (ad < tolerance*(t*0.0125 + 1.0)) {
hit = 1.0;
t += res.x; // "march" the ray
// if(abs(t) < tolerance * (t * 0.0125 + 1.0)) {
if(abs(res.x) < 0.0001) {
hit = 1.;
break;
}
t += res.x; // "march" the ray
if(t > 200)
break;
}
// t -= Z_REPEAT_DIST*1.;
//
// for( int i=0; i<30; i++ )
// {
// vec3 pos2 = ro + rd * t;
// res = mapScene(pos2); // get distance to objects
// ad = abs(res.x);
// mat = res.y;
// if (ad < (tolerance))
// {
// hit = 1.0;
// pos = pos2;
// break;
// }
// if (t > tmax) break;
// t += min(d.x, Z_REPEAT_DIST/2.0); // "march" the ray
// }
//if (t >= tmax) {
// t= - 1.0;
// hit = 0.;
//}
//Reduced from 40 to 24 steps
// for(int i = 0; i < 30; i++) {
// pos = ro + rd * t;
// vec2 res = mapScene(pos);
// // Increase step size multiplier for faster marching
// t += res.x;
// mat = res.y;
// if(t > 400.) { // Reduced max distance
// break;
// }
// if(res.x < 0.00001 * (t*0.00125 + 1.0)) { // Less precise hit detection
// hit = 1.;
// break;
// }
// }
// This will break fog effect
//if (t > 100.)
// t = 0.;
return vec3(t, mat, hit);
}
@ -288,16 +238,28 @@ vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPo
return (diffuse + specular * fresnel) * shadow;
}
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float b ) {
float getAmbientOcc(vec3 p, vec3 n) {
float occ = 0.;
float weight = 1.;
for(int i = 0; i < 8; i++) {
float len = 0.01 + 0.02 * float(i * i);
float dist = mapScene(p + n * len).x;
occ += (len - dist) * weight;
weight *= 0.85;
}
return 1.0 - clamp(0.6 * occ, 0., 1.);
}
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
float syncsBass = clamp((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
float fogAmount = 1.0 - exp(-t*b);
float fogAmount2 = 1.0 - exp(-t * fogAmount);
float sunAmount = max(dot(rd, lightDir), 0.0);
vec3 fogColor = mix( vec3(0.2667, 0.2941, 0.3451), // blue
vec3(0.302, 0.3176, 0.3725), // yellow
pow(sunAmount, syncsBass * 5.0) );
return mix( col, fogColor, fogAmount );
// highlight color
vec3 fogColor = mix(vec3(0.2706, 0.2706, 0.2863), vec3(0.2314, 0.2314, 0.2314), // Main color
pow(sunAmount, syncsBass * 1.0));
return mix(col, fogColor, fogAmount2);
}
// Point light with no shadow and radius based falloff
@ -331,7 +293,6 @@ vec3 addPointLightNoShadow(vec3 lightPos, vec3 lightColor, float intensity, floa
return diffuse + specular * fresnel;
}
/*vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPos, vec3 viewDir, vec3 normal) {
vec3 lightDir = normalize(lightPos - worldPos);
float lightDistance = length(lightPos - worldPos);
@ -354,14 +315,14 @@ vec3 addPointLightNoShadow(vec3 lightPos, vec3 lightColor, float intensity, floa
}
*/
vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
vec3 shading(vec3 p, vec3 n, vec3 dir, float material) {
float shininess = 0.01;
vec3 outMaterial = vec3(0.);
if(material == 0.) {
outMaterial = vec3(0.8314, 0.2941, 0.2941);
shininess = 0.1;
outMaterial = vec3(0.4941, 0.4941, 0.4941);
shininess = 0.6;
} else if(material == 1.) {
outMaterial = vec3(0.6196, 0.6118, 0.6118);
shininess = .7;
@ -380,8 +341,8 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
}
vec3 lights = vec3(0.);
lights += addPointLight(vec3(0., 40.0, -10.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
lights += addPointLight(vec3(0., 20.0, 15.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
lights += addPointLight(vec3(0., 20.0, 10.), vec3(0.77, 0.26, 0.73), 15.0, p, dir, n, shininess);
lights += addPointLight(vec3(-10., 20.0, -10.), vec3(0.18, 0.61, 0.86), 15., p, dir, n, shininess);
// LIGHTS IN HEX GRID PATTERN
/*
@ -407,12 +368,12 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
}
*/
vec3 lightDir = vec3(0., 1., -3);
vec3 lightDir = vec3(0., 2., 3);
//float sun_dif = clamp(dot(n, lightDir), 0., 1.);
//float shadow = softshadow(v + n * 0.01, lightDir, .01, 30., 18.);
//lights += vec3(0.6431, 0.7804, 0.8588) * sun_dif * shadow * occ;
float ind = clamp(dot(n, normalize(lightDir * vec3(.0, -1.0, -2.0))), 0.0, 1.0);
float ind = clamp(dot(n, normalize(lightDir * vec3(.0, 1.0, -2.0))), 0.0, 1.0);
lights += vec3(0.08, 0.62, 0.75) * ind * 0.8;
outMaterial *= max(vec3(0.), lights); // output with lights;
@ -421,26 +382,16 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
}
vec3 postProcess(vec3 col) {
// float random = noise(gl_FragCoord.xy, 0.01+u_time);
// float random2 = noise(gl_FragCoord.xy, .2+u_time);
//col += 0.075*clamp(vec3(0.5*random, 0.5*random2, 0.5*random), 0.02, 1.); // dither
// Normalized pixel coordinates (from 0 to 1)
vec2 screenCoord = getUV();
// Vignette
float radius = 0.8;
float d = smoothstep(radius, radius - 0.4, length(screenCoord - vec2(0.5)));
col = mix(col, col * d, 1.);
// Contrast
float contrast = .75;
float contrast = 0.75;
col = mix(col, smoothstep(0.0, 1.0, col), contrast);
// Colour mapping
col *= vec3(1.0, 1.0, 1.0);
// col *= vec3(1.0, 1.0, 1.0);
col = pow(col, vec3(0.4545)); // gamma
// Gamma
col = pow(col, vec3(0.4545)); // gamma 2.2
// fade in at the beginning
//col*=vec3(clamp((u_time-1.8)*0.5,0., 1.));
@ -455,21 +406,14 @@ vec3 postProcess(vec3 col) {
// RENDERING //
//////////////////
vec3 getCameraRayDir(vec2 uv, vec3 camPos, vec3 camTarget, float fov)
{
vec3 f = normalize(camTarget-camPos),
r = normalize(cross(vec3(0,1,0), f)),
u = cross(f,r),
c = f*fov,
i = c + uv.x*r + uv.y*u,
d = normalize(i);
vec3 getCameraRayDir(vec2 uv, vec3 camPos, vec3 camTarget, float fov) {
vec3 f = normalize(camTarget - camPos), r = normalize(cross(vec3(0, 1, 0), f)), u = cross(f, r), c = f * fov, i = c + uv.x * r + uv.y * u, d = normalize(i);
return d;
}
vec3 render(vec2 uv) {
vec3 camPos = vec3(-20.0, 20.0, -20.0);
vec3 camTarget = vec3(0.0, 10.0, 0.0); // Adjust target as needed
vec3 camPos = vec3(-20.0 + sin(syncs[0] * 0.25) * 5, abs(sin(syncs[0] * 0.25) * 10) + 25.0, -20.0);
vec3 camTarget = vec3(0.0, 0.0, 0.0); // Adjust target as needed
float fov = 1.0;
vec3 rayDir = getCameraRayDir(uv, camPos, camTarget, fov);
@ -490,10 +434,9 @@ vec3 render(vec2 uv) {
return col;
}
void main() {
vec3 finalColor = render(getUV());
//finalColor = postProcess(finalColor);
finalColor = postProcess(finalColor);
o = vec4(finalColor, 1.);
}

View File

@ -3,7 +3,7 @@
# define FRAGMENT_INL_
# define VAR_fft_output "f"
# define VAR_o "l"
# define VAR_shapes "H"
# define VAR_shapes "n"
# define VAR_syncs "m"
# define VAR_test "k"
# define VAR_u_ShapesTex "x"
@ -13,164 +13,147 @@ const char *fragment_frag =
"precision mediump float;"
"out vec4 l;"
"const float i=2.*acos(-1.),v=sqrt(5.)*.5+.5;"
"layout(location=0)uniform float m[12];"
"layout(location=0)uniform float m[11];"
"layout(location=20)uniform float f[512];"
"layout(location=600)uniform vec3 H[15];"
"layout(location=600)uniform vec3 n[15];"
"layout(location=700)uniform vec3 k;"
"layout(binding=0)uniform sampler2D x;"
"float n=m[0];"
"mat2 s()"
"{"
"float v=sin(.5),x=cos(.5);"
"return mat2(x,-v,v,x);"
"}"
"float s(vec3 v,vec2 l)"
"{"
"v.xz=abs(v.xz);"
"v.xz=vec2(v.x*.866025+v.z*.5,v.z);"
"return length(max(abs(v)-vec3(l.xyx)+.15,0.))-.15;"
"float v=sin(.5),m=cos(.5);"
"return mat2(m,-v,v,m);"
"}"
"struct HexData{vec3 local;vec2 axial;};"
"HexData s(vec3 v)"
"{"
"float x=sqrt(3.)/3.*v.x-1./3.*v.z,l=2./3.*v.z,m=round(x),y=round(l),t=round(-x-l),n=abs(m-x),d=abs(y-l);"
"x=abs(t+x+l);"
"if(n>d&&n>x)"
"m=-y-t;"
"else if(d>x)"
"y=-m-t;"
"x=sqrt(3.)*(m+y*.5);"
"l=1.5*y;"
"HexData f;"
"f.local=v-vec3(x,0,l);"
"f.axial=vec2(m,y);"
"return f;"
"float m=(sqrt(3.)/3.*v.x-1./3.*v.z)/1.5,l=2./3.*v.z/1.5,x=round(m),y=round(l),t=round(-m-l),a=abs(x-m),d=abs(y-l);"
"m=abs(t+m+l);"
"if(a>d&&a>m)"
"x=-y-t;"
"else if(d>m)"
"y=-x-t;"
"m=1.5*sqrt(3.)*(x+y*.5);"
"l=2.25*y;"
"HexData i;"
"i.local=v-vec3(m,0,l);"
"i.axial=vec2(x,y);"
"return i;"
"}"
"struct HexData{vec3 local;vec2 axial;};"
"float s(vec2 v)"
"{"
"float x=v.x,l=v.y;"
"return max(abs(x),max(abs(l),abs(-x-l)));"
"float m=v.x,l=v.y;"
"return max(abs(m),max(abs(l),abs(-m-l)));"
"}"
"float s(vec3 v,vec2 m)"
"{"
"v.xz=abs(v.xz);"
"v.xz=vec2(v.x*.866025+v.z*.5,v.z);"
"return length(max(abs(v)-vec3(m.xyx)+.15,0.))-.15;"
"}"
"vec2 t(vec3 v)"
"{"
"vec2 l=vec2(v.y,0);"
"HexData m=s(vec3(v.x,v.y-2.5,v.z));"
"float i=1.+f[int(clamp(s(m.axial)+1.,0.,511.))]*3.;"
"vec3 n=m.local;"
"n.xz*=s();"
"i=s(vec3(n.x,n.y-i/2,n.z),vec2(.83,i/2));"
"l=min(l,vec2(i,0));"
"for(float f=0.;f<16.;f++)"
"for(float i=0.;i<16.;i++)"
"{"
"ivec2 m=textureSize(x,0);"
"vec2 n=vec2(i,f)/vec2(m);"
"vec4 d=texture(x,n);"
"if(d.w<.5)"
"continue;"
"l=min(l,vec2(length(v-vec3(-70.+d.x*2.,12.+d.y*80.,0))-.8,1));"
"float m=1e8;"
"HexData l=s(vec3(v.x,v.y-2.5,v.z));"
"vec3 i=l.local;"
"i.xz*=s();"
"float n=s(vec3(i),vec2(.85,1.+f[int(clamp(s(l.axial)+1.,0.,511.))]*4.));"
"m=n<m?"
"n:"
"m;"
"return vec2(m,0);"
"}"
"return l;"
"}"
"vec3 s(vec3 v,vec3 x,inout vec3 l)"
"vec3 s(vec3 v,vec3 m,inout vec3 l)"
"{"
"float i=0.,n=0.,m=0.,f;"
"vec2 d;"
"for(int r=0;r<50;r++)"
"float i=0.,f=0.,x=0.;"
"vec2 n;"
"for(int r=0;r<20;r++)"
"{"
"l=v+x*m;"
"d=t(l);"
"f=abs(d.x);"
"i=d.y;"
"if(m>4e2)"
"break;"
"if(f<.001*(m*.0125+1.))"
"l=v+m*x;"
"n=t(l);"
"i=n.y;"
"x+=n.x;"
"if(abs(n.x)<1e-4)"
"{"
"n=1.;"
"f=1.;"
"break;"
"}"
"m+=d.x;"
"}"
"return vec3(m,i,n);"
"}"
"float s(vec3 v,vec3 x,float l)"
"{"
"float i=1.,m=.02;"
"for(int f=0;f<6;f++)"
"{"
"if(m>l)"
"if(x>200)"
"break;"
"float n=t(v+m*x).x;"
"i=min(i,n/(4.*m));"
"m+=clamp(n,.1,.8);"
"}"
"return vec3(x,i,f);"
"}"
"float s(vec3 v,vec3 m,float l)"
"{"
"float i=1.,x=.02;"
"for(int r=0;r<6;r++)"
"{"
"if(x>l)"
"break;"
"float n=t(v+x*m).x;"
"i=min(i,n/(4.*x));"
"x+=clamp(n,.1,.8);"
"if(i<-1.)"
"break;"
"}"
"i=max(i,-1.);"
"return.25*(1.+i)*(1.+i)*(2.-i);"
"}"
"vec3 e(vec3 v)"
"vec3 p(vec3 v)"
"{"
"vec2 i=vec2(.01,0);"
"v=vec3(t(v+i.xyy).x-t(v-i.xyy).x,t(v+i.yxy).x-t(v-i.yxy).x,t(v+i.yyx).x-t(v-i.yyx).x);"
"return normalize(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 e(vec3 v,vec3 m,vec3 l,vec3 x,float i)"
"vec3 p(vec3 v,vec3 m,vec3 i,vec3 l,vec3 x,float f)"
"{"
"vec3 n=vec3(.77,.26,.73);"
"v-=m;"
"float f=length(v);"
"v-=i;"
"float r=length(v);"
"v=normalize(v);"
"float y=30./(1.+.09*f+.032*f*f),d=max(dot(x,v),0.);"
"float n=15./(1.+.09*r+.032*r*r),y=max(dot(x,v),0.);"
"l=normalize(v-l);"
"vec3 r=vec3(.04);"
"r+=(1.-r)*pow(clamp(1.-max(dot(l,v),0.),0.,1.),5.);"
"f=s(m+x*.01,v,f);"
"return(n*d*y+n*pow(max(dot(x,l),0.),mix(128.,8.,i))*y*r)*f;"
"vec3 e=vec3(.04);"
"e+=(1.-e)*pow(clamp(1.-max(dot(l,v),0.),0.,1.),5.);"
"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 e(vec3 v,vec3 m,vec3 i,float l)"
"vec3 p(vec3 v,vec3 m,vec3 i,float l)"
"{"
"float n=.01;"
"vec3 x=vec3(0);"
"float f=.01;"
"vec3 n=vec3(0);"
"if(l==0.)"
"x=vec3(.8314,.2941,.2941),n=.1;"
"n=vec3(.4941),f=.6;"
"else if(l==1.)"
"x=vec3(.6196,.6118,.6118),n=.7;"
"n=vec3(.6196,.6118,.6118),f=.7;"
"else if(l==2.)"
"x=vec3(.3255,.4784,.3255),n=.2;"
"n=vec3(.3255,.4784,.3255),f=.2;"
"else if(l==3.)"
"x=vec3(.2471,.3059,.6314),n=1.;"
"n=vec3(.2471,.3059,.6314),f=1.;"
"else if(l==4.)"
"x=vec3(.9961,1,.9922),n=.1;"
"n=vec3(.9961,1,.9922),f=.1;"
"else if(l==5.)"
"x=vec3(.9961,1,.9922),n=.3;"
"vec3 f=vec3(0);"
"f+=e(vec3(0,40,-10),v,i,m,n);"
"f+=e(vec3(0,20,15),v,i,m,n);"
"f+=vec3(.08,.62,.75)*clamp(dot(m,normalize(vec3(0,1,-3)*vec3(0,-1,-2))),0.,1.)*.8;"
"return x*max(vec3(0),f);"
"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;"
"return n*max(vec3(0),v);"
"}"
"vec3 e(vec2 v,vec3 l)"
"vec3 p(vec2 v,vec3 m)"
"{"
"l=normalize(vec3(0,10,0)-l);"
"vec3 n=normalize(cross(vec3(0,1,0),l));"
"return normalize(l+v.x*n+v.y*cross(l,n));"
"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 e(vec2 v)"
"vec3 p(vec2 v)"
"{"
"vec3 l=vec3(-20,20,-20),n=e(v,l),i=vec3(0),x=vec3(0);"
"l=s(l,n,x);"
"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 v=e(x);"
"i=e(x,v,n,l.y);"
"vec3 v=p(x);"
"f=p(x,v,i,l.y);"
"}"
"return i*exp(-l.x*.01)+mix(i,mix(vec3(.2667,.2941,.3451),vec3(.302,.3176,.3725),pow(max(dot(n,vec3(0,-.5,1.8)),0.),clamp(m[1]+m[2]+m[3],0.,1.)*5.)),1.-exp(-l.x*.01))*(1.-exp(-l.x*.01));"
"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));"
"}"
"void main()"
"{"
"vec3 v=e(gl_FragCoord.xy*vec2(.00104166667,.00185185185)-1.);"
"vec3 v=p(gl_FragCoord.xy*vec2(.00104166667,.00185185185)-1.);"
"l=vec4(v,1);"
"}";