# Fixing translucent orbital surfaces

**URL:** <https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879>\
**Category:** Development\
**Created:** [March 28, 2025, 9:01pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879 "2025-03-28T21:01:18Z")\
**Posts on this page:** 17\
**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:** [March 28, 2025, 9:01pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/1 "2025-03-28T21:01:19Z")

</div>

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

 ![benzene-before](https://discuss.avogadro.cc/uploads/default/original/2X/6/649908d5038e3e2a3a002ade1ab7dae959d56a0a.png)

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

 ![benzene-fixed](https://discuss.avogadro.cc/uploads/default/original/2X/8/83b24307c2d16e323c0646db18ebfa661cc57a31.jpeg)

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

---

<div class="post-metadata">

**Author:** ![Thomas](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/thomas/32/3403_2.png) [@Thomas](https://discuss.avogadro.cc/u/Thomas)\
**Post date:** [March 28, 2025, 9:12pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/2 "2025-03-28T21:12:44Z")

</div>

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](https://discuss.avogadro.cc/uploads/default/original/2X/6/623d8e7fd499e6d66c1e04a80094894e8ab53c90.gif)

---

<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:** [March 28, 2025, 9:30pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/3 "2025-03-28T21:30:48Z")

</div>

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.

---

<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:** [April 6, 2025, 2:04pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/4 "2025-04-06T14:04:24Z")

</div>

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:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/4/433ae0cd2a28cc3757445a05ad434f84da4c817c.png)

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:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/0/0db2e225f7a3e3daf1aeebb4b468ac0efaba4369.png)  
 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/b/b77ef54a2229b57d7e2740cc440c8b907e6e98d0.png)  
 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/7/7debd483b23de17d7e85294a7f13d8df63b4606b.png)

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):

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/6/6b70dfda5a5abc540e327012a063d7be5c09a186.png)

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.

---

<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:** [April 6, 2025, 2:23pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/5 "2025-04-06T14:23:04Z")

</div>

There is also a peculiar jump from 99% opacity:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/2/2f7a4e3021779a44ee9f3c5ce3799b4f93e3fadd.png)

to 100%:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/8/870f6fac849a8c98f76ba80c54cdc021961a3100.png)

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…

---

<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 15, 2025, 12:39am UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/6 "2025-11-15T00:39:23Z")

</div>

Yes, there’s a difference in the “winding” of the triangles between + and - phases as far as lighting. But that hasn’t changed in the last few months.

---

<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 15, 2025, 1:17am UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/7 "2025-11-15T01:17:34Z")

</div>

Well, the bug was introduced as a result of your other bug fix in March, and @callumhind was using “1.98 or 1.99 or 1.100” previously, all of which pre-date that.

---

<div class="post-metadata">

**Author:** ![callumhind](https://discuss.avogadro.cc/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@callumhind](https://discuss.avogadro.cc/u/callumhind)\
**Post date:** [November 15, 2025, 4:59pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/8 "2025-11-15T16:59:52Z")

</div>

Can confirm that this issue is not present with the wireframe style (colours are vibrant and lighting is good). Seems like it’s isolated to the surface style on my end at least.

I’ve downgraded to v1.99.0 and the rendering is back to how it was previously. So it may be a bug in a subsequent version.

If it would help, I can attempt to pinpoint the version where the changes occur, if that would be of any help to you?

---

<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 16, 2025, 1:22am UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/9 "2025-11-16T01:22:37Z")

</div>

> [@callumhind](#):
>
> If it would help, I can attempt to pinpoint the version where the changes occur, if that would be of any help to you?

Sure - certainly knowing when the bug changed helps to narrow down the revisions.

I’m going to look into a few things this evening.

---

<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 18, 2025, 4:38pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/10 "2025-11-18T16:38:37Z")

</div>

As I mentioned in [another thread](https://discuss.avogadro.cc/t/does-anyone-know-what-has-changed-with-the-rendering-of-mos-since-earlier-this-year/7229/6) this is now fixed:

> <https://github.com/OpenChemistry/avogadrolibs/pull/2420>
>
> Should fix inconsistent lighting / opacity
> h/t to @matterhorn103 and @callumhin…d2302
> 
> Fixes #2417
> 
> Developer Certificate of Origin
> Version 1.1
> 
> Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
> 1 Letterman Drive
> Suite D4700
> San Francisco, CA, 94129
> 
> Everyone is permitted to copy and distribute verbatim copies of this
> license document, but changing it is not allowed.
> 
> 
> Developer's Certificate of Origin 1.1
> 
> By making a contribution to this project, I certify that:
> 
> (a) The contribution was created in whole or in part by me and I
> have the right to submit it under the open source license
> indicated in the file; or
> 
> (b) The contribution is based upon previous work that, to the best
> of my knowledge, is covered under an appropriate open source
> license and I have the right under that license to submit that
> work with modifications, whether created in whole or in part
> by me, under the same open source license (unless I am
> permitted to submit under a different license), as indicated
> in the file; or
> 
> (c) The contribution was provided directly to me by some other
> person who certified (a), (b) or (c) and I have not modified
> it.
> 
> (d) I understand and agree that this project and the contribution
> are public and that a record of the contribution (including all
> personal information I submit with it, including my sign-off) is
> maintained indefinitely and may be redistributed consistent with
> this project or the open source license(s) involved.

---

<div class="post-metadata">

**Author:** ![NRKEYES](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/nrkeyes/32/3499_2.png) [@NRKEYES](https://discuss.avogadro.cc/u/NRKEYES)\
**Post date:** [July 9, 2026, 3:27pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/11 "2026-07-09T15:27:02Z")

</div>

I am still seeing the initial bug reported in this thread on an apple silicone version.(not sure if that matters in this case)

 ![Screenshot 2026-07-09 at 9.26.44 AM](https://discuss.avogadro.cc/uploads/default/original/2X/5/5dd05c91e24bdc2eafcfa2c874b29b30bf0e084b.png)

I’ve attached the orca output file I am viewing as well.

[test.out](https://discuss.avogadro.cc/uploads/short-url/vD3f0eon6tgOzo2PYN1cluGe5QW.out) (668.6 KB)

---

<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:** [July 9, 2026, 3:58pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/12 "2026-07-09T15:58:52Z")

</div>

It would help significantly to know what version you’re using. But there’s only so much I can do as a non-render expert.

For me, it can still show up sometimes depending on the specific camera angle, but it’s less of a problem with higher resolution surfaces:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/1/17ff5a3ad52c45726d023236e656b87d092e7cb6.jpeg)

---

<div class="post-metadata">

**Author:** ![NRKEYES](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/nrkeyes/32/3499_2.png) [@NRKEYES](https://discuss.avogadro.cc/u/NRKEYES)\
**Post date:** [July 9, 2026, 4:03pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/13 "2026-07-09T16:03:38Z")

</div>

The above and included frames are from the nightly release render. But I was seeing the same in the stable release.

 ![Screenshot 2026-07-09 at 10.02.26 AM](https://discuss.avogadro.cc/uploads/default/original/2X/9/92fbeb4c609019376d08ab415663bdf4bf9f816c.jpeg)

---

<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:** [July 9, 2026, 4:08pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/14 "2026-07-09T16:08:00Z")

</div>

As I said, what you’re describing is different from this particular thread. It’s somewhat inherent in having multiple translucent triangles in the mesh and as a non-expert at OpenGL rendering, I’m not sure what else I can do to change it. We don’t do full ray-tracing for performance reasons.

---

<div class="post-metadata">

**Author:** ![NRKEYES](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/nrkeyes/32/3499_2.png) [@NRKEYES](https://discuss.avogadro.cc/u/NRKEYES)\
**Post date:** [July 9, 2026, 4:11pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/15 "2026-07-09T16:11:26Z")

</div>

Appreciate it. I’ll play around with some code on my end.

---

<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:** [July 9, 2026, 11:42pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/16 "2026-07-09T23:42:12Z")

</div>

The appropriate files would be the various `mesh*` code here:

> **[avogadrolibs/avogadro/rendering at master · OpenChemistry/avogadrolibs](https://github.com/OpenChemistry/avogadrolibs/tree/master/avogadro/rendering)**
>
> master/avogadro/rendering

My guess is there could be some tweaks to the fragment shader:

> <https://github.com/OpenChemistry/avogadrolibs/blob/416651ddaef33a4e20392392e7c0b505d446491b/avogadro/rendering/mesh_fs.glsl>

I’ll see if Claude or ChatGPT has some suggestion to tweak this.

---

<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:** [July 10, 2026, 2:58pm UTC](https://discuss.avogadro.cc/t/fixing-translucent-orbital-surfaces/6879/17 "2026-07-10T14:58:58Z")

</div>

Okay, Claude had a suggestion, which looks good code-wise and seems to solve the rendering:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/7/718f05378afd794e34eb015ec98444468976446e.jpeg)

> <https://github.com/OpenChemistry/avogadrolibs/pull/2893>
>
> Suggested by Claude Opus 4.8 - two-pass rendering to get ordering
> 
> Developer C…ertificate of Origin
> Version 1.1
> 
> Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
> 1 Letterman Drive
> Suite D4700
> San Francisco, CA, 94129
> 
> Everyone is permitted to copy and distribute verbatim copies of this
> license document, but changing it is not allowed.
> 
> 
> Developer's Certificate of Origin 1.1
> 
> By making a contribution to this project, I certify that:
> 
> (a) The contribution was created in whole or in part by me and I
> have the right to submit it under the open source license
> indicated in the file; or
> 
> (b) The contribution is based upon previous work that, to the best
> of my knowledge, is covered under an appropriate open source
> license and I have the right under that license to submit that
> work with modifications, whether created in whole or in part
> by me, under the same open source license (unless I am
> permitted to submit under a different license), as indicated
> in the file; or
> 
> (c) The contribution was provided directly to me by some other
> person who certified (a), (b) or (c) and I have not modified
> it.
> 
> (d) I understand and agree that this project and the contribution
> are public and that a record of the contribution (including all
> personal information I submit with it, including my sign-off) is
> maintained indefinitely and may be redistributed consistent with
> this project or the open source license(s) involved.
> 
> 
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*Bug Fixes\*\*
> \* Improved rendering of translucent mesh surfaces by drawing back-facing surfaces before front-facing surfaces.
> \* Preserved depth information during translucent rendering to improve visual layering and reduce rendering artifacts.
> \* Standard mesh rendering remains unchanged for non-translucent surfaces.
