Hello everyone,
I’m plotting a 3D red blood cell (RBC) shape using Makie and encountered a shading artifact—a black patch appears at the top pole of the shape. Here’s a minimal reproducible example:
using GLMakie
GLMakie.activate!()
GLMakie.closeall()
N = 16
nlat = N + 1
nlon = 2nlat
theta = range(0, step=π/(nlat-1), length=nlat)
phi = range(0, step=2π/nlon, length=nlon+1)
Xi = Array{Float64}(undef, nlat, nlon+1, 3)
# Compute the RBC shape in spherical coordinates
alpha = 1.3858189
Xi[:,:,1] .= alpha .* (sin.(theta) .* cos.(phi)')
Xi[:,:,2] .= alpha .* (sin.(theta) .* sin.(phi)')
Xi[:,:,3] .= (0.5 * alpha) .* (0.207 .+ 2.003 .* sin.(theta).^2 .- 1.123 .* sin.(theta).^4) .* cos.(theta) .* ones(1, nlon+1)
fig = Figure(size = (1200, 800))
axis = Axis3(fig[1, 1], aspect = :data)
surface!(axis, Xi[:,:,1], Xi[:,:,2], Xi[:,:,3]; colormap=[:red, :red], transparency=true, backlight=1.0f0, shading=MultiLightShading)
wireframe!(axis, Xi[:,:,1], Xi[:,:,2], Xi[:,:,3], color=:black, linewidth=1, transparency=true)
fig
The “black patch” artifact is visible at the top pole. If I set shading=NoShading
, the artifact disappears, but the figure looks too flat for my purpose.
Does anyone have suggestions for resolving this issue? I’d like to keep the shading (e.g., MultiLightShading
) but have a smooth surface without the black artifact. Are there any adjustments to the mesh, lighting, or parameterization that might help?
Any suggestions or best practices for smooth, artifact-free shading at poles?
Thanks in advance for your insights!