# Controling the shadows in 3D Makie visualizations

**URL:** <https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [June 12, 2021, 1:33pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796 "2021-06-12T13:33:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 12, 2021, 1:33pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/1 "2021-06-12T13:33:15Z")

</div>

I am new to 3D visualization, and wonder how people usually control the “shadows”. When I visualize the grid below the colors are too dark as if the light source was behind the cube by default:

![image](https://global.discourse-cdn.com/julialang/original/3X/9/9/995c3fcfaa5b925faf038484e70ae4c00cb71e78.png)

Is there a recommended set of defaults to make the colors look more vivid?

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [June 12, 2021, 1:55pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/2 "2021-06-12T13:55:40Z")

</div>

The light source is the camera by default. If a mesh isn’t lit it means you either don’t have normals or they point in the wrong/opposite direction. You can turn off lighting all together with `shading = false` or correct the normals to fix this.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [June 12, 2021, 1:56pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/3 "2021-06-12T13:56:08Z")

</div>

I usually just play with.  
ambient = Vec3f0(0.85, 0.85, 0.85), backlight = 1f0

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 12, 2021, 3:28pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/4 "2021-06-12T15:28:40Z")

</div>

@ffreyer I am using the meshscatter you shared in an issue to plot this grid as a collection of boxes in the 3D case. Is there any simple fix to the meshscatter call? I thought the defaults would be more vivid in terms of normals.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 12, 2021, 3:29pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/5 "2021-06-12T15:29:01Z")

</div>

Thanks @lazarusA I will try to play with these parameters.

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [June 12, 2021, 5:04pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/6 "2021-06-12T17:04:51Z")

</div>

Something like

```julia
m = Rect3D(Point3f0(-0.5), Vec3f0(1))
fig, ax, p = meshscatter([Point3f0(i,j,k) for i in 1:5 for j in 1:5 for k in 1:5], marker=m, color=rand(125), markersize=1)

```

shouldn’t have shading issues. It’s working fine for me with GLMakie 0.3.4

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 12, 2021, 6:57pm UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/7 "2021-06-12T18:57:13Z")

</div>

Maybe this issue is specific to WGLMakie? I’ve noticed some differences from GLMakie.

---

<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:** [July 2, 2021, 8:46am UTC](https://discourse.julialang.org/t/controling-the-shadows-in-3d-makie-visualizations/62796/8 "2021-07-02T08:46:17Z")

</div>

Oh this could be ☹ I can’t wait to have them share the same shaders, so that they’re 100% equivalent…
