Semester 2, Week 03 Post - 62firelight/manimRT-490 GitHub Wiki

What's New

  • Informally investigated the possibility of switching to OpenGL
  • Added comments to all methods
  • Put some more thought into the methods and parameters that I was using

Informal OpenGL Investigation

OpenGL Resources

Doing some investigating into OpenGL as it could improve rendering speeds...

The main resources for OpenGL are located at this links. Unfortunately, aquabeam.me does not seem to be active anymore, but there are still archived links from the Wayback Machine.

https://slama.dev/manim/opengl-and-interactivity/

https://web.archive.org/web/20221208125336/https://www.aquabeam.me/manim/

https://www.youtube.com/watch?v=KeXBLPC1tns

Below is the intro scene from the slama.dev link. It is indeed awesome.

image

OpenGL Testing

The example scenes from slama.dev work without any issues. I wanted to try rendering a 3D scene with OpenGL.

I did some quick testing by creating a 3D scene with one Mobject that gets added to the scene as a static object (add method) or animated object (play method).

Adding a sphere to the scene as a static object did not result in an error so the scene was successfully rendered in approximately 30 seconds on my laptop (see below image). I was able to move the camera around, albeit at a slower frame rate than with the 2D objects in the previous examples. The sphere looks a bit different than it does in Cairo though. Changing the color parameter doesn't seem to affect the sphere's appearance.

image

Animating the sphere caused an error for each of the animations I tried (GrowFromCenter, FadeIn). These animations work fine in Cairo.

I also tried using other objects besides a sphere (Arrow3D, NumberPlane) but I encountered errors when trying to render them as both static and animated objects.

From what I can tell, the 3D objects don't seem to work as seamlessly as they do with the Cairo renderer. I might have to tinker with the source code to actually make it work. The below image (from aquabeam.me) has some useful info relating to this. I should also consider searching around the Manim community (GitHub repo, Discord) to see if anyone has encountered the same issue.

image

3D Scene Examples with OpenGL

I found some more example scenes from this file in the Manim Community repo.

Below is what ThreeDMobjectTest looks like:

image

Questions

  1. How acceptable is it to repeat stuff from the interim report in the final report?
  2. When to capitalize mobject? I'm thinking of capitalizing only when referring to it as a Python class and not capitalizing anywhere else.
  3. Probably an obvious question, but should the distance parameter in the Ray3D mobject class be renamed to length instead? It determines how long the ray will be when created.
  4. What syntax is preferred when using the methods for calculating the vectors in the Phong illumination model?

For example, should the method be used as the direction for a Ray3D mobject?

reflected_vector = Ray3D(first_hit_point, ray.get_reflected_vector(0, camera))

Or should the method be called to instantly get a Ray3D mobject?

reflected_ray = ray.get_reflected_ray(0, camera, color=GRAY)

Or what about having both methods for both cases?

  1. For the second type of syntax (instantly getting a Ray3D mobject), what should the naming scheme be? E.g., get_reflected_vector_mobject, get_reflected_mobject?

What's Next

  • Ensure code is consistent and cohesive in terms of parameters and formatting
  • Develop full animation video for introducing the idea of ray tracing
  • Create tutorial documentation that introduces ManimRT and how to use it
  • Think about evaluation