Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Studios: pick a light for H3 Max relight, insert a moment in Edit video, retexture 3D results, Tripo P2

Claude1e644776fdbb
diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsx
index 3f18663a..5c903a15 100644
--- a/src/components/model3d/model-card.tsx
+++ b/src/components/model3d/model-card.tsx
@@ -1,6 +1,6 @@
"use client";
-import { Box, Clapperboard, Download, ImageIcon, Loader2, Pause, PersonStanding, Play, Rotate3d, Sparkles, Video } from "lucide-react";
+import { Box, Clapperboard, Download, ImageIcon, Loader2, Paintbrush, Pause, PersonStanding, Play, Rotate3d, Sparkles, Video } from "lucide-react";
import Link from "next/link";
import { createElement, useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
import { toast } from "sonner";
@@ -12,6 +12,7 @@ import { cn } from "@/lib/utils";
import { toastError } from "@/lib/refusals";
import { loadModelViewer, TURNTABLE_BACKDROP, useViewerSrc, viewerLook } from "./model-viewer";
import type { Model3dInfo } from "./model3d-studio";
+import { RetextureDialog } from "./retexture-dialog";
import { RigDialog } from "./rig-dialog";
import { PlaceholderChip } from "@/components/demo-mode";
import { recordableType, recordTurntable } from "./turntable";
@@ -49,6 +50,7 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
const [recording, setRecording] = useState<number | null>(null);
const [recorded, setRecorded] = useState<{ url: string; saved?: string } | null>(null);
const [rigging, setRigging] = useState(false);
+ const [retexturing, setRetexturing] = useState(false);
const pendingRecord = useRef(false);
// "View in 3D" unmounts itself: focus moves to the viewer once it's there.
const focusViewer = useRef(false);
@@ -326,6 +328,11 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
<PersonStanding className="size-3.5" /> {view.rigged ? "Another animation" : "Rig & animate"}
</Button>
)}
+ {view.glb && !view.rigged && !view.splat && g.op !== "splat" && (
+ <Button variant="outline" size="sm" className="rounded-full" onClick={() => setRetexturing(true)}>
+ <Paintbrush className="size-3.5" /> Retexture
+ </Button>
+ )}
{spin && (
<Button asChild size="sm" className="rounded-full">
<Link href={spin} prefetch={false}>
@@ -337,6 +344,7 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
{notices.length > 0 && <p className="text-[11px] text-muted-foreground">{notices.join(" · ")}</p>}
</div>
{rigSource && rigging && g.op !== "splat" && <RigDialog glb={rigSource} open={rigging} onOpenChange={setRigging} cloudAllowed={cloudAllowed} />}
+ {view.glb && retexturing && <RetextureDialog glb={view.glb} open={retexturing} onOpenChange={setRetexturing} cloudAllowed={cloudAllowed} />}
</article>
);
}
diff --git a/src/components/model3d/retexture-dialog.tsx b/src/components/model3d/retexture-dialog.tsx
new file mode 100644
index 00000000..d2b18dca
--- /dev/null
+++ b/src/components/model3d/retexture-dialog.tsx
@@ -0,0 +1,146 @@
+"use client";
+
+import { ImagePlus, Loader2, Paintbrush, X } from "lucide-react";
+import { useRef, useState } from "react";
+import { toast } from "sonner";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { Label } from "@/components/ui/label";
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { Textarea } from "@/components/ui/textarea";
+import { uploadFile, useCreateGeneration } from "@/lib/api";
+import { RETEXTURE_MODELS, RETEXTURE_PROMPT_MAX, RETEXTURE_SIZES, retextureRequest, type RetextureModel } from "@/lib/av/model3d";
+import { toastError } from "@/lib/refusals";
+import { priceLine, useRunPreview } from "./hooks";
+
+const SIZE_LABEL: Record<(typeof RETEXTURE_SIZES)[number], string> = { "2k": "2K textures", "4k": "4K textures", "8k": "8K textures" };
+
+/**
+ * Retexture a finished model: Meshy paints new textures on the same mesh from words or a style picture (the picture wins when
+ * both are given). Cloud only (fal.ai): no open retexturer runs in ComfyUI here.
+ */
+export function RetextureDialog({ glb, open, onOpenChange, cloudAllowed }: { glb: string; open: boolean; onOpenChange: (v: boolean) => void; cloudAllowed: boolean }) {
+ const create = useCreateGeneration();
+ const [prompt, setPrompt] = useState("");
+ const [style, setStyle] = useState<{ url: string; preview: string } | null>(null);
+ const [uploading, setUploading] = useState(false);
+ const [model, setModel] = useState<RetextureModel>(RETEXTURE_MODELS[0].id);
+ const [size, setSize] = useState<(typeof RETEXTURE_SIZES)[number]>("2k");
+ const file = useRef<HTMLInputElement>(null);
+ const ready = cloudAllowed && !uploading && (!!prompt.trim() || !!style);
+ const req = ready ? retextureRequest({ glb, prompt, style: style?.url, model, size }) : null;
+ const preview = useRunPreview(open ? req : null);
+ const price = priceLine(preview.data);
+ const pickStyle = async (f: File | undefined) => {
+ if (!f) return;
+ setUploading(true);
+ try {
+ const asset = await uploadFile(f);
+ setStyle({ url: asset.url, preview: URL.createObjectURL(f) });
+ } catch (e) {
+ toastError(e);
+ } finally {
+ setUploading(false);
+ }
+ };
+ const go = () => {
+ if (!req) return;
+ create.mutate(req, {
+ onSuccess: () => {
+ toast.success("Retexturing your model");
+ onOpenChange(false);
+ },
+ onError: (e) => toastError(e),
+ });
+ };
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Retexture</DialogTitle>
+ <DialogDescription>The same model with new textures: describe the look, or add a picture of the style. PBR maps are included.</DialogDescription>
+ </DialogHeader>
+ {!cloudAllowed ? (
+ <p className="rounded-xl bg-muted p-3 text-[13px] text-muted-foreground" role="note">
+ Retexturing runs on a cloud model, which isn&apos;t available here.
+ </p>
+ ) : (
+ <div className="grid gap-3">
+ <div className="grid gap-1.5">
+ <Label htmlFor="retexture-prompt">The new look</Label>
+ <Textarea
+ id="retexture-prompt"
+ value={prompt}
+ maxLength={RETEXTURE_PROMPT_MAX}
+ onChange={(e) => setPrompt(e.target.value)}
+ placeholder="e.g. weathered bronze with green patina"
+ className="min-h-20 rounded-xl"
+ />
+ </div>
+ <div className="flex flex-wrap items-center gap-2">
+ {style ? (
+ <span className="relative size-14 overflow-hidden rounded-xl border bg-muted">
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+ <img src={style.preview} alt="Style picture" className="size-full object-cover" />
+ <button
+ type="button"
+ onClick={() => setStyle(null)}
+ aria-label="Remove the style picture"
+ className="absolute top-0.5 right-0.5 grid size-5 place-items-center rounded-full bg-foreground/80 text-background"
+ >
+ <X className="size-3" />
+ </button>
+ </span>
+ ) : (
+ <Button variant="outline" size="sm" className="rounded-full" onClick={() => file.current?.click()} disabled={uploading}>
+ {uploading ? <Loader2 className="size-3.5 animate-spin" /> : <ImagePlus className="size-3.5" />} Style picture
+ </Button>
+ )}
+ <input ref={file} type="file" accept="image/png,image/jpeg" className="hidden" onChange={(e) => void pickStyle(e.target.files?.[0])} />
+ <Select value={model} onValueChange={(v) => setModel(v as RetextureModel)}>
+ <SelectTrigger size="sm" className="rounded-full" aria-label="Model">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {RETEXTURE_MODELS.map((m) => (
+ <SelectItem key={m.id} value={m.id}>
+ {m.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <Select value={size} onValueChange={(v) => setSize(v as (typeof RETEXTURE_SIZES)[number])}>
+ <SelectTrigger size="sm" className="rounded-full" aria-label="Texture size">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {RETEXTURE_SIZES.map((s) => (
+ <SelectItem key={s} value={s}>
+ {SIZE_LABEL[s]}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ <p className="text-[12px] text-muted-foreground" aria-live="polite">
+ {!prompt.trim() && !style
+ ? "Describe the look or add a style picture"
+ : preview.isError
+ ? (preview.error as Error).message
+ : (price ?? "Working out the price…")}{" "}
+ · Runs on Meshy in the cloud, on either engine.
+ </p>
+ </div>
+ )}
+ <DialogFooter>
+ <Button variant="ghost" className="rounded-full" onClick={() => onOpenChange(false)}>
+ Cancel
+ </Button>
+ <Button className="rounded-full" onClick={go} disabled={!req || create.isPending}>
+ {create.isPending ? <Loader2 className="size-4 animate-spin" /> : <Paintbrush className="size-4" />} Retexture
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index 1aa80581..5b24c314 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -94,6 +94,8 @@ import { LayoutStrip } from "./layout-strip";
import { loadFullCatalog, useCatalog } from "./catalog";
import { Chip, chipBase, chipIdle } from "./chip";
import { MediaSlot, SlotPreview, type SlotValue } from "./media-slot";
+import { InsertRangeChip, LightSphereChip } from "./hosted-chips";
+import { voiceWindowProblem } from "@/lib/catalog/clip-windows";
import { ControlsChip } from "./model-controls";
import { ModelPicker } from "./model-picker";
import { FinishChoices } from "./finish-choices";
@@ -530,7 +532,10 @@ export function Composer({ docked }: { docked: boolean }) {
}, [unknownPreset, config.preset, presetUrl, setDraft]);
// Single-purpose studios (Extend, Reframe, Edit video…) pin their operation.
- const studioOp = config.ops.length === 1 && !preset ? config.ops[0] : undefined;
+ // A studio's other tool on the model picked (Edit video's "Insert a moment" on H3 Max insert) takes the pin's place.
+ const pinnedOp = config.ops.length === 1 && !preset ? config.ops[0] : undefined;
+ const studioOp =
+ pinnedOp && model && !model.routes.some((r) => r.op === pinnedOp) ? (model.routes.find((r) => config.pickerOps?.includes(r.op))?.op ?? pinnedOp) : pinnedOp;
const opts = model?.options ?? {};
// Try-on names its images: "Person photo", then "Add garment" (instead of "Image" / "Add ref").
const baseSlots = preset?.inputs ?? config.slots;
@@ -654,6 +659,9 @@ export function Composer({ docked }: { docked: boolean }) {
// an open tool that holds the whole clip in more RAM than the ComfyUI can spare.
const clipProblem = config.clipFacts ? clipBlocker(studioOp ?? op, facts, draft.params, model, status?.providers.comfyui?.ramBytes) : null;
if (clipProblem && !planError) planError = clipProblem;
+ // A voice outside what a hosted talking-avatar model takes (H3 Max lip sync: 5 s to 15 min), as the server would say.
+ const voiceProblem = op === "avatar" && voiceRef && voice?.duration && model ? voiceWindowProblem(model, voice.duration) : null;
+ if (voiceProblem && !planError) planError = voiceProblem;
if (signed.blocker) planError = signed.blocker;
// Models that take no prompt (try-on, 3D, transcription, upscalers), or can run without one, never ask for one.
// A model that reads only words (Open-H3 Regenerate redraws from them) asks for them even in a tool that hides the box.
@@ -800,6 +808,13 @@ export function Composer({ docked }: { docked: boolean }) {
else extra[key] = v;
return { params: { ...d.params, extra: Object.keys(extra).length ? extra : undefined } };
});
+ const setLight = useCallback((v: SlotValue | null) => setSlot("image", v), [setSlot]);
+ // A light's sphere leaves the run when another model is picked: it means nothing to a model that reads words.
+ const lightLeft = !opts.lightSphere && !!typed.slots.image?.name?.startsWith("light:");
+ useEffect(() => {
+ if (lightLeft) setSlot("image", null);
+ }, [lightLeft, setSlot]);
+ const setInsertRange = useCallback((startTime: number, endTime: number) => setDraft((d) => ({ params: { ...d.params, startTime, endTime } })), [setDraft]);
const opNote = op && model ? routesFor(model, op)[0]?.note : undefined;
// Booleans in, not the model's options object: the React Compiler keeps the memos above.
const showPrompt = showsPrompt(
@@ -1100,12 +1115,15 @@ export function Composer({ docked }: { docked: boolean }) {
/>
)}
{opts.controls && <ControlsChip controls={opts.controls} values={p.extra ?? {}} onChange={setExtra} title={config.controlsTitle} op={effectiveOp} />}
+ {opts.lightSphere && <LightSphereChip value={draft.slots.image} onChange={setLight} />}
+ {effectiveOp === "insert-moment" && <InsertRangeChip clip={facts?.duration} start={p.startTime} resume={p.endTime} onChange={setInsertRange} />}
</>
);
const hasSecondary =
!!config.frames ||
!!config.layout ||
- (!!model && (!!opts.voices?.length || !!opts.voiceClone || !!opts.languages || !!opts.controls || !!opts.looks)) ||
+ (!!model && (!!opts.voices?.length || !!opts.voiceClone || !!opts.languages || !!opts.controls || !!opts.looks || !!opts.lightSphere)) ||
+ effectiveOp === "insert-moment" ||
!!config.presetPicker ||
!!config.signature ||
preset?.type === "motion" ||
diff --git a/src/components/studio/hosted-chips.tsx b/src/components/studio/hosted-chips.tsx
new file mode 100644
index 00000000..d375bb4b
--- /dev/null
+++ b/src/components/studio/hosted-chips.tsx
@@ -0,0 +1,142 @@
+"use client";
+
+import { Loader2, Scissors, Sun } from "lucide-react";
+import { useEffect, useRef, useState } from "react";
+import { toast } from "sonner";
+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
+import { Slider } from "@/components/ui/slider";
+import { uploadFile } from "@/lib/api";
+import { INSERT_STEP, insertHandles } from "@/lib/catalog/clip-windows";
+import { LIGHT_PRESETS, lightPreset, SPHERE_SIZE, spherePixels, type LightPreset } from "@/lib/relight-sphere";
+import { cn } from "@/lib/utils";
+import { Chip } from "./chip";
+import type { SlotValue } from "./media-slot";
+
+/** The preset's sphere on a canvas (the picker's swatch at `size`, or the full picture that is uploaded). */
+function sphereCanvas(preset: LightPreset, size: number): HTMLCanvasElement {
+ const c = document.createElement("canvas");
+ c.width = size;
+ c.height = size;
+ const ctx = c.getContext("2d");
+ if (ctx) ctx.putImageData(new ImageData(new Uint8ClampedArray(spherePixels(preset, size)), size, size), 0, 0);
+ return c;
+}
+
+function Swatch({ preset, size = 56 }: { preset: LightPreset; size?: number }) {
+ const ref = useRef<HTMLCanvasElement>(null);
+ useEffect(() => {
+ const ctx = ref.current?.getContext("2d");
+ if (ctx) ctx.putImageData(new ImageData(new Uint8ClampedArray(spherePixels(preset, 96)), 96, 96), 0, 0);
+ }, [preset]);
+ return <canvas ref={ref} width={96} height={96} aria-hidden className="rounded-lg bg-muted" style={{ width: size, height: size }} />;
+}
+
+/** The light a sphere-reading relight (fal's H3 Max relight) matches: pick a preset, and its sphere becomes the run's image. */
+export function LightSphereChip({ value, onChange }: { value: SlotValue | null | undefined; onChange: (v: SlotValue | null) => void }) {
+ const picked = value?.name?.startsWith("light:") ? lightPreset(value.name.slice(6)) : undefined;
+ const [busy, setBusy] = useState<string>();
+ const pick = async (preset: LightPreset) => {
+ setBusy(preset.id);
+ try {
+ const canvas = sphereCanvas(preset, SPHERE_SIZE);
+ const blob = await new Promise<Blob | null>((r) => canvas.toBlob(r, "image/png"));
+ if (!blob) throw new Error("Couldn't draw the light");
+ const asset = await uploadFile(new File([blob], `light-${preset.id}.png`, { type: "image/png" }));
+ onChange({ ref: asset.url, preview: canvas.toDataURL("image/png"), kind: "image", name: `light:${preset.id}` });
+ } catch (e) {
+ toast.error((e as Error).message || "Couldn't set the light");
+ } finally {
+ setBusy(undefined);
+ }
+ };
+ return (
+ <Popover>
+ <PopoverTrigger asChild>
+ <Chip icon={Sun} active={!!picked}>
+ {picked ? `Light · ${picked.label}` : "Pick a light"}
+ </Chip>
+ </PopoverTrigger>
+ <PopoverContent className="w-[min(92vw,380px)] p-3" align="start" side="top" collisionPadding={12}>
+ <p className="text-[13px] font-medium">The new light</p>
+ <p className="mb-2 text-[12px] text-muted-foreground">The shot is relit to match the light on the sphere.</p>
+ <div className="grid grid-cols-4 gap-2">
+ {LIGHT_PRESETS.map((p) => (
+ <button
+ key={p.id}
+ type="button"
+ title={p.hint}
+ aria-pressed={picked?.id === p.id}
+ disabled={!!busy}
+ onClick={() => pick(p)}
+ className={cn(
+ "relative flex flex-col items-center gap-1 rounded-xl p-1.5 text-[11px] leading-tight transition outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50",
+ picked?.id === p.id && "bg-brand-faint text-brand-text",
+ )}
+ >
+ <Swatch preset={p} />
+ <span className="text-center">{p.label}</span>
+ {busy === p.id && (
+ <span className="absolute inset-0 grid place-items-center rounded-xl bg-background/60" role="status" aria-label="Setting the light">
+ <Loader2 className="size-4 animate-spin" />
+ </span>
+ )}
+ </button>
+ ))}
+ </div>
+ </PopoverContent>
+ </Popover>
+ );
+}
+
+const at = (n: number) => `${Number(n.toFixed(3))} s`;
+
+/**
+ * Edit video's "Insert a moment": a two-handle range over the clip's timeline, where the new moment starts and where the
+ * clip picks up again (params.startTime / params.endTime).
+ */
+export function InsertRangeChip({
+ clip,
+ start,
+ resume,
+ onChange,
+}: {
+ clip: number | undefined;
+ start: number | undefined;
+ resume: number | undefined;
+ onChange: (start: number, resume: number) => void;
+}) {
+ const h = insertHandles(clip, [start, resume]);
+ // The run always carries both points: they start around the middle of the clip.
+ useEffect(() => {
+ if (start !== h.start || resume !== h.resume) onChange(h.start, h.resume);
+ }, [start, resume, h.start, h.resume, onChange]);
+ return (
+ <Popover>
+ <PopoverTrigger asChild>
+ <Chip icon={Scissors} active>
+ {`Insert · ${at(h.start)}–${at(h.resume)}`}
+ </Chip>
+ </PopoverTrigger>
+ <PopoverContent className="w-[min(92vw,420px)] space-y-3 p-3" align="start" side="top" collisionPadding={12}>
+ <div>
+ <p className="text-[13px] font-medium">Where the new moment goes</p>
+ <p className="text-[12px] text-muted-foreground">It starts at the first handle; your clip picks up again at the second.</p>
+ </div>
+ <Slider
+ min={h.min}
+ max={h.max}
+ step={INSERT_STEP}
+ minStepsBetweenThumbs={1}
+ value={[h.start, h.resume]}
+ onValueChange={(v) => onChange(v[0], v[1])}
+ thumbLabels={["New moment starts", "Clip picks up again"]}
+ />
+ <div className="flex justify-between text-[12px] text-muted-foreground tabular-nums">
+ <span>{at(h.start)}</span>
+ <span>{clip ? `of ${at(Math.round(clip * 10) / 10)}` : "Reading the clip…"}</span>
+ <span>{at(h.resume)}</span>
+ </div>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.ts
index fa64fdc5..f60bcac8 100644
--- a/src/lib/av/model3d.ts
+++ b/src/lib/av/model3d.ts
@@ -35,6 +35,7 @@ export const MODELS_3D: Record<Model3dMode, Record<Engine, Model3dChoice[]>> = {
{ id: "trellis-2", note: "Detailed geometry · ≈ $0.30" },
{ id: "tripo-h3-1", note: "Clean topology, PBR · ≈ $0.30" },
{ id: "meshy-7-1", note: "Textured, optional rigging · ≈ $1.20" },
+ { id: "tripo-p2", note: "Production tier: game-ready, PBR · ≈ $1.10" },
],
open: [
{ id: "oss-pixal3d", note: "Most faithful to your photo, with a turntable video" },
@@ -358,3 +359,28 @@ export function rigRequest(o: { glb: string; animation?: number | null }): Gener
const animation = o.animation === undefined || o.animation === null ? null : animationId(o.animation);
return { feature: MODEL3D_FEATURE, modelId: RIG_MODEL, op: "rig-3d", inputs: { model3d: o.glb }, ...(animation !== null && { params: { animation } }) };
}
+
+// ---------------------------------------------------------------------------
+// Retexture (Meshy 7 or 6 on fal; cloud only): new textures on a finished model, from words or a style picture.
+
+/** The retexture models, the default first. */
+export const RETEXTURE_MODELS = [
+ { id: "meshy-7-retexture", label: "Meshy 7" },
+ { id: "meshy-6-retexture", label: "Meshy 6" },
+] as const;
+export type RetextureModel = (typeof RETEXTURE_MODELS)[number]["id"];
+/** Meshy's style prompt: "Maximum 600 characters". */
+export const RETEXTURE_PROMPT_MAX = 600;
+export const RETEXTURE_SIZES = ["2k", "4k", "8k"] as const;
+
+/** Retexture a finished model: the words, or a style picture (which wins when both go), at a texture size. */
+export function retextureRequest(o: { glb: string; prompt?: string; style?: string; model?: RetextureModel; size?: (typeof RETEXTURE_SIZES)[number] }): GenerationRequest {
+ return {
+ feature: MODEL3D_FEATURE,
+ modelId: o.model ?? RETEXTURE_MODELS[0].id,
+ op: "retexture-3d",
+ prompt: (o.prompt ?? "").trim().slice(0, RETEXTURE_PROMPT_MAX),
+ inputs: { model3d: o.glb, ...(o.style && { images: [o.style] }) },
+ ...(o.size && o.size !== "2k" && { params: { extra: { texture_resolution: o.size } } }),
+ };
+}
diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.ts
index 6a7c8c7f..81085f44 100644
--- a/src/lib/catalog/cinema.ts
+++ b/src/lib/catalog/cinema.ts
@@ -637,7 +637,8 @@ export const CAST_SHEET_MODEL = "oss-zimage-soul-cast";
export const CINEMA_MODELS: Record<CinemaMode, Record<Engine, string[]>> = {
video: {
// Kling 4.0: a 30 s take (up to 6 shots) in one call, with @Elements and reference clips.
- cloud: [CINEMA_MODEL, "minimax-h3", "seedance-2-5", "kling-4", "kling-3", "veo-3-1", "minimax-h3-max"],
+ // H3 Max Turbo: the cheap draft take (about $0.14 for 5 s at 768P in November), with sound.
+ cloud: [CINEMA_MODEL, "minimax-h3", "seedance-2-5", "kling-4", "kling-3", "veo-3-1", "minimax-h3-max", "minimax-h3-max-turbo"],
open: [CINEMA_MODEL, "oss-minimax-h3", "oss-ltx25", "oss-wan22-14b"],
},
image: { cloud: [CINEMA_STILL_MODEL, "nano-banana-pro", "seedream-5-pro"], open: [CINEMA_STILL_MODEL, "oss-ideogram-4", "oss-qwen-image-21", "oss-krea2-realism", "oss-moss-image"] },
diff --git a/src/lib/catalog/clip-windows.ts b/src/lib/catalog/clip-windows.ts
index ada06cf3..7926a62f 100644
--- a/src/lib/catalog/clip-windows.ts
+++ b/src/lib/catalog/clip-windows.ts
@@ -60,6 +60,26 @@ export function insertRangeProblem(start: number | undefined, resume: number | u
return null;
}
+/** The insert range control's step: 1/8 s, so the earliest start (1.625 s) is one of its stops. */
+export const INSERT_STEP = 0.125;
+
+/**
+ * The two handles of Edit video's "Insert a moment" range on a clip `clip` seconds long (unknown while its header is read): the
+ * track runs from the earliest start to the clip's end (at most 60 s), and the handles keep to it, the start before the resume
+ * by a step at least, on 1/8 s stops. Without a value they open around the clip's middle.
+ */
+export function insertHandles(clip: number | undefined, value?: [number | undefined, number | undefined]): { min: number; max: number; start: number; resume: number } {
+ const snap = (n: number) => Math.round(n / INSERT_STEP) * INSERT_STEP;
+ const min = INSERT_RANGE.minStart;
+ const max = Math.max(min + INSERT_STEP, Math.floor(Math.min(INSERT_RANGE.max, clip && clip > 0 ? clip : INSERT_RANGE.max) / INSERT_STEP) * INSERT_STEP);
+ const mid = clip && clip > 0 ? clip / 2 : min + 2;
+ let start = snap(value?.[0] ?? mid - 0.5);
+ start = Math.min(Math.max(min, start), max - INSERT_STEP);
+ let resume = snap(value?.[1] ?? start + 1);
+ resume = Math.min(Math.max(start + INSERT_STEP, resume), max);
+ return { min, max, start, resume };
+}
+
export function sourceSeconds(modelId: string): { min?: number; max?: number } {
return SOURCE_SECONDS[modelId] ?? {};
}
diff --git a/src/lib/composer.ts b/src/lib/composer.ts
index 7d1da00c..d5899c8d 100644
--- a/src/lib/composer.ts
+++ b/src/lib/composer.ts
@@ -302,7 +302,8 @@ export function clipBlocker(
model: (Pick<ModelDef, "engine" | "options" | "defaults"> & Partial<Pick<ModelDef, "id" | "name">>) | undefined,
ramBytes: number | undefined,
): string | null {
- if (op === "v2v" && model?.id && (facts?.duration || facts?.width)) {
+ // (A clip relit, extended or given a new moment on a hosted model with a window of its own: H3 Max relight up to 15 s.)
+ if ((op === "v2v" || op === "relight-video" || op === "insert-moment" || op === "extend") && model?.id && (facts?.duration || facts?.width)) {
const named = { id: model.id, name: model.name ?? model.id, engine: model.engine };
return (
(facts.duration ? clipWindowProblem(named, facts.duration, facts.fps) : null) ??
diff --git a/src/lib/palette-index.ts b/src/lib/palette-index.ts
index cc75698c..84db1945 100644
--- a/src/lib/palette-index.ts
+++ b/src/lib/palette-index.ts
@@ -2,7 +2,7 @@
* The slim catalog behind the ⌘K palette (GET /api/search-index): names, categories and where each item
* opens. Built on the server from the catalog, so the palette never ships prompt templates or routes.
*/
-import { ALL_MODELS_3D, RIG_MODEL } from "@/lib/av/model3d";
+import { ALL_MODELS_3D, RETEXTURE_MODELS, RIG_MODEL } from "@/lib/av/model3d";
import { APPS, EFFECTS, MODELS, MOTIONS } from "@/lib/catalog";
import { enginesOf } from "@/lib/catalog/engines";
import { OPERATION_LABELS, type ModelDef, type Operation, type Preset } from "@/lib/catalog/types";
@@ -62,8 +62,8 @@ const MODEL_STUDIOS: [string, StudioConfig][] = [
["/video-tools/colors", VIDEO_COLOR_MATCH_STUDIO],
];
-/** Image to 3D picks its model from ?model= too (and rigs its results). */
-const IN_3D = new Set([...ALL_MODELS_3D.map((m) => m.id), RIG_MODEL]);
+/** Image to 3D picks its model from ?model= too (and rigs and retextures its results). */
+const IN_3D = new Set([...ALL_MODELS_3D.map((m) => m.id), RIG_MODEL, ...RETEXTURE_MODELS.map((m) => m.id)]);
/** The Layers editor's tools (cut-out, layers, text detection…): its project list is where they start. */
const IN_LAYERS = new Set(Object.values(TOOL_MODELS).flatMap((t) => [...t.cloud, ...t.open]));
/** Where a model no studio, app or tool offers opens: the studio of what it makes. */
diff --git a/src/lib/relight-sphere.ts b/src/lib/relight-sphere.ts
new file mode 100644
index 00000000..ed899bfa
--- /dev/null
+++ b/src/lib/relight-sphere.ts
@@ -0,0 +1,150 @@
+/**
+ * The lit sphere fal's H3 Max relight reads as its target light (reference_image_url: "Sphere render showing the target
+ * lighting"). Fuobe draws it from a light preset: a matte grey ball on a dark ground, lit by one to three lights (direction,
+ * colour, strength, softness) over a little ambient light. Pure: the browser puts the pixels on a canvas and uploads them
+ * (src/components/studio/light-sphere-chip.tsx); tests read them directly.
+ */
+
+/** The sphere picture's side in pixels: square, enough for the API to read the light's direction and colour. */
+export const SPHERE_SIZE = 512;
+
+export interface SphereLight {
+ /** Where the light comes from, seen from the camera: x right, y up, z toward the viewer (normalised when drawn). */
+ dir: [number, number, number];
+ /** Linear 0-1 RGB. */
+ color: [number, number, number];
+ /** How bright, 0-1.5. */
+ strength: number;
+ /** 0 = a hard edge between light and shadow, 1 = a very soft wrap. */
+ softness: number;
+}
+
+export interface LightPreset {
+ id: string;
+ label: string;
+ /** What the light is, for the run's prompt-free summary and the picker's tooltip. */
+ hint: string;
+ ambient: [number, number, number];
+ lights: SphereLight[];
+}
+
+export const LIGHT_PRESETS: LightPreset[] = [
+ {
+ id: "golden-left",
+ label: "Golden hour",
+ hint: "Warm, low sun from the left, long soft shadows",
+ ambient: [0.08, 0.07, 0.09],
+ lights: [{ dir: [-0.85, 0.25, 0.45], color: [1, 0.66, 0.32], strength: 1.15, softness: 0.35 }],
+ },
+ {
+ id: "noon",
+ label: "Midday sun",
+ hint: "Hard white sun from above",
+ ambient: [0.1, 0.11, 0.13],
+ lights: [{ dir: [0.15, 0.95, 0.25], color: [1, 0.97, 0.92], strength: 1.2, softness: 0.05 }],
+ },
+ {
+ id: "overcast",
+ label: "Overcast",
+ hint: "Soft, even daylight from a cloudy sky",
+ ambient: [0.22, 0.23, 0.25],
+ lights: [{ dir: [0, 0.8, 0.6], color: [0.85, 0.88, 0.92], strength: 0.8, softness: 1 }],
+ },
+ {
+ id: "window",
+ label: "Window light",
+ hint: "One cold window to the right, a dark room",
+ ambient: [0.02, 0.02, 0.03],
+ lights: [{ dir: [0.9, 0.2, 0.35], color: [0.72, 0.84, 1], strength: 1.1, softness: 0.45 }],
+ },
+ {
+ id: "studio",
+ label: "Studio key",
+ hint: "A soft key light from the front right, a little fill",
+ ambient: [0.06, 0.06, 0.06],
+ lights: [
+ { dir: [0.55, 0.45, 0.7], color: [1, 0.98, 0.95], strength: 1, softness: 0.6 },
+ { dir: [-0.7, 0.1, 0.7], color: [0.9, 0.92, 1], strength: 0.3, softness: 0.8 },
+ ],
+ },
+ {
+ id: "neon",
+ label: "Neon street",
+ hint: "Pink from the left, blue from the right",
+ ambient: [0.03, 0.02, 0.05],
+ lights: [
+ { dir: [-0.9, 0.1, 0.4], color: [1, 0.25, 0.7], strength: 1.1, softness: 0.3 },
+ { dir: [0.9, 0.05, 0.4], color: [0.2, 0.55, 1], strength: 1.1, softness: 0.3 },
+ ],
+ },
+ {
+ id: "campfire",
+ label: "Campfire",
+ hint: "Flickering orange light from below",
+ ambient: [0.02, 0.015, 0.02],
+ lights: [{ dir: [0.1, -0.85, 0.5], color: [1, 0.45, 0.12], strength: 1.2, softness: 0.4 }],
+ },
+ {
+ id: "rim",
+ label: "Rim light",
+ hint: "A bright edge from behind, the front in shadow",
+ ambient: [0.04, 0.04, 0.05],
+ lights: [{ dir: [0.35, 0.3, -0.88], color: [1, 0.96, 0.9], strength: 1.4, softness: 0.25 }],
+ },
+];
+
+export function lightPreset(id: string | undefined): LightPreset | undefined {
+ return LIGHT_PRESETS.find((p) => p.id === id);
+}
+
+/** The ground around the sphere: a dark neutral grey, so the API reads the ball's shading and not the frame. */
+const BACKGROUND: [number, number, number] = [0.05, 0.05, 0.05];
+/** The ball's matte grey (an 18% card's albedo, lifted a little so a dim light still shows). */
+const ALBEDO = 0.6;
+
+const norm = (v: [number, number, number]): [number, number, number] => {
+ const l = Math.hypot(v[0], v[1], v[2]) || 1;
+ return [v[0] / l, v[1] / l, v[2] / l];
+};
+const toByte = (linear: number) => Math.round(255 * Math.pow(Math.min(1, Math.max(0, linear)), 1 / 2.2));
+
+/**
+ * The preset's sphere as RGBA pixels, `size` × `size`, row by row from the top: a ball filling 80% of the frame, each light
+ * a wrapped Lambert term (softness widens the wrap) plus a small specular highlight, edges antialiased against the ground.
+ */
+export function spherePixels(preset: LightPreset, size = SPHERE_SIZE): Uint8ClampedArray {
+ const out = new Uint8ClampedArray(size * size * 4);
+ const r = size * 0.4;
+ const c = (size - 1) / 2;
+ const lights = preset.lights.map((l) => ({ ...l, d: norm(l.dir) }));
+ for (let y = 0; y < size; y++) {
+ for (let x = 0; x < size; x++) {
+ const nx = (x - c) / r;
+ const ny = (c - y) / r;
+ const rr = nx * nx + ny * ny;
+ // Coverage for a smooth edge: one pixel's worth of falloff at the rim.
+ const edge = Math.min(1, Math.max(0, (1 - Math.sqrt(rr)) * r + 0.5));
+ let col: [number, number, number] = [...BACKGROUND];
+ if (edge > 0) {
+ const nz = Math.sqrt(Math.max(0, 1 - Math.min(1, rr)));
+ const shade: [number, number, number] = [preset.ambient[0] * ALBEDO, preset.ambient[1] * ALBEDO, preset.ambient[2] * ALBEDO];
+ for (const l of lights) {
+ const ndl = nx * l.d[0] + ny * l.d[1] + nz * l.d[2];
+ const w = l.softness * 0.9;
+ const diffuse = Math.max(0, (ndl + w) / (1 + w));
+ // Blinn-Phong toward a viewer on +z, sharper for a harder light.
+ const h = norm([l.d[0], l.d[1], l.d[2] + 1]);
+ const spec = Math.pow(Math.max(0, nx * h[0] + ny * h[1] + nz * h[2]), 12 + 60 * (1 - l.softness)) * 0.25 * (ndl > 0 ? 1 : 0);
+ for (let i = 0; i < 3; i++) shade[i] += l.strength * l.color[i] * (ALBEDO * diffuse + spec);
+ }
+ col = [0, 1, 2].map((i) => BACKGROUND[i] * (1 - edge) + shade[i] * edge) as [number, number, number];
+ }
+ const o = (y * size + x) * 4;
+ out[o] = toByte(col[0]);
+ out[o + 1] = toByte(col[1]);
+ out[o + 2] = toByte(col[2]);
+ out[o + 3] = 255;
+ }
+ }
+ return out;
+}
diff --git a/src/lib/studios.ts b/src/lib/studios.ts
index 69c848d5..82e0b213 100644
--- a/src/lib/studios.ts
+++ b/src/lib/studios.ts
@@ -398,6 +398,8 @@ export const VIDEO_EDIT_STUDIO: StudioConfig = {
placeholder: "Describe the edit… e.g. “make it snow”, “replace the car with a horse”",
kind: "video",
ops: ["v2v"],
+ // "Insert a moment" (H3 Max insert): a new scene between two points of the clip, picked like any edit model.
+ pickerOps: ["v2v", "insert-moment"],
feed: { features: ["video-edit"] },
slots: [{ key: "video", label: "Video", accept: "video", required: true }],
multiRef: { label: "Add ref", max: 4 },
@@ -468,6 +470,8 @@ export const VIDEO_RELIGHT_STUDIO: StudioConfig = {
subtitle: "Describe the new light — golden hour, neon, a single window, a campfire.",
placeholder: "e.g. “warm sunset light from the left, long soft shadows”",
ops: ["relight-video"],
+ // The clip's length prices a relight billed by the second (H3 Max relight) and holds it to the model's window (up to 15 s).
+ clipFacts: true,
defaultModels: { cloud: "lightx-relight", open: "oss-bernini-relight" },
promptOptional: false,
suggestions: ["Warm golden-hour sun from the left", "Pink and blue neon from the street", "A single cold window light, dark room", "Flickering campfire light from below"],
diff --git a/tests/cinema-models.test.ts b/tests/cinema-models.test.ts
index b92e3ccc..d4173d20 100644
--- a/tests/cinema-models.test.ts
+++ b/tests/cinema-models.test.ts
@@ -13,7 +13,7 @@ const refs = Array.from({ length: 6 }, (_, i) => `/api/files/uploads/r${i}.png`)
describe("Cinema Studio's models", () => {
it("video: Fuobe Cinema, then MiniMax H3, on both engines; the cloud adds H3 Max", () => {
expect(CINEMA_MODELS.video.open).toEqual(["fuobe-cinema", "oss-minimax-h3", "oss-ltx25", "oss-wan22-14b"]);
- expect(CINEMA_MODELS.video.cloud).toEqual(["fuobe-cinema", "minimax-h3", "seedance-2-5", "kling-4", "kling-3", "veo-3-1", "minimax-h3-max"]);
+ expect(CINEMA_MODELS.video.cloud).toEqual(["fuobe-cinema", "minimax-h3", "seedance-2-5", "kling-4", "kling-3", "veo-3-1", "minimax-h3-max", "minimax-h3-max-turbo"]);
for (const engine of ["open", "cloud"] as const) for (const id of CINEMA_MODELS.video[engine]) expect(getModel(id), id).toBeTruthy();
// The default stays Fuobe Cinema.
expect(planCinema(input({}), ctx).model.id).toBe("fuobe-cinema");