-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgallery.html
More file actions
361 lines (326 loc) · 18.8 KB
/
gallery.html
File metadata and controls
361 lines (326 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<!DOCTYPE html>
<html lang="en">
<head>
<title>ShaderBrew - Live Gallery</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{background:#050508;color:#fff;font-family:'Segoe UI',system-ui,sans-serif;padding:1.25rem}
h1{text-align:center;margin-bottom:0.25rem;font-size:1.5rem;color:#e0e0ff;letter-spacing:2px;font-family:monospace}
.subtitle{text-align:center;color:#555;margin-bottom:1.25rem;font-size:0.8rem;font-family:monospace}
.subtitle a{color:#e94560;text-decoration:none}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(280px, 100%),1fr));gap:0.875rem;max-width:1900px;margin:0 auto 1.875rem}
.card{background:#0a0a12;border:1px solid #1a1a2e;border-radius:8px;overflow:hidden;cursor:pointer;transition:all 0.25s;position:relative}
.card:hover{border-color:#e94560;box-shadow:0 0 24px rgba(233,69,96,0.2);transform:translateY(-1px)}
.card canvas{width:100%;aspect-ratio:1;display:block;background:#000}
.card .label{padding:0.5rem 0.75rem;font-size:0.75rem;color:#ccc;text-align:center;border-top:1px solid #1a1a2e;letter-spacing:0.5px;display:flex;justify-content:space-between;align-items:center;font-family:monospace}
.card .label .name{font-weight:bold;color:#e0e0ff}
.card .label .tag{font-size:0.6rem;padding:0.125rem 0.5rem;border-radius:0.625rem;background:#1a1a2e;color:#888}
.card .label .tag.custom{background:#2a1030;color:#e94560}
.card .badges{position:absolute;top:0.5rem;right:0.5rem;display:flex;gap:0.25rem}
.card .badge{font-size:0.5625rem;padding:0.125rem 0.375rem;border-radius:0.5rem;background:rgba(10,10,20,0.85);border:1px solid #333;font-family:monospace}
.card .badge.polar{color:#ff6b8a;border-color:#e94560}
.card .badge.tiling{color:#6bffb8;border-color:#4ae94a}
.card .badge.toon{color:#6bb8ff;border-color:#4a94e9}
.card .badge.gradient{color:#ffb86b;border-color:#ff8c00}
#status{text-align:center;color:#666;margin:1rem 0;font-size:0.8rem;font-family:monospace}
.controls{text-align:center;margin-bottom:1.25rem;display:flex;justify-content:center;gap:0.5rem;flex-wrap:wrap;padding:0 0.5rem}
.controls button{padding:0.5rem 1rem;border:1px solid #222;border-radius:1.25rem;background:#0a0a12;color:#888;font-family:monospace;font-size:0.75rem;cursor:pointer;transition:all 0.2s;letter-spacing:0.3px}
.controls button:hover{background:#1a1a2e;border-color:#555;color:#ccc}
.controls button.on{background:#1a1030;border-color:#e94560;color:#e94560}
.stats{text-align:center;padding:0.625rem;font-family:monospace;font-size:0.6875rem;color:#333;margin-top:1.25rem;border-top:1px solid #111}
@media(max-width:600px){
body{padding:0.75rem}
h1{font-size:1.25rem}
.grid{grid-template-columns:repeat(auto-fill,minmax(min(200px,100%),1fr));gap:0.5rem}
.controls button{padding:0.375rem 0.75rem;font-size:0.6875rem}
}
</style>
</head>
<body>
<h1>Effect Texture Maker</h1>
<p class="subtitle">Live GPU-rendered procedural textures with gradient color mapping | <a href="editor.html">Open Editor</a></p>
<div class="controls">
<button onclick="filterCat('custom')" class="on" id="btn-custom">Showcase Presets</button>
<button onclick="filterCat('all')" id="btn-all">All Effects</button>
<button onclick="filterCat('fire')" id="btn-fire">Fire / Energy</button>
<button onclick="filterCat('light')" id="btn-light">Light / Glow</button>
<button onclick="filterCat('shape')" id="btn-shape">Shapes</button>
<button onclick="filterCat('atmo')" id="btn-atmo">Atmospheric</button>
<button onclick="filterCat('noise')" id="btn-noise">Noise</button>
<button onclick="filterCat('art')" id="btn-art">Artistic</button>
</div>
<div id="status">Loading Three.js + shaders...</div>
<div class="grid" id="grid"></div>
<div class="stats" id="stats"></div>
<script type="importmap">
{"imports":{"three":"https://unpkg.com/three@0.174.0/build/three.module.min.js","three/addons/":"https://unpkg.com/three@0.174.0/examples/jsm/","pixy":"./pixy.module.min.js"}}
</script>
<script type="module">
import*as THREE from"three";
import*as PIXY from"pixy";
// --- Gradient Map System (Phase 2 feature, embedded for gallery) ---
const GRADIENTS={
Fire:[{p:0,c:"#000000"},{p:.25,c:"#8b0000"},{p:.5,c:"#ff4500"},{p:.75,c:"#ffa500"},{p:1,c:"#ffff00"}],
Ice:[{p:0,c:"#000022"},{p:.3,c:"#003366"},{p:.6,c:"#4488cc"},{p:.85,c:"#aaddff"},{p:1,c:"#ffffff"}],
Neon:[{p:0,c:"#0a0020"},{p:.2,c:"#6600cc"},{p:.5,c:"#ff00ff"},{p:.7,c:"#00ffff"},{p:1,c:"#ffffff"}],
Earth:[{p:0,c:"#1a0f00"},{p:.3,c:"#4a3000"},{p:.5,c:"#8b6914"},{p:.75,c:"#c4a35a"},{p:1,c:"#f5e6c8"}],
Toxic:[{p:0,c:"#000000"},{p:.3,c:"#003300"},{p:.5,c:"#00cc00"},{p:.75,c:"#66ff00"},{p:1,c:"#ccff66"}],
Plasma:[{p:0,c:"#0a0015"},{p:.2,c:"#4400aa"},{p:.4,c:"#cc00ff"},{p:.6,c:"#ff0066"},{p:.8,c:"#ff6600"},{p:1,c:"#ffff00"}],
Ocean:[{p:0,c:"#000510"},{p:.25,c:"#002244"},{p:.5,c:"#006688"},{p:.75,c:"#00aacc"},{p:1,c:"#88ffee"}],
Ember:[{p:0,c:"#000000"},{p:.3,c:"#330000"},{p:.5,c:"#991100"},{p:.7,c:"#ff4400"},{p:.9,c:"#ffaa00"},{p:1,c:"#ffeecc"}],
Frost:[{p:0,c:"#050520"},{p:.3,c:"#1a3355"},{p:.5,c:"#5588bb"},{p:.8,c:"#bbddff"},{p:1,c:"#ffffff"}],
Void:[{p:0,c:"#000000"},{p:.3,c:"#1a0033"},{p:.5,c:"#440066"},{p:.75,c:"#8800aa"},{p:1,c:"#cc44ff"}]
};
function makeGradientTexture(stops){
const c=document.createElement("canvas");c.width=256;c.height=1;
const ctx=c.getContext("2d");
const g=ctx.createLinearGradient(0,0,256,0);
for(const s of stops)g.addColorStop(s.p,s.c);
ctx.fillStyle=g;ctx.fillRect(0,0,256,1);
const tex=new THREE.CanvasTexture(c);
tex.minFilter=THREE.LinearFilter;tex.magFilter=THREE.LinearFilter;
tex.wrapS=THREE.ClampToEdgeWrapping;tex.wrapT=THREE.ClampToEdgeWrapping;
tex.needsUpdate=true;
return tex;
}
// Gradient map shader (post-process)
const gradMapVert=`varying vec2 vUv;void main(){vUv=uv;gl_Position=vec4(position.xy,0.0,1.0);}`;
const gradMapFrag=`uniform sampler2D tDiffuse;uniform sampler2D tGradient;uniform float intensity;varying vec2 vUv;void main(){vec4 t=texture2D(tDiffuse,vUv);float l=clamp(dot(t.rgb,vec3(0.299,0.587,0.114)),0.0,1.0);vec4 g=texture2D(tGradient,vec2(l,0.5));gl_FragColor=vec4(mix(t.rgb,g.rgb,intensity),t.a);}`;
const gradScene=new THREE.Scene();
const gradCam=new THREE.Camera();
const gradQuad=new THREE.Mesh(new THREE.PlaneGeometry(2,2),null);
gradScene.add(gradQuad);
// Which presets get which gradient maps
const PRESET_GRADIENTS={
"helix-nebula":"Neon","magma-channels":"Fire","storm-eye":"Plasma",
"bioluminescent-deep":"Ocean","solar-chromosphere":"Ember","neural-tissue":"Neon",
"crystal-voronoi":"Frost","frozen-lightning":"Ice","inferno-vortex":"Fire",
"alien-nebula":"Void","plasma-storm":"Plasma","ocean-caustics":"Ocean",
"dark-matter":"Void","cyberpunk-circuit":"Neon","lava-planet":"Fire",
"ice-crystal":"Ice","aurora-borealis":"Ocean","toxic-waste":"Toxic",
"dragon-scales":"Ember","ocean-abyss":"Ocean","blood-moon":"Fire",
"electric-storm":"Plasma","copper-patina":"Earth","starfield":"Frost",
"sacred-geometry":"Ember","supernova":"Plasma","rust-metal":"Earth",
"neon-veins":"Toxic","black-hole":"Void","digital-rain":"Toxic",
"plasma-ball":"Plasma","desert-sand":"Earth","mercury-pool":"Frost",
"alien-flesh":"Neon","fire-mandala":"Fire","smoke-vortex":"Ocean",
"quantum-foam":"Void","emerald-marble":"Toxic"
};
// Pre-build gradient textures
const gradTextures={};
for(const[name,stops]of Object.entries(GRADIENTS)){gradTextures[name]=makeGradientTexture(stops)}
// --- Effect Types ---
const TYPES=[
"Wood","Circle","Solar","Corona","Spark","Ring","Gradation","GradationLine",
"Flash","Cone","Flower","FlowerFun","WaveRing","Smoke","Flame","FlameEye",
"Fire","Cell","Lightning","Flare","Flare2","Flare3","LensFlare","Sun",
"MagicCircle","Mandara","Explosion","Explosion2","Cross","Laser","Laser2",
"Light","Cloud","Cloud2","CoherentNoise","PerlinNoise","SeamlessNoise",
"BooleanNoise","CellNoise","TurbulentNoise","FbmNoise","FbmNoise2","FbmNoise3",
"RandomNoise","VoronoiNoise","SparkNoise","MarbleNoise","TessNoise","GradientNoise",
"Checker","FlameLance","Bonfire","Snow","DiamondGear","BrushStroke","Speckle",
"Bubbles","Pentagon","Grunge","Energy","InkSplat","Particle","Electric",
"Caustics","Squiggles","WaterTurbulence","Trabeculum","BinaryMatrix"
];
const CATS={
fire:["Flame","FlameEye","Fire","FlameLance","Bonfire","Energy","Electric","Explosion","Explosion2"],
light:["Solar","Corona","Spark","Flash","Flare","Flare2","Flare3","LensFlare","Sun","Light","Laser","Laser2"],
shape:["Circle","Ring","Cross","Cone","Flower","FlowerFun","WaveRing","Pentagon","DiamondGear","MagicCircle","Mandara"],
atmo:["Smoke","Cloud","Cloud2","Snow","Bubbles","WaterTurbulence","Caustics"],
noise:["CoherentNoise","PerlinNoise","SeamlessNoise","BooleanNoise","CellNoise","TurbulentNoise","FbmNoise","FbmNoise2","FbmNoise3","RandomNoise","VoronoiNoise","SparkNoise","MarbleNoise","TessNoise","GradientNoise"],
art:["Wood","BrushStroke","InkSplat","Grunge","Speckle","Squiggles","Trabeculum","BinaryMatrix","Checker","Gradation","GradationLine","Cell","Lightning","Particle"]
};
const CUSTOM_PRESETS=[
"helix-nebula","magma-channels","storm-eye","bioluminescent-deep",
"solar-chromosphere","neural-tissue","crystal-voronoi","frozen-lightning",
"inferno-vortex","alien-nebula","plasma-storm","ocean-caustics","dark-matter",
"cyberpunk-circuit","lava-planet","ice-crystal","aurora-borealis","toxic-waste",
"dragon-scales","ocean-abyss","blood-moon","electric-storm","copper-patina",
"starfield","sacred-geometry","supernova","rust-metal","neon-veins",
"black-hole","digital-rain","plasma-ball","desert-sand","mercury-pool",
"alien-flesh","fire-mandala","smoke-vortex","quantum-foam","emerald-marble"
];
const RES=512;
const grid=document.getElementById("grid");
const statusEl=document.getElementById("status");
const renderer=new THREE.WebGLRenderer({alpha:true,antialias:false});
renderer.setSize(RES,RES);
renderer.autoClear=true;
const scene=new THREE.Scene();
const cam=new THREE.Camera();
scene.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),new THREE.MeshBasicMaterial()));
const grungeTex=new THREE.TextureLoader().load("images/grunge.png");
grungeTex.wrapS=grungeTex.wrapT=THREE.RepeatWrapping;
grungeTex.minFilter=THREE.LinearFilter;
grungeTex.magFilter=THREE.LinearFilter;
function getDefaults(){return{animate:true,time:0,resolution:RES+"",polarConversion:false,tiling:false,normalMap:false,cHeightScale:2,cRadialMask:1,cColorBalanceShadowsR:0,cColorBalanceShadowsG:0,cColorBalanceShadowsB:0,cColorBalanceMidtonesR:0,cColorBalanceMidtonesG:0,cColorBalanceMidtonesB:0,cColorBalanceHighlightsR:0,cColorBalanceHighlightsG:0,cColorBalanceHighlightsB:0,cToonEnable:false,cToonDark:.8,cToonLight:.95,cFrequency:30,cAmplitude:.01,cIntensity:.5,cDirectionX:0,cDirectionY:1,cPowerExponent:1,cRadius:.5,cInnerRadius:1,cInnerRadius2:1,cSize:1,cWidth:1,cHeight:1,cDepth:1,cColor:1,cPetals:6,cOffset:.2,cVolume:3,cBeta:4,cDelta:.05,cScale:1,cInnerWidth:.4,cStrength:1,cPower:1,cRange:2,cEmission:1,cBloom:1,cLightX:1,cLightY:1,cLightZ:1,cAmbient:1,cSmoothness:1,cSmoothnessPower:1,cThickness:1,cThicknessPower:1,cCameraTilt:0,cCameraPan:0,cSpeed:1,cAngle:0,cDensity:1,cAlpha:1,cRepeat:1,cScaleShift:0,cBias:0,cGain:0,cInvert:0,cThreshold:0,cDiamondGearTeeth:18,cDiamondGearMid:.8,cBrushStrokeX1:-.4,cBrushStrokeY1:0,cBrushStrokeX2:1.1,cBrushStrokeY2:.8,cBubblesVariation:1,cFlameEyeInnerFade:1,cFlameEyeOuterFade:1,cFlameEyeBorder:1,cSplatLines:20,cSplatSpotStep:.04,cTrabeculumVariation:2,cLifeTime:.9,cGravity:.26,cCount:300,cExplosionRadius:1.75,cExplosionDownScale:1.25,cExplosionGrain:2,cExplosionSpeed:.3,cExplosionBallness:2,cExplosionGrowth:2.2,cExplosionFade:1.6,cExplosionDensity:1.35,cExplosionContrast:1,cExplosionRollingInitDamp:.3,cExplosionRollingSpeed:2,cExplosionDelayRange:.25,cExplosionBallSpread:1,cExplosionBloom:0,cExplosionEmission:.2,cExplosionColor:1,cNoiseOctave:8,cNoiseFrequency:1,cNoiseAmplitude:.65,cNoisePersistence:.5,cNoiseScale:1,cNoiseSphereEnable:false,cNoiseGraphEnable:false,cNoiseStrength:1,cNoiseDepth:3,cNoiseSize:8,cNoiseLacunarity:2,cTurbulence:0,cRidge:0,cRidgeOffset:.9,cGradientNoise:0,cValueNoise:0,cVoronoiNoise:0,cVoronoiCell:0,cSimplexNoise:1}}
const effects=[];
const pixelBuf=new Uint8Array(RES*RES*4);
// Gradient map render target for post-processing
const gradRT=new THREE.WebGLRenderTarget(RES,RES,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter});
const gradMat=new THREE.ShaderMaterial({
uniforms:{tDiffuse:{value:null},tGradient:{value:null},intensity:{value:1.0}},
vertexShader:gradMapVert,fragmentShader:gradMapFrag,depthTest:false,depthWrite:false
});
function buildEffect(type,ec,label,tags,gradientName,clickUrl){
const sh=new PIXY.FxgenShader();
sh.enable(type.toUpperCase());
sh.enable("TOON");
sh.enable("GLSL3");
const uniforms=sh.generateUniforms();
const mat=sh.createMaterial(uniforms,{defines:sh.generateDefines()});
const rt=new THREE.WebGLRenderTarget(RES,RES,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter});
const canvas=document.createElement("canvas");
canvas.width=RES;canvas.height=RES;
const ctx=canvas.getContext("2d",{willReadFrequently:true});
const card=document.createElement("div");
card.className="card";
card.dataset.type=type;
card.appendChild(canvas);
const badges=document.createElement("div");
badges.className="badges";
if(ec.polarConversion){const b=document.createElement("span");b.className="badge polar";b.textContent="POLAR";badges.appendChild(b)}
if(ec.tiling){const b=document.createElement("span");b.className="badge tiling";b.textContent="TILE";badges.appendChild(b)}
if(ec.cToonEnable){const b=document.createElement("span");b.className="badge toon";b.textContent="TOON";badges.appendChild(b)}
if(gradientName){const b=document.createElement("span");b.className="badge gradient";b.textContent="GRAD:"+gradientName;badges.appendChild(b)}
card.appendChild(badges);
const lbl=document.createElement("div");
lbl.className="label";
const nameSpan=document.createElement("span");
nameSpan.className="name";
nameSpan.textContent=label;
lbl.appendChild(nameSpan);
const tagSpan=document.createElement("span");
tagSpan.className="tag"+(tags.includes("custom")?" custom":"");
tagSpan.textContent=tags.filter(t=>t!=="custom"&&t!=="animated").join(" | ")||type;
lbl.appendChild(tagSpan);
card.appendChild(lbl);
card.addEventListener("click",()=>window.open(clickUrl,"_blank"));
const eff={type,ec,uniforms,mat,rt,canvas,ctx,card,visible:false,gradientName};
effects.push(eff);
grid.appendChild(card);
observer.observe(card);
return eff;
}
function renderOneFrame(eff,dt){
eff.ec.time+=dt;
const ec=eff.ec;
const u=eff.uniforms;
u.resolution.value.set(RES,RES);
u.mouse.value.set(0.5,0.5);
u.cameraPos.value.set(0,0,3.8);
u.cameraDir.value.set(0,0,-1);
for(const k of Object.keys(ec)){
if(k==="resolution")continue;
PIXY.FxgenShaderUtils.SetShaderParameter(u,k,ec[k]);
}
PIXY.FxgenShaderUtils.SetShaderParameter(u,"cColorBalanceShadows",new THREE.Vector3(ec.cColorBalanceShadowsR,ec.cColorBalanceShadowsG,ec.cColorBalanceShadowsB));
PIXY.FxgenShaderUtils.SetShaderParameter(u,"cColorBalanceMidtones",new THREE.Vector3(ec.cColorBalanceMidtonesR,ec.cColorBalanceMidtonesG,ec.cColorBalanceMidtonesB));
PIXY.FxgenShaderUtils.SetShaderParameter(u,"cColorBalanceHighlights",new THREE.Vector3(ec.cColorBalanceHighlightsR,ec.cColorBalanceHighlightsG,ec.cColorBalanceHighlightsB));
PIXY.FxgenShaderUtils.SetShaderParameter(u,"cDirection",new THREE.Vector2(ec.cDirectionX,ec.cDirectionY));
PIXY.FxgenShaderUtils.SetShaderParameter(u,"tGrunge",grungeTex);
// Render base effect
scene.overrideMaterial=eff.mat;
renderer.setRenderTarget(eff.rt);
renderer.render(scene,cam);
renderer.setRenderTarget(null);
scene.overrideMaterial=null;
// Apply gradient map if assigned (Phase 2 feature!)
let readRT=eff.rt;
if(eff.gradientName&&gradTextures[eff.gradientName]){
gradMat.uniforms.tDiffuse.value=eff.rt.texture;
gradMat.uniforms.tGradient.value=gradTextures[eff.gradientName];
gradMat.uniformsNeedUpdate=true;
gradQuad.material=gradMat;
renderer.setRenderTarget(gradRT);
renderer.clear();
renderer.render(gradScene,gradCam);
renderer.setRenderTarget(null);
readRT=gradRT;
}
renderer.readRenderTargetPixels(readRT,0,0,RES,RES,pixelBuf);
const img=eff.ctx.createImageData(RES,RES);
for(let y=0;y<RES;y++){
const src=(RES-1-y)*RES*4,dst=y*RES*4;
for(let x=0;x<RES*4;x++)img.data[dst+x]=pixelBuf[src+x];
}
eff.ctx.putImageData(img,0,0);
}
const observer=new IntersectionObserver((entries)=>{
for(const e of entries){
const card=e.target;
const eff=effects.find(f=>f.card===card);
if(eff){eff.visible=e.isIntersecting}
}
},{threshold:0.05});
let lastTime=0;
const MAX_PER_FRAME=8;
let roundRobin=0;
function animate(now){
requestAnimationFrame(animate);
const dt=(now-lastTime)/1000;
lastTime=now;
if(dt>1||dt<=0)return;
const visible=effects.filter(e=>e.visible&&e.card.style.display!=="none");
if(!visible.length)return;
let rendered=0;
for(let i=0;i<visible.length&&rendered<MAX_PER_FRAME;i++){
const idx=(roundRobin+i)%visible.length;
try{renderOneFrame(visible[idx],dt)}catch(e){}
rendered++;
}
roundRobin=(roundRobin+MAX_PER_FRAME)%Math.max(visible.length,1);
}
window.filterCat=function(cat){
document.querySelectorAll(".controls button").forEach(b=>b.classList.remove("on"));
const btn=document.getElementById("btn-"+cat);
if(btn)btn.classList.add("on");
effects.forEach(eff=>{
const t=eff.type;
if(cat==="all")eff.card.style.display="";
else if(cat==="custom")eff.card.style.display=eff.card.dataset.custom?"":"none";
else eff.card.style.display=(CATS[cat]||[]).includes(t)?"":"none";
});
};
async function init(){
statusEl.textContent="Building showcase presets with gradient maps...";
let count=0;
// Load custom presets FIRST with gradient maps applied
for(const name of CUSTOM_PRESETS){
try{
const resp=await fetch("presets/"+name+".json");
const preset=await resp.json();
const ec=Object.assign(getDefaults(),preset);
const label=name.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());
const tags=["custom"];
const gradName=PRESET_GRADIENTS[name]||null;
const eff=buildEffect(ec.type,ec,label,tags,gradName,"editor.html");
eff.card.dataset.custom="1";
count++;
statusEl.textContent=`Building ${count}/${CUSTOM_PRESETS.length+TYPES.length}...`;
}catch(e){console.warn("preset fail:",name,e)}
await new Promise(r=>setTimeout(r,2));
}
// Then all base effects (no gradient)
for(const type of TYPES){
const ec=getDefaults();
ec.type=type;
ec.time=Math.random()*5;
buildEffect(type,ec,type,[type],null,"editor.html");
count++;
statusEl.textContent=`Building ${count}/${CUSTOM_PRESETS.length+TYPES.length}...`;
await new Promise(r=>setTimeout(r,2));
}
const gradCount=Object.keys(PRESET_GRADIENTS).length;
statusEl.textContent=`${count} live textures | ${CUSTOM_PRESETS.length} curated presets | ${gradCount} with gradient color maps | GPU-rendered in real-time`;
document.getElementById("stats").textContent=`Features: Color Balance + Gradient Maps (10 palettes) + Polar Warping + Toon Shading + Seamless Tiling | Click any to edit`;
filterCat("custom");
requestAnimationFrame(animate);
}
setTimeout(init,500);
</script>
<script type="module" src="src/ui/top-nav.js"></script>
</body>
</html>