• Installation Guide
  • Amoebot Model
  • User Guide
  • Model Reference
  • Dev Guide
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • Architecture Overview
    • Simulator
      • History
      • Save and Load
      • User API
      • Round Simulation
      • Reflection
      • Error Handling
    • User Interface
    • Input Handling
    • Render System
      • Unity Rendering Basics
      • Background Renderer
      • UI Renderer
      • Object Renderer
      • Particle Renderer
        • Particles
        • Shader Example
        • Circuits and Bonds
        • Data Structures and Interface

    Dev Guide: Circuit and Bonds Renderer

    The RendererParticles class manages a RendererCircuitsAndBonds instance to handle the rendering of all elements that are added to the basic particle bodies, namely bonds, circuit lines and partition set handles, including the beep origin, receiving and failure highlights. The circuit lines also include little circles placed where the bends of the lines are to cover up the gaps between the rectangles.

    Circuit Renderer example Bonds Circuit lines Beep highlights and partition set handles

    As mentioned before, the structure of the circuit and bond rendering sub-tree is a bit more complex than the base particle rendering system. In particular, there is one extra management level and there are two instances of a manager class that take turns with rendering rounds.

    Circuit rendering sub-tree

    The RendererCircuitsAndBonds class only serves as a container for the RendererCircuits_Instance class, which handles the actual rendering management. The role of this class is similar to that of the RendererParticles class, which manages the RendererParticles_RenderBatch instances, as explained on the particle rendering page. The RendererCircuitsAndBonds manages two instances of the RendererCircuits_Instance. At any time, one of the two instances is rendered while the other one can be modified. Once all changes are applied to the instance, the two instances are swapped. This usually happens every time a round simulation has finished.

    Note

    This feature was originally implemented to allow updating circuit and bond data over multiple frames. However, the performance is good enough even when all updates are made in a single frame, so there is no mechanism for splitting the updates.

    Instances

    Each RendererCircuits_Instance manages its own set of render batches, just like the RendererParticles. It also has dictionaries that map PropertyBlocks to XY_RenderBatch instances, but this time, we need two different kinds of render batches. The RendererCircuits_RenderBatch class only renders rectangles that are used to draw both bonds and circuit lines, while the RendererCircuitPins_RenderBatch class only renders circles to draw partition set handles, beep highlights, and the circuit line caps. Both of the render batch classes define their own dictionary keys in the form of the RendererCircuits_RenderBatch.PropertyBlockData and RendererCircuitPins_RenderBatch.PropertyBlockData structs.

    The main purpose of the RendererCircuits_Instance is managing the render batches: When circuit or bond data is added to the instance (as managed by the RendererCircuitsAndBonds), the instance creates the corresponding line and circle objects and moves them to the correct render batch. If necessary, it creates a new batch for properties that are not yet covered by the existing batches.

    The instance also provides several helper data structures and methods to organize the data that has to be handled in this sub-tree. To bundle circuit data that belongs to a single particle, it defines the ParticleCircuitData struct. This struct defines the PSetInnerPinRef struct to represent the partition set handles and circuit line caps so that they can be addressed individually and their positions are easily accessible. The GDRef struct is used to bundle references to various graphical data with indexing information for a single object like a line or partition set handle.

    Additionally, the class defines methods for placing the partition set handles, using the CircleDistributionCircleLine and CircleDistributionCircleArea helper classes.

    Render Batches

    As mentioned above, the render batch classes are RendererCircuits_RenderBatch (rendering lines) and RendererCircuitPins_RenderBatch (rendering circles). They are very similar to the RendererParticles_RenderBatch class that has been explained on a previous page. Both of these circuit render batches use MaterialPropertyBlockData_Circuits instances to store the material properties that are common among all objects drawn by one batch. They also store TRS matrices in lists of arrays to draw as many objects simultaneously as possible. The Init() method of each render batch initializes the materials and its parameters according to the given properties. Both of the classes also implement the IGenerateDynamicMesh interface, meaning that they generate meshes at runtime, using the constants defined by the RenderSystem. Just like the particle render batch class, the circuit render batches handle animations by updating the animation time stamps in the material property blocks. These updates are applied in each frame so that changes to the animation speed take effect immediately. In general, understanding how the particle render batch class RendererParticles_RenderBatch works is sufficient to understand how the circuit render batches work.

    In this article
    Back to top AmoebotSim 2.0 Documentation v1.11
    Copyright © 2025 AmoebotSim 2.0 Authors
    Generated by DocFX