Fixing translucent orbital surfaces

I think I have a fix for the visual artifacts with translucent orbital rendering:

The issue happens because the translucent surfaces “add up” along a particular viewing angle.

I’ll do a bit more testing, but so far it looks good.

1 Like

Sometimes the surfaces yield “windows” both to front and back side, though (to someone who relays quantumchemical computations to whose in the know) apparently there is sufficient volume around the molecules enclosed. Below, an observation with Avogadro 1.100.0-7-gac3rf38r in Windows 10.

2025-03-28_screencast-ezgif.com-optimize

1 Like

There’s definitely a separate bug there - that once you move the molecule, the surface should be invalid.

But it looks like for the VdW surfaces, we need to add a bit more padding. Basically, when you create any kind of surface (orbital, etc.) we generate a “cube” data structure for tracking the value of f(x,y,z) at points in space.

The current code then generates a mesh based on the isosurface of particular values (e.g., the VdW surface in your example). But if the cube didn’t enclose all the points .. you get gaps like that. (It comes up with some diffuse orbitals too.)

That should be a fairly easy fix.

The surfaces now look the same from all angles, which is great, and the result looks very nice!

For me though, I now see the slightly odd behaviour shown in the image below:

It looks like when looking at orbital surfaces with the color2 colour, here the default blue, only the interior face of the surface is visible, not the exterior. Hence the atoms not being tinted blue.

These other angles help to make this obvious – look at the way the orbital vanishes on the left of the carbonyl carbon:



The red phases on the other hand seem to render correctly.

The different behaviour of the two phases also seems to be apparent from the way that they seem to be lit/shaded inversely (presumably because you are seeing the convex red surface and the concave blue surface):

It makes it look like the red phase is being lit from above (i.e. matching the atoms) while the blue phase appears to be being lit from below.

There is also a peculiar jump from 99% opacity:

to 100%:

The exterior surface of the blue phase is suddenly rendered, but the lighting directions are suddenly inverted. They are inverted for both phases, with the result that they are still inconsistent between the phases, but now it’s the red phase that is wrong…