This is used as a default texture for the chrome animation.
Also, fix a typo in creating combiners.
TextureBuilder::Registrar installWhite("white", new WhiteTextureBuilder);
}
+class TransparentTextureBuilder : public TextureBuilder
+{
+public:
+ Texture* build(Effect* effect, const SGPropertyNode*,
+ const osgDB::ReaderWriter::Options* options);
+};
+
+Texture* TransparentTextureBuilder::build(Effect* effect, const SGPropertyNode*,
+ const osgDB::ReaderWriter::Options* options)
+{
+ return StateAttributeFactory::instance()->getTransparentTexture();
+}
+
+namespace
+{
+TextureBuilder::Registrar installTransparent("transparent",
+ new TransparentTextureBuilder);
+}
+
osg::Image* make3DNoiseImage(int texSize)
{
osg::Image* image = new osg::Image;
if ((p = getEffectPropertyChild(effect, envProp, "combine-alpha"))) {
TexEnvCombine::CombineParam calpha = TexEnvCombine::MODULATE;
findAttr(combineParams, p, calpha);
- result->setCombine_RGB(calpha);
+ result->setCombine_Alpha(calpha);
}
if ((p = getEffectPropertyChild(effect, envProp, "source0-rgb"))) {
TexEnvCombine::SourceParam source = TexEnvCombine::TEXTURE;
const Texture2D* texture = dynamic_cast<const Texture2D*>(tex);
makeChild(texUnit, "unit")->setValue(0);
if (!tex) {
+ // The default shader-based technique ignores active
makeChild(texUnit, "active")->setValue(false);
- makeChild(texUnit, "type")->setValue("white");
return false;
}
const Image* image = texture->getImage();
_whiteTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
_whiteTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
_whiteTexture->setDataVariance(osg::Object::STATIC);
+ // And now the transparent texture
+ dummyImage = new osg::Image;
+ dummyImage->allocateImage(1, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
+ imageBytes = dummyImage->data(0, 0);
+ imageBytes[0] = 255;
+ imageBytes[1] = 0;
+ _transparentTexture = new osg::Texture2D;
+ _transparentTexture->setImage(dummyImage);
+ _transparentTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
+ _transparentTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
+ _transparentTexture->setDataVariance(osg::Object::STATIC);
_white = new Vec4Array(1);
(*_white)[0].set(1.0f, 1.0f, 1.0f, 1.0f);
_white->setDataVariance(Object::STATIC);
osg::Texture2D* getWhiteTexture() { return _whiteTexture.get(); }
// White color
osg::Vec4Array* getWhiteColor() {return _white.get(); }
+ // A white, completely transparent texture
+ osg::Texture2D* getTransparentTexture()
+ {
+ return _transparentTexture.get();
+ }
// cull front and back facing polygons
osg::CullFace* getCullFaceFront() { return _cullFaceFront.get(); }
osg::CullFace* getCullFaceBack() { return _cullFaceBack.get(); }
osg::ref_ptr<osg::BlendFunc> _standardBlendFunc;
osg::ref_ptr<osg::TexEnv> _standardTexEnv;
osg::ref_ptr<osg::Texture2D> _whiteTexture;
+ osg::ref_ptr<osg::Texture2D> _transparentTexture;
osg::ref_ptr<osg::Vec4Array> _white;
osg::ref_ptr<osg::CullFace> _cullFaceFront;
osg::ref_ptr<osg::CullFace> _cullFaceBack;