diff --git a/antidemo_50.go b/antidemo_50.go index f478813..3303d31 100644 --- a/antidemo_50.go +++ b/antidemo_50.go @@ -112,7 +112,9 @@ func (s *antidemoSim) syncSel(e *physEngine) { func (s *antidemoSim) reset(e *physEngine) { s.sel = 0 s.syncSel(e) - s.ofxPrep(e, 2, 1, 0x61643530+uint64(s.sel)) + k:=2 + if antidemoSelected360(s.sel){k=1} // Bounded authored field; archived effects retain their original resolution. + s.ofxPrep(e, k, 1, 0x61643530+uint64(s.sel)) s.depthMap(e, true) } @@ -191,6 +193,7 @@ func antidemoShadePixel( pr, pg, pb, dep, nx, ny, nz, rim float32, isObj bool, pulse float32, noise *hxNoise, ) (float32, float32, float32) { + if antidemoSelected360(sel){return antidemoArt360(sel,u,v,t,pr,pg,pb,dep,nx,ny,nz,rim,isObj,pulse)} p := float64(sel) sub := sel % 10 if sub < 0 { @@ -446,7 +449,7 @@ func antidemoShadePixel( func init() { physKinds = append(physKinds, physKind{ id: "phys:antidemo", - name: "Antidemo (50 Tech Demos)", + name: "Antidemo (20 Curated Illustrations)", tags: "antidemo tech demo depth normal objectiq sdf gi neural hologram", fill: 0, boxes: false, diff --git a/antidemo_art360.go b/antidemo_art360.go new file mode 100644 index 0000000..20aad5e --- /dev/null +++ b/antidemo_art360.go @@ -0,0 +1,268 @@ +package main + +import "math" + +// Explicit authored illustrations. No physical, learned or measured solver. +func antidemoArt360(sel int, u, v, t float64, pr, pg, pb, dep, nx, ny, nz, rim float32, obj bool, pulse float32) (float32, float32, float32) { + if math.IsNaN(u+v+t) || math.IsInf(u+v+t, 0) { + return 0, 0, 0 + } + x, y := (u-.5)*1.6, (v - .5) + r := math.Hypot(x, y) + a := math.Atan2(y, x) + glow := func(d, w float64) float64 { + d = math.Abs(d) + if d > w*9 { + return 0 + } + return math.Exp(-d / w) + } + line := func(ax, ay, bx, by, w float64) float64 { + if x < math.Min(ax, bx)-w*9 || x > math.Max(ax, bx)+w*9 || y < math.Min(ay, by)-w*9 || y > math.Max(ay, by)+w*9 { + return 0 + } + dx, dy := bx-ax, by-ay + f := 0. + if dx*dx+dy*dy > 1e-12 { + f = clamp01(((x-ax)*dx + (y-ay)*dy) / (dx*dx + dy*dy)) + } + return glow(math.Hypot(x-ax-f*dx, y-ay-f*dy), w) + } + pal := func(z float64) rgb { + return rgb{float32(.5 + .5*math.Cos(z)), float32(.5 + .5*math.Cos(z+2.1)), float32(.5 + .5*math.Cos(z+4.2))} + } + c := rgb{.006, .012, .025} + add := func(q float64, col rgb) { + q = math.Max(0, q) + c.r += float32(q) * col.r + c.g += float32(q) * col.g + c.b += float32(q) * col.b + } + cyan, gold, red, violet := rgb{.1, .8, 1}, rgb{1, .62, .12}, rgb{1, .08, .15}, rgb{.55, .18, 1} + switch sel { + case 1: // Moving refracted-light net with irregular caustic folds. + xx := x + .07*math.Sin(y*12+t) + yy := y + .08*math.Sin(x*9-t*.8) + ca := math.Sin(xx*19+t*.6) + math.Sin(yy*23-t*.7) + math.Sin((xx+yy)*17+t) + add(glow(ca, .13), cyan) + add(glow(ca-.4, .06)*.4, gold) + case 2: // Aperture blades and nested receding rings. + for k := 0; k < 7; k++ { + z := float64(k) + rr := .10 + frac(z/7+t*.08)*.4 + add(glow(r-rr, .004)*(1-rr), pal(z*.7)) + } + blade := math.Cos(a*8 + t*.45) + if r > .28+.035*blade && r < .41 { + add(.35+.35*blade, violet) + } + add(glow(r-.42, .006), cyan) + case 3: // Two shaded wax/jade objects, not thickness reconstruction. + for k := 0; k < 2; k++ { + cx := -.23 + float64(k)*.46 + dx, dy := x-cx, y+.035*math.Sin(t+float64(k)) + rr := math.Hypot(dx/.17, dy/.3) + if rr < 1 { + z := math.Sqrt(1 - rr*rr) + col := gold + if k == 1 { + col = rgb{.08, .8, .38} + } + add(.12+.75*z, col) + add(.45*math.Exp(-math.Pow((rr-.91)/.07, 2)), col) + } + } + case 9: // Four explicit cutout scales, not a ray-marched Menger solid. + xx, yy := x+.025*math.Sin(t*.6), y+.025*math.Cos(t*.5) + solid := true + edge := 0. + for k := 0; k < 4; k++ { + s := math.Pow(3, float64(k)) * 3 + fx, fy := math.Abs(frac(xx*s)-.5), math.Abs(frac(yy*s)-.5) + if fx < .16 && fy < .16 { + solid = false + } + edge += glow(math.Min(math.Abs(fx-.16), math.Abs(fy-.16)), .018) / float64(k+1) + } + if solid { + add(.25+.12*math.Sin(x*4+t), violet) + } + add(edge*.3, cyan) + case 10: // Phase interference cloud with an animated collapse envelope. + collapse := .16 + .22*(.5+.5*math.Sin(t*.8)) + env := math.Exp(-r * r / (collapse * collapse)) + psi := math.Cos(x*32-t*1.8) * math.Sin(y*25+t) + add(env*psi*psi, pal(a+t*.2)) + add(glow(r-collapse, .004)*.4, cyan) + case 13: // Oscillating nodal plate. + field := math.Sin(4*math.Pi*u)*math.Sin(3*math.Pi*v) + math.Cos(3*math.Pi*u+t*.5)*math.Cos(4*math.Pi*v-t*.5) + add(glow(field, .12), gold) + add(glow(field-.4, .04)*.3, cyan) + case 16: // Independently orbiting elliptical light kernels. + for k := 0; k < 12; k++ { + z := float64(k) + cx := .45 * math.Sin(z*2.4+t*.35) + cy := .30 * math.Cos(z*1.7+t*.47) + ang := z + t*.3 + dx, dy := x-cx, y-cy + xx, yy := dx*math.Cos(ang)+dy*math.Sin(ang), -dx*math.Sin(ang)+dy*math.Cos(ang) + add(math.Exp(-xx*xx*900-yy*yy*6000), pal(z)) + } + case 18: // Growing cellular rings with offset centers. + jy := int(math.Round((y + .4) / .2)) + ix := int(math.Round((x + .65) / .21)) + for j := maxi(0, jy-1); j <= mini(4, jy+1); j++ { + for i := maxi(0, ix-1); i <= mini(6, ix+1); i++ { + z := float64(i + j*7) + cx := -.65 + float64(i)*.21 + cy := -.4 + float64(j)*.2 + rr := math.Hypot(x-cx, y-cy) + rad := .035 + .045*(.5+.5*math.Sin(t*.8+z)) + add(glow(rr-rad, .005), pal(z*.7)) + add(math.Exp(-rr*rr*2500)*.35, cyan) + } + } + case 20: // Scan reveals a procedural sample lattice, not sensor data. + sweep := .38 * math.Sin(t*.7) + gx := math.Round(x/.035) * .035 + gy := math.Round(y/.035) * .035 + z := .06 * math.Sin(gx*11+gy*5+t*.2) + dot := math.Exp(-((x-gx)*(x-gx) + (y-gy-z)*(y-gy-z)) * 40000) + add(dot*.16, cyan) + if y < sweep { + add(dot*.75, cyan) + } + add(glow(y-sweep, .007), gold) + case 21: // Drifting soap-film spheres. + for k := 0; k < 4; k++ { + z := float64(k) + cx := .4 * math.Sin(z*2+t*.17) + cy := .23 * math.Cos(z*1.8+t*.23) + rr := math.Hypot(x-cx, y-cy) + rad := .12 + z*.015 + if rr < rad { + add((.12 + .6*math.Pow(rr/rad, 5)), pal(rr*90+t+z)) + } + add(glow(rr-rad, .0025)*.8, cyan) + } + case 25: // Vertical aurora curtains with a dark sky and stars. + for k := 0; k < 5; k++ { + z := float64(k) + yy := -.15 + z*.06 + .1*math.Sin(x*6+t*.35+z*.6) + add(glow(y-yy, .025)*(0.4+.6*math.Pow(.5+.5*math.Sin(x*50+t+z), 2)), pal(1+z*.3)) + } + case 27: // A revolving blueprint wire globe and coordinate grid. + for k := -3; k <= 3; k++ { + z := float64(k) / 4 + rr := .32 * math.Sqrt(1-z*z) + add(glow(math.Hypot(x, y-z*.22)-rr, .002)*.5, cyan) + add(glow(math.Hypot(x*math.Cos(t*.2)-z*.25, y)-rr, .002)*.4, cyan) + } + add(line(-.6, 0, .6, 0, .002)*.4, gold) + add(line(0, -.45, 0, .45, .002)*.4, gold) + case 30: // Braided moving flow paths, not a fluid simulation. + for k := 0; k < 9; k++ { + z := float64(k) + yy := -.4 + z*.1 + .055*math.Sin(x*8-t+z*.7) + .02*math.Sin(x*20+t) + add(glow(y-yy, .007), pal(z*.6+x*2)) + } + case 31: // Branch-like coral lobes growing from a shared trunk. + add(line(0, .45, 0, -.2, .012), red) + for k := 0; k < 12; k++ { + z := float64(k) + yy := .35 - z*.045 + side := 1. + if k%2 == 0 { + side = -1 + } + extent := (.12 + .2*(.5+.5*math.Sin(z))) * (.7 + .3*math.Sin(t*.4+z*.3)) + tipx, tipy := side*extent, yy-.13 + add(line(0, yy, tipx, tipy, .008), pal(z*.2)) + add(line(tipx*.6, yy-.08, tipx*.9, tipy-.07, .005), gold) + } + case 37: // Connected branching arc segments, smooth brightness not strobe. + for branch := 0; branch < 3; branch++ { + lastx, lasty := -.65, -.15+float64(branch)*.16 + for k := 1; k <= 14; k++ { + xx := -.65 + float64(k)*1.3/14 + yy := lasty*.4 + .13*math.Sin(float64(k)*1.7+t*2+float64(branch)) + add(line(lastx, lasty, xx, yy, .005), cyan) + if k%3 == 0 { + add(line(xx, yy, xx+.07, yy-.13, .003)*.6, violet) + } + lastx, lasty = xx, yy + } + } + case 39: // Floating shaded metallic droplets, not liquid mechanics. + for k := 0; k < 7; k++ { + z := float64(k) + cx := .45 * math.Sin(z*2.2+t*.4) + cy := .28 * math.Cos(z*1.6+t*.3) + rad := .05 + .02*math.Sin(z) + dx, dy := (x-cx)/rad, (y-cy)/rad + rr := dx*dx + dy*dy + if rr < 1 { + zz := math.Sqrt(1 - rr) + shade := .12 + .5*zz + .7*math.Pow(math.Max(0, -dx*.5-dy*.4+zz*.7), 16) + add(shade, rgb{.7, .85, 1}) + } + } + case 42: // Reticles and rotating angular ticks, no fabricated telemetry. + for _, rr := range []float64{.15, .29, .37} { + add(glow(r-rr, .0025)*(.4+.6*math.Pow(.5+.5*math.Sin(a*6+t), 3)), cyan) + } + for k := 0; k < 24; k++ { + ang := float64(k)*math.Pi/12 + t*.1 + add(line(.32*math.Cos(ang), .32*math.Sin(ang), .35*math.Cos(ang), .35*math.Sin(ang), .002), gold) + } + add(line(-.12, 0, .12, 0, .002), cyan) + add(line(0, -.12, 0, .12, .002), cyan) + case 44: // Explicit perspective highway, striped sunset and horizon. + horizon := -.03 + if y > horizon { + z := 1 / (y - horizon + .06) + gx := math.Abs(frac(x*z*1.1) - .5) + gy := math.Abs(frac(z*.25-t*.5) - .5) + add(glow(gx, .025)+glow(gy, .025), violet) + } else { + rr := math.Hypot(x, y+.16) + if rr < .16 && math.Sin(y*180) > -.1 { + add(.8, gold) + } + } + add(glow(y-horizon, .003), red) + case 48: // Curved harp strings with traveling pluck pulses. + for k := 0; k < 13; k++ { + z := float64(k) + xx := -.6 + z*.1 + .02*math.Sin(y*18-t*3+z)*math.Sin(math.Pi*v) + add(glow(x-xx, .0025), pal(z*.3)) + py := -.35 + .7*frac(t*.18+z*.13) + add(math.Exp(-((x-xx)*(x-xx)*2000 + (y-py)*(y-py)*3000)), gold) + } + case 49: // Black lens, orbiting accretion ellipse and bent star arcs. + if r > .10 { + for k := 0; k < 6; k++ { + z := float64(k) + arc := .2 + z*.035 + .025*math.Sin(a*3+t*.5+z) + add(glow(r-arc, .0025)*(.35+.65*math.Pow(.5+.5*math.Cos(a-t*.3+z), 4)), pal(z*.5)) + } + } + er := math.Hypot(x, y*3) + if r > .10 { + add(glow(er-.25, .012), gold) + } else { + c = rgb{} + } + } + // Reuse only actual supplied shading inputs. No synthetic beat is added here. + shade := float32(.8 + .2*math.Max(0, float64(nx)*-.4+float64(ny)*.4+float64(nz)*.7)) + gain := float32(1 + .12*clamp01(float64(pulse))) + if obj { + shade *= .95 + .05*dep + } + c = c.scale(shade * gain) + c.r += pr*.04 + rim*.04 + c.g += pg*.04 + rim*.05 + c.b += pb*.04 + rim*.06 + return float32(clamp01(float64(c.r))), float32(clamp01(float64(c.g))), float32(clamp01(float64(c.b))) +} diff --git a/antidemo_selection360.go b/antidemo_selection360.go new file mode 100644 index 0000000..fbbf07f --- /dev/null +++ b/antidemo_selection360.go @@ -0,0 +1,59 @@ +package main + +// Stable HX indices are saved in projects. Never reorder the historical table. +var antidemoSelection360 = []int{1, 2, 3, 9, 10, 13, 16, 18, 20, 21, 25, 27, 30, 31, 37, 39, 42, 44, 48, 49} + +func antidemoSelected360(i int) bool { + for _, n := range antidemoSelection360 { + if i == n { + return true + } + } + return false +} +func antidemoChoice360(i int) int { + if antidemoSelected360(i) { + return i + } + return antidemoSelection360[0] +} +func antidemoChoicePosition360(i int) int { + for n, j := range antidemoSelection360 { + if i == j { + return n + 1 + } + } + return 1 +} +func antidemoVisible360(cat int) []int { + out := make([]int, 0, 20) + for _, i := range antidemoSelection360 { + if cat < 0 || antidemoSpecs[i].Cat == cat { + out = append(out, i) + } + } + return out +} + +var antidemoTitles360 = []string{ + "Refracted Light Caustics", "Spiral Aperture Portal", "Wax & Jade Glow", "Recursive Cutout Lattice", + "Interference Cloud Collapse", "Harmonic Nodal Membrane", "Gaussian Light Ellipses", "Organic Cellular Rings", + "Point-Cloud Scan Sweep", "Soap-Film Prism", "Aurora Curtains", "Fresnel Blueprint Grid", + "Curl-Flow Ribbons", "Coral Growth Pattern", "Branching Lightning Arcs", "Floating Mercury Droplets", + "Orbital HUD Reticles", "Synthwave Horizon", "Laser Harp Strings", "Singularity Lens Finale", +} + +func antidemoSpec360(i int) antidemoSpec { + i = antidemoChoice360(i) + s := antidemoSpecs[i] + for j, n := range antidemoSelection360 { + if i == n { + s.Name = antidemoTitles360[j] + break + } + } + s.Desc = "Authored procedural tech illustration. Mapped masks clip the result. Available photo/depth inputs can change its shading; this is not a physical solver, neural model, LiDAR scan or path tracer." + return s +} + +var antidemoCats360 = []string{"Light & Form", "Wave & Cells", "Optical", "Flow & Matter", "Cyber & Light"} diff --git a/antidemo_selection360_test.go b/antidemo_selection360_test.go new file mode 100644 index 0000000..a1abc10 --- /dev/null +++ b/antidemo_selection360_test.go @@ -0,0 +1,242 @@ +package main + +import ( + "bytes" + "fmt" + "image" + "image/color" + "image/png" + "math" + "os" + "path/filepath" + "testing" + "time" +) + +func Test360Selection20KeepsSaved50(t *testing.T) { + if len(antidemoSpecs) != 50 || len(antidemoSelection360) != 20 { + t.Fatal("counts") + } + seen := map[int]bool{} + cats := map[int]int{} + for _, i := range antidemoSelection360 { + if seen[i] || i < 0 || i >= 50 { + t.Fatal("duplicate/range") + } + seen[i] = true + cats[antidemoSpecs[i].Cat]++ + if antidemoSpec360(i).ID != antidemoSpecs[i].ID { + t.Fatal("ID changed") + } + } + for cat := 0; cat < 5; cat++ { + if cats[cat] != 4 || len(antidemoVisible360(cat)) != 4 { + t.Fatal("category count") + } + } + for i, sp := range antidemoSpecs { + if sp.ID != fmt.Sprintf("ad-%02d", i+1) { + t.Fatal("saved HX reordered") + } + } +} +func Test360ArtFiniteDistinctAnimatedAndArchive(t *testing.T) { + noise := newHxNoise(42) + seen := map[string]int{} + dir := os.Getenv("AD360_FRAMES") + if dir != "" { + os.MkdirAll(dir, 0755) + } + for i, sp := range antidemoSpecs { + frames := [][]byte{} + for j, tm := range []float64{0, 2, 5} { + im := image.NewRGBA(image.Rect(0, 0, 200, 125)) + for y := 0; y < 125; y++ { + for x := 0; x < 200; x++ { + r, g, b := antidemoShadePixel(i, sp.Cat, (float64(x)+.5)/200, (float64(y)+.5)/125, tm, .2, .3, .4, .5, 0, 0, 1, 0, false, 0, noise) + for _, c := range []float32{r, g, b} { + if math.IsNaN(float64(c)) || math.IsInf(float64(c), 0) { + t.Fatal("nonfinite", i) + } + } + im.SetRGBA(x, y, color.RGBA{uint8(clamp01(float64(r)) * 255), uint8(clamp01(float64(g)) * 255), uint8(clamp01(float64(b)) * 255), 255}) + } + } + frames = append(frames, im.Pix) + if antidemoSelected360(i) && dir != "" { + f, e := os.Create(filepath.Join(dir, fmt.Sprintf("%02d-%d.png", i+1, j))) + if e != nil { + t.Fatal(e) + } + png.Encode(f, im) + f.Close() + } + } + if bytes.Equal(frames[0], frames[1]) && bytes.Equal(frames[1], frames[2]) { + t.Error("static", i) + } + if antidemoSelected360(i) { + k := string(frames[1]) + if old, ok := seen[k]; ok { + t.Error("duplicate", old, i) + } + seen[k] = i + } + } +} +func Benchmark360Art(b *testing.B) { + noise := newHxNoise(42) + for i := 0; i < b.N; i++ { + sel := antidemoSelection360[i%20] + antidemoShadePixel(sel, antidemoSpecs[sel].Cat, .31, .42, float64(i)*.01, .2, .3, .4, .5, 0, 0, 1, 0, false, 0, noise) + } +} + +func Test360ActualFinalRendererExactMaskAndSavedHX(t *testing.T) { + p := roomTestProject(160, 100) + poly := [][2]float64{{.1, .1}, {.9, .1}, {.9, .9}, {.55, .9}, {.55, .6}, {.1, .6}} + p.Surfaces = []Surface{{ID: "wall", Cls: "wall", Poly: poly, Quad: polyBox(poly)}} + r := newRenderer(p, "") + defer r.closeVideoResources() + dir := os.Getenv("AD360_FRAMES") + for sel := 0; sel < len(antidemoSpecs); sel++ { + sc := &Scene{ID: fmt.Sprintf("ad360-%d", sel), Assign: map[string]Assign{"wall": {Type: "fx", ID: "phys:antidemo", Speed: 1, Scale: 1, Inten: 1, Phys: &PhysParams{Shared: true, HX: []float64{float64(sel)}}}}} + f := newFrame(160, 100) + r.RenderScene(sc, 2, f, 1, time.Unix(100, 0)) + lit := 0 + for y := 0; y < 100; y++ { + for x := 0; x < 160; x++ { + o := (y*160 + x) * 4 + if f.Pix[o]|f.Pix[o+1]|f.Pix[o+2] > 0 { + lit++ + if !pointInPolyXY((float64(x)+.5)/160, (float64(y)+.5)/100, poly) { + t.Fatal("outside", sel, x, y) + } + } + } + } + if lit < 10 { + t.Error("blank final renderer", sel, lit) + } + if dir != "" { + im := image.NewRGBA(image.Rect(0, 0, 160, 100)) + for y := 0; y < 100; y++ { + for x := 0; x < 160; x++ { + o := (y*160 + x) * 4 + im.SetRGBA(x, y, color.RGBA{f.Pix[o+2], f.Pix[o+1], f.Pix[o], 255}) + } + } + file, er := os.Create(filepath.Join(dir, fmt.Sprintf("mapped-%02d.png", sel+1))) + if er != nil { + t.Fatal(er) + } + png.Encode(file, im) + file.Close() + } + } +} + +func Benchmark360FullSimShader(b *testing.B) { + kind, _ := physKindOf("phys:antidemo") + cfg := physResolve(kind, nil, rgb{1, 1, 1}, rgb{}, 1) + cfg.hx = []float64{27} + g := physBuildGrid(nil, [4]float64{0, 0, 1, 1}, 16.0/9, physSimW, false, nil, "", nil) + e := newPhysEngine(kind, cfg, g) + defer physStopSim(e.sim) + s := e.sim.(*antidemoSim) + b.Logf("field=%dx%d", s.sw, s.sh) + b.ResetTimer() + for i := 0; i < b.N; i++ { + s.t = float64(i) * .1 + s.shade(e) + } +} +func Test360ActualLiveInputNeutralWithoutSource(t *testing.T) { + kind, _ := physKindOf("phys:antidemo") + cfg := physResolve(kind, nil, rgb{1, 1, 1}, rgb{}, 1) + cfg.hx = []float64{1} + g := physBuildGrid(nil, [4]float64{0, 0, 1, 1}, 16.0/9, 48, false, nil, "", nil) + e := newPhysEngine(kind, cfg, g) + defer physStopSim(e.sim) + s := e.sim.(*antidemoSim) + s.live = hxLiveQ{} + s.tick(e, .1) + if s.pulse != 0 || s.in.Level != 0 || s.in.Beat { + t.Fatal("invented live input") + } + s.live = hxLiveQ{active: true, level: .5, bass: .3, mid: .2, treble: .1, beat: true} + s.tick(e, .1) + if s.pulse <= 0 || s.in.Level != .5 || !s.in.Beat { + t.Fatal("actual input ignored") + } + s.live = hxLiveQ{} + e.exportMode = true + s.tick(e, .1) + if s.in.Level != 0 || s.in.Beat { + t.Fatal("export used live input") + } +} + +func Test360ActualSimulationTimeAndBoundedResolution(t *testing.T) { + kind, _ := physKindOf("phys:antidemo") + for _, sel := range []int{1, 20, 27, 48, 0} { + cfg := physResolve(kind, nil, rgb{1, 1, 1}, rgb{}, 1) + cfg.hx = []float64{float64(sel)} + g := physBuildGrid(nil, [4]float64{0, 0, 1, 1}, 16.0/9, physSimW, false, nil, "", nil) + e := newPhysEngine(kind, cfg, g) + s := e.sim.(*antidemoSim) + if s.sel != sel { + t.Fatal("HX selection lost", sel, s.sel) + } + want := 640 + if antidemoSelected360(sel) { + want = 320 + } + if s.sw != want { + t.Fatal("resolution", sel, s.sw, want) + } + e.render() + before := append([]float32(nil), e.field...) + e.stepN(20) + e.render() + changed := false + for i, v := range e.field { + if i < len(before) && v != before[i] { + changed = true + break + } + } + physStopSim(e.sim) + if !changed { + t.Fatal("actual clock static", sel) + } + } +} +func Test360SuppliedShadingInputsAffectArt(t *testing.T) { + for _, i := range antidemoSelection360 { + baseR, baseG, baseB := antidemoArt360(i, .33, .42, 2, 0, 0, 0, 0, 0, 0, 1, 0, false, 0) + r, g, b := antidemoArt360(i, .33, .42, 2, .4, .2, .1, .7, .3, .4, .8, .2, true, .7) + if r == baseR && g == baseG && b == baseB { + t.Error("supplied shading ignored", i) + } + } +} + +func Benchmark360AllSelectedFullSim(b *testing.B) { + for _, sel := range antidemoSelection360 { + b.Run(fmt.Sprintf("ad-%02d", sel+1), func(b *testing.B) { + kind, _ := physKindOf("phys:antidemo") + cfg := physResolve(kind, nil, rgb{1, 1, 1}, rgb{}, 1) + cfg.hx = []float64{float64(sel)} + g := physBuildGrid(nil, [4]float64{0, 0, 1, 1}, 16.0/9, physSimW, false, nil, "", nil) + e := newPhysEngine(kind, cfg, g) + defer physStopSim(e.sim) + s := e.sim.(*antidemoSim) + b.ResetTimer() + for i := 0; i < b.N; i++ { + s.t = float64(i) * .1 + s.shade(e) + } + }) + } +} diff --git a/antidemo_selection360_windows_test.go b/antidemo_selection360_windows_test.go new file mode 100644 index 0000000..a3111ef --- /dev/null +++ b/antidemo_selection360_windows_test.go @@ -0,0 +1,44 @@ +//go:build windows + +package main + +import "testing" + +func Test360UISelectionKeepsStableSavedHX(t *testing.T) { + antidemoUI.mu.Lock() + oldSel, oldCat := antidemoUI.sel, antidemoUI.cat + antidemoUI.cat = -1 + antidemoUI.mu.Unlock() + defer func() { antidemoUI.mu.Lock(); antidemoUI.sel, antidemoUI.cat = oldSel, oldCat; antidemoUI.mu.Unlock() }() + a := &app{} + for i := 0; i < 50; i++ { + handled := a.antidemoCommand(idAdCardBase + i) + if handled != antidemoSelected360(i) { + t.Fatal("hidden card dispatch", i, handled) + } + if !handled { + continue + } + as := antidemoAssignNow() + if as.ID != "phys:antidemo" || as.Phys == nil || int(as.Phys.HX[0]) != i { + t.Fatal("renumbered saved HX", i, as.Phys) + } + if !as.Phys.Shared { + t.Fatal("shared scene disabled") + } + } + for cat := 0; cat < 5; cat++ { + a.antidemoCommand(idAdCatBase + cat) + vis := antidemoVisibleIndices(cat) + if len(vis) != 4 { + t.Fatal("category count") + } + first := antidemoUI.sel + for j := 0; j < 4; j++ { + antidemoStepChoice(1) + } + if antidemoUI.sel != first { + t.Fatal("category step escaped") + } + } +} diff --git a/antidemo_ui_windows.go b/antidemo_ui_windows.go index 122a2bc..055ab4a 100644 --- a/antidemo_ui_windows.go +++ b/antidemo_ui_windows.go @@ -35,7 +35,7 @@ var antidemoUI = struct { sel int cat int // -1 = All, 0..4 = category status string -}{sel: 0, cat: -1} +}{sel: 1, cat: -1} func init() { for i, n := range pageNames { @@ -57,18 +57,12 @@ func init() { } func antidemoVisibleIndices(cat int) []int { - var out []int - for i, sp := range antidemoSpecs { - if cat < 0 || sp.Cat == cat { - out = append(out, i) - } - } - return out + return antidemoVisible360(cat) } func antidemoAssignNow() Assign { antidemoUI.mu.Lock() - i := clampi(antidemoUI.sel, 0, len(antidemoSpecs)-1) + i := antidemoChoice360(antidemoUI.sel) antidemoUI.mu.Unlock() return Assign{ Type: "fx", @@ -105,9 +99,9 @@ func (a *app) antidemoHooks() fxStdHooks { owns: func(id string) bool { return id == "phys:antidemo" }, name: func() string { antidemoUI.mu.Lock() - i := clampi(antidemoUI.sel, 0, len(antidemoSpecs)-1) + i := antidemoChoice360(antidemoUI.sel) antidemoUI.mu.Unlock() - return antidemoSpecs[i].Name + return antidemoSpec360(i).Name }, step: antidemoStepChoice, note: func(s string) { @@ -123,7 +117,7 @@ func (a *app) antidemoHooks() fxStdHooks { return Scene{}, false } antidemoUI.mu.Lock() - i := clampi(antidemoUI.sel, 0, len(antidemoSpecs)-1) + i := antidemoChoice360(antidemoUI.sel) antidemoUI.mu.Unlock() as := antidemoAssignNow() m := map[string]Assign{} @@ -132,7 +126,7 @@ func (a *app) antidemoHooks() fxStdHooks { m[sf.ID] = as } } - return Scene{Name: "Antidemo: " + antidemoSpecs[i].Name, Assign: m}, true + return Scene{Name: "Antidemo: " + antidemoSpec360(i).Name, Assign: m}, true }, } } @@ -156,9 +150,10 @@ func (a *app) antidemoSyncLive() { func (a *app) antidemoCommand(id int) bool { if id >= idAdCardBase && id < idAdCardBase+len(antidemoSpecs) { idx := id - idAdCardBase + if !antidemoSelected360(idx){return false} antidemoUI.mu.Lock() antidemoUI.sel = idx - antidemoUI.status = fmt.Sprintf("Selected %s [%s]", antidemoSpecs[idx].Name, antidemoCatNames[antidemoSpecs[idx].Cat]) + antidemoUI.status = fmt.Sprintf("Selected %s [%s]", antidemoSpec360(idx).Name, antidemoCats360[antidemoSpecs[idx].Cat]) antidemoUI.mu.Unlock() a.antidemoSyncLive() return true @@ -186,19 +181,19 @@ func (a *app) antidemoCommand(id int) bool { func (a *app) antidemoLayout(add func(widget) int, rx, rw, y, bh, pad int) { antidemoUI.mu.Lock() - sel := clampi(antidemoUI.sel, 0, len(antidemoSpecs)-1) + sel := antidemoChoice360(antidemoUI.sel) cat := antidemoUI.cat status := antidemoUI.status antidemoUI.mu.Unlock() - sp := antidemoSpecs[sel] + sp := antidemoSpec360(sel) y = a.fxStdHeaderLayout(add, rx, rw, y, pad, fxStdHeaderOpts{ - Title: "Antidemo — 50 Groundbreaking Tech Demos", - Subtitle: "50 real-time SDF, GI, Neural/Quantum, Holographic, Fluid & Spatial Audio tech-demo effects.", - Sensing: "3D Depth + Surface Normals + ObjectIQ + Room Photo + Beat BPM", - Selected: fmt.Sprintf("%s [%s]", sp.Name, antidemoCatNames[sp.Cat]), - Index: sel + 1, - Total: len(antidemoSpecs), + Title: "Antidemo: 20 Curated Tech Illustrations", + Subtitle: "20 distinct procedural illustrations. All 50 saved HX indices remain recoverable.", + Sensing: "Optional photo/depth shading. No measured solver or spatial-sound claim.", + Selected: fmt.Sprintf("%s [%s]", sp.Name, antidemoCats360[sp.Cat]), + Index: antidemoChoicePosition360(sel), + Total: len(antidemoSelection360), Description: sp.Desc, Status: status, }) @@ -209,12 +204,12 @@ func (a *app) antidemoLayout(add func(widget) int, rx, rw, y, bh, pad int) { text string c int }{ - {idAdCatAll, "All (50)", -1}, - {idAdCatBase + 0, "SDF & GI (10)", 0}, - {idAdCatBase + 1, "Neural/Quantum (10)", 1}, - {idAdCatBase + 2, "Holographic (10)", 2}, - {idAdCatBase + 3, "Physics/Fluid (10)", 3}, - {idAdCatBase + 4, "Cyber/Audio (10)", 4}, + {idAdCatAll, "All (20)", -1}, + {idAdCatBase + 0, "Light & Form (4)", 0}, + {idAdCatBase + 1, "Wave & Cells (4)", 1}, + {idAdCatBase + 2, "Optical (4)", 2}, + {idAdCatBase + 3, "Flow & Matter (4)", 3}, + {idAdCatBase + 4, "Cyber & Light (4)", 4}, } pw := (rw - sc(32) - sc(12)) / 3 for idx, pl := range pills { @@ -253,7 +248,7 @@ func (a *app) antidemoLayout(add func(widget) int, rx, rw, y, bh, pad int) { y += cardH + cardPad } lx := rx + cardPad + col*(cardW+cardPad) - f := antidemoSpecs[idx] + f := antidemoSpec360(idx) add(widget{ kind: kBtn, id: idAdCardBase + idx, diff --git a/common.go b/common.go index 2205f77..b8d71e1 100644 --- a/common.go +++ b/common.go @@ -11,7 +11,7 @@ import ( "time" ) -const version = "0.98.359-experimental1" +const version = "0.98.360-experimental1" const appDisplayName = "Projection Mapper - Built by Instinct" diff --git a/effect_browser_catalog326_windows.go b/effect_browser_catalog326_windows.go index d092784..8027378 100644 --- a/effect_browser_catalog326_windows.go +++ b/effect_browser_catalog326_windows.go @@ -125,8 +125,9 @@ func (a *app) effectCatalog326(page int) (items []effectBrowserItem326, selected antidemoUI.mu.Lock() sel := antidemoUI.sel antidemoUI.mu.Unlock() - for i, e := range antidemoSpecs { - add("preset:antidemo:"+e.ID, "phys:antidemo", e.Name, antidemoCatNames[e.Cat], i, i == sel) + for _, i := range antidemoSelection360 { + e:=antidemoSpec360(i) + add("preset:antidemo:"+e.ID, "phys:antidemo", e.Name, antidemoCats360[e.Cat], i, i == sel) } default: if more, key := a.extendedCatalog331(page); len(more) > 0 { @@ -250,6 +251,7 @@ func (a *app) effectSelect326(page int, key string) bool { roomFiltersUI.sel = i roomFiltersUI.mu.Unlock() case antidemoPageIdx: + if !antidemoSelected360(i){return false} antidemoUI.mu.Lock() antidemoUI.sel = i antidemoUI.mu.Unlock() diff --git a/experimental_engines_dispatch_windows_test.go b/experimental_engines_dispatch_windows_test.go index 7036206..932bd41 100644 --- a/experimental_engines_dispatch_windows_test.go +++ b/experimental_engines_dispatch_windows_test.go @@ -50,7 +50,7 @@ func TestExperimentalCommandIDsClearOfNewHandlerRanges(t *testing.T) { if !a.xmasCommand(idXmasTile) { t.Fatal("xmasCommand no longer handles its own tile after base move") } - if !a.antidemoCommand(idAdCardBase) { + if !a.antidemoCommand(idAdCardBase+antidemoSelection360[0]) { t.Fatal("antidemoCommand no longer handles its own card after base move") } } diff --git a/library_preview_windows.go b/library_preview_windows.go index 3b2dca8..136d49f 100644 --- a/library_preview_windows.go +++ b/library_preview_windows.go @@ -219,9 +219,9 @@ func (a *app) librarySample() (string, string, *Frame) { return ef.Name, "Current outlines in photo coordinates. "+ef.Description, a.libraryAssignSample(Assign{Type: "fx", ID: ef.ID, C1: "#ff2a2a", C2: "#18d860", Scale: 1, Speed: 1, Inten: 1, Fit: "fill"}) case antidemoPageIdx: antidemoUI.mu.Lock() - i := clampi(antidemoUI.sel, 0, len(antidemoSpecs)-1) + i := antidemoChoice360(antidemoUI.sel) antidemoUI.mu.Unlock() - sp := antidemoSpecs[i] + sp := antidemoSpec360(i) return sp.Name, "Current outlines in photo coordinates. "+sp.Desc, a.libraryAssignSample(antidemoAssignNow()) case antiRustPageIdx: i:=antiCuratedSelected340();sp:=antiCurated340[i];return sp.Name,"Current outlines in photo coordinates. Original saved playback preserved.",a.libraryAssignSample(antiCuratedAssign340(i))