Oldest known version of this page was edited on 2009-03-29 19:56:53 by DintHer []
Page view:
Articles - Setting a GLScene object transparency
Texture transparency covers a wide range of applications. In this article I want to describe how to handle textures with and without an alpha layer.
Standard transparent texture without alpha layer:
Material.BlendingMode := bmTransparency;
Material.Texture.Disabled := False;
Material.Texture.TextureMode := tmModulate;
Material.FrontProperties.Diffuse.Alpha := 0.5
gives 50% transparency
Note that the TextureMode is set to tmModulate. For sprites this seems to be the only way that the diffuse.alpha property is taken into account.
Texture using alpha layer
A normal image typically contains the three color channels Red, Green and Blue. Per pixel it uses one byte for each color channel and images like this are often referred to as 24 bit images. There are also 32 bit images which have an alpha channel in addition to the three color channels. The alpha channel basically defines how transparent the pixel will be against it's background. Amazing effects can be achieved with properly made alpha transparent bitmaps.
32 bit BMP imgages, 32 bit PNG images and 32 bit TGA images all contain alpha information. Only TGA images are natively supported in GLScene. Make sure to include the TGA unit in your uses clause. GLScene also has special requirements for the size of the TGA image. The width of the image in pixels must be a multiple of 4. eg: 4, 8, 12,16,20,24 and so on... The height of the image does not have such requirement. Internally GLScene will resize this image into a Power of Two (POT) image eg: A width and height of 2,4,8,16,32... pixels.
Material.BlendingMode := bmTransparency;
Material.Texture.Disabled := False;
Material.Texture.TextureMode := tmReplace;
Texture using alpha layer AND general transparency
As above but this time a TextureMode of tmModulate is to be used
Material.BlendingMode := bmTransparency;
Material.Texture.Disabled := False;
Material.Texture.TextureMode := tmModulate;
Material.FrontProperties.Diffuse.Alpha := 0.5 gives 50% transparency in
-