Skip to content

Implement :class:~.OpenGLImageMobject #2534

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

Merged
merged 19 commits into from
Apr 24, 2022
Merged

Implement :class:~.OpenGLImageMobject #2534

merged 19 commits into from
Apr 24, 2022

Conversation

icedcoffeeee
Copy link
Collaborator

@icedcoffeeee icedcoffeeee commented Feb 8, 2022

Overview: What does this pull request change?

This PR aims to bring compatibility for ImageMobject to the opengl renderer. In light of issues from 3b1b's version (some warping issue, further discussed in #1837 ), this approach uses the shaders from OpenGLTexturedSurface.

OpenGLImageMobjectTest.mp4

Numpy arrays as input

In making its cairo counterpart as equals, there exist efforts in making a numpy array as an acceptable input. Though, the output between cairo and this (opengl) is very clear, since the default sampling filter on cairo is 'bicubic' while moderngl only allows 'linear' and 'nearest' as well as some mipmap combination. Consequently, making a checkerboard pattern on an OpenGLSurface should be easy since all that's left is to automate the numpy array calculation to be passed to an OpenGLTexturedSurface (left for another PR).

Motivation and Explanation: Why and how do your changes improve the library?

Links to added or changed documentation pages

Further Information and Comments

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

make OpenGLImageMobject a subclass of OpenGLTexturedSurface
Copy link
Member

@Darylgolden Darylgolden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed the main part of the PR yet, but just some comments that jumped out at me.

@icedcoffeeee
Copy link
Collaborator Author

icedcoffeeee commented Mar 9, 2022

Update:

I managed to make moderngl textures to only take in PIL.Image.Image and let PIL handle the image processing such as resampling and image modes.

Code:

from manim import *
from manim.opengl import *
class Test(Scene):
    def construct(self):
        assets = Path("example_scenes", "assets")
        picture = assets / "1280px-Whole_world_-_land_and_oceans"
        a = OpenGLImageMobject(picture)
        b = OpenGLImageMobject(np.uint8([[0, 100, 30, 200], [255, 0, 5, 33]]))
        Group(a, b).arrange()
        self.add(a, b)

CLI: manim example.py Test -p --renderer=opengl

Output:

Test_ManimCE_v0 15 0

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've finally reviewed this: thank you very much, the code LGTM and I've also tested it successfully. I'll leave this open for just a little while longer in case anyone else wants to take another look.

@behackl behackl added new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) opengl Concerning the OpenGL renderer. labels Apr 21, 2022
@naveen521kk naveen521kk added this to the v0.15.2 milestone Apr 23, 2022
Copy link
Member

@naveen521kk naveen521kk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@behackl behackl dismissed Darylgolden’s stale review April 23, 2022 18:41

requested changes have been carried out

@naveen521kk naveen521kk merged commit 7f5624e into ManimCommunity:main Apr 24, 2022
@naveen521kk naveen521kk changed the title Implement OpenGLImageMobject Implement :class:OpenGLImageMobject Apr 24, 2022
@naveen521kk naveen521kk changed the title Implement :class:OpenGLImageMobject Implement :class:~.OpenGLImageMobject Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) opengl Concerning the OpenGL renderer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants