Tags

, , , , , , , , , , , , ,

PyMovieStudio is a Python application for making movies. We can record a movie using up to four webcams, edit the movie and add some audio. And, of course, add some special effects!

Up until now, the special effects consisted of crosshairs to track the killer robot, as it dealt carnage to some Lego policemen at a woodland hospital:

PyMovieStudio_EffectsMovie3

The crosshairs are simply drawn upon each frame of our movie.

But what about some special effects that make use of the OpenGL graphics library, that can be rendered in a 3D environment? No problem. Let’s add a fog effect to PyMovieStudio!

Here’s the settings we have at our disposal, in the appsettings.ini file:

FogIntensity=0.5
FogDelay=2

The FogIntensity setting controls the collective level of the red, green and blue colours of our fog. It can be any value above 0.0 and below 1.0. A value of 0.0 will result in no fog.

The FogDelay setting controls the gap between a Fog Intensity Shift. What the hell is a Fog Intensity Shift? you rightly ask. It is a small change in the fog intensity, resulting in a more pleasing fog effect.

Okay, now that we have the settings at our disposal, how does the OpenGL fog effect work? Well, here it is:

# apply fog
def fog(self, fog_intensity):
    glFogi(GL_FOG_MODE, GL_LINEAR)
    glFogfv(GL_FOG_COLOR, (fog_intensity, fog_intensity, fog_intensity, 1.0))
    glHint(GL_FOG_HINT, GL_NICEST)
    glFogf(GL_FOG_START, 1.0)
    glFogf(GL_FOG_END, 12.0)
    glEnable(GL_FOG)

Pretty simple, and you can see how our FogIntensity setting is applied to the fog colour.

Now, I did mention that the fog is rendered in a 3D environment, rather than drawn on each frame of the movie. So how do we preserve the fog intensity values so that they can be replayed? A log file, that’s how:

0,0.51
1,0.51
2,0.51
3,0.52
4,0.53
5,0.54
6,0.54
7,0.54
8,0.54

As you can see, the first frame of our movie – frame 0 – has a fog intensity value of 0.51. The last frame in our log file sample is frame number 8, which has a fog intensity value of 0.54.

Armed with our log file, the movie can be screened again and again with the exact same fog effect.

PyMovieStudio is now able to render special effects in an OpenGL 3D environment. The possibilities are endless!

Here’s PyMovieStudio rendering fog in my killer robot movie:

If you want to make your own movies, or play about with the killer robot movie, check out the PyMovieStudio Wiki.

The destructive mechanoid has only served to invoke memory of my own violent tussles. Damn that blackbird.

Ciao!