// https://www.shadertoy.com/view/XljBW3 #define vec2 float2 #define vec3 float3 #define vec4 float4 #define ivec2 int2 #define ivec3 int3 #define ivec4 int4 #define mat2 float2x2 #define mat3 float3x3 #define mat4 float4x4 #define fract frac #define mix lerp #define iTime Time.x #define iResolution ViewSize uniform float2 mouse< string name = "Virtual Mouse Coordinates"; string field_type = "slider"; float2 minimum = {0, 0}; float2 maximum = {100., 100.}; float2 scale = {.01, .01}; float2 step = {.01, .01}; > = {0., 0.}; uniform float4x4 ViewProj< bool automatic = true; >; uniform bool direction< string name = "Invert Direction"; > = true; uniform float4 Time< bool automatic = true; >; uniform float4 ViewSize< bool automatic = true; >; int2 iMouse() { return int2(mouse.x * ViewSize.x, mouse.y * ViewSize.y); } /* ps start */ #define time iTime uniform float ratio; #define PI2 6.28318530718 #define PI 3.1416 float vorocloud(float2 p){ float f = 0.0; float flow = 1.0; if(direction){ flow *= -1; } float2 pp = cos(float2(p.x * 14.0, (16.0 * p.y + cos(floor(p.x * 30.0)) + flow * time * PI2)) ); p = cos(p * 12.1 + pp * 10.0 + 0.5 * cos(pp.x * 10.0)); float2 pts[4]; pts[0] = float2(0.5, 0.6); pts[1] = float2(-0.4, 0.4); pts[2] = float2(0.2, -0.7); pts[3] = float2(-0.3, -0.4); float d = 5.0; for(int i = 0; i < 4; i++){ pts[i].x += 0.03 * cos(float(i)) + p.x; pts[i].y += 0.03 * sin(float(i)) + p.y; d = min(d, distance(pts[i], pp)); } f = 2.0 * pow(1.0 - 0.3 * d, 13.0); f = min(f, 1.0); return f; } vec4 scene(float2 UV){ float x = UV.x; float y = UV.y; float2 p = float2(x, y) - 0.5; vec4 col = vec4(0.0,0.0,0.0,0.0); col.g += 0.02; float v = vorocloud(p); v = 0.2 * floor(v * 5.0); col.r += 0.1 * v; col.g += 0.6 * v; col.b += 0.5 * pow(v, 5.0); v = vorocloud(p * 2.0); v = 0.2 * floor(v * 5.0); col.r += 0.1 * v; col.g += 0.2 * v; col.b += 0.01 * pow(v, 5.0); col.a = 1.0; return col; } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = fragCoord.xy / iResolution.xy; fragColor = scene(uv); } /*ps end*/ struct VertFragData { float4 pos : POSITION; float2 uv : TEXCOORD0; }; VertFragData VSDefault(VertFragData vtx) { vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); return vtx; } float4 PSDefault(VertFragData vtx) : TARGET { float4 col = float4(1., 1., 1., 1.); mainImage(col, vtx.uv * ViewSize.xy); return col; } technique Draw { pass { vertex_shader = VSDefault(vtx); pixel_shader = PSDefault(vtx); } }