Rendering Attributes

The appearance of any RasterNode can be modified by a number of common attributes. These attributes work for ImageNodes, VideoNodes, WordsNodes and CameraNodes. The rendering.py sample shows masking and blend modes in action.

Masking

The maskhref attribute along with its companions maskpos and masksize add a separate alpha mask to the node that can be moved and resized. This mask is used in addition to the transparency channel of the node image itself. The sample images to the right show the original, a mask and the resulting masked image.

Blend Mode

Setting the blendmode attribute allows interesting compositing effects. Allowed values are:

  • blend: Standard blending.
  • add: The brightness of each pixel is the sum of the node's brightness and whatever was on the screen already at that point.
  • min: The brightness of each pixel is the minimum of the node's brightness and whatever was on the screen already at that point.
  • max: The brightness of each pixel is the maximum of the node's brightness and whatever was on the screen already at that point.

Mipmapping

Mipmaping can be used to reduce rendering artifacts when nodes are displayed at a smaller size than the original image and is especially useful when a node changes position. When used for large images, mipmaping can also significantly help performance. It can be turned on and off using the mipmap attribute. libavg mipmaps are generated automatically when the image is first transferred to the GPU.

Color Adjustments

The attributes contrast, intensity and gamma change the colors of a node. Each attribute takes a triple of values - one value each for the red, green and blue color components. The corresponding photoshop controls are brightness/contrast and levels.

Performance Considerations

Masking and color correction are performed by a GPU shader, since they would be too performance-intensive for standard CPU code. Standard graphics cards are more than capable of handling the load this produces. Care must be taken, however, for low-end chipset graphics processors.

Changing any of the attributes at runtine incurs no additional cost.

rgb24-64x64.png (2 kB) coder, 11/10/2014 22:55

mask.png (2.3 kB) coder, 11/10/2014 22:55

masked.png (7.7 kB) coder, 11/10/2014 23:00