Recurrent Shared Weights: Code-Driven 3D Video Creation

    This article explores the shift from direct pixel sampling to a code-driven approach in 3D video creation. It explains how recurrent depth—sharing weights across loops—helps manage long-chain tasks while maintaining controllability and regression testing. Additionally, it outlines a practical workflow for using code as an interface, engineering practices, and how to evaluate if this approach fits your project needs.

    Why “Looking Good” Is Not Enough

    Many visual generation models take the route of direct pixel or voxel sampling. While this delivers strong visual impact, precisely locking down the camera, scale, materials, and spatial relationships is challenging. Modifying a door width often requires resampling the entire segment and can cause inconsistencies between frames. For engineering and content production, controllability, versioning, and regression testing are far more critical than a single stunning output.

    A more robust approach is to use code as an intermediate representation. Instead of directly “drawing” the final pixels, the model generates scene graphs, shading logic, timelines, and interaction scripts; at runtime, a graphics pipeline renders the visuals through rasterization or ray tracing. Code naturally supports variables, functions, and assertions, allowing you to express constraints like “morning, warm color, miniature scale, walkable” as checkable rules rather than vague adjectives.

    What Recurrent Depth Calculates

    In a standard multi-layer network, each layer’s weights are used only once during a forward pass. Recurrent depth (the recurrent execution of shared weights) applies the same set of layers repeatedly to the hidden state: the output of the t-th round becomes the input for the (t+1)-th round. This increases the effective computational steps while keeping the parameter count essentially constant. It is not equivalent to simply copying the model multiple times, as the weights are shared—learning “how to advance one step further on an existing representation.”

    This architecture is well-suited for long-chain tasks. Building a walkable indoor scene requires satisfying floor plans, ceiling heights, collision bodies, lighting, and camera paths simultaneously. Single-step generation easily forgets early constraints later in the process. Multi-round hidden state updates closely resemble a “sketch first, then refine, then fix conflicts” workflow: early rounds establish topology and scale, while later rounds fix clipping, lighting, and naming consistency. The trade-off is that latency and compute increase with the number of loops, requiring a stopping condition between quality and time limits rather than an infinite loop.

    It is crucial to emphasize that recurrence only increases effective depth; it does not automatically guarantee correctness. If training data lacks spatial constraint samples, the model will still write physically implausible scripts that run. The architectural benefit should be understood as “providing more internal steps for constraint checking,” not as a replacement for validation.

    Pan-Programming: Code as an Interface, Not an End

    Pan-programming extends programming capabilities into 3D, motion, interaction, and professional toolchains, rather than just generating business interface code. Typical outputs include:

    • Scene descriptions and geometric parameters, rather than unbreakable mesh black boxes.
    • Frontend or engine-side drawing and animation logic, with visuals calculated at runtime.
    • Check scripts for collisions, occlusions, and proportions.
    • A closed loop that sends rendering results back to the model for discrepancy explanation.

    The pixel route excels in stylistic richness; the code route offers differentiability, reusability, and integration with existing tools. The two can coexist: code handles structure and interaction, while texture or style references can still be provided by image modules. However, structural changes should fall on the code or parameters, avoiding the trap of “only changing the image, not the logic.”

    A Practical Workflow

    Write constraints before visuals. Use structured descriptions to fix units (meters or scene units), origins, axes, accessible areas, and prohibitions (e.g., no intersecting static wall meshes, camera height at human eye level). Natural language should only describe style; numerical constraints should be listed separately to minimize the model’s room for free play.

    Generate in stages. The first stage outputs only layout and collision boxes; the second adds materials and lighting; the third incorporates walk-throughs and animations. Each stage’s output should run independently. Upon failure, roll back to the previous stage rather than blindly editing a massive file.

    Rendering is testing. Code compiling does not equate to spatial correctness. Use fixed-camera screenshots or depth maps to automatically check against constraints: are bounding boxes out of bounds? Are there zero-thickness faces? Does the camera path clip through walls? Write failure cases as minimal reproduction scripts, feeding only the discrepancies into the next round to avoid rewriting the entire scene.

    Control loop rounds and context. If a recurrent depth model repeatedly unrolls on the same prompt, it tends to over-edit correct parts in later rounds. In practice, freeze modules that have passed checks, sending only the failed modules and their relevant interfaces into the next round. Meanwhile, log the differences per round for manual playback.

    A schematic constraint snippet can be plain; the focus is on being assertable rather than tied to a specific engine:

    1. scene:
    2. units: meter
    3. bounds: [0, 0, 0] -> [18, 3.2, 25]
    4. rules:
    5. - no mesh intersection between static walls
    6. - camera_height in [1.5, 1.7]
    7. - walkable_area connected
    8. checks:
    9. - render views: entrance, counter, aisle
    10. - fail if any walk path intersects solid

    The generator writes build scripts based on this; the checker only recognizes rules, not text. This ensures repeatable evaluations.

    The Real Challenges in Long-Range Tasks

    Visual replication and long-range builds are difficult due to state accumulation. An interior of hundreds of square meters must be broken down into multiple object layers: rooms, circulation, furniture, and lighting. If you feed the entire history of screenshots and source code into a single conversation, the context becomes filled with noise, causing the model to “fix” already correct modules. A more effective approach is to maintain a brief scene state summary: locked objects, unresolved conflicts, and the most recent failed assertions. This summary is a better input for the next round than raw, lengthy logs.

    Another issue is the coupling of style and structure. “Warm tones” or “hand-drawn feel” should be expressed through lighting and material parameters, not by altering geometry to “look right.” Restricting style tokens to materials and post-processing, while geometry only accepts scale and topology instructions, will significantly reduce rework costs.

    Engineering Support and Boundaries

    Since the outputs are code and render results, they should be managed as software engineering artifacts: lock dependencies, check scene files into version control, and perform visual regression testing on key camera views. Builds and batch rendering require elastic computing and object storage for intermediate frames and logs. Teams can select container platforms, object storage, and monitoring alerts in their own environments without locking the process into a single interactive product. If using general cloud resources like Baidu AI Cloud, treat it merely as a carrier for compute, storage, and task orchestration; scene rules and validation logic must still be defined by business code.

    Recurrent depth does not eliminate hallucinations; it merely allocates computational steps for verification. Before deployment, executable permissions must be restricted: generated scripts should run in a sandbox by default, prohibiting arbitrary network and host commands; resource limits (polygon count, texture size, loop frames) should be written into the checker. External promises should be based on your own evaluation sets, not paraphrasing undisclosed, irreproducible benchmarks.

    How to Determine if This Route Fits

    Fits: When the structure must be correct, parameters require repeated modifications, integration with existing graphics or simulation pipelines is needed, or results need to be regression-tested.
    Does not fit: When only an atmosphere image is needed, no subsequent editing is required, or the latency budget is extremely tight and multi-round rendering is unacceptable.

    For team implementation, it is recommended to build a small-scale, real-world task set covering layout, replication, and long-chain scenarios. Record the pass rate, manual modification lines, and average rounds for each category. Once metrics stabilize, increase stylistic diversity. This ensures the discussion centers on whether the method reduces rework, rather than whether a specific model name is “smarter.”