Although Python has gain significant popularity in many fields of computer science, the computer graphics community seems to reject this trend. Indeed, in a field where performance is almost number one priority, Python seems a bit clumsy for CG applications. However, I think it is still possible for Python to play an important role in this field. First of all, graphics developers can still benefit from the incredible Python ecosystem. Python can be equipped with existing functionalities rather easily, whereas for C/C++, it may take a long time to install packages and make use of them. Second of all, Python scripts are cross-platform, so it almost takes no effort to transfer the program form one machine to another. For other languages, this process may require additional configuration and modification to the code. Therefore, Python can be a helpful tool for graphics research or fast prototyping.

This series is about writing simple graphics program with Python. It makes use of PyOpenGL very frequently. For GL programming style, I favor the modern OpenGL approach preferred by learnopengl, therefore readers are suggested to visit that site at first.

The source code of this series can be found on Github.

  • PyCG 1: Introduction

    Although there are a handful of tools for visualizing data in Python, nothing can come close to OpenGL regarding performance and interaction. As for myself, I have found two cases where I have to use OpenGL inevitably: there was once when I need to write a demonstration of solving partial differential equations to animate liquid surface; and there was another time when I needed to build an interactive program that shows what it is like if a projector is presenting its image on a spherical surface. I will elaborate on these two cases during this series of tutorials.

  • PyCG 3: Rendering Textures and Text

    It is very common to render images and text in OpenGL programs. In OpenGL, both tasks can be done using textures. With the help of numerous helpful Python packages, it is much easier to load images under PyOpenGL environment.

  • PyCG 4: Spherical Projection

    I think most of you may have heard of the concept of dome theaters. Basically, the screen of these type of theaters are not a flat plane, but instead a sphere-like surface.

    A dome theater

    Usually they use special projectors to generate correct images on the screen. But have you ever wondered what it is like if we use a normal projector on one of these screens? With OpenGL and Python, we can develop a simulation program for this scenario very quickly.

  • PyCG 5: Inverse Kinematics

    Have you ever wondered how robotic arms control each of its segments so that its tip locates at an precise location? This is exactly one of the topics of inverse kinematics. Inverse kinematics is the mathematical process of recovering the movements of an object in the world from some other data, such as a film of those movements, or a film of the world as seen by a camera which is itself making those movements. In this case, the data we know is where the tip of the arm should be, and we would like to find out a way to position the arm segments correctly.

    Video capture of the demo
  • PyCG 6: Cloth Simulation

    The computer graphics lecture at Berkeley constantly uses awesome cloth simulation videos (e.g. this one) to demonstrate the beauty of computer graphics, and I was truly absorbed by it. As it turns out, the mathematics behind it is not very difficult to understand, and it can be fairly easy to build a simple simulation.

    Video capture of the demo. The video is sped up five times.
  • PyCG 7: Simple Ray Tracing

    Ray tracing is a way of rendering photo-realistic photos. I made use of this concept in this post to compute the image of projecting on a spherical screen. This time, let us build a simple ray tracer with Python. This time, OpenGL is not needed.

    Output of the demo
  • PyCG 8: Audio Oscilloscope

    Oscilloscope music is a very unique music genre, which is mainly developped by Jerobeam Fenderson (see the video below as an example). The idea is that you can not only listen to it, but you can also see it visually. Indeed, if you pass the audio signal into an oscilloscope, the fancy patterns cleverly designed by the artist will be revealed. This time, let us find out how to visualize the wave form given an oscilloscope music.