160 lines
4.6 KiB
Plaintext
160 lines
4.6 KiB
Plaintext
const highp vec2 mouse = vec2(0.0);
|
|
const highp float time = 0.0;
|
|
|
|
const highp int iterations = 12;
|
|
const highp float formuparam2 = 0.79;
|
|
const highp float volsteps = 7.0;
|
|
const highp float stepsize = 0.290;
|
|
const highp float zoom = 0.5;
|
|
const highp float tile = 0.850;
|
|
const highp float speed2 = 0.1;
|
|
|
|
const highp float brightness = 0.0015;
|
|
const highp float darkmatter = 0.100;
|
|
const highp float distfading = 0.560;
|
|
const highp float saturation = 0.90;
|
|
|
|
|
|
const highp float transverseSpeed = 1.0; //zoom;
|
|
const highp float cloud = 0.06;
|
|
|
|
|
|
highp float triangle(highp float x, highp float a) {
|
|
highp float output2 = 2.0*abs( 3.0* ( (x/a) - floor( (x/a) + 0.5) ) ) - 1.0;
|
|
return output2;
|
|
}
|
|
|
|
highp float field(in highp vec3 p) {
|
|
highp float strength = 15.0 + 0.03 * log(0.0000001 + fract(sin(time) * 373.11));
|
|
highp float accum = 0.0;
|
|
highp float prev = 0.0;
|
|
highp float tw = 0.0;
|
|
|
|
for (highp float i = 0.0; i < 6.0; ++i) {
|
|
highp float mag = dot(p, p);
|
|
p = abs(p) / mag + vec3(-0.5, -0.8 + 0.1*sin(-time*0.1 + 2.0), -1.1+0.3*cos(time*0.3));
|
|
highp float w = exp(-i / 7.0);
|
|
accum += w * exp(-strength * pow(abs(mag - prev), 2.3));
|
|
tw += w;
|
|
prev = mag;
|
|
}
|
|
return max(0.0, 5.0 * accum / tw - 0.7);
|
|
}
|
|
|
|
void fragment() {
|
|
highp vec2 uv2 = 2.0 * FRAGCOORD.xy / vec2(1024) - 1.0;
|
|
highp vec2 uvs = uv2 * vec2(1024) / 1024.0;
|
|
|
|
highp float time = TIME * 0.01;
|
|
highp float time2 = time;
|
|
highp float speed = -speed2;
|
|
speed = 0.005 * cos(time2*0.02 + 3.1415926/4.0);
|
|
//speed = 0.0;
|
|
highp float formuparam = formuparam2;
|
|
|
|
//get coords and direction
|
|
highp vec2 uv = uvs;
|
|
//mouse rotation
|
|
highp float a_xz = 0.9;
|
|
highp float a_yz = -0.6;
|
|
highp float a_xy = 0.9 + time*0.08;
|
|
|
|
highp mat2 rot_xz = mat2(vec2(cos(a_xz),sin(a_xz)),vec2(-sin(a_xz),cos(a_xz)));
|
|
highp mat2 rot_yz = mat2(vec2(cos(a_yz),sin(a_yz)),vec2(-sin(a_yz),cos(a_yz)));
|
|
highp mat2 rot_xy = mat2(vec2(cos(a_xy),sin(a_xy)),vec2(-sin(a_xy),cos(a_xy)));
|
|
|
|
highp float v2 =1.0;
|
|
highp vec3 dir=vec3(uv*zoom,1.0);
|
|
highp vec3 from=vec3(0.0, 0.0,0.0);
|
|
// from.x = 0.5;
|
|
// from.y = 0.5;
|
|
|
|
highp vec3 forward = vec3(0.0,0.0,1.0);
|
|
from.x += transverseSpeed*(1.0)*cos(0.01*time) + 0.001*time;
|
|
from.y += transverseSpeed*(1.0)*sin(0.01*time) +0.001*time;
|
|
from.z += 0.003*time;
|
|
|
|
dir.xy*=rot_xy;
|
|
forward.xy *= rot_xy;
|
|
dir.xz*=rot_xz;
|
|
forward.xz *= rot_xz;
|
|
dir.yz*= rot_yz;
|
|
forward.yz *= rot_yz;
|
|
|
|
from.xy*=-1.0*rot_xy;
|
|
from.xz*=rot_xz;
|
|
from.yz*= rot_yz;
|
|
|
|
//zoom
|
|
highp float zooom = (time2-3311.0)*speed;
|
|
from += forward* zooom;
|
|
highp float sampleShift = mod( zooom, stepsize );
|
|
|
|
highp float zoffset = -sampleShift;
|
|
sampleShift /= stepsize; // make from 0 to 1
|
|
|
|
//volumetric rendering
|
|
highp float s=0.24;
|
|
highp float s3 = s + stepsize/2.0;
|
|
highp vec3 v=vec3(0.0);
|
|
highp float t3 = 0.0;
|
|
|
|
highp vec3 backCol2 = vec3(0.0);
|
|
for (highp float r=0.0; r<volsteps; r++) {
|
|
highp vec3 p2=from+(s+zoffset)*dir;// + vec3(0.0,0.0,zoffset);
|
|
highp vec3 p3=from+(s3+zoffset)*dir;// + vec3(0.0,0.0,zoffset);
|
|
|
|
p2 = abs(vec3(tile)-mod(p2,vec3(tile*2.0))); // tiling fold
|
|
p3 = abs(vec3(tile)-mod(p3,vec3(tile*2.0))); // tiling fold
|
|
// #ifdef cloud
|
|
t3 = field(p3);
|
|
|
|
highp float pa,a=pa=0.0;
|
|
for (highp int i=0; i<iterations; i++) {
|
|
p2=abs(p2)/dot(p2,p2)-formuparam; // the magic formula
|
|
//p=abs(p)/max(dot(p,p),0.005)-formuparam; // another interesting way to reduce noise
|
|
highp float D = abs(length(p2)-pa); // absolute sum of average change
|
|
a += i > 7 ? min( 12.0, D) : D;
|
|
pa=length(p2);
|
|
}
|
|
|
|
|
|
//float dm=max(0.0,darkmatter-a*a*0.001); //dark matter
|
|
a*=a*a; // add contrast
|
|
//if (r>3) fade*=1.0-dm; // dark matter, don't render near
|
|
// brightens stuff up a bit
|
|
highp float s1 = s+zoffset;
|
|
// need closed form expression for this, now that we shift samples
|
|
highp float fade = pow(distfading,max(0.0,r-sampleShift));
|
|
//t3 += fade;
|
|
v+=fade;
|
|
//backCol2 -= fade;
|
|
|
|
// fade out samples as they approach the camera
|
|
if( r == 0.0 )
|
|
fade *= (1.0 - (sampleShift));
|
|
// fade in samples as they approach from the distance
|
|
if( r == volsteps-1.0 )
|
|
fade *= sampleShift;
|
|
v+=vec3(s1,s1*s1,s1*s1*s1*s1)*a*brightness*fade; // coloring based on distance
|
|
|
|
backCol2 += mix(0.4, 1.0, v2) * vec3(1.8 * t3 * t3 * t3, 1.4 * t3 * t3, t3) * fade;
|
|
|
|
|
|
s+=stepsize;
|
|
s3 += stepsize;
|
|
}
|
|
|
|
v = mix(vec3(length(v)),v,saturation); //color adjust
|
|
|
|
highp vec4 forCol2 = vec4(v*0.001,1.0);
|
|
backCol2 *= cloud;
|
|
backCol2.b *= 1.3;
|
|
backCol2.r *= 0.05;
|
|
|
|
backCol2.b = 0.5*mix(backCol2.g, backCol2.b, 0.8);
|
|
backCol2.g = 0.0;
|
|
backCol2.bg = mix(backCol2.gb, backCol2.bg, 0.5*(cos(time*0.01) + 1.0));
|
|
COLOR = forCol2 + vec4(backCol2, 1.0);
|
|
}
|