rgl really slow LiDAR rendering
Saadi4469 opened this issue ยท 28 comments
Based on this issue, can you please provide some feedback and solutions?
Thank you,
Saad
Not a chance without something reproducible.
Well I can't share the LiDAR data I am using, however the code is quite simple load a LiDAR file of approximately 500 MB and render that object via plot(LiDAR_Object). LiDAR data consists of very dense 3D point data.
If you srill need LiDAR data then I will have to share some other LiDAR data with you outside of Github just to be more secure than sharing it publically.
Also dose rgl make use of a GPU or does it default to integrared graphics chipset on the motherboard?
rgl
doesn't know anything about LiDAR objects. The problem likely lies with the lidR
package, but it won't install here, so I can't help you.
Well I did contact lidR's author about this issue and the author tells me it doesn't have to do with lidR. You can even see his response to my question on stackoverflow.
A similar issue was reported by another user too on lidR's github page and part of the response OP got was:
Roughly lidR uses rgl like the following:
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
x = lidR::readLAS(LASfile)
minx = min(x@data$X)
miny = min(x@data$Y)
with = list(x = x@data$X - minx, y = x@data$Y - miny, z = x@data$Z)
rgl::open3d()
do.call(rgl::points3d, with)
As I told you, I can't install lidR
and can't run that example. So how many points are in the plot in your example?
Sure no worries but will have to be tomorrow once I get to my office. Thank you
I got lidR
to install finally. The example from the lidR
issue page displays instantly on my system. So I've got no idea what problem you were having.
Good morning, so the LiDAR file I am using has 18319689
spatially distributed points in 3D and then I use the locate_trees
(which draws red dots (spheres) to represent tree tops) function to manually correct tree identification which are 2439
in my case.
The code I use is as follows:
# Import LiDAR data
LiDAR_File = readLAS("path/file_name.las")
# Find tree tops
TTops = find_trees(LiDAR_File , lmf(ws = 15, hmin = 5))
# Manually correct tree identification
TTops_Manual = locate_trees(LiDAR_File , manual(TTops)) # This is where rgl rendering becomes too slow if there are too many points involved.
Have you tried save <- par3d(skipRedraw=TRUE); <do plotting here> ; par3d(save)
?
Yes, it's still too slow.
If you want I can provide you with some LiDAR data tonight via email, will that work?
I don't think my mailbox would accept something that big. If you can put it online somewhere and send me the link, that could work.
Please also include the full source to draw it.
Sure, I will upload the file on box,com
and share the link with you via email.
Full source meaning the code?
btw where can I find your email contact?
Yes, give me the script you would use to plot it in a new R session (assuming I have downloaded the file to the current directory).
My email is available by running maintainer("rgl")
.
I am pretty sure this is due to two things.
First, you definitely need to suppress redrawing while you are adding to a plot, or rgl
will redraw it after every change, and with tens of millions of points, that takes time.
The second thing is that rgl
was making some unnecessary copies of vectors as it was sending data to the display. For normal size vectors this doesn't really matter, but with tens of millions of entries in those vectors, R would run out of regular (non-graphics) memory, and things would slow down drastically. I've made some changes to the code to avoid these. It helps noticeably with 10^7 points, more with 10^8 points. I'll close this issue again when those changes are tested and merged.
You asked earlier about whether rgl
would use your Nvidia GPU or the integrated chipset. I don't think that really matters here; the slowdown is mostly in the CPU, but the answer is that it depends on how you have your system set up. rgl
just uses whatever OpenGL hardware it gets by default, it doesn't offer you a way to use different hardware. If your default is the integrated graphics, that's what rgl
will use. Presumably Nvidia offers a way to make its hardware the default, but I don't know what that would be.
Thank you for the thorough feedback, I have a Corei9 with 14 threads, so does rgl
use multiple cores/threads while rendering?
No, it is single threaded.
Would it possible to add multithread utilization in a future release? As, that might really help as well with rendering LiDAR data in 3D.
Not a chance.
Is it because of a R
limitation?