private precision mediump float = new precision();
private uniform vec2 location = new uniform();
private uniform vec3 colour = new uniform();
private uniform float alpha = new uniform();
private uniform float time = new uniform();
private mat3 rotX(float a)
{
float c = Math.cos(a);
float s = Math.sin(a);
return mat3(1, 0, 0, 0, c, -s, 0, s, c);
}
private mat3 rotY(float a)
{
float c = Math.cos(a);
float s = Math.sin(a);
return mat3(c, 0, -s, 0, 1, 0, s, 0, c);
}
private float random(vec2 pos)
{
return fract(Math.sin(dot(pos.xy, vec2(1399.9898, 78.233))) * 43758.5453123);
}
private float noise(vec2 pos)
{
vec2 i = Math.floor(pos);
vec2 f = fract(pos);
float a = random(i + vec2(0.0, 0.0));
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
}
private float fbm(vec2 pos)
{
float v = 0.0F;
float a = 0.5F;
vec2 shift = new vec2(100.0);
mat2 rot = new mat2(Math.cos(0.5), Math.sin(0.5), -Math.sin(0.5), Math.cos(0.5));
for (int i = 0; i < DefineConstants.NUM_OCTAVES; i++)
{
v += a * noise(new vec2(pos));
pos = rot * pos * 2.0 + shift;
a *= 0.5F;
}
return v;
}
public static void main(String[] args)
{
vec2 p = gl_FragCoord.xy / 150.0;
float t = 3.0F;
float d;
float time2 = 1.6 * time / 2.0;
vec2 q = new vec2(0.0);
q.x = fbm(p + 0.30 * time2);
q.y = fbm(p + vec2(1.0));
vec2 r = new vec2(0.0);
r.x = fbm(p + 1.0 * q + vec2(1.2, 3.2) + 0.135 * time2);
r.y = fbm(p + 1.0 * q + vec2(8.8, 2.8) + 0.126 * time2);
float f = fbm(p + r);
vec3 color = mix(vec3(0.0, 0.0, 0), vec3(1, 0, 0.7), clamp((f * f) * 8.0, 0.0, 5.0));
color = mix(color, vec3(0, 0, 1), clamp(length(q), 0.0, 1.0));
color = mix(color, vec3(1, 1, 1), clamp(length(r.x), 0.0, 1.0));
color = (f * f * f + 0.6 * f * f + 0.9 * f) * color;
gl_FragColor = vec4(color, 1.0);
}
final class DefineConstants
{
public static final int NUM_OCTAVES = 16;
}
package tangible;
public final class RandomNumbers
{
private static java.util.Random r;
public static int nextNumber()
{
if (r == null)
Seed();
return r.nextInt();
}
public static int nextNumber(int ceiling)
{
if (r == null)
Seed();
return r.nextInt(ceiling);
}
public static void seed()
{
r = new java.util.Random();
}
public static void seed(int seed)
{
r = new java.util.Random(seed);
}
}