Per Render Engine Painters

From K-3D

Jump to: navigation, search


Currently, only one mesh painter can be assigned to a MeshInstance at-a-time, making it impossible for a mesh to be rendered using different styles in different viewports. The following proposal makes it possible to assign painters to mesh instances on a per-render-engine (per-viewport) basis. Note that this is a logical follow-on to the (currently partially implemented) work described in Node Visibility.


  • Painters should be shareable between render engines (unless configured otherwise), so that changes to a painter's parameters (such as color) are visible in all render engines by default.
  • A mesh instance should share the same painter across multiple render engines (unless configured otherwise), so that its appearance is uniform across all render engines by default.
  • All policy to be implemented in the user interface layer, to enable flexibility in scripting.


  • Modify MeshInstance by removing the k3d::gl::idrawable interface. By eliminating the need to render themselves, MeshInstance can be reduced to a minimalist object that simply acts as a "handle" to an input mesh and a tranformation matrix.
  • Create a new "MeshPainterLink" that implements k3d::gl::idrawable and "links" a MeshInstance with a painter. Conceptually it simply contains a pointer to a MeshInstance and a pointer to a painter.
    • Painters retain their current tightly-focused interface.
    • Painters can be shared between render-engines.
    • MeshInstances can share painters.
    • A MeshInstance can be linked to multiple painters for a given engine (an interesting alternative to OpenGLMultiPainter and RenderManMultiPainter).
  • MeshPainterLink objects are normal document nodes. Rationale: anything else would be reinventing the wheel.
  • The user interface layer is responsible for creating / altering / destroying MeshPainterLink objects between mesh instances and painters.
    • When a mesh instance is created, it is automatically linked (made visible) for every existing render-engine.
    • When a render-engine is created, every visible mesh instance has links created for the new render engine.
    • We assume that the UI layer does a good job of "hiding" MeshPainterLink instances by default, since documents will contain lots of them.
    • We further assume that the UI layer will do a good job of "reaping" unused MeshPainterLink instances as objects are destroyed.