# Understanding GLMakie 3D meshscatter transparency/alpha

**URL:** <https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414>\
**Category:** Visualization\
**Tags:** makie, glmakie\
**Created:** [October 17, 2024, 10:07am UTC](https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414 "2024-10-17T10:07:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [October 17, 2024, 10:07am UTC](https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414/1 "2024-10-17T10:07:09Z")

</div>

I’m trying to visualize a weighted 3D point set using `meshscatter`, where the weight is visualized using transparency: Low weight means high transparency.  
To do this I set a color alpha value for each point.

The result looks like this:

 ![Bildschirmfoto vom 2024-10-17 12-01-51](https://global.discourse-cdn.com/julialang/original/3X/0/e/0e5bae1e57a25dc72b1173ffcee6797dfc6af764.png)

There are a couple of things I don’t understand:

1. Why do single spheres/points have this dark/light pattern?
2. Why are points transparent to some point but not others?  
I don’t see a pattern related to depth here.  
`ssao=true/false` does not make a difference.

> **Code to reproduce the image:**
>
> ```julia
> using GLMakie
> 
> points = rand(Float32, 3, 20)
> alpha = rand(Float32, 20)
>     
> basecolor = RGBf(0.0, 0.44705883, 0.698039230)
> markercolor = RGBAf.(basecolor, alpha)
> 
> fig = Figure();
> ax = Axis3(fig[1, 1])
> ax.scene.lights = [ # define lights by hand, just to be sure
> AmbientLight(RGBf(0.2, 0.2, 0.2)), DirectionalLight(RGBf(1, 1, 1), Vec3f(0, 0, -1))
> ]
> 
> meshscatter!(ax, points; color=markercolor, markersize=0.1f0, ssao=true)
> 
> ```

> **Point coordinates used in my example**
>
> ```julia
> 0.08144003, 0.76462823, 0.3078106
> 0.08184856, 0.88391453, 0.70793194
> 0.2750585, 0.21764505, 0.36415952
> 0.30778933, 0.5571264, 0.57384634
> 0.5351146, 0.94121045, 0.6286627
> 0.13961536, 0.97269565, 0.39499444
> 0.34692007, 0.49153197, 0.2805946
> 0.9911157, 0.22105312, 0.42372352
> 0.78404695, 0.2793542, 0.5839179
> 0.5117918, 0.8036711, 0.278471
> 0.7802961, 0.45787352, 0.6333635
> 0.9258438, 0.5479086, 0.713095
> 0.86555547, 0.012489796, 0.27193218
> 0.13506001, 0.05365455, 0.31954545
> 0.8792992, 0.48838484, 0.50887954
> 0.374256, 0.25085568, 0.28193265
> 0.4643891, 0.5176311, 0.13900834
> 0.06747496, 0.99334013, 0.67928374
> 0.28540635, 0.6764825, 0.38197
> 0.12089592, 0.3304742, 0.31492037
> 
> ```

Order independent transparency (via `transparency=true`) gives a somewhat reasonable look to the above MWE, but in my actual data (with many more points) that’s not what I want, because I want to keep some perception of depth.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [October 17, 2024, 12:16pm UTC](https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414/2 "2024-10-17T12:16:49Z")

</div>

Have you tried transparency true for the large dataset and evaluated how much of the depth perception is kept?

---

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [October 17, 2024, 4:08pm UTC](https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414/3 "2024-10-17T16:08:15Z")

</div>

I actually have several larger datasets.

This is how `transparency=false` vs `transparency=true` looks like for one of them:

 ![Bildschirmfoto vom 2024-10-17 18-05-16](https://global.discourse-cdn.com/julialang/original/3X/3/d/3d9b81bca12c9f088787af8204217c8371758d8a.jpeg)

The problem here is also than with `transparency=true` my fake “shadow” (which is just a 2d meshscatter of grey circles) shines through.

---

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [October 21, 2024, 8:19am UTC](https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414/4 "2024-10-21T08:19:05Z")

</div>

If I change the camera angle to get a “top view” the “two half spheres” artefact does dissapear (but the transparency issue remains):

 ![Bildschirmfoto vom 2024-10-21 10-12-39](https://global.discourse-cdn.com/julialang/original/3X/0/2/022cdf8a50f9aeee34b9c500ea07d246df150382.png)

But with just a slight tilt these artifacts do appear:

 ![Bildschirmfoto vom 2024-10-21 10-12-51](https://global.discourse-cdn.com/julialang/original/3X/e/3/e3d34d12ea02fb245ccdc2653fb77e91570d5346.png)

until they look like two half-spheres.  
This is independent of the direction in `DirectionalLight`.  
I also tried with `WGLMakie` with the same result.

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [August 26, 2025, 2:15am UTC](https://discourse.julialang.org/t/understanding-glmakie-3d-meshscatter-transparency-alpha/121414/5 "2025-08-26T02:15:26Z")

</div>

I ran into the same problem, especially if one has rotated spheres it is impossible to find a prober angle.

The plot below is made `Meshes.viz!()`:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/30bd13380c6d61bba95fe48559285174a222d833.jpeg)

(maybe I missed some updates in the last 6 months though, need to update my Julia project. Currently just Meshes v0.52.9 GLMakie v0.10.18 …)
