tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization
https://www.rayshader.com/
2.05k stars 211 forks source link

wrong result with multiple floating overlays and render_highquality() #210

Closed wiesehahn closed 2 years ago

wiesehahn commented 2 years ago

When rendering multiple floating overlays at different heights render_highquality() renders the first overlay multiple times.

e.g.:

library(rayshader)
library(sf)

polys1 <- monterey_counties_sf %>% dplyr::filter(ALAND <= 291773605)
polys2 <- monterey_counties_sf %>% dplyr::filter(ALAND > 291773605)

poly_overlay1 <- generate_polygon_overlay(polys1, palette = rainbow, 
                                          extent = attr(montereybay,"extent"), heightmap = montereybay)

poly_overlay2 <- generate_polygon_overlay(polys2, palette = rainbow, 
                                          extent = attr(montereybay,"extent"), heightmap = montereybay)

montereybay %>%
  height_shade() %>%
  add_shadow(ray_shade(montereybay,zscale=50),0.3) %>% 
  plot_3d(montereybay)

#Render Floating Overlays
render_floating_overlay(poly_overlay1, altitude = 5000,zscale = 50, alpha = 1)
render_floating_overlay(poly_overlay2, altitude = 10000,zscale = 50, alpha = 1)

render_snapshot() works as expected: multioverlay_snapshot

while render_highquality() does this: multioverlay_highquality

tylermorganwall commented 2 years ago

This is working on my system—Can you provide more information on your system via sessionInfo()?

wiesehahn commented 2 years ago

see here https://github.com/tylermorganwall/rayshader/issues/208#issuecomment-1030897207

tylermorganwall commented 2 years ago

See this comment, try it out and tell me if it fixes your problem:

https://github.com/tylermorganwall/rayshader/issues/208#issuecomment-1032012029

wiesehahn commented 2 years ago

Unfortunately, updating to the latest rgl version does not solve this issue.

Actually it seems a little random. I ran the code a couple of times and in one case the upper (second) overlay was rendered duplicated.

tylermorganwall commented 2 years ago

What happens if you set a cache_filename in render_highquality()?

I also recommend fully uninstalling rayshader on your system, and then doing a fresh install. Check your package directory (call .libPaths()) and make sure it's deleting the old version. I have found problems with Windows not actually uninstalling packages in the past.

wiesehahn commented 2 years ago

When setting the cache_filename the cached layer files were correct, but the rendered image still displayed two times the first layer.

But your second suggestion to simply do a fully reinstall of rayshader seems to do the trick, thanks.

multioverlay_reinstall

tylermorganwall commented 2 years ago

Great!