User Tools

Site Tools


Lab 7 - Various Special Effects

Before You Start

Effect Room

In this exercise you'll start with an empty room and then add some “sparkly” special effects to make it more engaging.

  1. Creating and adding an animated texture
    Find the function create_lightbeam and add the following code to it:
            beammaterial = Material()
            beammodel = loader.loadModel("Models/Textures/wall_door_beams.egg")
            beam = self.parent.attachNewNode("beam")
            beam2 = self.parent.attachNewNode("beam2")

    But note that wall_door_beams.egg doe snot exist yet! You have to create this animation from a couple of still frames in your texture folder. Go into the texture folder and run the following command egg-texture-cards -fps 2 -o wall_door_beams.egg wall_tanned_door_beams3.tif wall_tanned_door_beams4.tif. This will create a card that switches between the two given textures at the rate of 2 frames per second. If this is successful, then you should see the animated beams in the room. Experiment with the frame rate.

  2. Creating projected light
    Now you want to create the lit up window pattern on the floor, as if it's light coming through the broken window panes. You can do this by setting up a texture projector that essentially projects a texture with a perspective projection from somewhere outside the window and onto the floor panel. Add the following code to the create_projectedlight function:
            projector = self.parent.attachNewNode(LensNode('projector'))
            lens = PerspectiveLens()
            lightimage = loader.loadTexture("Models/Textures/wall_tanned_door_light.tif")
            lightts = TextureStage('lightts')
    1. The projector is correctly set up here, but there are a few things you still need to do to make this work. First of all, you have to create the texture that you want to project on the floor. Here we call it wall_tanned_door_light.tif. What should this texture look like? Study the screen shot above and try to understand what kind of texture you need. Then start with a copy of wall_tanned_door.tif and change it into the right texture for the light pattern. Try it out.
    2. You may notice that the texture doesn't blend with the floor texture. You need to set the blending parameter for the texture stage for that to happen, using the method setMode(<blend mode>) method on the texture stage. Try figuring out what blend mode you need to use for this to come out right.
  3. Crating particles
    Add the following code to the create_particles funtion to get a particle generator installed:
            self.p = ParticleEffect()

    This already comes with a small particle system called “ar.ptf”, make sure you see those particles in your scene. Then see if you can create a new particle system using the Panda 3D Particle Panel (it's under Samples/Particles) and insert that system instead. Can you make something that looks and behaves like flies?

  4. Creating a bloom effect
    The following code may not work on all graphics cards, since they have to support programmable shaders. You should get warning messages on the console about this as well as not seeing the actual effect. Try adding the following code to the create_bloom function:
            self.filters = CommonFilters(,   

    You can play with the “size” value, which can also be “small” and “medium”. Experiment with other filters as well, such as blur. You can look up all the common filters on the Common Image Filters page in the manual.

/var/www/ · Last modified: 2024/04/29 13:33 by

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki