dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
84 stars 20 forks source link

Save a mesh without rendering it #387

Open stla opened 10 months ago

stla commented 10 months ago

Hello,

In the Python library PyVista, it is possible to save a mesh without rendering it. This gains some time if you want to do an animation with several meshes. I don't know whether this would be possible with rgl, but this would be a nice feature.

dmurdoch commented 10 months ago

I don't understand. In rgl meshes are R objects, so they can be saved just like any r object. Do you mean saving them directly to some external format? Which format would you prefer?

On Mon, Sep 11, 2023, 05:04 stla @.***> wrote:

Hello,

In the Python library PyVista, it is possible to save a mesh without rendering it. This gains some time if you want to do an animation with several meshes. I don't know whether this would be possible with rgl, but this would be a nice feature.

  • rgl Version: 1.2.1
  • R Version: 4.3.1
  • Platform: Windows

— Reply to this email directly, view it on GitHub https://github.com/dmurdoch/rgl/issues/387, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOYSQFX45EKJ3FLHIAQINLXZ346HANCNFSM6AAAAAA4TGZXJM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

stla commented 10 months ago

Maybe PyVista (based on VTK) meshes are not objects, I don't know. With rgl I often make a loop to do an animation and I save the mesh as PNG with snapshot3d. In PyVista there is a parameter off_screen which does not plot the mesh when it is set but it is possible to save the mesh as an image. This is faster than rendering the mesh at each iteration.

dmurdoch commented 10 months ago

If you want to save a PNG, the mesh has to be rendered.

Currently there are two ways to save the PNG. The faster one renders to the screen and then copies the screen to a file. The slower (but better quality) method uses webshot2 to render to a virtual browser and saves from there. It can be much slower, and I don't think there's anything I can do to speed it up.

A third way would be to render to a memory buffer and save from there. That might be possible in the future after I update to a newer version of opengl, but that work is unlikely to be done for quite a while.

On Mon, Sep 11, 2023, 07:17 stla @.***> wrote:

Maybe PyVista (based on VTK) meshes are not objects, I don't know. With rgl I often make a loop to do an animation and I save the mesh as PNG with snapshot3d. In PyVista there is a parameter off_screen which does not plot the mesh when it is set but it is possible to save the mesh as an image. This is faster than rendering the mesh at each iteration.

— Reply to this email directly, view it on GitHub https://github.com/dmurdoch/rgl/issues/387#issuecomment-1713983369, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOYSQFFMOQB2B762O6ZLRDXZ4MQNANCNFSM6AAAAAA4TGZXJM . You are receiving this because you commented.Message ID: @.***>

stla commented 10 months ago

If you want to save a PNG, the mesh has to be rendered.

Does that mean there's another format allowing not to render the mesh? As long as I can mount the pictures to a GIF animation, I don't mind the format if it has good quality.

I stopped to use webshot2, except for very small meshes, cause it can crash the laptop otherwise.

dmurdoch commented 10 months ago

PNG is the only graphics format that other software would recognize. For some very special cases, you could write HTML that would handle the animation in JavaScript - but that means modifying each frame to produce the next one. That's usually hard to do in JavaScript.

On Tue, Sep 12, 2023, 10:09 stla @.***> wrote:

If you want to save a PNG, the mesh has to be rendered.

Does that mean there's another format allowing not to render the mesh? As long as I can mount the pictures to a GIF animation, I don't mind the format if it has good quality.

I stopped to use webshot2, except for very small meshes, cause it can crash the laptop otherwise.

— Reply to this email directly, view it on GitHub https://github.com/dmurdoch/rgl/issues/387#issuecomment-1716120543, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOYSQDE7PNW7DR5NQ256TLX2CJNXANCNFSM6AAAAAA4TGZXJM . You are receiving this because you commented.Message ID: @.***>