// Original by srtuss, 2013
// mechanical by Inc. & zeroZshadow
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform float2 mouse;
uniform float2 resolution = float2(800, 600); // change Resolution
// rotate position around axis
float2 rotate(float2 p, float a)
{
return float2(p.y * cos(a) + p.x * sin(a), p.y * sin(a) - p.x * cos(a)); // hier kannst du die richtung und div. zeux ändern
}
// 1D random numbers
float rand(float n)
{
return frac(sin(n) * 43758.5453123);
}
// 2D random numbers
float2 rand2(in float2 p)
{
return frac(float2(sin(p.x * 591.32 + p.y * 154.077), cos(p.x * 391.32 + p.y * 49.077)));
}
// 1D noise
float noise1(float p)
{
float fl = floor(p);
float fc = frac(p);
return lerp(rand(fl), rand(fl + 1.0), fc);
}
// voronoi distance noise, based on iq's articles
float voronoi(in float2 x)
{
float2 p = floor(x);
float2 f = frac(x);
float2 res = float2(8.0, 8.0);
for(int j = -1; j <= 1; j ++)
{
for(int i = -1; i <= 1; i ++)
{
float2 b = float2(i, j);
float2 r = float2(b) - f + rand2(p + b);
// chebyshev distance, one of many ways to do this
float d = max(abs(r.x), abs(r.y));
if(d < res.x)
{
res.y = res.x;
res.x = d;
}
else if(d < res.y)
{
res.y = d;
}
}
}
return res.y - res.x;
}
float4 main(float2 Tex : TEXCOORD) : COLOR
{
float flicker = noise1(time * 2.0) * 0.8 - 0.4; // hier kannst du das aufblitzen ändern
float2 uv = Tex.xy;
uv = (uv - 0.5) * 2.0;
float2 suv = uv;
uv.x *= resolution.x / resolution.y;
float v = 0.0;
// a bit of camera movement
uv *= 0.6 + sin(time * 0.1) * 0.4;
uv = rotate(uv, sin(time * 2.3) * 1.0); // hier die Kamera bewegung 2.3 war ursprünglich 0.3
uv += time * 0.4;
// add some noise octaves
float a = 0.6, f = 1.0;
for(int i = 0; i < 3; i ++) // 4 octaves also look nice, its getting a bit slow though
{
float v1 = voronoi(uv * f + 5.0);
float v2 = 0.0;
// make the moving electrons-effect for higher octaves
if(i > 0)
{
// of course everything based on voronoi
v2 = voronoi(uv * f * 0.5 + 50.0 + time);
float va = 0.0, vb = 0.0;
va = 1.0 - smoothstep(0.0, 0.1, v1);
vb = 1.0 - smoothstep(0.0, 0.08, v2);
v += a * pow(va * (0.5 + vb), 2.0);
}
// make sharp edges
v1 = 1.0 - smoothstep(0.0, 0.3, v1);
// noise is used as intensity map
v2 = a * (noise1(v1 * 5.5 + 0.1));
// octave 0's intensity changes a bit
if(i == 0)
v += v2 * flicker;
else
v += v2;
f *= 3.0;
a *= 0.7;
}
// slight vignetting
v *= exp(-0.1* length(suv)) * 1.2;
// use texture channel0 for color? why not.
//float3 cexp = texture2D(iChannel0, uv * 0.001).xyz * 3.0 + texture2D(iChannel0, uv * 0.01).xyz;//float3(1.0, 2.0, 4.0);
// old blueish color set
float3 cexp = float3(3.0, 5.0, 3.0); // hier Farbe ändern
cexp *= 1.3;
float3 col = float3(pow(v, cexp.x), pow(v, cexp.y), pow(v, cexp.z)) * 2.0;
return float4(col, 1.0);
}
// Vertex Shader
struct VS_INPUT
{
float3 position : POSITION;
float2 texture0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 hposition : POSITION;
float2 texture0 : TEXCOORD0;
};
VS_OUTPUT myvs( VS_INPUT IN )
{
VS_OUTPUT OUT;
OUT.hposition = float4(IN.position.x ,-IN.position.y ,IN.position.z, 1);
OUT.texture0 = IN.texture0;
return OUT;
}
technique Start
{
pass p1
{
VertexShader = compile vs_3_0 myvs();
PixelShader = compile ps_3_0 main();
}
}