When plotting surfaces using CairoMakie they appear dull because invert_normals = true doesn’t seem to work.
MWE: code that plots an open sphere using GLMakie and CairoMakie, with invert_normals=true/false, and saves a png image. The CairoMakie spheres are lit on the inside with both invert_normals=true and false.
using GLMakie,CairoMakie
function get_sphere_mesh(N,x0,a)
X(r,theta,phi) = r * sin(theta) * sin(phi)
Y(r,theta,phi) = r * sin(theta) * cos(phi)
Z(r,theta,phi) = r * cos(theta)
thetas = range(0.3*pi, stop=pi, length=N)
phis = range(0, stop=2*pi, length=N)
xs = a.*[X(1, theta, phi) for theta in thetas, phi in phis] .+ x0[1]
ys = a.*[Y(1, theta, phi) for theta in thetas, phi in phis] .+ x0[2]
zs = a.*[Z(1, theta, phi) for theta in thetas, phi in phis] .+ x0[3]
return [xs,ys,zs]
end
GLMakie.activate!(inline=true)
f = Figure()
ax1 = Axis3(f[1,1],aspect=:data,title="GLMakie, invert_normals = true")
surface!(ax1,get_sphere_mesh(100,[0,0,0],0.1)...,invert_normals=true)
ax2 = Axis3(f[1,2],aspect=:data,title="GLMakie, invert_normals = false")
surface!(ax2,get_sphere_mesh(100,[0,0,0],0.1)...,invert_normals=false)
save("GLMakie_example.png",f)
CairoMakie.activate!(inline=true)
f = Figure()
ax1 = Axis3(f[1,1],aspect=:data,title="CairoMakie, invert_normals = true")
surface!(ax1,get_sphere_mesh(100,[0,0,0],0.1)...,invert_normals=true)
ax2 = Axis3(f[1,2],aspect=:data,title="CairoMakie, invert_normals = false")
surface!(ax2,get_sphere_mesh(100,[0,0,0],0.1)...,invert_normals=false)
save("CairoMakie_example.png",f)
My output: