OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

Tips - How to vary transparency on a texture using the Alpha Channel


To change the transparency on different parts of a texture you can use an alpha channel. An example of alpha channel transparency is:
 
image
 


where you can see the edge of the apple has changing degree of transparency.
To use alpha channel transparency you need an image that includes an alpha channel. TGA and 32 Bit BMP files both support alpha channels but JPG format doesn't. GIMP and Photoshop both allow the editing and displaying of the alpha channel. For example in GIMP :
 
image
 


To add an alpha channel in Gimp 2:

1. Load the image in Gimp you want to add the alpha channel to
2. Right click on the image then select layer, transparency and add alpha channel
3. Right click on the image then select layer, mask, 'add layer mask'
4. Right click on the image then select layer, mask then 'show layer mask'
This will display a blank image. In this image use black for high transparency and white for no transparency
 
image
 


5. Right click on the image then select layer, mask then deselect 'show layer mask'. This will display the image with the transparency.
6. Save the image in TGA format so that the alpha channel will be saved.

In GLScene a texture with an alpha channel will be displayed transparently with the following texture settings:

blendingmode is set to bmTransparency
texturemode is set to tmModulate
imagealpha is default

To see a demo that uses the alpha channel check out the TextureTB demo in CVS AdvDemos. Some quick steps to show alpha transparency are:
1. In the TextureTB demo click on the 'RGB' button then click on 'Import Image' and load the main texture (eg GLScene.bmp in the Demos media directory)
2. Click on the 'Alpha' button then click on 'Import Image' button to load the grayscale bitmap that defines the transparency. White is non transparent while black is transparent. For example Flare1.bmp in the CVS demos media directory. You should now see a cube that has the main texture with different degrees of transparency. You can export the main texture with its alpha channel as a single file by clicking on the 'export image' button.

Note that in the TextureTB demo textures must be to the power of 2 in length and width eg 32 x 64 , 128x128 , 16 x 256 and so on.


 
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0348 seconds