Panda3D Manual: Common Image Filters
<<prev | top | next>> |
## Common Image Filters Note: the following information applies to Panda version 1.5.0 and beyond. It does not apply to older versions of Panda3D. The purpose of class CommonFilters is to make it easy to set up a number of common image postprocessing operations. Currently, the image postprocessing operations supported by class CommonFilters is: Bloom Filter - creates a glowing halo around bright objects. Cartoon Inker - draws black lines around 3D objects. We expect this list to grow rather substantially over the next year or so. ## Basic Setup The first step is to create an object of class CommonFilters. Pass in a pointer to your window, and your 3D camera:
    filters = CommonFilters(base.win, base.cam)
This will have no effect until you enable a filter (instructions below.) Once a filter is enabled, class CommonFilters will reconfigure the Panda3D rendering as follows: It will render the scene into an offscreen buffer, using the camera you provided. It will remove the scene from the specified window, and replace it with a fullscreen quad. The quad will be textured with the scene, plus a shader that implements whatever filter you have selected. If all goes well, the net effect is that your scene will continue to appear in your window, but it will be filtered as you specify. ## What if the Video Card can't handle it? If the video card is not capable of implementing your filters, then all filters will be removed and the filter-enabling function will return False. Otherwise, filter-enabling functions will return True. ## The Bloom Filter The bloom filter causes bright objects to have a glowing halo around them. To enable a bloom filter, use `setBloom`. To disable, use `delBloom`:
    filters.setBloom( ... options ...)
    filters.delBloom()
The bloom filter works as follows. First, it renders the scene into a texture. It also asks the renderer to render any glow-maps into the alpha channel of the texture. After rendering the scene, it generates a second copy of the scene which has been darkened until only the brightest pixels are visible, and all the others go to black. It then blurs that texture, yielding soft halos where the bright pixels used to be, and black everywhere else. It then adds the soft halos back onto the scene in the window. The bloom filter has many keyword parameters: blend - The bloom filter needs to measure the brightness of each pixel. It does this by weighting the R,G,B, and A components. Default weights: (0.3,0.4,0.3,0.0). You should assign a nonzero weight to the alpha channel if you want the glow map to have an effect. mintrigger - Minimum brightness at which a halo is generated. Default: 0.6 maxtrigger - Maximum brightness at which the halo reaches peak intensity. Default: 1.0 desat - Degree to which the halo is desaturated. Setting this to zero means the halo is the same color as the bright pixel. Setting it to one means the halo is white. Default: 0.6 intensity - An adjustment parameter for the brightness of the halos. Default: 1.0 size - Adjusts the size of the halos. Takes a string value: "small", "medium", or "large". The reason that this is a discrete value and not a continuous one is that the blur operation involves downsampling the original texture by a power of two. Default: "medium" ## The Cartoon Inking Filter The cartoon inking filter causes objects to have black lines around them. To enable a cartoon inking filter, use `setCartoonInk`. To disable, use `delCartoonInk`:
    filters.setCartoonInk( ... options ...)
    filters.delCartoonInk()
The cartoon inking filter works by rendering a camera-space normal into an texture. Then, a postprocessing filter does an edge-detect algorithm on the camera-space normal texture. The filter has the following keyword parameters: separation - distance in pixels, controls the width of the ink line. Default: 1 pixel.
<<prev | top | next>> |