Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore fast mesa display #110

Merged
merged 5 commits into from
Mar 13, 2022
Merged

Conversation

ederag
Copy link
Contributor

@ederag ederag commented Feb 20, 2022

This PR brings back ipynbplotutils.py that was removed by b2b785a.
ipynbplotutils.Plot3D has no interaction but is much faster
(2.5 s instead of 25 s with the new ipywidgets).

The image format has been changed from JPEG to PNG, initially to work around python-pillow/Pillow#2609,
but PNG should be very good for that type of images (lot of pixels with the same color) anyway.
By default the background is opaque black, as before.
Since PNG handles transparency, now a new background keyword argument is allowed,
e.g. to get a transparent background:

from pyoptools.all import *
from pyoptools.gui.ipynbplotutils import Plot3D
# from the tutorial
L = library.Edmund.get("32475")
SEN = CCD(size=(20,20))
R = parallel_beam_c(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0.0),
                  size=(10, 10), num_rays=(5, 5), wavelength=0.58929)
S = System(complist=[(L,(0,0,50),(0,0,0)),(SEN,(0,0,150),(0,0,0))],n=1)
Plot3D(S, rot=[(0, pi/2, 0), (-pi/2, -1e-2, 0)],
       center=(0, 0, 50), size=(30, 30), scale=6,
       background=(0, 0, 0, 0))

image

From the docstring:

    background: (R, G, B, A) tuple of floating point values.
                All values must be between 0 and 1.
                A is the opacity (0 means completely transparent).
                Defaults to opaque black: (0, 0, 0, 1).

Tested with PyOpenGL-3.1.0.

meshgrid is in numpy now.
PIL now correctly refuses to store an RGBA as JPEG,
see python-pillow/Pillow#2609.
Disabled for correct transparency.
@ederag
Copy link
Contributor Author

ederag commented Feb 27, 2022

With glDisable(GL_DEPTH_TEST) the lenses are smoother (no polygons with different shades as on the previous image):
image
And the material opacity was decreased to better see rays passing through.
Please let me know if you prefer these changes to be in a separate PR.

@ramezquitao
Copy link
Member

Thanks for the contribution. I apologize for not merging it sooner, but I have been very busy. Next week I will check and apply all the PR

@ramezquitao ramezquitao merged commit 5e17e7a into cihologramas:master Mar 13, 2022
@ederag ederag deleted the restore_mesa branch March 13, 2022 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants