[ { "id": "347c3c57-1b24-49bb-9c1c-37b6a4aff0de", "name": "跃迁", "author": "unknown", "code": "// Interstellar\n// Hazel Quantock\n// This code is licensed under the CC0 license http://creativecommons.org/publicdomain/zero/1.0/\n\nconst float tau = 6.28318530717958647692;\n\n// Gamma correction\n#define GAMMA (2.2)\n\nvec3 ToLinear( in vec3 col )\n{\n\t// simulate a monitor, converting colour values into light values\n\treturn pow( col, vec3(GAMMA) );\n}\n\nvec3 ToGamma( in vec3 col )\n{\n\t// convert back into colour values, so the correct light will come out of the monitor\n\treturn pow( col, vec3(1.0/GAMMA) );\n}\n\nvec4 Noise( in ivec2 x )\n{\n\treturn texture( iChannel0, (vec2(x)+0.5)/256.0, -100.0 );\n}\n\nvec4 Rand( in int x )\n{\n\tvec2 uv;\n\tuv.x = (float(x)+0.5)/256.0;\n\tuv.y = (floor(uv.x)+0.5)/256.0;\n\treturn texture( iChannel0, uv, -100.0 );\n}\n\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n\tvec3 ray;\n\tray.xy = 2.0*(fragCoord.xy-iResolution.xy*.5)/iResolution.x;\n\tray.z = 1.0;\n\n\tfloat offset = iTime*.5;\t\n\tfloat speed2 = (cos(offset)+1.0)*2.0;\n\tfloat speed = speed2+.1;\n\toffset += sin(offset)*.96;\n\toffset *= 2.0;\n\t\n\t\n\tvec3 col = vec3(0);\n\t\n\tvec3 stp = ray/max(abs(ray.x),abs(ray.y));\n\t\n\tvec3 pos = 2.0*stp+.5;\n\tfor ( int i=0; i < 20; i++ )\n\t{\n\t\tfloat z = Noise(ivec2(pos.xy)).x;\n\t\tz = fract(z-offset);\n\t\tfloat d = 50.0*z-pos.z;\n\t\tfloat w = pow(max(0.0,1.0-8.0*length(fract(pos.xy)-.5)),2.0);\n\t\tvec3 c = max(vec3(0),vec3(1.0-abs(d+speed2*.5)/speed,1.0-abs(d)/speed,1.0-abs(d-speed2*.5)/speed));\n\t\tcol += 1.5*(1.0-z)*c*w;\n\t\tpos += stp;\n\t}\n\t\n\tfragColor = vec4(ToGamma(col),1.0);\n}", "views": 11032, "likes": 192, "createdAt": "2026-04-02T01:57:49.494Z", "sourceFormat": "glsl" }, { "id": "b08237ae-6fc0-4b06-bfb8-ae0f6a8e1354", "name": "科技", "author": "unknown", "code": "#define O(Z,c) ( length( /* orb */ \\\n p - vec3( sin( T*c*6. ) * 6., \\\n sin( T*c*4. ) * 1. + 1e1, \\\n T+Z+2e1+1e1*cos(T*.6) ) ) - c )\n// MENGERLAYER\n#define m(f, h)\\\n s /= (f), \\\n p = abs(fract(q/s)*s - s*.5), \\\n \tm = min(m, min(max(p.x, p.y), \\\n min(max(p.y, p.z), \\\n max(p.x, p.z))) - s/(h))\n\nvoid mainImage(out vec4 o, vec2 u) {\n \n float i, e, T = iTime * 2.,m,d,s = 1.5,l,\n j = 0.;\n vec3 c,r = iResolution;\n mat2 rot = mat2(cos(cos(T*.05)*.6+vec4(0,33,11,0)));\n \n u = (u+u - r.xy) / r.y;\n\n vec3 q,p = vec3(0,1e1,T),\n D = vec3(rot*u, 1);\n \n for(;i++ < 1e2;\n c += 1./s + 2e1*vec3(1,2,5)/max(e, .001)\n )\n q = p += j + D * s,\n e = max( .6* min( O( 3., .1),\n min( O( 5., .2),\n O( 9., .3) )), .001),\n m=1e1,\n s = 64.,\n m(2., 6.),\n s = 26.,\n m(2., 4.),\n m(2., 4.),\n m(2., 4.),\n s = 32.,\n m(2., 4.),\n d += s = min(e,\n max(.01+.7*abs(m), .01+.7*abs(.6+dot(sin(.3*T+q/6.), cos(q.yzx/16.))))),\n p = q;\n o.rgb = tanh(c*c/5e5);\n\n}", "views": 3849, "likes": 532, "createdAt": "2026-04-02T01:56:37.273Z", "sourceFormat": "glsl" }, { "id": "50d1783d-35ec-4cc1-8d0a-0167bbf3c1e0", "name": "甲板", "author": "unknown", "code": "/*\n\tNeon Lit Hexagons\n\t-----------------\n\n\tI needed a break from a few technical shaders I've beem hacking away at, so I finished an old \n\tgeometric example that'd been sitting on the blocks for a while.\n\t\n\t3D hexagon tech imagery is a bit of a cliche, but I've always been a fan. Most tend to be high \n\tquality pathtraced renderings, but since this is a realtime raymarched example, I had to make \n\ta lot of concessions. The glowing neon lights were inspired by some of Shau's examples, some\n\tonline imagery, and practically half the demos out there. :)\n\n\tI tried to create the glowing effect without the use of a volumetric pass, but my eyes weren't\n\taccepting the results, which meant the observant people on here -- pretty much everyone -- would \n\tnotice immediately, so I put a relatively cheap one in. The improvements were immediate, but it\n\twas at the cost of rendering speed... I'm just hoping no one notices the lack of reflections from \n\tthe neon lights. :) I have a pretty quick laptop, but ever since the WebGL 2 update, it hasn't \n\tenjoyed compiling extra passes, so reflections had to go. At a later stage, I might attempt to \n\tfake them in some way.\n\n\tThere are a couple of surface detail defines below that I had to leave out. I also came pretty \n\tclose to greebling the surfaces, but figured that might be overkill. In the end, I took the \n\t\"less is more\" approach. However, I intend to put together a greebled surface pretty soon.\n\n\n // Other neon-looking examples:\n\n\t// Shau has a heap of bright glowing examples, but here's a few.\n\tOTT - shau\n\thttps://www.shadertoy.com/view/4sVyDd\n\n\t43% Burnt - shau\n\thttps://www.shadertoy.com/view/XljBWW\n\n\tAngle Grinder - shau\n\thttps://www.shadertoy.com/view/XtsfWX\n\n\n // Great example.\n\tNeon World - zguerrero\n https://www.shadertoy.com/view/MlscDj\n\n*/\n\n\n\n// Hexagon: 0, Dodecahedron: 1, Circle: 2.\n// Squares, stars, etc, are possible too, but I didn't include those.\n#define SHAPE 0\n\n\n// Details usually make a scene more interesting. In this case, however, they seemed a\n// little expensive, so I left them out.\n//\n// I wanted to include the grooves, at least, but I figured speed on slower machines was\n// more important.\n//#define ADD_DETAIL_GROOVE \n//#define ADD_DETAIL_BOLT\n\n// Animating the neon lights, or not. I find them a little too distracting, \n// so the default is \"off.\"\n//#define ANIMATE_LIGHTS\n\n// If Borg green is more your thing. :)\n//#define GREEN_GLOW\n\n// Maximum ray distance.\n#define FAR 50.\n\n// Standard 2D rotation formula.\nmat2 r2(in float a){ float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\n// vec2 to float hash.\nfloat hash21(vec2 p){\n \n float n = dot(p, vec2(7.163, 157.247)); \n return fract(sin(n)*43758.5453);\n}\n\n// vec3 to float hash.\nfloat hash31(vec3 p){\n \n float n = dot(p, vec3(13.163, 157.247, 7.951)); \n return fract(sin(n)*43758.5453); \n}\n\n\n// Commutative smooth maximum function. Provided by Tomkh, and taken \n// from Alex Evans's (aka Statix) talk: \n// http://media.lolrus.mediamolecule.com/AlexEvans_SIGGRAPH-2015.pdf\n// Credited to Dave Smith @media molecule.\nfloat smax(float a, float b, float k){\n \n float f = max(0., 1. - abs(b - a)/k);\n return max(a, b) + k*.25*f*f;\n}\n\n/*\n// Commutative smooth minimum function. Provided by Tomkh, and taken \n// from Alex Evans's (aka Statix) talk: \n// http://media.lolrus.mediamolecule.com/AlexEvans_SIGGRAPH-2015.pdf\n// Credited to Dave Smith @media molecule.\nfloat smin(float a, float b, float k){\n\n float f = max(0., 1. - abs(b - a)/k);\n return min(a, b) - k*.25*f*f;\n}\n\n*/\n\n/*\n// Tri-Planar blending function. Based on an old Nvidia tutorial.\nvec3 tex3D( sampler2D tex, in vec3 p, in vec3 n ){\n \n n = max((abs(n) - .2)*7., .001); // n = max(abs(n), .001), etc.\n n /= (n.x + n.y + n.z ); \n \n\tvec3 tx = (texture(tex, p.yz)*n.x + texture(tex, p.zx)*n.y + texture(tex, p.xy)*n.z).xyz;\n \n return tx*tx;\n}\n*/\n\n// Tri-Planar blending function. Based on an old Nvidia writeup:\n// GPU Gems 3 - Ryan Geiss: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch01.html\nvec3 tex3D(sampler2D t, in vec3 p, in vec3 n){\n \n // We only want positive normal weightings. The normal is manipulated to suit\n // your needs.\n n = max(abs(n) - .2, .001); // n = max(n*n - .1, .001), etc.\n //n /= dot(n, vec3(1)); // Rough renormalization approximation.\n n /= length(n); // Renormalizing.\n \n\tvec3 tx = texture(t, p.yz).xyz; // Left and right sides.\n vec3 ty = texture(t, p.zx).xyz; // Top and bottom.\n vec3 tz = texture(t, p.xy).xyz; // Front and back.\n \n // Blending the surrounding textures with the normal weightings. If the surface is facing\n // more up or down, then a larger \"n.y\" weighting would make sense, etc.\n //\n // Textures are stored in sRGB (I think), so you have to convert them to linear space \n // (squaring is a rough approximation) prior to working with them... or something like that. :)\n // Once the final color value is gamma corrected, you should see correct looking colors.\n return (tx*tx*n.x + ty*ty*n.y + tz*tz*n.z);\n \n}\n\n// More concise, self contained version of IQ's original 3D noise function.\nfloat noise3D(in vec3 p){\n \n // Just some random figures, analogous to stride. You can change this, if you want.\n\tconst vec3 s = vec3(113, 157, 1);\n\t\n\tvec3 ip = floor(p); // Unique unit cell ID.\n \n // Setting up the stride vector for randomization and interpolation, kind of. \n // All kinds of shortcuts are taken here. Refer to IQ's original formula.\n vec4 h = vec4(0., s.yz, s.y + s.z) + dot(ip, s);\n \n\tp -= ip; // Cell's fractional component.\n\t\n // A bit of cubic smoothing, to give the noise that rounded look.\n p = p*p*(3. - 2.*p);\n \n // Standard 3D noise stuff. Retrieving 8 random scalar values for each cube corner,\n // then interpolating along X. There are countless ways to randomize, but this is\n // the way most are familar with: fract(sin(x)*largeNumber).\n h = mix(fract(sin(h)*43758.5453), fract(sin(h + s.x)*43758.5453), p.x);\n\t\n // Interpolating along Y.\n h.xy = mix(h.xz, h.yw, p.y);\n \n // Interpolating along Z, and returning the 3D noise value.\n float n = mix(h.x, h.y, p.z); // Range: [0, 1].\n\t\n return n;//abs(n - .5)*2.;\n}\n\n// Simple fBm to produce some clouds.\nfloat fbm(in vec3 p){\n \n // Four layers of 3D noise.\n //p /= 1.5;\n //p -= vec3(0, 0, iTime*1.);\n return 0.5333*noise3D( p ) + 0.2667*noise3D( p*2.02 ) + 0.1333*noise3D( p*4.03 ) + 0.0667*noise3D( p*8.03 );\n\n}\n\n\n\n// The path is a 2D sinusoid that varies over time, depending upon the frequencies, and amplitudes.\nvec2 path(in float z){ \n\n //return vec2(0);\n \n //return vec2(sin(z * 0.15)*2.4, cos(z * 0.075)*.15); \n \n return vec2(sin(z * 0.15)*2.4, 0);\n}\n\n\n\n\n//////\n//float objID, svObjID;\n\n// Helper vector. If you're doing anything that involves regular triangles or hexagons, the\n// 30-60-90 triangle will be involved in some way, which has sides of 1, sqrt(3) and 2.\nconst vec2 s = vec2(.866025, 1);//const vec2 s = vec2(1, 1.7320508); //\n\n\n// The 2D hexagonal isosuface function: If you were to render a horizontal line and one that\n// slopes at 60 degrees, mirror, then combine them, you'd arrive at the following.\nfloat hex(in vec2 p){\n \n //return length(p);\n p = abs(p);\n \n // Below is equivalent to:\n return max(p.x*.866025 + p.y*.5, p.y); \n\n //return max(dot(p, s*.5), p.x); // Hexagon.\n \n}\n\n/*\n// More accurate formula, but involves more operations and didn't improve quality by any\n// significant amount, so I've used the estimation below.\nfloat hexPylon(vec2 p2, float pz, float r, float ht){\n\n vec3 p = vec3(p2.x, pz, p2.y);\n \n // Note the \"*1.5\" You need to take the minimum of\n // long-sided rectangles, not squares. Squares will give\n // you a dodecahedron.\n vec3 b = vec3(r*1.5, ht, r); \n \n //p.xz = abs(p.xz);\n //p.xz = vec2(p.x*.866025 + p.z*.5, p.z);\n \n b -= .015;\n //p.xz = r2(-3.14159/3.)*q.xz;\n \tfloat d1 = length(max(abs(p) - b, 0.));\n p.xz = r2(6.2831/3.)*p.xz;\n float d2 = length(max(abs(p) - b, 0.));\n\n p.xz = r2(6.2831/3.)*p.xz;\n float d3 = length(max(abs(p) - b, 0.)); \n return max(max(d1, d2), d3) - .015;\n}\n*/\n\n/*\n// Signed distance to a regular hexagon -- using IQ's more exact method.\nfloat sdHexagon(in vec2 p, in float r){\n \n const vec3 k = vec3(-.8660254, .5, .57735); // pi/6: cos, sin, tan.\n\n // X and Y reflection.\n p = abs(p);\n p -= 2.*min(dot(k.xy, p), 0.)*k.xy;\n \n // Polygon side.\n return length(p - vec2(clamp(p.x, -k.z*r, k.z*r), r))*sign(p.y - r);\n \n}\n\n// IQ's extrusion formula, with a bit of rounding (the .015 bit) thrown in.\nfloat opExtrusion(in float sdf, in float pz, in float h)\n{\n vec2 w = vec2( sdf, abs(pz) - h );\n \treturn min(max(w.x,w.y), 0.) + length(max(w + .015, 0.)) - .015;\n}\n\n// A technically correct hexagonal pylon formual.\nfloat hexPylon(vec2 p2, float pz, float r, float ht){\n \n float hex = sdHexagon(p2, r);\n return opExtrusion(hex, pz, ht);\n}\n*/\n\n// Normally, I'd say this is the hexagonal pylon distance function. However, I should \n// probably make the distinction between a fully bonafide distance function and something\n// that estimates it. This is a bound of sorts. There's not a great deal between it and \n// the real thing, but it does exhibit different behaviour away from the surface, which \n// can affect things like shadows, etc. However, as you can see, in this situation, you\n// can't really tell. I figured I'd mention this, because myself and others use a lot of\n// these kind of functions.\n//\n// By the way, a more exact formula is commented out above.\n//\n// Hexagonal pylon field. There's also defines for a dodecahedron and a cylinder.\nfloat hexPylon(vec2 p2, float pz, float r, float ht){\n\n vec3 p = vec3(p2.x, pz, p2.y);\n vec3 b = vec3(r, ht, r);\n \n \n #if SHAPE == 0\n // Hexagon.\n p.xz = abs(p.xz);\n p.xz = vec2(p.x*.866025 + p.z*.5, p.z);\n // The \".015\" is a subtle rounding factor. Zero gives sharp edges,\n // and larger numbers give a more rounded look.\n \treturn length(max(abs(p) - b + .015, 0.)) - .015;\n #elif SHAPE == 1\n // Dodecahedron.\n p.xz = abs(p.xz);\n p2 = p.xz*.8660254 + p.zx*.5;\n p.xz = vec2(max(p2.x, p2.y), max(p.z, p.x));\n // The \".015\" is a subtle rounding factor. Zero gives sharp edges,\n // and larger numbers give a more rounded look.\n \treturn length(max(abs(p) - b + .015, 0.)) - .015;\n #else\n // Cylinder -- IQ's cylinder function, to be precise, so I think this particular\n // function is a proper distance field.\n p.xy = abs(vec2(length(p.xz), p.y)) - b.xy + .015;\n return min(max(p.x, p.y), 0.) + length(max(p.xy, 0.)) - .015;\n #endif\n \n \n}\n \n\n\n// IDs for the neon lights. Added at the last minute. Identifying things can be tiresome. Individual \n// objects need to be identified, and sometimes, objects within objects need identification too.\n// In this case, there are four pylon groupings. Each pylon object contains a neon light object that \n// is either on or off.\n// \n// If you're seting IDs withing the distance function, they can be lost when calling things like the \n// \"normal\" function, etc. Therefore, you need extra variables to save the IDs directly after calling \n// the trace function. Then there's the matter of ID sorting, which should be done outside the loop... \n// Even with a \"struct,\" or something to that effect, it can still be messy. Having said that, I might \n// start trying to streamline and formalize the process.\nvec4 litID;\nfloat svLitID;\n\n// The pylon and light distance field.\n// Variables in order: p.xz, p.y, radius, height, ID, direction (unused).\nfloat objDist(vec2 p, float pH, float r, float ht, inout float id, float dir){\n \n // Neon light height: Four levels, plus the height is divided by two.\n const float s = 1./16.; //1./4./2.*.5; \n\n // Main hexagon pylon.\n float h1 = hexPylon(p, pH, r, ht);\n \n #ifdef ADD_DETAIL_GROOVE\n // I like this extra detail, but it was a little too expensive.\n\th1 = max(h1, -hexPylon(p, pH + ht, r - .06, s/4.)); // Extra detail.\n #endif\n \n #ifdef ADD_DETAIL_BOLT\n // An alternative extra detail. Also a little on the expensive side.\n h1 = min(h1, hexPylon(p, pH, .1, ht + s/4.)); // Extra detail.\n #endif\n\n \n \n // Thin hexagon slab -- sitting just below the top of the main hexagon. It's\n // lit differently to represent the neon portion.\n float h2 = hexPylon(p, pH + ht - s, r + .01, s/3.);\n \n \n // Opens a space around the neon lit hexagon. Used, if the radius of \"h2\" is\n // less that \"h1,\" which isn't the case here.\n //h1 = smax(h1, -(abs(pH + ht - s) - s/3.), .015);\n \n // Identifying the main hexagon pylon or the neon lit portion.\n id = h1FAR) break;\n \n // Applying some glow. There are probably better ways to go about it, but this\n // will suffice. If the ray passes within \"gd\" units of the neon object, add some\n // distance-based glow.\n const float gd = .1;\n float rnd = getRndID(v2Rnd);\n if(rnd>0. && gLitID == 1. && adFAR) break;\n\n const float gd = .1;\n float rnd = getRndID(vRnd);\n if(rnd>0. && gLitID == 1. && adFAR) break;\n \n t += d;\n }\n \n return min(t, FAR);\n}\n*/\n\n\n// Cheap shadows are hard. In fact, I'd almost say, shadowing repeat objects - in a setting like this - with limited \n// iterations is impossible... However, I'd be very grateful if someone could prove me wrong. :)\nfloat softShadow(vec3 ro, vec3 lp, float k){\n\n // More would be nicer. More is always nicer, but not really affordable.\n const int maxIterationsShad = 32; \n \n vec3 rd = (lp-ro); // Unnormalized direction ray.\n\n float shade = 1.0;\n float dist = 0.01; \n float end = max(length(rd), 0.001);\n float stepDist = end/float(maxIterationsShad);\n \n rd /= end;\n\n // Max shadow iterations - More iterations make nicer shadows, but slow things down. Obviously, the lowest \n // number to give a decent shadow is the best one to choose. \n for (int i=0; i end) break; \n }\n\n // I've added 0.5 to the final shade value, which lightens the shadow a bit. It's a preference thing. \n // Really dark shadows look too brutal to me.\n return min(max(shade, 0.) + .05, 1.); \n}\n\n\n\n// Standard normal function. It's not as fast as the tetrahedral calculation, but more symmetrical. Due to \n// the intricacies of this particular scene, it's kind of needed to reduce jagged effects.\nvec3 getNormal(in vec3 p) {\n\tconst vec2 e = vec2(0.0025, 0);\n\treturn normalize(vec3(map(p + e.xyy) - map(p - e.xyy), map(p + e.yxy) - map(p - e.yxy),\tmap(p + e.yyx) - map(p - e.yyx)));\n}\n\n\n\n/*\n// Tetrahedral normal, to save a couple of \"map\" calls. Courtesy of IQ.\nvec3 getNormal( in vec3 p ){\n\n // Note the slightly increased sampling distance, to alleviate\n // artifacts due to hit point inaccuracies.\n vec2 e = vec2(0.0025, -0.0025); \n return normalize(\n e.xyy * map(p + e.xyy) + \n e.yyx * map(p + e.yyx) + \n e.yxy * map(p + e.yxy) + \n e.xxx * map(p + e.xxx));\n}\n*/\n\n/*\n// Normal calculation, with some edging and curvature bundled in.\nvec3 getNormal(vec3 p, inout float edge, inout float crv, float ef) { \n\t\n // Roughly two pixel edge spread, but increased slightly with larger resolution.\n vec2 e = vec2(ef/mix(450., iResolution.y, .5), 0);\n\n\tfloat d1 = map(p + e.xyy), d2 = map(p - e.xyy);\n\tfloat d3 = map(p + e.yxy), d4 = map(p - e.yxy);\n\tfloat d5 = map(p + e.yyx), d6 = map(p - e.yyx);\n\tfloat d = map(p)*2.;\n\n edge = abs(d1 + d2 - d) + abs(d3 + d4 - d) + abs(d5 + d6 - d);\n //edge = abs(d1 + d2 + d3 + d4 + d5 + d6 - d*3.);\n edge = smoothstep(0., 1., sqrt(edge/e.x*2.));\n\n \n // Wider sample spread for the curvature.\n //e = vec2(12./450., 0);\n\t//d1 = map(p + e.xyy), d2 = map(p - e.xyy);\n\t//d3 = map(p + e.yxy), d4 = map(p - e.yxy);\n\t//d5 = map(p + e.yyx), d6 = map(p - e.yyx);\n //crv = clamp((d1 + d2 + d3 + d4 + d5 + d6 - d*3.)*32. + .5, 0., 1.);\n \t \n \n e = vec2(.0025, 0); //iResolution.y - Depending how you want different resolutions to look.\n\td1 = map(p + e.xyy), d2 = map(p - e.xyy);\n\td3 = map(p + e.yxy), d4 = map(p - e.yxy);\n\td5 = map(p + e.yyx), d6 = map(p - e.yyx);\n\t\n return normalize(vec3(d1 - d2, d3 - d4, d5 - d6));\n}\n*/\n\n// Ambient occlusion, for that self shadowed look.\n// Based on the original by IQ.\nfloat calcAO(in vec3 p, in vec3 n)\n{\n\tfloat sca = 4., occ = 0.0;\n for( int i=1; i<6; i++ ){\n \n float hr = float(i)*.125/5.; \n float dd = map(p + hr*n);\n occ += (hr - dd)*sca;\n sca *= .75;\n }\n return clamp(1. - occ, 0., 1.); \n \n}\n\n\n// Texture bump mapping. Four tri-planar lookups, or 12 texture lookups in total. I tried to\n// make it as concise as possible. Whether that translates to speed, or not, I couldn't say.\nvec3 texBump( sampler2D tx, in vec3 p, in vec3 n, float bf){\n \n const vec2 e = vec2(.001, 0);\n \n // Three gradient vectors rolled into a matrix, constructed with offset greyscale texture values. \n mat3 m = mat3(tex3D(tx, p - e.xyy, n), tex3D(tx, p - e.yxy, n), tex3D(tx, p - e.yyx, n));\n \n vec3 g = vec3(.299, .587, .114)*m; // Converting to greyscale.\n g = (g - dot(tex3D(tx, p , n), vec3(.299, .587, .114)))/e.x; \n \n // Adjusting the tangent vector so that it's perpendicular to the normal -- Thanks to\n // EvilRyu for reminding me why we perform this step. It's been a while, but I vaguely\n // recall that it's some kind of orthogonal space fix using the Gram-Schmidt process. \n // However, all you need to know is that it works. :)\n g -= n*dot(n, g);\n \n return normalize( n + g*bf ); // Bumped normal. \"bf\" - bump factor.\n\t\n}\n\n\n// Very basic pseudo environment mapping... and by that, I mean it's fake. :) However, it \n// does give the impression that the surface is reflecting the surrounds in some way.\n//\n// More sophisticated environment mapping:\n// UI easy to integrate - XT95 \n// https://www.shadertoy.com/view/ldKSDm\nvec3 envMap(vec3 p){\n \n p *= 3.;\n //p.xz += iTime*.5;\n \n float n3D2 = noise3D(p*3.);\n \n // A bit of fBm.\n float c = noise3D(p)*.57 + noise3D(p*2.)*.28 + noise3D(p*4.)*.15;\n c = smoothstep(.25, 1., c); // Putting in some dark space.\n \n p = vec3(c, c*c, c*c*c); // Bluish tinge.\n \n return mix(p, p.zyx, n3D2*.25 + .75); // Mixing in a bit of purple.\n\n}\n\n\nvec3 getObjectColor(vec3 p, vec3 n){\n \n \n //p.xy -= path(p.z);\n float sz0 = 1./2.;\n \n // Texel retrieval.\n vec3 txP = p;\n //txP.xz *= r2(getRndID(svVRnd)*6.2831);\n vec3 col = tex3D(iChannel0, txP*sz0, n );\n col = smoothstep(-.0, .5, col);//*vec3(.5, .8, 1.5);\n col = mix(col, vec3(1)*dot(col, vec3(.299, .587, .114)), .5);\n // Darken the surfaces to bring more attention to the neon lights.\n col /= 16.;\n \n \n // Unique random ID for the hexagon pylon.\n float rnd = getRndID(svV2Rnd);\n \n // Subtly coloring the unlit hexagons... I wasn't feeling it. :)\n //if(svLitID==1. && rnd<=.0) col *= vec3(1, .85, .75)*4.;\n\n // Applying the glow.\n //\n // It's took a while to hit upon the right combination. You can create a cheap lit object \n // effect by simply ramping up the object's color intensity. However, your eyes can tell that\n // it's lacking that volumetric haze. Volumetric haze is achievable via a volumetric appoach.\n // However, it's prone to patchiness. The solutionm, of course, is to combine the smoothness\n // of direct object coloring with a portion of the glow. That's what is happining here.\n\n // Object glow.\n float oGlow = 0.;\n \n // Color every lit object with a gradient based on its vertical positioning.\n if(rnd>0. && svLitID==1.) {\n \n float ht = hexHeight(svV2Rnd);\n \tht = floor(ht*4.99)/4./2. + .02;\n const float s = 1./4./2.*.5; // Four levels, plus the height is divided by two.\n \n oGlow = mix(1., 0., clamp((abs(p.y - (ht - s)))/s*3.*1., 0., 1.));\n oGlow = smoothstep(0., 1., oGlow*1.);\n }\n \n // Mix the object glow in with a small potion of the volumetric glow.\n glow = mix(glow, vec3(oGlow), .75);\n \n // Colorizing the glow, depending on your requirements. I've used a colorful orangey palette,\n // then have modified the single color according to a made up 3D transcental function.\n //glow = pow(vec3(1, 1.05, 1.1)*glow.x, vec3(6, 3, 1));\n glow = pow(vec3(1.5, 1, 1)*glow, vec3(1, 3, 6)); // Mild firey orange.\n glow = mix(glow, glow.xzy, dot(sin(p*4. - cos(p.yzx*4.)), vec3(.166)) + .5); // Mixing in some pink.\n glow = mix(glow, glow.zyx, dot(cos(p*2. - sin(p.yzx*2.)), vec3(.166)) + .5); // Blue tones.\n //glow = mix(glow.zyx, glow, smoothstep(-.1, .1, dot(sin(p + cos(p.yzx)), vec3(.166))));\n \n #ifdef GREEN_GLOW \n glow = glow.yxz;\n #endif\n \n \n return col;\n \n}\n\n\n// Using the hit point, unit direction ray, etc, to color the \n// scene. Diffuse, specular, falloff, etc. It's all pretty \n// standard stuff.\nvec3 doColor(in vec3 sp, in vec3 rd, in vec3 sn, in vec3 lp, in float t){\n \n vec3 sceneCol = vec3(0);\n \n if(t 0.0031308 ? (1.055 * pow(linearColor, 1.0 / 2.4) - 0.055) : (12.92 * linearColor); \n}\n\nvec3 sRGBencode(vec3 linearColor) \n{ \n linearColor = clamp(linearColor, 0.0, 1.0); \n return vec3(sRGBencode(linearColor.x), sRGBencode(linearColor.y), sRGBencode(linearColor.z)); \n}\n\nfloat Star(vec2 uv, float flare)\n{\n float d = length(uv);\n float m = 0.02 / (d + 0.001); // Add tiny number for dividing zero\n float rays = max(0.0, 1.0 - abs(uv.x * uv.y * 200.0)); \n m += rays * flare;\n m *= smoothstep(0.8, 0.05, d); \n return m;\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord)\n{\n vec2 uv = (2.0 * fragCoord - iResolution.xy) / iResolution.y;\n vec3 finalColor = vec3(0.0);\n float currentTime = iTime;\n\n // Camera Setup\n float focalLength = 2.0;\n vec3 rayOrigin = vec3(0.5, 3.8, 0.5 - currentTime); \n vec3 rayDir = normalize(vec3(uv, -focalLength)); \n\n // Camera Rotation Angles\n float pitchAngle = -0.35;\n float cp = cos(pitchAngle), sp = sin(pitchAngle);\n float yawAngle = 0.25 * sin(currentTime * 0.3);\n float cy = cos(yawAngle), sy = sin(yawAngle);\n\n // Apply Rotation to Ray Direction\n rayDir.yz *= mat2(cp, sp, -sp, cp);\n rayDir.xz *= mat2(cy, sy, -sy, cy);\n\n // Calc Camera local axis(right, up) for 3D billboard\n vec3 camRight = vec3(1.0, 0.0, 0.0);\n camRight.yz *= mat2(cp, sp, -sp, cp);\n camRight.xz *= mat2(cy, sy, -sy, cy);\n\n vec3 camUp = vec3(0.0, 1.0, 0.0);\n camUp.yz *= mat2(cp, sp, -sp, cp);\n camUp.xz *= mat2(cy, sy, -sy, cy);\n\n // Raymarching Loop\n float rayDistance = 0.0; \n for(int i = 0; i < MAX_RAY_STEPS; i++)\n {\n vec3 rayPos = rayDir * rayDistance + rayOrigin;\n vec2 gridCell = round(rayPos.xz);\n \n // Change for texture image size\n //ivec2 texCoord = (ivec2(gridCell) % 1024 + 1024) % 1024;\n //vec4 noiseData = texelFetch(iChannel0, texCoord, 0); \n ivec2 texSize = textureSize(iChannel0, 0);\n ivec2 texCoord = (ivec2(gridCell) % texSize + texSize) % texSize;\n vec4 noiseData = texelFetch(iChannel0, texCoord, 0);\n\n float dropHeadY = mod(noiseData.a * 93.0 - currentTime * FALL_SPEED, 45.0);\n \n // Calc tail\n vec3 nearestPointOnLine = vec3(gridCell.x, clamp(rayPos.y, dropHeadY, dropHeadY + TAIL_LENGTH), gridCell.y);\n float distToLine = length(rayPos - nearestPointOnLine);\n \n float tailAttenuation = exp(-max(TAIL_DECAY * (rayPos.y - dropHeadY), 0.0)); \n float tailGlow = tailAttenuation / (abs(distToLine * distToLine) + 0.001); \n\n // Calc cross-flare-head position for billboard\n vec3 headPos = vec3(gridCell.x, dropHeadY, gridCell.y);\n vec3 deltaToHead = rayPos - headPos;\n\n // Project cross-shaped-head from 3d to 2d for billboard\n vec2 flareUV = vec2(dot(deltaToHead, camRight), dot(deltaToHead, camUp));\n \n // Rotate head through time\n float rotSpeed = currentTime * (3.0 + noiseData.b * 2.0);\n float cr = cos(rotSpeed), sr = sin(rotSpeed);\n flareUV *= mat2(cr, sr, -sr, cr);\n \n float headGlow = Star(flareUV * (1.0 / STAR_SIZE), STAR_BRIGHTNESS);\n float depthAttenuation = exp(-0.05 * rayDistance); \n finalColor += depthAttenuation * (tailGlow * 0.5 + headGlow * 15.0) * noiseData.rgb;\n \n rayDistance += min(0.5, distToLine) + 0.01;\n } \n\n finalColor = tanh(finalColor / GLOW_EXPOSURE);\n finalColor = sRGBencode(finalColor);\n fragColor = vec4(finalColor, 1.0);\n}", "views": 14244, "likes": 240, "createdAt": "2026-04-02T01:43:43.091Z", "sourceFormat": "glsl" }, { "id": "02bd9517-38ba-4392-8fa2-e79abc18eded", "name": "球体", "author": "unknown", "code": "// fur ball\n// (c) simon green 2013\n// @simesgreen\n// v1.1\n\nconst float uvScale = 1.0;\nconst float colorUvScale = 0.1;\nconst float furDepth = 0.2;\nconst int furLayers = 64;\nconst float rayStep = furDepth*2.0 / float(furLayers);\nconst float furThreshold = 0.4;\nconst float shininess = 50.0;\n\nbool intersectSphere(vec3 ro, vec3 rd, float r, out float t)\n{\n\tfloat b = dot(-ro, rd);\n\tfloat det = b*b - dot(ro, ro) + r*r;\n\tif (det < 0.0) return false;\n\tdet = sqrt(det);\n\tt = b - det;\n\treturn t > 0.0;\n}\n\nvec3 rotateX(vec3 p, float a)\n{\n float sa = sin(a);\n float ca = cos(a);\n return vec3(p.x, ca*p.y - sa*p.z, sa*p.y + ca*p.z);\n}\n\nvec3 rotateY(vec3 p, float a)\n{\n float sa = sin(a);\n float ca = cos(a);\n return vec3(ca*p.x + sa*p.z, p.y, -sa*p.x + ca*p.z);\n}\n\nvec2 cartesianToSpherical(vec3 p)\n{\t\t\n\tfloat r = length(p);\n\n\tfloat t = (r - (1.0 - furDepth)) / furDepth;\t\n\tp = rotateX(p.zyx, -cos(iTime*1.5)*t*t*0.4).zyx;\t// curl\n\n\tp /= r;\t\n\tvec2 uv = vec2(atan(p.y, p.x), acos(p.z));\n\n\t//uv.x += cos(iTime*1.5)*t*t*0.4;\t// curl\n\t//uv.y += sin(iTime*1.7)*t*t*0.2;\n\tuv.y -= t*t*0.1;\t// curl down\n\treturn uv;\n}\n\n// returns fur density at given position\nfloat furDensity(vec3 pos, out vec2 uv)\n{\n\tuv = cartesianToSpherical(pos.xzy);\t\n\tvec4 tex = textureLod(iChannel0, uv*uvScale, 0.0);\n\n\t// thin out hair\n\tfloat density = smoothstep(furThreshold, 1.0, tex.x);\n\t\n\tfloat r = length(pos);\n\tfloat t = (r - (1.0 - furDepth)) / furDepth;\n\t\n\t// fade out along length\n\tfloat len = tex.y;\n\tdensity *= smoothstep(len, len-0.2, t);\n\n\treturn density;\t\n}\n\n// calculate normal from density\nvec3 furNormal(vec3 pos, float density)\n{\n float eps = 0.01;\n vec3 n;\n\tvec2 uv;\n n.x = furDensity( vec3(pos.x+eps, pos.y, pos.z), uv ) - density;\n n.y = furDensity( vec3(pos.x, pos.y+eps, pos.z), uv ) - density;\n n.z = furDensity( vec3(pos.x, pos.y, pos.z+eps), uv ) - density;\n return normalize(n);\n}\n\nvec3 furShade(vec3 pos, vec2 uv, vec3 ro, float density)\n{\n\t// lighting\n\tconst vec3 L = vec3(0, 1, 0);\n\tvec3 V = normalize(ro - pos);\n\tvec3 H = normalize(V + L);\n\n\tvec3 N = -furNormal(pos, density);\n\t//float diff = max(0.0, dot(N, L));\n\tfloat diff = max(0.0, dot(N, L)*0.5+0.5);\n\tfloat spec = pow(max(0.0, dot(N, H)), shininess);\n\t\n\t// base color\n\tvec3 color = textureLod(iChannel1, uv*colorUvScale, 0.0).xyz;\n\n\t// darken with depth\n\tfloat r = length(pos);\n\tfloat t = (r - (1.0 - furDepth)) / furDepth;\n\tt = clamp(t, 0.0, 1.0);\n\tfloat i = t*0.5+0.5;\n\t\t\n\treturn color*diff*i + vec3(spec*i);\n}\t\t\n\nvec4 scene(vec3 ro,vec3 rd)\n{\n\tvec3 p = vec3(0.0);\n\tconst float r = 1.0;\n\tfloat t;\t\t\t\t \n\tbool hit = intersectSphere(ro - p, rd, r, t);\n\t\n\tvec4 c = vec4(0.0);\n\tif (hit) {\n\t\tvec3 pos = ro + rd*t;\n\n\t\t// ray-march into volume\n\t\tfor(int i=0; i 0.0) {\n\t\t\t\tsampleCol.rgb = furShade(pos, uv, ro, sampleCol.a);\n\n\t\t\t\t// pre-multiply alpha\n\t\t\t\tsampleCol.rgb *= sampleCol.a;\n\t\t\t\tc = c + sampleCol*(1.0 - c.a);\n\t\t\t\tif (c.a > 0.95) break;\n\t\t\t}\n\t\t\t\n\t\t\tpos += rd*rayStep;\n\t\t}\n\t}\n\t\n\treturn c;\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n\tvec2 uv = fragCoord.xy / iResolution.xy;\n\tuv = uv*2.0-1.0;\n\tuv.x *= iResolution.x / iResolution.y;\n\t\n\tvec3 ro = vec3(0.0, 0.0, 2.5);\n\tvec3 rd = normalize(vec3(uv, -2.0));\n\t\n\tvec2 mouse = iMouse.xy / iResolution.xy;\n\tfloat roty = 0.0;\n\tfloat rotx = 0.0;\n\tif (iMouse.z > 0.0) {\n\t\trotx = (mouse.y-0.5)*3.0;\n\t\troty = -(mouse.x-0.5)*6.0;\n\t} else {\n\t\troty = sin(iTime*1.5);\n\t}\n\t\n ro = rotateX(ro, rotx);\t\n ro = rotateY(ro, roty);\t\n rd = rotateX(rd, rotx);\n rd = rotateY(rd, roty);\n\t\n\tfragColor = scene(ro, rd);\n}", "views": 19672, "likes": 529, "createdAt": "2026-04-02T01:40:46.648Z", "sourceFormat": "glsl" }, { "id": "29c5453f-5a8b-4995-a4a7-c8379e2d50e9", "name": "齿轮", "author": "unknown", "code": "// Copyright Inigo Quilez, 2019 - https://iquilezles.org/\n// I am the sole copyright owner of this Work. You cannot\n// host, display, distribute or share this Work neither as\n// is or altered, in any form including physical and\n// digital. You cannot use this Work in any commercial or\n// non-commercial product, website or project. You cannot\n// sell this Work and you cannot mint an NFTs of it. You\n// cannot use this Work to train AI models. I share this\n// Work for educational purposes, you can link to it as\n// an URL, proper attribution and unmodified screenshot,\n// as part of your educational material. If these\n// conditions are too restrictive please contact me.\n\n// Basically the same as https://www.shadertoy.com/view/XlVcWz\n// but optimized through symmetry so it only needs to evaluate\n// four gears instead of 18. Also I made the gears with actual\n// boxes rather than displacements, which creates an exact SDF\n// allowing me to raymarch the scene at the speed of light, or\n// in other words, without reducing the raymarching step size.\n// Also I'm using a bounding volume to speed things up further\n// so I can affor some nice ligthing and motion blur.\n//\n// Live streamed tutorial on this shader:\n// PART 1: https://www.youtube.com/watch?v=sl9x19EnKng\n// PART 2: https://www.youtube.com/watch?v=bdICU2uvOdU\n//\n// Video capture here: https://www.youtube.com/watch?v=ydTVmDBSGYQ\n//\n#if HW_PERFORMANCE==0\n#define AA 1\n#else\n#define AA 2 // Set AA to 1 if your machine is too slow\n#endif\n\n\n// https://iquilezles.org/articles/smin\nfloat smax( float a, float b, float k )\n{\n float h = max(k-abs(a-b),0.0);\n return max(a, b) + h*h*0.25/k;\n}\n\n// https://iquilezles.org/articles/distfunctions\nfloat sdSphere( in vec3 p, in float r )\n{\n return length(p)-r;\n}\n\nfloat sdVerticalSemiCapsule( vec3 p, float h, float r )\n{\n p.y = max(p.y-h,0.0);\n return length( p ) - r;\n}\n\n// https://iquilezles.org/articles/distfunctions2d\nfloat sdCross( in vec2 p, in vec2 b, float r ) \n{\n p = abs(p); p = (p.y>p.x) ? p.yx : p.xy;\n \n\tvec2 q = p - b;\n float k = max(q.y,q.x);\n vec2 w = (k>0.0) ? q : vec2(b.y-p.x,-k);\n \n return sign(k)*length(max(w,0.0)) + r;\n}\n\n// https://www.shadertoy.com/view/MlycD3\nfloat dot2( in vec2 v ) { return dot(v,v); }\nfloat sdTrapezoid( in vec2 p, in float r1, float r2, float he )\n{\n vec2 k1 = vec2(r2,he);\n vec2 k2 = vec2(r2-r1,2.0*he);\n\n\tp.x = abs(p.x);\n vec2 ca = vec2(max(0.0,p.x-((p.y<0.0)?r1:r2)), abs(p.y)-he);\n vec2 cb = p - k1 + k2*clamp( dot(k1-p,k2)/dot2(k2), 0.0, 1.0 );\n \n float s = (cb.x < 0.0 && ca.y < 0.0) ? -1.0 : 1.0;\n \n return s*sqrt( min(dot2(ca),dot2(cb)) );\n}\n\n// https://iquilezles.org/articles/intersectors\nvec2 iSphere( in vec3 ro, in vec3 rd, in float rad )\n{\n\tfloat b = dot( ro, rd );\n\tfloat c = dot( ro, ro ) - rad*rad;\n\tfloat h = b*b - c;\n\tif( h<0.0 ) return vec2(-1.0);\n h = sqrt(h);\n\treturn vec2(-b-h, -b+h );\n}\n\n//----------------------------------\n\nfloat dents( in vec2 q, in float tr, in float y )\n{\n const float an = 6.283185/12.0;\n float fa = (atan(q.y,q.x)+an*0.5)/an;\n float sym = an*floor(fa);\n vec2 r = mat2(cos(sym),-sin(sym), sin(sym), cos(sym))*q;\n \n#if 1\n float d = length(max(abs(r-vec2(0.17,0))-tr*vec2(0.042,0.041*y),0.0));\n#else\n float d = sdTrapezoid( r.yx-vec2(0.0,0.17), 0.085*y, 0.028*y, tr*0.045 );\n#endif\n\n\treturn d - 0.005*tr;\n}\n\nvec4 gear(vec3 q, float off, float time)\n{\n {\n float an = 2.0*time*sign(q.y) + off*6.283185/24.0;\n float co = cos(an), si = sin(an);\n q.xz = mat2(co,-si,si,co)*q.xz;\n }\n \n q.y = abs(q.y);\n \n float an2 = 2.0*min(1.0-2.0*abs(fract(0.5+time/10.0)-0.5),1.0/2.0);\n vec3 tr = min( 10.0*an2 - vec3(4.0,6.0,8.0),1.0);\n \n // ring\n float d = abs(length(q.xz) - 0.155*tr.y) - 0.018;\n\n // add dents\n float r = length(q);\n d = min( d, dents(q.xz,tr.z, r) );\n\n \n // slice it\n float de = -0.0015*clamp(600.0*abs(dot(q.xz,q.xz)-0.155*0.155),0.0,1.0);\n d = smax( d, abs(r-0.5)-0.03+de, 0.005*tr.z );\n\n // add cross\n float d3 = sdCross( q.xz, vec2(0.15,0.022)*tr.y, 0.02*tr.y );\n vec2 w = vec2( d3, abs(q.y-0.485)-0.005*tr.y );\n d3 = min(max(w.x,w.y),0.0) + length(max(w,0.0))-0.003*tr.y;\n d = min( d, d3 ); \n \n // add pivot\n d = min( d, sdVerticalSemiCapsule( q, 0.5*tr.x, 0.01 ));\n\n // base\n d = min( d, sdSphere(q-vec3(0.0,0.12,0.0),0.025) );\n \n return vec4(d,q.xzy);\n}\n\nvec2 rot( vec2 v )\n{\n return vec2(v.x-v.y,v.y+v.x)*0.707107;\n}\n \nvec4 map( in vec3 p, float time )\n{\n // center sphere\n vec4 d = vec4( sdSphere(p,0.12), p );\n \n // gears. There are 18, but we only evaluate 4 \n vec3 qx = vec3(rot(p.zy),p.x); if(abs(qx.x)>abs(qx.y)) qx=qx.zxy;\n vec3 qy = vec3(rot(p.xz),p.y); if(abs(qy.x)>abs(qy.y)) qy=qy.zxy;\n vec3 qz = vec3(rot(p.yx),p.z); if(abs(qz.x)>abs(qz.y)) qz=qz.zxy;\n vec3 qa = abs(p); qa = (qa.x>qa.y && qa.x>qa.z) ? p.zxy : \n (qa.z>qa.y ) ? p.yzx :\n p.xyz;\n vec4 t;\n t = gear( qa,0.0,time ); if( t.x>1)&1),((i>>1)&1),(i&1))-1.0);\n n += e*map(pos+0.0005*e,time).x;\n }\n return normalize(n);\n#endif \n}\n\nfloat calcAO( in vec3 pos, in vec3 nor, in float time )\n{\n\tfloat occ = 0.0;\n float sca = 1.0;\n for( int i=ZERO; i<5; i++ )\n {\n float h = 0.01 + 0.12*float(i)/4.0;\n float d = map( pos+h*nor, time ).x;\n occ += (h-d)*sca;\n sca *= 0.95;\n }\n return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );\n}\n\n// https://iquilezles.org/articles/rmshadows\nfloat calcSoftshadow( in vec3 ro, in vec3 rd, in float k, in float time )\n{\n float res = 1.0;\n \n // bounding sphere\n vec2 b = iSphere( ro, rd, 0.535 );\n\tif( b.y>0.0 )\n {\n // raymarch\n float tmax = b.y;\n float t = max(b.x,0.001);\n for( int i=0; i<64; i++ )\n {\n float h = map( ro + rd*t, time ).x;\n res = min( res, k*h/t );\n t += clamp( h, 0.012, 0.2 );\n if( res<0.001 || t>tmax ) break;\n }\n }\n \n return clamp( res, 0.0, 1.0 );\n}\n\nvec4 intersect( in vec3 ro, in vec3 rd, in float time )\n{\n vec4 res = vec4(-1.0);\n \n // bounding sphere\n vec2 tminmax = iSphere( ro, rd, 0.535 );\n\tif( tminmax.y>0.0 )\n {\n // raymarch\n float t = max(tminmax.x,0.001);\n for( int i=0; i<128 && t1\n for( int m=ZERO; m0.0 )\n {\n // shading/lighting\t\n vec3 pos = ro + tuvw.x*rd;\n vec3 nor = calcNormal(pos, time);\n \n vec3 te = 0.5*texture( iChannel0, tuvw.yz*2.0 ).xyz+\n 0.5*texture( iChannel0, tuvw.yw*1.0 ).xyz;\n \n vec3 mate = 0.22*te;\n float len = length(pos);\n \n mate *= 1.0 + vec3(2.0,0.5,0.0)*(1.0-smoothstep(0.121,0.122,len) ) ;\n \n float focc = 0.1+0.9*clamp(0.5+0.5*dot(nor,pos/len),0.0,1.0);\n focc *= 0.1+0.9*clamp(len*2.0,0.0,1.0);\n float ks = clamp(te.x*1.5,0.0,1.0);\n vec3 f0 = mate;\n float kd = (1.0-ks)*0.125;\n \n float occ = calcAO( pos, nor, time ) * focc;\n \n col = vec3(0.0);\n \n // side\n {\n vec3 lig = normalize(vec3(0.8,0.2,0.6));\n float dif = clamp( dot(nor,lig), 0.0, 1.0 );\n vec3 hal = normalize(lig-rd);\n float sha = 1.0; if( dif>0.001 ) sha = calcSoftshadow( pos+0.001*nor, lig, 20.0, time );\n vec3 spe = pow(clamp(dot(nor,hal),0.0,1.0),16.0)*(f0+(1.0-f0)*pow(clamp(1.0+dot(hal,rd),0.0,1.0),5.0));\n col += kd*mate*2.0*vec3(1.00,0.70,0.50)*dif*sha;\n col += ks* 2.0*vec3(1.00,0.80,0.70)*dif*sha*spe*3.14;\n }\n\n // top\n {\n vec3 ref = reflect(rd,nor);\n float fre = clamp(1.0+dot(nor,rd),0.0,1.0);\n float sha = occ;\n col += kd*mate*25.0*vec3(0.19,0.22,0.24)*(0.6 + 0.4*nor.y)*sha;\n col += ks* 25.0*vec3(0.19,0.22,0.24)*sha*smoothstep( -1.0+1.5*focc, 1.0-0.4*focc, ref.y ) * (f0 + (1.0-f0)*pow(fre,5.0));\n }\n \n // bottom\n {\n float dif = clamp(0.4-0.6*nor.y,0.0,1.0);\n col += kd*mate*5.0*vec3(0.25,0.20,0.15)*dif*occ;\n }\n }\n \n // compress \n // col = 1.2*col/(1.0+col);\n \n // vignetting\n col *= 1.0-0.1*dot(p,p);\n \n // gamma \n\t tot += pow(col,vec3(0.45) );\n #if AA>1\n }\n tot /= float(AA*AA);\n #endif\n\n // s-curve \n tot = min(tot,1.0);\n tot = tot*tot*(3.0-2.0*tot);\n \n // cheap dithering\n tot += sin(fragCoord.x*114.0)*sin(fragCoord.y*211.1)/512.0;\n\n fragColor = vec4( tot, 1.0 );\n}", "views": 16421, "likes": 420, "createdAt": "2026-04-02T01:39:56.715Z", "sourceFormat": "glsl" }, { "id": "a8016745-d7ae-4fb3-ada9-0573e9fc213b", "name": "点云", "author": "unknown", "code": "const float PI = acos(-1.);\nconst float LAYER_DISTANCE = 5.;\n\nconst vec3 BLUE = vec3(47, 75, 162) / 255.; \nconst vec3 PINK = vec3(233, 71, 245) / 255.;\nconst vec3 PURPLE = vec3(128, 63, 224) / 255.;\nconst vec3 CYAN = vec3(61, 199, 220) / 255.;\nconst vec3 MAGENTA = vec3(222, 51, 150) / 255.;\nconst vec3 LIME = vec3(160, 220, 70) / 255.;\nconst vec3 ORANGE = vec3(245, 140, 60) / 255.;\nconst vec3 TEAL = vec3(38, 178, 133) / 255.;\nconst vec3 RED = vec3(220, 50, 50) / 255.; \nconst vec3 YELLOW = vec3(240, 220, 80) / 255.;\nconst vec3 VIOLET = vec3(180, 90, 240) / 255.;\nconst vec3 AQUA = vec3(80, 210, 255) / 255.;\nconst vec3 FUCHSIA = vec3(245, 80, 220) / 255.;\nconst vec3 GREEN = vec3(70, 200, 100) / 255.;\n\nconst int NUM_COLORS = 14;\nconst vec3 COLS[NUM_COLORS] = vec3[](\n BLUE,\n PINK,\n PURPLE,\n CYAN,\n MAGENTA,\n LIME,\n ORANGE,\n TEAL,\n RED,\n YELLOW,\n VIOLET,\n AQUA,\n FUCHSIA,\n GREEN\n);\n\n// t within the range [0, 1]\nvec3 get_color(float t) {\n float scaledT = t * float(NUM_COLORS - 1);\n\n float curr = floor(scaledT);\n float next = min(curr + 1., float(NUM_COLORS) - 1.);\n\n float localT = scaledT - curr;\n return mix(COLS[int(curr)], COLS[int(next)], localT);\n}\n\n// https://www.shadertoy.com/view/4djSRW\nvec4 hash41(float p)\n{\n\tvec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));\n p4 += dot(p4, p4.wzxy+33.33);\n return fract((p4.xxyz+p4.yzzw)*p4.zywx);\n \n}\n\nfloat get_height(vec2 id, float layer) {\n float t = iTime;\n\n vec4 h = hash41(layer)*1000.;\n\n float o = 0.;\n o += sin(( id.x+h.x) *.2 + t)*.3;\n o += sin(( id.y+h.y) *.2 + t)*.3;\n o += sin((-id.x+id.y+h.z)*.3 + t)*.3;\n o += sin(( id.x+id.y+h.z)*.3 + t)*.4;\n o += sin(( id.x-id.y+h.w)*.8 + t)*.1;\n\n return o;\n}\n\nmat2x2 rotate(float r) {\n return mat2x2(cos(r), -sin(r), sin(r), cos(r));\n}\n\nfloat sdSphere(vec3 p, float r) {\n return length(p) - r;\n}\n\nfloat map(vec3 p) {\n float t = iTime;\n const float xz = .3;\n vec3 s = vec3(xz, LAYER_DISTANCE, xz);\n vec3 id = round(p / s);\n\n float ho = get_height(id.xz, id.y);\n p.y += ho;\n p -= s*id;\n return sdSphere(p, smoothstep(1.3, -1.3, ho)*.03+.0001);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n float seed = iDate.x + iDate.y + iDate.z + iDate.w;\n float t = iTime;\n vec3 col = vec3(0.);\n vec2 uv = (2. * gl_FragCoord.xy - iResolution.xy) / iResolution.y;\n uv.y *= -1.;\n\n float phase = t*.2;\n float y = sin(phase);\n float ny = smoothstep(-1., 1., y);\n vec3 c = get_color(mod((t + seed)/float(NUM_COLORS), 5.*2.*PI)/(5.*2.*PI));\n \n vec3 ro = vec3(0., y*LAYER_DISTANCE*.5, -t);\n vec3 rd = normalize(vec3(uv, -1.));\n\n rd.xy *= rotate(-ny*PI);\n rd.xz *= rotate(sin(t*.5)*.4);\n \n float d = 0.;\n for (int i = 0; i < 30; ++i) {\n vec3 p = ro + rd *d;\n\n float dt = map(p);\n dt = max(dt*(cos(ny*PI*2.)*.3+.5), 1e-3);\n\n col += (.1 / dt) * c;\n d += dt*.8;\n }\n\n col = tanh(col * .01);\n\n fragColor = vec4(col, 1.);\n}", "views": 22975, "likes": 583, "createdAt": "2026-04-02T01:37:37.687Z", "sourceFormat": "glsl" }, { "id": "0d1722d9-c2f6-4d69-8a97-31e5baba1975", "name": "火焰", "author": "unknown", "code": "// \"Volumetric explosion\" by Duke\n// https://www.shadertoy.com/view/lsySzd\n//-------------------------------------------------------------------------------------\n// Based on \"Supernova remnant\" (https://www.shadertoy.com/view/MdKXzc) \n// and other previous shaders \n// otaviogood's \"Alien Beacon\" (https://www.shadertoy.com/view/ld2SzK)\n// and Shane's \"Cheap Cloud Flythrough\" (https://www.shadertoy.com/view/Xsc3R4) shaders\n// Some ideas came from other shaders from this wonderful site\n// Press 1-2-3 to zoom in and zoom out.\n// License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License\n//-------------------------------------------------------------------------------------\n\n// comment this string to see each part in full screen\n#define BOTH\n// uncomment this string to see left part\n//#define LEFT\n\n//#define LOW_QUALITY\n\n#define DITHERING\n\n//#define TONEMAPPING\n\n//-------------------\n#define pi 3.14159265\n#define R(p, a) p=cos(a)*p+sin(a)*vec2(p.y, -p.x)\n\n// iq's noise\nfloat noise( in vec3 x )\n{\n vec3 p = floor(x);\n vec3 f = fract(x);\n\tf = f*f*(3.0-2.0*f);\n\tvec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;\n\tvec2 rg = textureLod( iChannel0, (uv+ 0.5)/256.0, 0.0 ).yx;\n\treturn 1. - 0.82*mix( rg.x, rg.y, f.z );\n}\n\nfloat fbm( vec3 p )\n{\n return noise(p*.06125)*.5 + noise(p*.125)*.25 + noise(p*.25)*.125 + noise(p*.4)*.2;\n}\n\nfloat Sphere( vec3 p, float r )\n{\n return length(p)-r;\n}\n\n//==============================================================\n// otaviogood's noise from https://www.shadertoy.com/view/ld2SzK\n//--------------------------------------------------------------\n// This spiral noise works by successively adding and rotating sin waves while increasing frequency.\n// It should work the same on all computers since it's not based on a hash function like some other noises.\n// It can be much faster than other noise functions if you're ok with some repetition.\nconst float nudge = 4.;\t// size of perpendicular vector\nfloat normalizer = 1.0 / sqrt(1.0 + nudge*nudge);\t// pythagorean theorem on that perpendicular to maintain scale\nfloat SpiralNoiseC(vec3 p)\n{\n float n = -mod(iTime * 0.2,-2.); // noise amount\n float iter = 2.0;\n for (int i = 0; i < 8; i++)\n {\n // add sin and cos scaled inverse with the frequency\n n += -abs(sin(p.y*iter) + cos(p.x*iter)) / iter;\t// abs for a ridged look\n // rotate by adding perpendicular and scaling down\n p.xy += vec2(p.y, -p.x) * nudge;\n p.xy *= normalizer;\n // rotate on other axis\n p.xz += vec2(p.z, -p.x) * nudge;\n p.xz *= normalizer;\n // increase the frequency\n iter *= 1.733733;\n }\n return n;\n}\n\nfloat VolumetricExplosion(vec3 p)\n{\n float final = Sphere(p,4.);\n #ifdef LOW_QUALITY\n final += noise(p*12.5)*.2;\n #else\n final += fbm(p*50.);\n #endif\n final += SpiralNoiseC(p.zxy*0.4132+333.)*3.0; //1.25;\n\n return final;\n}\n\nfloat map(vec3 p) \n{\n\tR(p.xz, iMouse.x*0.008*pi+iTime*0.1);\n\n\tfloat VolExplosion = VolumetricExplosion(p/0.5)*0.5; // scale\n \n\treturn VolExplosion;\n}\n//--------------------------------------------------------------\n\n// assign color to the media\nvec3 computeColor( float density, float radius )\n{\n\t// color based on density alone, gives impression of occlusion within\n\t// the media\n\tvec3 result = mix( vec3(1.0,0.9,0.8), vec3(0.4,0.15,0.1), density );\n\t\n\t// color added to the media\n\tvec3 colCenter = 7.*vec3(0.8,1.0,1.0);\n\tvec3 colEdge = 1.5*vec3(0.48,0.53,0.5);\n\tresult *= mix( colCenter, colEdge, min( (radius+.05)/.9, 1.15 ) );\n\t\n\treturn result;\n}\n\nbool RaySphereIntersect(vec3 org, vec3 dir, out float near, out float far)\n{\n\tfloat b = dot(dir, org);\n\tfloat c = dot(org, org) - 8.;\n\tfloat delta = b*b - c;\n\tif( delta < 0.0) \n\t\treturn false;\n\tfloat deltasqrt = sqrt(delta);\n\tnear = -b - deltasqrt;\n\tfar = -b + deltasqrt;\n\treturn far > 0.0;\n}\n\n// Applies the filmic curve from John Hable's presentation\n// More details at : http://filmicgames.com/archives/75\nvec3 ToneMapFilmicALU(vec3 _color)\n{\n\t_color = max(vec3(0), _color - vec3(0.004));\n\t_color = (_color * (6.2*_color + vec3(0.5))) / (_color * (6.2 * _color + vec3(1.7)) + vec3(0.06));\n\treturn _color;\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{ \n const float KEY_1 = 49.5/256.0;\n\tconst float KEY_2 = 50.5/256.0;\n\tconst float KEY_3 = 51.5/256.0;\n float key = 0.0;\n key += 0.7*texture(iChannel1, vec2(KEY_1,0.25)).x;\n key += 0.7*texture(iChannel1, vec2(KEY_2,0.25)).x;\n key += 0.7*texture(iChannel1, vec2(KEY_3,0.25)).x;\n\n vec2 uv = fragCoord/iResolution.xy;\n \n\t// ro: ray origin\n\t// rd: direction of the ray\n\tvec3 rd = normalize(vec3((fragCoord.xy-0.5*iResolution.xy)/iResolution.y, 1.));\n\tvec3 ro = vec3(0., 0., -6.+key*1.6);\n \n\t// ld, td: local, total density \n\t// w: weighting factor\n\tfloat ld=0., td=0., w=0.;\n\n\t// t: length of the ray\n\t// d: distance function\n\tfloat d=1., t=0.;\n \n const float h = 0.1;\n \n\tvec4 sum = vec4(0.0);\n \n float min_dist=0.0, max_dist=0.0;\n\n if(RaySphereIntersect(ro, rd, min_dist, max_dist))\n {\n \n\tt = min_dist*step(t,min_dist);\n \n\t// raymarch loop\n #ifdef LOW_QUALITY\n\tfor (int i=0; i<56; i++)\n #else\n for (int i=0; i<86; i++)\n #endif\n\t{\n\t \n\t\tvec3 pos = ro + t*rd;\n \n\t\t// Loop break conditions.\n\t if(td>0.9 || d<0.12*t || t>10. || sum.a > 0.99 || t>max_dist) break;\n \n // evaluate distance function\n float d = map(pos);\n \n #ifdef BOTH\n /*\n if (uv.x<0.5)\n {\n d = abs(d)+0.07;\n }\n */\n //split screen variant\n //d = uv.x < 0.5 ? abs(d)+0.07 : d;\n \n d = cos(iTime)*uv.x < 0.1 ? abs(d)+0.07 : d;\n #else\n #ifdef LEFT\n d = abs(d)+0.07;\n #endif\n\t\t#endif\n \n\t\t// change this string to control density \n\t\td = max(d,0.03);\n \n // point light calculations\n vec3 ldst = vec3(0.0)-pos;\n float lDist = max(length(ldst), 0.001);\n\n // the color of light \n vec3 lightColor=vec3(1.0,0.5,0.25);\n \n sum.rgb+=(lightColor/exp(lDist*lDist*lDist*.08)/30.); // bloom\n \n\t\tif (deps )\n\t\t{\n\t\t\tif(flame(p) < .0)\n\t\t\t\tglowed=true;\n\t\t\tif(glowed)\n \t\t\tglow = float(i)/64.;\n\t\t}\n\t}\n\treturn vec4(p,glow);\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n\tvec2 v = -1.0 + 2.0 * fragCoord.xy / iResolution.xy;\n\tv.x *= iResolution.x/iResolution.y;\n\t\n\tvec3 org = vec3(0., -2., 4.);\n\tvec3 dir = normalize(vec3(v.x*1.6, -v.y, -1.5));\n\t\n\tvec4 p = raymarch(org, dir);\n\tfloat glow = p.w;\n\t\n\tvec4 col = mix(vec4(1.,.5,.1,1.), vec4(0.1,.5,1.,1.), p.y*.02+.4);\n\t\n\tfragColor = mix(vec4(0.), col, pow(glow*2.,4.));\n\t//fragColor = mix(vec4(1.), mix(vec4(1.,.5,.1,1.),vec4(0.1,.5,1.,1.),p.y*.02+.4), pow(glow*2.,4.));\n\n}", "views": 23256, "likes": 84, "createdAt": "2026-04-01T16:01:12.555Z", "sourceFormat": "glsl" }, { "id": "40cdf4d1-62fb-43fb-9891-3e7d4dc3c641", "name": "星云1", "author": "unknown", "code": "// Playing with https://x.com/YoheiNishitsuji/status/1918213871375892638\n\n// You should probably listen to something like this while watching ^_^\n// https://www.youtube.com/watch?v=FtukH_bCDHg\n\nfloat sRGBencode(float C_linear) { return C_linear > 0.0031308 ? (1.055 * pow(C_linear, 1./2.4) - 0.055) : (12.92 * C_linear); }\nvec3 sRGBencode(vec3 C_linear) { C_linear = clamp(C_linear, 0., 1.); return vec3(sRGBencode(C_linear.x), sRGBencode(C_linear.y), sRGBencode(C_linear.z)); }\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n \n vec3 color = texelFetch(iChannel0, ivec2(fragCoord), 0).rgb;\n vec2 uv = (2. * fragCoord.xy- iResolution.xy)/iResolution.y;\n color *= 1.-.05*dot(uv,uv);\n color = 1.-exp(-9.*pow(color, vec3(3.35)));\n color = sRGBencode(color);\n fragColor = vec4(color, 1);\n}", "views": 12044, "likes": 244, "createdAt": "2026-04-01T16:00:02.916Z", "sourceFormat": "glsl" }, { "id": "82ac512b-f051-42d1-b3cc-bd2f6d92fdb2", "name": "流光", "author": "unknown", "code": "#define A 9. // amplitude\n#define T (iTime/3e2)\n#define H(a) (cos(radians(vec3(180, 90, 0))+(a)*6.2832)*.5+.5) // hue\n\nfloat map(vec3 u, float v) // sdf\n{\n float t = T, // speed\n l = 5., // loop to reduce clipping\n f = 1e10, i = 0., y, z;\n \n u.xy = vec2(atan(u.x, u.y), length(u.xy)); // polar transform\n u.x += t*v*3.1416*.7; // counter rotation\n \n for (; i++ 1e3) break;\n }\n \n c += texture(iChannel0, u*d +o).rrr * vec3(0, .4, s)*s*z*.03; // wavy aqua\n c += min(exp(-p.z -f*A)*z*k*.01/s, 1.); // light tips\n \n j = p.xy/v +m; // 2d coords\n c /= clamp(dot(j, j)*4., .04, 4.); // brightness\n \n C = vec4(exp(log(c)/2.2), 1);\n}", "views": 19147, "likes": 521, "createdAt": "2026-04-01T15:58:19.514Z", "sourceFormat": "glsl" }, { "id": "e25336ee-9857-47b8-b5da-a87267dc6aad", "name": "天际", "author": "unknown", "code": "/*\n Mostly just playing with nimitz' triangle noise, thought it came out nice.\n \n Yeah, it's *another* cloud shader :D\n\n See nimitz' \"Oblivion\" for the triangle noise source, I tweaked it a bit for this iirc.\n\n https://www.shadertoy.com/view/XtX3DH\n \n*/\n\n#define T iTime\n#define R(a) mat2(cos(a+vec4(0,33,11,0)))\n#define N normalize\n\nfloat tri(in float x){return abs(fract(x)-.5);}\nvec3 tri3(in vec3 p){return vec3( tri(p.z+tri(p.y*1.)), tri(p.z+tri(p.x*1.)), tri(p.y+tri(p.x*1.)));} \n\nfloat triNoise3d(vec3 p)\n{\n p.z += T/4e1;\n float z=1.5;\n\tfloat rz = 0.;\n vec3 bp = p;\n mat2 m2 = R(.3);\n\tfor (float i=0.; i<=3.; i++ )\n\t{\n vec3 dg = tri3(bp*2.)*1.;\n p += (dg+T/3e1);\n\n bp *= 2.;\n\t\tz *= 1.75;\n\t\tp *= 1.1;\n p.yz*= m2;\n \n rz+= (tri(p.z+tri(p.x+tri(p.y))))/z;\n bp += .2;\n\t}\n\treturn rz;\n}\n\nvoid mainImage(out vec4 o, vec2 u) {\n float a,i,s,d;\n vec3 p = iResolution; \n \n vec3 D = N(vec3(u = (u+u-p.xy)/p.y, 1));\n for(o*=i; i++<1e2;\n d += s = .1+.4*abs(s),\n o += 6.*(1.+cos(T/2.+.1*i+vec4(5,4,3,0)))/s\n + .5*vec4(1,2,4,0)/abs(1.01+u.y-cos(u.x/3.3))\n + 4.*vec4(6,2,1,0)/length(u*2.)\n )\n p = D*d,\n p.y+=2.5,\n s = 6. - abs(p.y-cos(p.x/3e1)*4.),\n s -= 7.*triNoise3d(p/3e1);\n\n o = tanh(o/5e3*exp(1e2*vec4(5,2,1,0)/d/d));\n}", "views": 10493, "likes": 103, "createdAt": "2026-04-01T15:57:36.080Z", "sourceFormat": "glsl" }, { "id": "d6942ee2-97be-4d9d-bfaf-c0fde0558de0", "name": "气泡", "author": "unknown", "code": "// noise from https://www.shadertoy.com/view/4sc3z2\nvec3 hash33(vec3 p3)\n{\n\tp3 = fract(p3 * vec3(.1031,.11369,.13787));\n p3 += dot(p3, p3.yxz+19.19);\n return -1.0 + 2.0 * fract(vec3(p3.x+p3.y, p3.x+p3.z, p3.y+p3.z)*p3.zyx);\n}\nfloat snoise3(vec3 p)\n{\n const float K1 = 0.333333333;\n const float K2 = 0.166666667;\n \n vec3 i = floor(p + (p.x + p.y + p.z) * K1);\n vec3 d0 = p - (i - (i.x + i.y + i.z) * K2);\n \n vec3 e = step(vec3(0.0), d0 - d0.yzx);\n\tvec3 i1 = e * (1.0 - e.zxy);\n\tvec3 i2 = 1.0 - e.zxy * (1.0 - e);\n \n vec3 d1 = d0 - (i1 - K2);\n vec3 d2 = d0 - (i2 - K1);\n vec3 d3 = d0 - 0.5;\n \n vec4 h = max(0.6 - vec4(dot(d0, d0), dot(d1, d1), dot(d2, d2), dot(d3, d3)), 0.0);\n vec4 n = h * h * h * h * vec4(dot(d0, hash33(i)), dot(d1, hash33(i + i1)), dot(d2, hash33(i + i2)), dot(d3, hash33(i + 1.0)));\n \n return dot(vec4(31.316), n);\n}\n\nvec4 extractAlpha(vec3 colorIn)\n{\n vec4 colorOut;\n float maxValue = min(max(max(colorIn.r, colorIn.g), colorIn.b), 1.0);\n if (maxValue > 1e-5)\n {\n colorOut.rgb = colorIn.rgb * (1.0 / maxValue);\n colorOut.a = maxValue;\n }\n else\n {\n colorOut = vec4(0.0);\n }\n return colorOut;\n}\n\n#define BG_COLOR (vec3(sin(iTime)*0.5+0.5) * 0.0 + vec3(0.0))\n#define time iTime\nconst vec3 color1 = vec3(0.611765, 0.262745, 0.996078);\nconst vec3 color2 = vec3(0.298039, 0.760784, 0.913725);\nconst vec3 color3 = vec3(0.062745, 0.078431, 0.600000);\nconst float innerRadius = 0.6;\nconst float noiseScale = 0.65;\n\nfloat light1(float intensity, float attenuation, float dist)\n{\n return intensity / (1.0 + dist * attenuation);\n}\nfloat light2(float intensity, float attenuation, float dist)\n{\n return intensity / (1.0 + dist * dist * attenuation);\n}\n\nvoid draw( out vec4 _FragColor, in vec2 vUv )\n{\n vec2 uv = vUv;\n float ang = atan(uv.y, uv.x);\n float len = length(uv);\n float v0, v1, v2, v3, cl;\n float r0, d0, n0;\n float r, d;\n \n // ring\n n0 = snoise3( vec3(uv * noiseScale, time * 0.5) ) * 0.5 + 0.5;\n r0 = mix(mix(innerRadius, 1.0, 0.4), mix(innerRadius, 1.0, 0.6), n0);\n d0 = distance(uv, r0 / len * uv);\n v0 = light1(1.0, 10.0, d0);\n v0 *= smoothstep(r0 * 1.05, r0, len);\n cl = cos(ang + time * 2.0) * 0.5 + 0.5;\n \n // high light\n float a = time * -1.0;\n vec2 pos = vec2(cos(a), sin(a)) * r0;\n d = distance(uv, pos);\n v1 = light2(1.5, 5.0, d);\n v1 *= light1(1.0, 50.0 , d0);\n \n // back decay\n v2 = smoothstep(1.0, mix(innerRadius, 1.0, n0 * 0.5), len);\n \n // hole\n v3 = smoothstep(innerRadius, mix(innerRadius, 1.0, 0.5), len);\n \n // color\n vec3 c = mix(color1, color2, cl);\n vec3 col = mix(color1, color2, cl);\n col = mix(color3, col, v0);\n col = (col + v1) * v2 * v3;\n col.rgb = clamp(col.rgb, 0.0, 1.0);\n \n //gl_FragColor = extractAlpha(col);\n _FragColor = extractAlpha(col);\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n vec2 uv = (fragCoord*2.-iResolution.xy)/iResolution.y;\n \n vec4 col;\n draw(col, uv);\n\n vec3 bg = BG_COLOR;\n\n fragColor.rgb = mix(bg, col.rgb, col.a); //normal blend\n}", "views": 19836, "likes": 476, "createdAt": "2026-04-01T15:57:05.112Z", "sourceFormat": "glsl" }, { "id": "34548b08-2577-4fd9-b428-7deef9aca610", "name": "玄彩", "author": "unknown", "code": "/*\n \"Singularity\" by @XorDev\n\n A whirling blackhole.\n Feel free to code golf!\n \n FabriceNeyret2: -19\n dean_the_coder: -12\n iq: -4\n*/\n\nvoid mainImage(out vec4 O, vec2 F)\n{\n //Iterator and attenuation (distance-squared)\n float i = .2, a;\n //Resolution for scaling and centering\n vec2 r = iResolution.xy,\n //Centered ratio-corrected coordinates\n p = ( F+F - r ) / r.y / .7,\n //Diagonal vector for skewing\n d = vec2(-1,1),\n //Blackhole center\n b = p - i*d,\n //Rotate and apply perspective\n c = p * mat2(1, 1, d/(.1 + i/dot(b,b))),\n //Rotate into spiraling coordinates\n v = c * mat2(cos(.5*log(a=dot(c,c)) + iTime*i + vec4(0,33,11,0)))/i,\n //Waves cumulative total for coloring\n w;\n \n //Loop through waves\n for(; i++<9.; w += 1.+sin(v) )\n //Distort coordinates\n v += .7* sin(v.yx*i+iTime) / i + .5;\n //Acretion disk radius\n i = length( sin(v/.3)*.4 + c*(3.+d) );\n //Red/blue gradient\n O = 1. - exp( -exp( c.x * vec4(.6,-.4,-1,0) )\n //Wave coloring\n / w.xyyx\n //Acretion disk brightness\n / ( 2. + i*i/4. - i )\n //Center darkness\n / ( .5 + 1. / a )\n //Rim highlight\n / ( .03 + abs( length(p)-.7 ) )\n );\n }", "views": 19599, "likes": 721, "createdAt": "2026-04-01T15:56:37.442Z", "sourceFormat": "glsl" }, { "id": "256b1d36-4713-4103-b9d3-8f4e10667288", "name": "热眼", "author": "unknown", "code": "// CC0: Clearly a bug\n// A \"Happy Accident\" Shader\n\n// Twigl: https://twigl.app?ol=true&ss=-OUOudmBPJ57CIb7rAxS\n\n// This shader uses a technique called \"raymarching\" to render 3D\n// Think of it like casting rays from your eye through each pixel into a 3D world,\n// then stepping along each ray until we hit something interesting.\n//\n// Key concepts for C developers:\n// - vec4/vec3/vec2: Like structs with x,y,z,w components (SIMD-style)\n// - Swizzling: p.xy means \"give me just the x,y parts of vector p\"\n// - mat2(): Creates a 2x2 rotation matrix from an angle\n// - All math operations work on vectors component-wise\n//\n// ATTRIBUTION: Shader techniques inspired by (alphabetical):\n// @byt3_m3chanic\n// @FabriceNeyrat2\n// @iq\n// @shane\n// @XorDev\n// + many more\n\nvoid mainImage(out vec4 O, vec2 C) {\n float \n i // Loop counter (starts at 0)\n , d // Distance to nearest surface\n , z = fract(dot(C,sin(C)))-.5 // Ray distance + noise for anti-banding\n ;\n vec4 \n o // Accumulated color/lighting\n , p // Current 3D position along ray\n ;\n for(\n vec2 r = iResolution.xy // Screen resolution\n ; ++i < 77. \n ; z += .6*d // Step forward (larger steps when far from surfaces)\n )\n // Convert 2D pixel to 3D ray direction\n p = vec4(z*normalize(vec3(C-.5*r,r.y)),.1*iTime)\n \n // Move through 3D space over time\n , p.z += iTime\n \n // Save position for lighting calculations\n , O = p\n \n // Apply rotation matrices to create fractal patterns\n // (These transform the 3D coordinates in interesting ways)\n , p.xy *= mat2(cos(2.+O.z+vec4(0,11,33,0)))\n \n // This was originally a bug in the matrix calculation\n // The incorrect transformation created an unexpectedly interesting pattern\n // Bob Ross would call this a \"happy little accident\"\n , p.xy *= mat2(cos(O+vec4(0,11,33,0)))\n \n // Calculate color based on position and space distortion\n // The sin() creates a nice looking palette, division by dot() creates falloff\n , O = (1.+sin(.5*O.z+length(p-O)+vec4(0,4,3,6)))\n / (.5+2.*dot(O.xy,O.xy))\n \n // Domain repetition, repeats the single line and the 2 planes infinitely\n , p = abs(fract(p)-.5)\n \n // Calculate distance to nearest surface\n // This combines a cylinder (length(p.xy)-.125) with 2 planesbox (min(p.x,p.y))\n , d = abs(min(length(p.xy)-.125,min(p.x,p.y)+1e-3))+1e-3\n \n // Add lighting contribution (brighter when closer to surfaces)\n , o += O.w/d*O\n ;\n \n // tanh() compresses the accumulated brightness to 0-1 range\n // (Like HDR tone mapping in photography)\n O = tanh(o/2e4);\n}", "views": 22519, "likes": 636, "createdAt": "2026-04-01T15:56:04.431Z", "sourceFormat": "glsl" }, { "id": "f77eacef-c66d-4a84-b0f5-2044b6a83b5b", "name": "炫彩", "author": "unknown", "code": "#define T iTime\n#define s1(v) (sin(v)*.5+.5)\n#define P(z) vec3(cos((z)*.1)*4.,sin((z)*.1)*4.,(z))\n#define t_path T*3.\n\n\nmat2 rotate(float a){\n float s = sin(a);\n float c = cos(a);\n return mat2(c,-s,s,c);\n}\n\n// https://www.shadertoy.com/view/lsKcDD\nmat3 setCamera( in vec3 ro, in vec3 ta, float cr )\n{\n\tvec3 cw = normalize(ta-ro); // 相机前\n\tvec3 cp = vec3(sin(cr), cos(cr),0.0); // 滚角\n\tvec3 cu = normalize( cross(cw,cp) ); // 相机右\n\tvec3 cv = normalize( cross(cu,cw) ); // 相机上\n return mat3( cu, cv, cw );\n}\n\nfloat noise(vec3 p){\n // p*=vec3(.1,.1,2.2);\n float n1 = dot(cos(p+sin(p*.4)*4.), vec3(.1)); // 不要在raymarch中用tanh,真的很费性能\n float n2 = dot(cos(p), vec3(.1));\n return mix(n1,n2,s1(T*.5));\n}\n\nvec3 C = vec3(10,2,1);\nvec3 RO;\nfloat fbm(vec3 p){\n float amp = 1.;\n float n = 0.;\n\n for(float i=0.;i<4.;i++){\n p += sin(p.zxy+T*i*2.)*amp;\n n += abs(noise(p))*amp;\n amp *= .5;\n p *= 2.;\n C += amp*.1;\n }\n return n;\n}\n\nvec3 col = vec3(0);\nfloat map(vec3 p){\n\n float d = fbm(p);\n float d1 = length(p - RO)-4.;\n d = max(d, -d1);\n col += s1(C+T)/(max(d, .01));\n\n return d;\n}\n\nvoid mainImage(out vec4 O, in vec2 I){\n vec2 R = iResolution.xy;\n vec2 uv = (I*2.-R)/R.y;\n\n O.rgb *= 0.;\n O.a = 1.;\n\n vec3 ro = P(t_path);\n RO = ro;\n vec3 rd = setCamera(ro, P(t_path+1.), sin(T*.5)*.4) * normalize(vec3(uv, 1.));\n\n float z = .1;\n\n float i=0.;\n while(i++<80.){\n vec3 p = ro + rd * z;\n\n float d = map(p);\n z += d;\n }\n\n\n O.rgb += col;\n O.rgb = tanh(O.rgb/8e2);\n}", "views": 7870, "likes": 161, "createdAt": "2026-04-01T15:55:32.788Z", "sourceFormat": "glsl" }, { "id": "62d7b82f-a078-4f08-af39-e527ba916a01", "name": "着色", "author": "unknown", "code": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nfloat cosRange(float amt, float range, float minimum) {\n\treturn (((1.0 + cos(radians(amt))) * 0.5) * range) + minimum;\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n const int zoom = 40;\n const float brightness = 0.975;\n\tfloat time = iTime * 1.25;\n\tvec2 uv = fragCoord.xy / iResolution.xy;\n\tvec2 p = (2.0*fragCoord.xy-iResolution.xy)/max(iResolution.x,iResolution.y);\n\tfloat ct = cosRange(time*5.0, 3.0, 1.1);\n\tfloat xBoost = cosRange(time*0.2, 5.0, 5.0);\n\tfloat yBoost = cosRange(time*0.1, 10.0, 5.0);\n\tfloat fScale = cosRange(time * 15.5, 1.25, 0.5);\n\t\n\tfor(int i=1;i.98 || uv.y>.98) col += 1.;\n #else\n col *= 1.-dot(uv,uv);\n t = mod(iTime, 230.);\n col *= S(0., 20., t)*S(224., 200., t);\n #endif\n \n fragColor = vec4(col,1);\n}", "views": 13711, "likes": 399, "createdAt": "2026-04-01T15:53:34.082Z", "sourceFormat": "glsl" }, { "id": "da6767b8-bca1-4c1f-a18d-70767db6d81c", "name": "海洋", "author": "unknown", "code": "// afl_ext 2017-2024\n// MIT License\n\n// Use your mouse to move the camera around! Press the Left Mouse Button on the image to look around!\n\n#define DRAG_MULT 0.38 // changes how much waves pull on the water\n#define WATER_DEPTH 1.0 // how deep is the water\n#define CAMERA_HEIGHT 1.5 // how high the camera should be\n#define ITERATIONS_RAYMARCH 12 // waves iterations of raymarching\n#define ITERATIONS_NORMAL 36 // waves iterations when calculating normals\n\n#define NormalizedMouse (iMouse.xy / iResolution.xy) // normalize mouse coords\n\n// Calculates wave value and its derivative, \n// for the wave direction, position in space, wave frequency and time\nvec2 wavedx(vec2 position, vec2 direction, float frequency, float timeshift) {\n float x = dot(direction, position) * frequency + timeshift;\n float wave = exp(sin(x) - 1.0);\n float dx = wave * cos(x);\n return vec2(wave, -dx);\n}\n\n// Calculates waves by summing octaves of various waves with various parameters\nfloat getwaves(vec2 position, int iterations) {\n float wavePhaseShift = length(position) * 0.1; // this is to avoid every octave having exactly the same phase everywhere\n float iter = 0.0; // this will help generating well distributed wave directions\n float frequency = 1.0; // frequency of the wave, this will change every iteration\n float timeMultiplier = 2.0; // time multiplier for the wave, this will change every iteration\n float weight = 1.0;// weight in final sum for the wave, this will change every iteration\n float sumOfValues = 0.0; // will store final sum of values\n float sumOfWeights = 0.0; // will store final sum of weights\n for(int i=0; i < iterations; i++) {\n // generate some wave direction that looks kind of random\n vec2 p = vec2(sin(iter), cos(iter));\n \n // calculate wave data\n vec2 res = wavedx(position, p, frequency, iTime * timeMultiplier + wavePhaseShift);\n\n // shift position around according to wave drag and derivative of the wave\n position += p * res.y * weight * DRAG_MULT;\n\n // add the results to sums\n sumOfValues += res.x * weight;\n sumOfWeights += weight;\n\n // modify next octave ;\n weight = mix(weight, 0.0, 0.2);\n frequency *= 1.18;\n timeMultiplier *= 1.07;\n\n // add some kind of random value to make next wave look random too\n iter += 1232.399963;\n }\n // calculate and return\n return sumOfValues / sumOfWeights;\n}\n\n// Raymarches the ray from top water layer boundary to low water layer boundary\nfloat raymarchwater(vec3 camera, vec3 start, vec3 end, float depth) {\n vec3 pos = start;\n vec3 dir = normalize(end - start);\n for(int i=0; i < 64; i++) {\n // the height is from 0 to -depth\n float height = getwaves(pos.xz, ITERATIONS_RAYMARCH) * depth - depth;\n // if the waves height almost nearly matches the ray height, assume its a hit and return the hit distance\n if(height + 0.01 > pos.y) {\n return distance(pos, camera);\n }\n // iterate forwards according to the height mismatch\n pos += dir * (pos.y - height);\n }\n // if hit was not registered, just assume hit the top layer, \n // this makes the raymarching faster and looks better at higher distances\n return distance(start, camera);\n}\n\n// Calculate normal at point by calculating the height at the pos and 2 additional points very close to pos\nvec3 normal(vec2 pos, float e, float depth) {\n vec2 ex = vec2(e, 0);\n float H = getwaves(pos.xy, ITERATIONS_NORMAL) * depth;\n vec3 a = vec3(pos.x, H, pos.y);\n return normalize(\n cross(\n a - vec3(pos.x - e, getwaves(pos.xy - ex.xy, ITERATIONS_NORMAL) * depth, pos.y), \n a - vec3(pos.x, getwaves(pos.xy + ex.yx, ITERATIONS_NORMAL) * depth, pos.y + e)\n )\n );\n}\n\n// Helper function generating a rotation matrix around the axis by the angle\nmat3 createRotationMatrixAxisAngle(vec3 axis, float angle) {\n float s = sin(angle);\n float c = cos(angle);\n float oc = 1.0 - c;\n return mat3(\n oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, \n oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, \n oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c\n );\n}\n\n// Helper function that generates camera ray based on UV and mouse\nvec3 getRay(vec2 fragCoord) {\n vec2 uv = ((fragCoord.xy / iResolution.xy) * 2.0 - 1.0) * vec2(iResolution.x / iResolution.y, 1.0);\n // for fisheye, uncomment following line and comment the next one\n //vec3 proj = normalize(vec3(uv.x, uv.y, 1.0) + vec3(uv.x, uv.y, -1.0) * pow(length(uv), 2.0) * 0.05); \n vec3 proj = normalize(vec3(uv.x, uv.y, 1.5));\n if(iResolution.x < 600.0) {\n return proj;\n }\n return createRotationMatrixAxisAngle(vec3(0.0, -1.0, 0.0), 3.0 * ((NormalizedMouse.x + 0.5) * 2.0 - 1.0)) \n * createRotationMatrixAxisAngle(vec3(1.0, 0.0, 0.0), 0.5 + 1.5 * (((NormalizedMouse.y == 0.0 ? 0.27 : NormalizedMouse.y) * 1.0) * 2.0 - 1.0))\n * proj;\n}\n\n// Ray-Plane intersection checker\nfloat intersectPlane(vec3 origin, vec3 direction, vec3 point, vec3 normal) { \n return clamp(dot(point - origin, normal) / dot(direction, normal), -1.0, 9991999.0); \n}\n\n// Some very barebones but fast atmosphere approximation\nvec3 extra_cheap_atmosphere(vec3 raydir, vec3 sundir) {\n //sundir.y = max(sundir.y, -0.07);\n float special_trick = 1.0 / (raydir.y * 1.0 + 0.1);\n float special_trick2 = 1.0 / (sundir.y * 11.0 + 1.0);\n float raysundt = pow(abs(dot(sundir, raydir)), 2.0);\n float sundt = pow(max(0.0, dot(sundir, raydir)), 8.0);\n float mymie = sundt * special_trick * 0.2;\n vec3 suncolor = mix(vec3(1.0), max(vec3(0.0), vec3(1.0) - vec3(5.5, 13.0, 22.4) / 22.4), special_trick2);\n vec3 bluesky= vec3(5.5, 13.0, 22.4) / 22.4 * suncolor;\n vec3 bluesky2 = max(vec3(0.0), bluesky - vec3(5.5, 13.0, 22.4) * 0.002 * (special_trick + -6.0 * sundir.y * sundir.y));\n bluesky2 *= special_trick * (0.24 + raysundt * 0.24);\n return bluesky2 * (1.0 + 1.0 * pow(1.0 - raydir.y, 3.0));\n} \n\n// Calculate where the sun should be, it will be moving around the sky\nvec3 getSunDirection() {\n return normalize(vec3(-0.0773502691896258 , 0.5 + sin(iTime * 0.2 + 2.6) * 0.45 , 0.5773502691896258));\n}\n\n// Get atmosphere color for given direction\nvec3 getAtmosphere(vec3 dir) {\n return extra_cheap_atmosphere(dir, getSunDirection()) * 0.5;\n}\n\n// Get sun color for given direction\nfloat getSun(vec3 dir) { \n return pow(max(0.0, dot(dir, getSunDirection())), 720.0) * 210.0;\n}\n\n// Great tonemapping function from my other shader: https://www.shadertoy.com/view/XsGfWV\nvec3 aces_tonemap(vec3 color) { \n mat3 m1 = mat3(\n 0.59719, 0.07600, 0.02840,\n 0.35458, 0.90834, 0.13383,\n 0.04823, 0.01566, 0.83777\n );\n mat3 m2 = mat3(\n 1.60475, -0.10208, -0.00327,\n -0.53108, 1.10813, -0.07276,\n -0.07367, -0.00605, 1.07602\n );\n vec3 v = m1 * color; \n vec3 a = v * (v + 0.0245786) - 0.000090537;\n vec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;\n return pow(clamp(m2 * (a / b), 0.0, 1.0), vec3(1.0 / 2.2)); \n}\n\n// Main\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n // get the ray\n vec3 ray = getRay(fragCoord);\n if(ray.y >= 0.0) {\n // if ray.y is positive, render the sky\n vec3 C = getAtmosphere(ray) + getSun(ray);\n fragColor = vec4(aces_tonemap(C * 2.0),1.0); \n return;\n }\n\n // now ray.y must be negative, water must be hit\n // define water planes\n vec3 waterPlaneHigh = vec3(0.0, 0.0, 0.0);\n vec3 waterPlaneLow = vec3(0.0, -WATER_DEPTH, 0.0);\n\n // define ray origin, moving around\n vec3 origin = vec3(iTime * 0.2, CAMERA_HEIGHT, 1);\n\n // calculate intersections and reconstruct positions\n float highPlaneHit = intersectPlane(origin, ray, waterPlaneHigh, vec3(0.0, 1.0, 0.0));\n float lowPlaneHit = intersectPlane(origin, ray, waterPlaneLow, vec3(0.0, 1.0, 0.0));\n vec3 highHitPos = origin + ray * highPlaneHit;\n vec3 lowHitPos = origin + ray * lowPlaneHit;\n\n // raymatch water and reconstruct the hit pos\n float dist = raymarchwater(origin, highHitPos, lowHitPos, WATER_DEPTH);\n vec3 waterHitPos = origin + ray * dist;\n\n // calculate normal at the hit position\n vec3 N = normal(waterHitPos.xz, 0.01, WATER_DEPTH);\n\n // smooth the normal with distance to avoid disturbing high frequency noise\n N = mix(N, vec3(0.0, 1.0, 0.0), 0.8 * min(1.0, sqrt(dist*0.01) * 1.1));\n\n // calculate fresnel coefficient\n float fresnel = (0.04 + (1.0-0.04)*(pow(1.0 - max(0.0, dot(-N, ray)), 5.0)));\n\n // reflect the ray and make sure it bounces up\n vec3 R = normalize(reflect(ray, N));\n R.y = abs(R.y);\n \n // calculate the reflection and approximate subsurface scattering\n vec3 reflection = getAtmosphere(R) + getSun(R);\n vec3 scattering = vec3(0.0293, 0.0698, 0.1717) * 0.1 * (0.2 + (waterHitPos.y + WATER_DEPTH) / WATER_DEPTH);\n\n // return the combined result\n vec3 C = fresnel * reflection + scattering;\n fragColor = vec4(aces_tonemap(C * 2.0), 1.0);\n}", "views": 21588, "likes": 137, "createdAt": "2026-04-01T15:52:47.322Z", "sourceFormat": "glsl" }, { "id": "3cfa51f8-b1d3-48f2-9f52-9f6fca69b08f", "name": "穿越", "author": "unknown", "code": "// i was listening to Fear Factory then some random youtube industrial\n// it'd be cool with some flickering or something but i'm done with it for now\n\n#define T (sin(iTime*.4)/2.+iTime)\n#define P(z) (vec3(cos((z)*.02)*64., cos((z)*.015)*32., (-z)))\n#define R(a) mat2(cos(a + vec4(0,33,11,0)))\n#define N normalize\n\n\nfloat box (vec3 p, float i){\n p = i*.41 - abs(fract(p/i)*i - i/2.);\n return min(p.x, min(p.y, p.z));\n}\n\nfloat boxen(vec3 p) {\n float d = -9e9, i = 1e2;\n p *= 5e1;\n for(; i > .1; i *= .3)\n p.xz *= R((i < 50. ? i : 1.)),\n p.yz *= R((i < 20. ? i*i : 1.)),\n d = max(d, box(p, i));\n return d/5e1;\n}\n\nfloat map(vec3 p) {\n return max(1e1-length(p), max(boxen(p), 1e2*boxen(p.yxz/1e2)));\n}\n\nvoid mainImage(out vec4 o, vec2 u) {\n float s, i;\n\n vec3 r= iResolution;\n u = (u+u - r.xy) / r.y;\n if(abs(u.x) > 1.4) { o *= i; return; }\n \n \n vec3 p = P(T*6e1),\n Z = N(P(T*6e1 + 2e1) - p),\n X = N(vec3(Z.z, 0, -Z)),\n D = N(vec3(R(tanh(sin(p.z*.01)*4.)*6.) * u, 1) * mat3(-X, cross(X, Z), Z));\n vec2 v = 2e2*(.1*sin(T/1.5))+u + (u.yx*.8+.2-vec2(-1.,.1));\n for(o *= i; i++ < 64.; )\n p += D * s,\n s = map(p) * .8,\n o += s/i\n + .2*(vec4(clamp(v.x,1.,4.),1,2,0))*s,\n + vec4(4,2,1,0)/ length(v);\n \n vec4 lights = abs(vec4(8,1,1,0) / dot(cos(iTime*3.+p/4e1),vec3(1e1)));\n o += lights;\n\n o = tanh(o / 1e2 * length(v-u)/3e1);\n}", "views": 21349, "likes": 484, "createdAt": "2026-04-01T15:51:59.158Z", "sourceFormat": "glsl" }, { "id": "ad4ccd5d-4c58-43f1-af72-fda7350bddc7", "name": "光流", "author": "unknown", "code": "#define SCROLL 2.8\n#define SPEED 3.4\n\nfloat ncos(float x)\n{\n return cos(x) / (.5 + .4 * abs(cos(x)));\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord)\n{\n vec2 s = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;\n float v = (s.y + 1.0) * (s.y + 1.0) * 0.25;\n s.y -= 1.2;\n float per = 2.0 / abs(s.y);\n\n vec3 col = vec3(0);\n for (float z = 0.0; z < 1.0; z += 0.08)\n {\n float d = 1.0 + 0.4 * z;\n vec2 p = vec2(s.x * d, s.y + d) * per;\n vec2 s = p;\n s.y += SCROLL * iTime;\n vec2 c = s - 0.05 * iTime + sin(s * 5.3 + 0.03 * iTime);\n\n float shift = cos(z / 0.08);\n float wave = ncos(s.y * 1.4) + ncos(s.y * 0.9 + 0.3 * iTime);\n s.x += shift + (wave) / (1.0 + 0.01 * per * per);\n\n float w = s.x;\n float l = sin(s.y * 0.7 + z / 0.08 + SPEED * iTime * sign(shift));\n float intensity = exp(min(l, -l / 0.3 / (1.0 + 4.0 * w * w)));\n\n // Cold palette: deep blue -> cyan/ice-white\n vec3 coldA = vec3(0.05, 0.12, 0.45); // deep navy blue\n vec3 coldB = vec3(0.55, 0.85, 1.0); // ice cyan\n vec3 tint = mix(coldA, coldB, tanh(shift / 0.1) * 0.5 + 0.5);\n\n // Subtle purple shimmer on some strands\n tint += vec3(0.15, 0.0, 0.25) * smoothstep(0.3, 0.7, sin(z * 30.0 + iTime * 0.7));\n\n col += intensity * tint / (abs(w) + 0.01 * per) * per;\n }\n col = tanh(col / 2e1);\n fragColor = vec4(col * col, 1);\n}", "views": 21822, "likes": 311, "createdAt": "2026-04-01T15:35:13.690Z", "sourceFormat": "glsl" }, { "id": "7c9bb8e9-503e-44ce-b5a0-85b9f11dbae3", "name": "箱体", "author": "unknown", "code": "// CC0: Just another cube\n// Glowtracers are great for compact coding, but I wanted to see how much\n// I could squeeze a more normal raymarcher in terms of characters used.\n\n// Twigl: https://twigl.app?ol=true&ss=-OW-y9xgRgWubwKcn0Nd\n\n// == Globals ==\n// Single-letter variable names are used to save characters (code golfing).\nmat2 R; // A 2D rotation matrix, calculated once per frame in mainImage and used by D.\nfloat d=1. // Stores the most recent distance to the scene from the ray's position.\n , z // Stores the total distance traveled along the ray.\n , G=9. // \"Glow\" variable. Tracks the closest the ray comes to the object (for volumetric glow effect).\n , M=1e-3\n ;\n// == Distance Function (SDF - Signed Distance Field) ==\n// This function calculates the shortest distance from a given point 'p' to the scene geometry.\n// A positive result means the point is outside an object, negative is inside, and zero is on the surface.\n// This is the core of \"raymarching\", as it tells us the largest safe step we can take along a ray.\nfloat D(vec3 p) {\n // Apply two rotations to the point's coordinates. This twists the space the object\n // exists in, making the simple cube shape appear more complex and animated.\n p.xy *= R;\n p.xz *= R;\n\n // Create a higher-frequency version of the coordinate for detailed surface patterns.\n vec3 S = sin(123.*p);\n\n // This creates a volumetric glow effect by tracking the minimum distance\n // to either the existing glow value or a glowing shell around the object.\n G = min(\n G\n // The glowing shell\n , max(\n abs(length(p)-.6)\n // The main object distance calculation:\n // 1. A superquadric (rounded cube shape) is created using an L8-norm.\n // The expression `pow(dot(p=p*p*p*p,p),.125)` is a golfed version of\n // `pow(pow(p.x,8)+pow(p.y,8)+pow(p.z,8), 1./8.)`.\n // The `- .5` defines the object's size.\n , d = pow(dot(p*=p*p*p,p),.125) - .5\n // 2. Surface detail subtraction. This creates small surface variations\n // using high-frequency sine waves for more appealing reflections.\n - pow(1.+S.x*S.y*S.z,8.)/1e5\n )\n );\n\n return d;\n}\n\n// == Main Render Function ==\n// This function is called for every pixel on the screen to determine its color.\n// 'o' is the final output color (rgba). 'C' is the input pixel coordinate (xy).\nvoid mainImage(out vec4 o, vec2 C) {\n // Single-letter variable names are used to save characters (code golfing).\n vec3 p // The current point in 3D space along the ray.\n , O // Multi-purpose vector: color accumulator, then normal vector, then final color.\n , r=iResolution // 'r' holds screen resolution, later re-used for the epsilon vector and reflection.\n // 'I' is the Ray Direction vector. It's calculated once per pixel.\n // This converts the 2D screen coordinate 'C' into a 3D direction, creating the camera perspective.\n , I=normalize(vec3(C-.5*r.xy, r.y))\n // Base glow color (dark bluish tint).\n , B=vec3(1,2,9)*M\n ;\n\n // == Raymarching Loop ==\n // This loop \"marches\" a ray from the camera out into the scene to find what it hits.\n // It uses a golfed structure where the body of the loop updates the ray position 'p',\n // and the \"advancement\" step moves the ray forward.\n for(\n // -- Initializer (runs once before the loop) --\n // Calculate the rotation matrix for this frame based on time.\n R = mat2(cos(.3*iTime+vec4(0,11,33,0)))\n // -- Condition --\n // Loop while total distance 'z' is less than 9 and we are not yet touching a surface (d > 1e-3).\n ; z<9. && d > M\n // -- Advancement --\n // The ray advances by the safe distance 'd' returned by D(p).\n // The result of D(p) is also assigned to the global 'd' inside the function.\n ; z += D(p)\n )\n // -- Loop Body --\n // Calculate the current position 'p' in world space.\n // The camera starts at (0,0,-2) and points forward.\n p = z*I\n , p.z -= 2.\n ;\n\n // -- Hit Condition --\n // If the loop finished because z exceeded the max distance, we hit nothing. Otherwise, we hit the surface.\n if (z < 9.) {\n // -- Calculate Surface Normal --\n // Estimate the gradient ∇D at the hit point 'p' via central differences on the SDF D.\n // We use ε = 1e-3 and loop over each axis (x, y, z):\n // • Zero r, then set r[i] = ε.\n // • Compute O[i] = D(p + r) – D(p – r).\n // After the loop, O holds the unnormalized normal vector.\n for (\n int i // axis index: 0→x, 1→y, 2→z\n ; i < 3\n ; O[i++] = D(p+r) - D(p-r)\n )\n r -= r // clear r to vec3(0)\n , r[i] = M // set only the i-th component\n ;\n\n // -- Lighting and Shading --\n // 'z' is re-purposed to store a fresnel factor (1 - cos(angle)) for edge brightness.\n // `dot(O, I)` calculates how much the surface faces away from the camera.\n // O is also normalized here to become a proper normal vector.\n z = 1.+dot(O = normalize(O),I);\n\n // 'r' is re-purposed to store the reflection vector.\n r = reflect(I,O);\n\n // Calculate a point 'C' along the reflection vector 'r' to sample a background color.\n // For upward reflections (r.y > 0), this finds the intersection with the plane y=5.\n C = (p+r*(5.-p.y)/abs(r.y)).xz;\n \n // Calculate the final color 'O' of the hit point.\n O =\n // Multiply by the fresnel factor squared for stronger edge reflections.\n z*z *\n // Use a ternary operator to decide the color based on where the reflection ray goes.\n (\n // If the reflection vector points upward...\n r.y>0.\n // ...sample a procedural \"sky\" with a radial gradient and blue tint.\n ? 5e2*smoothstep(5., 4., d = sqrt(length(C*C))+1.)*d*B\n // ...otherwise, sample a \"floor\" with a deep blue exponential falloff.\n : exp(-2.*length(C))*(B/M-1.)\n )\n // Add rim lighting (brighter on upward-facing surfaces).\n + pow(1.+O.y,5.)*B\n ;\n }\n\n // == Tonemapping & Output ==\n // Apply final effects and map the High Dynamic Range (HDR) color to a displayable range.\n // Add glow contribution: smaller G values (closer ray passes) create a brighter blue glow.\n o = sqrt(O+B/G).xyzx;\n}", "views": 3108, "likes": 51, "createdAt": "2026-04-01T15:34:35.030Z", "sourceFormat": "glsl" }, { "id": "2881c592-2827-413b-8f91-270c2f6f6788", "name": "粒子隧道", "author": "unknown", "code": "着色器输入\n// MIT License\n\n// low tech tunnel\n// 28 steps\n\n/*\n @FabriceNeyret2 -40 chars\n → 611 (from 651)!\n \n Further golfing below shader code\n \n*/\n\n#define T iTime*4. + 5. + 5.*sin(iTime*.3) //\n#define P(z) vec3( 12.* cos( (z)*vec2(.1,.12) ) , z) //\n#define A(F,H,K) abs(dot( sin(F*p*K), H +p-p )) / K\n\nvoid mainImage(out vec4 o, in vec2 u) {\n \n float t,s,i,d,e;\n vec3 c,r = iResolution;\n\n u = ( u - r.xy/2. ) / r.y; // scaled coords\n if (abs(u.y) > .375) { o*= i; return;}// cinema bars\n \n \n vec3 p = P(T), // setup ray origin, direction, and look-at\n Z = normalize( P(T+4.) - p),\n X = normalize(vec3(Z.z,0,-Z)),\n D = vec3(u, 1) * mat3(-X, cross(X, Z), Z);\n \n for(; i++ < 28. && d < 3e1 ;\n c += 1./s + 1e1*vec3(1,2,5)/max(e, .6)\n )\n p += D * s, // march\n X = P(p.z), // get path\n t = sin(iTime), // store sine of iTime (not T)\n e = length(p - vec3( // orb (sphere with xyz offset by t)\n X.x + t,\n X.y + t*2.,\n 6.+T + t*2.))-.01,\n s = cos(p.z*.6)*2.+ 4. // tunnel with modulating radius\n - min( length(p.xy - X.x - 6.)\n , length((p-X).xy) )\n + A( 4., .25, .1) // noise, large scoops\n + A(T+8., .22, 2.), // noise, detail texture \n // (remove \"T+\" if you don't like the texture moving)\n d += s = min(e,.01+.3*abs(s)); // accumulate distance\n \n o.rgb = c*c/1e6; // adjust brightness and saturation\n}", "views": 24459, "likes": 695, "createdAt": "2026-04-01T15:33:45.538Z", "sourceFormat": "glsl" }, { "id": "cddda4e7-5f78-4c1b-8aaf-5d7e7e0f0a37", "name": "粒子束", "author": "unknown", "code": "#define R iResolution\n#define T iTime\n#define rot(a) mat2(cos(a), sin(a), -sin(a), cos(a))\n\nvec3 path(float v) {\n return vec3(sin(v*.1)*7., cos(v*.15)*5., v);\n}\n\nfloat bulk(vec3 p, float h) {\n float t = T * .3;\n for(int i=0; i<8; i++) {\n p = abs(p) - vec3(1.2, 2.5, 2.);\n p.yz *= rot(t*.5 + p.x*.1);\n p.xz *= rot(t*.8 + p.y*.12);\n p = p * 1.3 - .2;\n }\n return max(length(p) * pow(1.3, -8.0), -h);\n}\n\nvoid mainImage(out vec4 O, vec2 C) {\n vec2 uv = (C*2. - R.xy) / R.y;\n float s = T * 5., z = .3;\n vec3 ro = path(s), \n ta = path(s + 1.2),\n f = normalize(ta - ro),\n r = normalize(cross(f, vec3(0, 1, 0))),\n rd = mat3(r, cross(r, f), f) * normalize(vec3(uv, 1.8)),\n col = vec3(0);\n\n for(float i=0.; i<120.; i++) {\n vec3 p = ro + rd * z;\n vec3 q = p - path(p.z);\n float h = length(q.xy) - 4.5;\n float d = bulk(q, h);\n \n vec3 id = floor(p/10. + .5);\n vec3 hsh = fract(sin(id * vec3(12.9, 78.2, 45.3)) * 43758.5);\n float ds = length(p - id*10. - (hsh-.5)*10.) - .01;\n \n d = max(min(d, max(ds, -h)), .001);\n \n float sh = pow(sin(p.z*.05 + T*3.)*.5 + .5, 1.6);\n vec3 gc = sin(vec3(4, 2.8, 1.2) + p.z*.03 + hsh.x);\n \n col += (2.2 + gc) * sh / (d + .08);\n \n if(z > 80.) break;\n z += d * 0.55;\n }\n \n O = vec4(pow(tanh(col / 350.0), vec3(1.2)), 1.0);\n}", "views": 12483, "likes": 705, "createdAt": "2026-04-01T15:31:53.940Z", "sourceFormat": "glsl" }, { "id": "e1f817dd-627c-419c-a5ce-7dc7a4b05f64", "name": "线条", "author": "unknown", "code": "void mainImage(out vec4 o, vec2 u) {\n \n vec3 q,p = iResolution,\n D = normalize(vec3(u =(u+u-p.xy)/p.y+vec2(cos(iTime*2.)*.15, cos(iTime)*.13), .7));\n \n float i,s,d;\n \n for(o*=i; i++<50.; ) {\n \n p = D * d;\n p.z = cos(p.z*(sin(p.x+iTime*.7)+1.5));\n for (s = 2.; s++ <15.;\n p = p*1.05+sin(2.6*iTime+p.yzx*s)*(.125*cos(iTime*.7)));\n d += s = .01 + .1*abs(length(p)-.8);\n o += vec4(sin(p*vec3(.9,.3,.2)-vec3(1.,4.,1.)),0)/s;\n \n }\n o = tanh(o*o/1e6)*(1.-.2*dot(u,u));\n}", "views": 5699, "likes": 105, "createdAt": "2026-04-01T15:29:41.289Z", "sourceFormat": "glsl" }, { "id": "07545078-a585-4e2b-b35e-66f75f080bbd", "name": "星云", "author": "unknown", "code": "#define N(a) abs(dot(sin(iTime+.1*p.z+.3*p / a), vec3(a+a)))\n#define NUM_LAYERS 12.\n#define TAU 6.28318\n#define PI 3.141592\n#define Velocity .025 //modified value to increse or decrease speed, negative value travel backwards\n#define StarGlow 0.025\n#define StarSize 02.\n#define CanvasView 20.\n\n\nfloat Star(vec2 uv, float flare){\n float d = length(uv);\n \tfloat m = sin(StarGlow*1.2)/d; \n float rays = max(0., .5-abs(uv.x*uv.y*1000.)); \n m += (rays*flare)*2.;\n m *= smoothstep(1., .1, d);\n return m;\n}\n\nfloat Hash21(vec2 p){\n p = fract(p*vec2(123.34, 456.21));\n p += dot(p, p+45.32);\n return fract(p.x*p.y);\n}\n\n\nvec3 StarLayer(vec2 uv){\n vec3 col = vec3(0);\n vec2 gv = fract(uv);\n vec2 id = floor(uv);\n for(int y=-1;y<=1;y++){\n for(int x=-1; x<=1; x++){\n vec2 offs = vec2(x,y);\n float n = Hash21(id+offs);\n float size = fract(n);\n float star = Star(gv-offs-vec2(n, fract(n*34.))+.5, smoothstep(.1,.9,size)*.46);\n vec3 color = sin(vec3(.2,.3,.9)*fract(n*2345.2)*TAU)*.25+.75;\n color = color*vec3(.9,.59,.9+size);\n star *= sin(iTime*.6+n*TAU)*.5+.5;\n col += star*size*color;\n }\n }\n return col;\n}\n\n\nvoid mainImage(out vec4 o, vec2 u) {\n float i,s;\n vec3 p,r = iResolution; \n \n vec4 o2=o;\n vec2 F =u;\n \n vec2 uv = (u-.5*iResolution.xy)/iResolution.y;\n\tvec2 M = vec2(0);\n\n float t = iTime*.0; \n vec3 col = vec3(0); \n for(float i=0.; i<1.; i+=1./NUM_LAYERS){\n float depth = fract(i+t);\n float scale = mix(CanvasView, .5, depth);\n float fade = depth*smoothstep(1.,.9,depth);\n col += StarLayer(uv*scale+i*453.2-iTime*.05+M)*fade;} \n \n \n \n u = (u+u-r.xy)/r.y;\n \n \n for(o*=i; i++<1e2; ) {\n p += vec3(u * s, s);\n s = 6.+(p.y);\n s -= N(.08);\n s -= N(.2);\n s -= N(.6);\n s = .1 + abs(s)*.2;\n o += vec4(4,2,1,0)/s;\n }\n \n o *= smoothstep(0.8, 0.75, abs(u.y));\n \n vec2 R = iResolution.xy; \n o2-=o2;\n for(float d,t = -iTime*.005, i = 0. ; i > -1.; i -= .06 ) \t\n { d = fract( i -3.*t ); \t\n vec4 c = vec4( ( F - R *.5 ) / R.y *d ,i,0 ) * 28.; \t\n for (int j=0 ; j++ <27; ) \t\n c.xzyw = abs( c / dot(c,c) \t\n -vec4( 7.-.2*sin(t) , 6.3 , .7 , 1.-cos(t/.8))/7.);\t\n o2 -= c * c.yzww * d--*d / vec4(3,5,1,1); \n }\n o+=o2;\n \n o = tanh(o / 2e3 / length(u));\n\n float starMask = smoothstep(-0.4, 0.1, u.y);\n \n o.rgb += col * starMask*o2.xyz*12.;\n \n}", "views": 3552, "likes": 195, "createdAt": "2026-04-01T15:25:55.867Z", "sourceFormat": "glsl", "updatedAt": "2026-04-01T15:26:50.214Z" }, { "id": "d90c5b45-858f-41ca-a826-28ab3444188b", "name": "雪花", "author": "unknown", "code": "precision highp float;\n\n\nfloat gTime = 0.;\nconst float REPEAT = 5.0;\n\n// 回転行列\nmat2 rot(float a) {\n\tfloat c = cos(a), s = sin(a);\n\treturn mat2(c,s,-s,c);\n}\n\nfloat sdBox( vec3 p, vec3 b )\n{\n\tvec3 q = abs(p) - b;\n\treturn length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);\n}\n\nfloat box(vec3 pos, float scale) {\n\tpos *= scale;\n\tfloat base = sdBox(pos, vec3(.4,.4,.1)) /1.5;\n\tpos.xy *= 5.;\n\tpos.y -= 3.5;\n\tpos.xy *= rot(.75);\n\tfloat result = -base;\n\treturn result;\n}\n\nfloat box_set(vec3 pos, float iTime) {\n\tvec3 pos_origin = pos;\n\tpos = pos_origin;\n\tpos .y += sin(gTime * 0.4) * 2.5;\n\tpos.xy *= rot(.8);\n\tfloat box1 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);\n\tpos = pos_origin;\n\tpos .y -=sin(gTime * 0.4) * 2.5;\n\tpos.xy *= rot(.8);\n\tfloat box2 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);\n\tpos = pos_origin;\n\tpos .x +=sin(gTime * 0.4) * 2.5;\n\tpos.xy *= rot(.8);\n\tfloat box3 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);\t\n\tpos = pos_origin;\n\tpos .x -=sin(gTime * 0.4) * 2.5;\n\tpos.xy *= rot(.8);\n\tfloat box4 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);\t\n\tpos = pos_origin;\n\tpos.xy *= rot(.8);\n\tfloat box5 = box(pos,.5) * 6.;\t\n\tpos = pos_origin;\n\tfloat box6 = box(pos,.5) * 6.;\t\n\tfloat result = max(max(max(max(max(box1,box2),box3),box4),box5),box6);\n\treturn result;\n}\n\nfloat map(vec3 pos, float iTime) {\n\tvec3 pos_origin = pos;\n\tfloat box_set1 = box_set(pos, iTime);\n\n\treturn box_set1;\n}\n\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord ) {\n\tvec2 p = (fragCoord.xy * 2. - iResolution.xy) / min(iResolution.x, iResolution.y);\n\tvec3 ro = vec3(0., -0.2 ,iTime * 4.);\n\tvec3 ray = normalize(vec3(p, 1.5));\n\tray.xy = ray.xy * rot(sin(iTime * .03) * 5.);\n\tray.yz = ray.yz * rot(sin(iTime * .05) * .2);\n\tfloat t = 0.1;\n\tvec3 col = vec3(0.);\n\tfloat ac = 0.0;\n\n\n\tfor (int i = 0; i < 99; i++){\n\t\tvec3 pos = ro + ray * t;\n\t\tpos = mod(pos-2., 4.) -2.;\n\t\tgTime = iTime -float(i) * 0.01;\n\t\t\n\t\tfloat d = map(pos, iTime);\n\n\t\td = max(abs(d), 0.01);\n\t\tac += exp(-d*23.);\n\n\t\tt += d* 0.55;\n\t}\n\n\tcol = vec3(ac * 0.02);\n\n\tcol +=vec3(0.,0.2 * abs(sin(iTime)),0.5 + sin(iTime) * 0.2);\n\n\n\tfragColor = vec4(col ,1.0 - t * (0.02 + 0.02 * sin (iTime)));\n}\n\n/** SHADERDATA\n{\n\t\"title\": \"Octgrams\",\n\t\"description\": \"Lorem ipsum dolor\",\n\t\"model\": \"person\"\n}\n*/", "views": 23855, "likes": 545, "createdAt": "2026-04-01T15:24:44.569Z", "sourceFormat": "glsl", "updatedAt": "2026-04-01T15:26:50.214Z" }, { "id": "a5e23f6d-aa92-4ed1-9cea-4ba04181e3ff", "name": "冰层", "author": "unknown", "code": "precision highp float;\n\n\nmat2 rot(float a) {\n float c = cos(a), s = sin(a);\n return mat2(c,s,-s,c);\n}\n\nconst float pi = acos(-1.0);\nconst float pi2 = pi*2.0;\n\nvec2 pmod(vec2 p, float r) {\n float a = atan(p.x, p.y) + pi/r;\n float n = pi2 / r;\n a = floor(a/n)*n;\n return p*rot(-a);\n}\n\nfloat box( vec3 p, vec3 b ) {\n vec3 d = abs(p) - b;\n return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));\n}\n\nfloat ifsBox(vec3 p) {\n for (int i=0; i<5; i++) {\n p = abs(p) - 1.0;\n p.xy *= rot(iTime*0.3);\n p.xz *= rot(iTime*0.1);\n }\n p.xz *= rot(iTime);\n return box(p, vec3(0.4,0.8,0.3));\n}\n\nfloat map(vec3 p, vec3 cPos) {\n vec3 p1 = p;\n p1.x = mod(p1.x-5., 10.) - 5.;\n p1.y = mod(p1.y-5., 10.) - 5.;\n p1.z = mod(p1.z, 16.)-8.;\n p1.xy = pmod(p1.xy, 5.0);\n return ifsBox(p1);\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord ) {\n vec2 p = (fragCoord.xy * 2.0 - iResolution.xy) / min(iResolution.x, iResolution.y);\n\n vec3 cPos = vec3(0.0,0.0, -3.0 * iTime);\n // vec3 cPos = vec3(0.3*sin(iTime*0.8), 0.4*cos(iTime*0.3), -6.0 * iTime);\n vec3 cDir = normalize(vec3(0.0, 0.0, -1.0));\n vec3 cUp = vec3(sin(iTime), 1.0, 0.0);\n vec3 cSide = cross(cDir, cUp);\n\n vec3 ray = normalize(cSide * p.x + cUp * p.y + cDir);\n\n // Phantom Mode https://www.shadertoy.com/view/MtScWW by aiekick\n float acc = 0.0;\n float acc2 = 0.0;\n float t = 0.0;\n for (int i = 0; i < 99; i++) {\n vec3 pos = cPos + ray * t;\n float dist = map(pos, cPos);\n dist = max(abs(dist), 0.02);\n float a = exp(-dist*3.0);\n if (mod(length(pos)+24.0*iTime, 30.0) < 3.0) {\n a *= 2.0;\n acc2 += a;\n }\n acc += a;\n t += dist * 0.5;\n }\n\n vec3 col = vec3(acc * 0.01, acc * 0.011 + acc2*0.002, acc * 0.012+ acc2*0.005);\n fragColor = vec4(col, 1.0 - t * 0.03);\n}", "views": 22810, "likes": 76, "createdAt": "2026-04-01T15:24:08.297Z", "sourceFormat": "glsl", "updatedAt": "2026-04-01T15:26:50.214Z" }, { "id": "ab0cc421-e34d-4244-a540-03f029ec7372", "name": "繁花", "author": "unknown", "code": "/* This animation is the material of my first youtube tutorial about creative \n coding, which is a video in which I try to introduce programmers to GLSL \n and to the wonderful world of shaders, while also trying to share my recent \n passion for this community.\n Video URL: https://youtu.be/f4s1h2YETNY\n*/\n\n//https://iquilezles.org/articles/palettes/\nvec3 palette( float t ) {\n vec3 a = vec3(0.5, 0.5, 0.5);\n vec3 b = vec3(0.5, 0.5, 0.5);\n vec3 c = vec3(1.0, 1.0, 1.0);\n vec3 d = vec3(0.263,0.416,0.557);\n\n return a + b*cos( 6.28318*(c*t+d) );\n}\n\n//https://www.shadertoy.com/view/mtyGWy\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord ) {\n vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;\n vec2 uv0 = uv;\n vec3 finalColor = vec3(0.0);\n \n for (float i = 0.0; i < 4.0; i++) {\n uv = fract(uv * 1.5) - 0.5;\n\n float d = length(uv) * exp(-length(uv0));\n\n vec3 col = palette(length(uv0) + i*.4 + iTime*.4);\n\n d = sin(d*8. + iTime)/8.;\n d = abs(d);\n\n d = pow(0.01 / d, 1.2);\n\n finalColor += col * d;\n }\n \n fragColor = vec4(finalColor, 1.0);\n}", "views": 14780, "likes": 487, "createdAt": "2026-04-01T15:17:20.407Z", "sourceFormat": "glsl", "updatedAt": "2026-04-01T15:23:17.765Z" }, { "id": "d5728c14-a698-4a58-94d7-76a81f97cc99", "name": "云层", "author": "unknown", "code": "/*\n \"Rocaille\" by @XorDev\n \n This time I added multiple layers of turbulence\n with time and color offsets. Loved the shapes.\n \n -1 Thanks to GregRostami\n*/\nvoid mainImage(out vec4 O, vec2 I)\n{\n //Vector for scaling and turbulence\n vec2 v = iResolution.xy,\n //Centered and scaled coordinates\n p = (I+I-v)/v.y/.3;\n \n //Iterators for layers and turbulence frequency\n float i, f;\n for(O*=i;i++<9.;\n //Add coloring, attenuating with turbulent coordinates\n O += (cos(i+vec4(0,1,2,3))+1.)/6./length(v))\n //Turbulence loop\n //https://mini.gmshaders.com/p/turbulence\n for(v=p,f=0.;f++<9.;v+=sin(v.yx*f+i+iTime)/f);\n \n //Tanh tonemapping\n //https://www.shadertoy.com/view/ms3BD7\n O = tanh(O*O);\n}", "views": 19808, "likes": 171, "createdAt": "2026-04-01T15:06:25.335Z", "sourceFormat": "glsl", "updatedAt": "2026-04-01T15:23:17.766Z" }, { "id": "alien-core-ported", "name": "Alien Core (Ported)", "author": "glkt", "views": 9754, "likes": 256, "createdAt": "2026-04-01T00:00:00.000Z", "code": "vec3 paletteAC(float d) {\n return mix(vec3(0.2, 0.7, 0.9), vec3(1.0, 0.0, 1.0), d);\n}\n\nvec2 rotateAC(vec2 p, float a) {\n float c = cos(a);\n float s = sin(a);\n return mat2(c, -s, s, c) * p;\n}\n\nfloat mapAC(vec3 p) {\n for (int i = 0; i < 8; i++) {\n float t = iTime * 0.2;\n p.xz = rotateAC(p.xz, t);\n p.xy = rotateAC(p.xy, t * 1.89);\n p.xz = abs(p.xz) - 0.5;\n }\n return dot(sign(p), p) / 5.0;\n}\n\nvec4 raymarchAC(vec3 ro, vec3 rd) {\n float t = 0.0;\n vec3 col = vec3(0.0);\n float d = 0.0;\n for (int i = 0; i < 64; i++) {\n vec3 p = ro + rd * t;\n d = mapAC(p) * 0.5;\n if (d < 0.02 || d > 100.0) break;\n col += paletteAC(length(p) * 0.1) / (400.0 * d);\n t += d;\n }\n float alpha = 1.0 / (max(d, 0.0001) * 100.0);\n return vec4(col, alpha);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.x;\n vec3 ro = vec3(0.0, 0.0, -50.0);\n ro.xz = rotateAC(ro.xz, iTime);\n\n vec3 cf = normalize(-ro);\n vec3 cs = normalize(cross(cf, vec3(0.0, 1.0, 0.0)));\n vec3 cu = normalize(cross(cf, cs));\n vec3 uuv = ro + cf * 3.0 + uv.x * cs + uv.y * cu;\n vec3 rd = normalize(uuv - ro);\n\n fragColor = raymarchAC(ro, rd);\n}" } ]