# Rendering Plugins with Surfaces

**URL:** <https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600>\
**Category:** Plugins\
**Created:** [November 24, 2026, 4:28pm UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600 "2026-11-24T16:28:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 24, 2026, 4:28pm UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600/1 "2026-11-24T16:28:16Z")

</div>

Okay, I’m curious to get feedback including thoughts from @matterhorn103 and @brockdyer03 in particular.

I wanted to add a ray-tracing option for an Avogadro plugin and found [Mitsuba](https://mitsuba.readthedocs.io/en/stable/src/gallery.html) - a “path based” render code that’s on PyPI.

 ![Mitsuba-generated rendering of caffeine](https://discuss.avogadro.cc/uploads/default/original/2X/9/9106bcbd79283b940727c711244205637c0661df.webp)

The problem is that _surfaces_ aren’t sent along with the CJSON sent to plugins at the moment. In general, for export to various rendering formats, we’ve used a “Visitor” class in C++ that gets all the render bits (e.g., draw a red sphere at this position, radius, etc.) including surface meshes.

I’d really like to export surface meshes. One option is to add an option to the plugins to request a scene export, e.g.

```toml
[[tool.avogadro.menu-commands]]
identifier = "render"
menu = "File"
submenu = "Export"
item = "Path-Traced Image (Mitsuba)..."
input-format = "cjson"
# Avogadro 2.2 adds a glTF "scene" to the input (older versions ignore this)
input-scene = "glb"

```

I think this is a good backwards-compatible way to allow rendering commands - Avogadro will export the scene through the `glb` / `glTF` format including surfaces and colors and then the render plugin can do whatever it wants.

 ![caffeine-3](https://discuss.avogadro.cc/uploads/default/original/2X/c/cd06ac41569072aad77ca7ff184510b9a02cc7f7.webp)

Thoughts? Better ideas?

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 24, 2026, 9:52pm UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600/2 "2026-11-24T21:52:29Z")

</div>

Sounds very cool, and if Avogadro can already produce a gLTF or glb, hopefully fairly straightforward to implement as well.

A few points/questions:

- I think it’d open up even more opportunities for plugins to do useful stuff if the plugin can also send a surface back after editing it. Then plugins could be written that change the general rendering of Avogadro. Is that feasible?
- When a plugin receives the scene, can it distinguish between the different kinds of surface (the atoms/bonds, any orbitals, etc.)? If not, would it be an idea to let the plugin choose which kinds of surfaces it processes via a given menu command?
- Is there any particular reason to have the value of the `input-scene` key be a string rather than just `true`?

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 26, 2026, 12:21am UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600/3 "2026-11-26T00:21:52Z")

</div>

> [@matterhorn103](#):
>
> - Is there any particular reason to have the value of the `input-scene` key be a string rather than just `true`?

It’s a format. In principle, there could be other formats, e.g. PLY, etc.

> [@matterhorn103](#):
>
> - If not, would it be an idea to let the plugin choose which kinds of surfaces it processes via a given menu command?

It gets the atoms and bonds separately (e.g., CJSON) and it gets the surfaces that are currently in the scene. So I’m not sure why you’d need a menu command - it processes whatever surface / cube the user has generated.

> [@matterhorn103](#):
>
> - I think it’d open up even more opportunities for plugins to do useful stuff if the plugin can also send a surface back after editing it. Then plugins could be written that change the general rendering of Avogadro. Is that feasible?

Hmm. I think we’ll need some benchmarking. The reason I’ve avoided having meshes is because they can get really big depending on resolution and the size of the molecule. Some of the rendering benchmarks are showing me that we’re uploading ~1GB for rendering protein surfaces.

It’s a reasonable long-term question though. I can imagine “reduce the mesh” or analysis options could be useful (surface area, volume, etc.)

I’ll push the change for now and we can see where it leads before v2.2 release. 🙂

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 26, 2026, 11:23am UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600/4 "2026-11-26T11:23:23Z")

</div>

> [@ghutchis](#):
>
> It gets the atoms and bonds separately (e.g., CJSON) and it gets the surfaces that are currently in the scene. So I’m not sure why you’d need a menu command - it processes whatever surface / cube the user has generated.

But the atom spheres are also amongst the surfaces that are exported, no? Or is it only the extra ones created via **Generate Surfaces**?

> [@ghutchis](#):
>
> Hmm. I think we’ll need some benchmarking.

Fair enough. Even if it’s not possible to “change the general rendering of Avogadro” though, it would still be useful to let plugins change the way the current surface is rendered, no? And it not be a permanent thing, just a one-time action that only lasts until Avogadro has to re-render the surface for whatever reason? Because from your description it sounds like the only things plugins can do with a surface they receive is render it externally to Avogadro, that they can’t change it and pass it back.

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 26, 2026, 2:40pm UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600/5 "2026-11-26T14:40:28Z")

</div>

> [@matterhorn103](#):
>
> let plugins change the way the current surface is rendered

What’s the use case you have in mind? I can potentially see some use in modifying the mesh, but as I said, it’s a lot of data in many cases going each direction.

> [@matterhorn103](#):
>
> until Avogadro has to re-render the surface for whatever reason

You understand that can happen 60 fps… Things that affect the rendering pipeline need to be really efficient. That’s why I’ve been working with Claude and other LLM (Google Gemini this week) to profile, test and optimize the rendering speed.

It’s not that I’m opposed to allowing a plugin to modify the mesh - it just helps to know a use case vs. “run ELF analysis on the current electron density and return a cube”

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 26, 2026, 4:30pm UTC](https://discuss.avogadro.cc/t/rendering-plugins-with-surfaces/7600/6 "2026-11-26T16:30:55Z")

</div>

It’s entirely possible I’m completely misunderstanding the rendering pipeline here and what’s actually being proposed.

I was assuming that Avogadro doesn’t generate a surface from scratch (e.g. from a density or from orbital coefficients and atomic orbitals) every time the view of the scene needs to be re-rendered. I assumed that the surface is calculated once, then stored as some sort of intermediate representation of the surface itself, and that is used as the starting point for rendering it in each frame.

I also figured that this intermediate representation was what you’re proposing passing to a plugin, and that this intermediate representation already includes properties of the surface, not just its shape. I was conceptualizing glTF as being basically like an SVG, in that it contains both mathematical descriptions of objects (paths in SVG, meshes here, I suppose) and their properties like colours etc.

Your proposal seems to mainly be about enabling plugins to overtake the rendering step, by handing them the intermediate representation, from which they can then produce a 2D image to save to file.

I think that you think that I’m suggesting we make it possible for a plugin to handle the rendering step for Avogadro – the plugin takes a glTF in, renders it to a bitmap, hands it back, Avogadro displays it – all the time, for every frame. That’s why you’re talking about performance, because naturally a plugin couldn’t really do that quick enough.

What I actually meant was that if you are giving the intermediate representation to a plugin, how about letting it return an alternative intermediate representation that it has modified in some way? And it’s Avogadro that continues to handle the rendering.

Reducing the mesh would be one thing that could be done like this, but like I say, I imagined that this intermediate representation already included things like colours, opacity, reflectivity, etc. and that it might be useful to have plugins that change those things.

Naturally if all that understanding is nonsense, the suggestion doesn’t make any sense at all 😅
