I do not get it to work .... I follow these steps:
Code:
// load texture as an image
imgTexture = osgDB::readImageFile("model/BAKE_OVERRIDE.jpg");
// if the image is successfully loaded
if (imgTexture)
{
imgTexture->allocateImage(3500, 3500, 1, GL_RGBA, GL_UNSIGNED_BYTE);
// create a new two-dimensional texture object
texAvatar = new osg::Texture2D;
// set the texture to the loaded image
texAvatar->setImage(imgTexture);
}
node->getOrCreateStateSet()->setTextureAttributeAndModes(1, texAvatar,
osg::StateAttribute::ON);
node->getOrCreateStateSet()->addUniform(new osg::Uniform("editedMap", 1));
// tell the camera to use OpenGL frame buffer objects
//getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
getCamera()->attach(osg::Camera::COLOR_BUFFER1, imgTexture);
and shder code:
Code:
uniform sampler2D baseMap;
uniform sampler2D editedMap;
uniform vec3 interPos;
varying vec4 color;
varying vec2 Texcoord;
varying vec3 position;
void main( void )
{
float radio = 3.0;
vec3 a = position - interPos;
float dist = sqrt((a.x*a.x)+(a.y*a.y)+(a.z*a.z));
vec4 paintColor = vec4(1.0,0.0,0.0,1.0);
if(dist<radio){
gl_FragData[0] = texture2D( baseMap, Texcoord ) * color + paintColor;
gl_FragData[1] = paintColor;
}
else{
gl_FragData[0] = texture2D( baseMap, Texcoord ) * color;
}
}
I comment FBO activation line because I'm using OSG on Qt and gime me errors
activating this option...
I check to see if there are changes in the texture storing the image, but there
aren't:
Code:
osgDB::writeImageFile(*texAvatar->getImage(),"koko.jpg");
Thank you!
Cheers,
Aitor
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32463#32463
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org