Skip to content

Commit

Permalink
fix RPRMakie with Material (#3872)
Browse files Browse the repository at this point in the history
* fix RPRMakie with Material

* revert example
  • Loading branch information
SimonDanisch committed May 17, 2024
1 parent 4181ab6 commit dd64632
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions RPRMakie/examples/bars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ radiance = 10000
lights = [EnvironmentLight(0.5, load(RPR.assetpath("studio026.exr"))),
PointLight(Vec3f(0, 0, 20), RGBf(radiance, radiance, radiance))]

ax = LScene(fig[1, 1]; scenekw=(lights=lights,))
Makie.axis3d!(ax.scene, Rect3f(Vec3f(0), Vec3f(1, 1, 1.2)))
ax = LScene(fig[1, 1]; scenekw=(lights=lights, showaxis=false))
rectMesh = FRect3D(Vec3f0(-0.5, -0.5, 0), Vec3f0(1))
recmesh = GeometryBasics.normal_mesh(rectMesh)
n = 100
pos = [Point3f(i, j, 0) ./ 10 for i in 1:n for j in 1:n]
z = rand(n, n)

mat = (type=:Microfacet, color=:gray, roughness=0.2, ior=1.390)

meshscatter!(ax, pos; marker=recmesh, markersize=Vec3f.(0.1, 0.1, z[:]), material=mat, color=vec(z))

cam = cameracontrols(ax.scene)
cam.eyeposition[] = Float32[5, 22, 12]
cam.lookat[] = Float32[5, 5, -0.5]
cam.upvector[] = Float32[0.0, 0.0, 1.0]
cam.fov[] = 14.0

@time display(ax.scene)
2 changes: 1 addition & 1 deletion RPRMakie/src/meshes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function extract_material(matsys, plot)
if haskey(plot, :material) && !isnothing(plot.material[])
if haskey(plot, :material) && !isnothing(to_value(plot.material))
if plot.material isa Attributes
return RPR.Material(matsys, Dict(map(((k,v),)-> k => to_value(v), plot.material)))
else
Expand Down

0 comments on commit dd64632

Please sign in to comment.