JeromeEippers / ipywebgl

A simple webgl2 jupyter lab widget
BSD 3-Clause "New" or "Revised" License
6 stars 0 forks source link

Getting the rendered image #1

Closed sr71684 closed 10 months ago

sr71684 commented 10 months ago

Hello,

epic library. Two questions:

  1. Is it possible to get the rendered image instead of just looking at the result on the canvas? Ideally I'd want a numpy array with the rendered result.
  2. Possible to create a bunch of moving spheres inside a render loop?
JeromeEippers commented 10 months ago

Hello,

Thanks.

  1. It is not possible today as I haven't implemented the readpixel command. It is something I can add. How would you want to use that feature? Because reading back from webgl is always slow.
  2. Yes it is possible, you can have a look at the end of the "instanced" example where I animate a bunch of line.

Cheers

sr71684 commented 10 months ago

Thanks for the quick response!

I'm building an n-body astrodynamics sim for eclipsing exoplanets around a their host star (practically, this is just orbiting spheres). Ideally, I run one iteration of my dynamics loop, update the position of the spheres, and get the rendered frame (somehow). I need the rendered frame for post-processing downstream. I'd expect this read_back_image() to be called every frame, and in a given simulaiton, there'd be on the order of 10,000 frames.

Or if reading back from webgl is slow we could, at the end of a simulation, get a sequence of rendered images, returning a (N,W,H,3) numpy array (num frames, width, height, rbg)

JeromeEippers commented 10 months ago

Hello,

I've update the project to version 0.4.0 that supports a get_image_data function.

See the documentation : https://ipywebgl.readthedocs.io/en/latest/examples/get_image_data.html

Cheers

sr71684 commented 10 months ago

Nice! Thanks for the quick turn around on this :+1: