[osg-users] How to set the transparency for one of my terrain layers?

Adrian Jelffs adrian.jelffs at makai.com
Mon Feb 5 19:19:18 PST 2018


Hello,

I am using osgEarth to overlay a survey map onto another map. The survey image is generated as a GeoTiff and draped across the base map. I would like the areas that have no data (white) to be transparent. How do I do this? So far my code is like this but it does nothing at all. 


Code:
GDALOptions gdalOptImg;
gdalOptImg.url() = url;
gdalOptImg.noDataValue() = 0;

ImageLayerOptions layerOptions(name, gdalOptImg);
osg::Vec4ub *transparentColor = new osg::Vec4ub();
transparentColor->r() = 255.0f;
transparentColor->g() = 255.0f;
transparentColor->b() = 255.0f;
transparentColor->a() = 1.0;

layerOptions.transparentColor() = *transparentColor;
layerOptions.name() = name;
imageryLayer = new ImageLayer(layerOptions);




I have tried a trillion different combinations but none of them seem to do anything.

If you reply please provide a code example, or links to where I can read more information about this, not just an API. Some source code is worth a thousand words :)

Many thanks for your help!
[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72935#72935







More information about the osg-users mailing list