Hi,

I'm still not sure what you want to save... Just the texture data?

You can get an osg::Image for any or all of the RTT textures. Have a look at osgmultiplerendertargets.cpp example. Read below the line:

// we can also read back any of the targets as an image, modify this image and push it back

You don't have to modify and send back, but in the callback you can just save the image to disk.

cheers
jp

On 14/10/10 14:23, Aitor Ardanza wrote:
Hi,

The idea is to capture the mouse picking in the model and paint on. We can see 
a red circle in the model and the result of RTT in the quad. I guess it will 
catch part of the models arm..
[Image: http://img844.imageshack.us/img844/9583/kokkp.jpg ]
Whith these shaders I can paint red circles:
Vertex Shader

Code:
varying vec2 Texcoord;
varying vec3 ViewDirection;
varying vec3 LightDirection;
varying vec3 Normal;
varying vec4 color;
varying vec3 position;

void main( void )
{
     gl_Position = ftransform();
     Texcoord    = gl_MultiTexCoord0.xy;
     position = gl_Vertex.xyz;

     vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;

     ViewDirection  = normalize(- fvObjectPosition.xyz);
     LightDirection = normalize(gl_LightSource[0].position.xyz - 
fvObjectPosition.xyz);
     Normal         = normalize(gl_NormalMatrix * gl_Normal);

     float fNDotL    = dot( Normal, LightDirection );

     float NdotL = max(dot(Normal, LightDirection), 0.0);
     vec4 diffuse = NdotL * gl_FrontMaterial.diffuse * 
gl_LightSource[0].diffuse;

     vec4 ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
     vec4 globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient;

     vec3  fvReflection     = normalize( ( ( 2.0 * Normal ) * fNDotL ) - 
LightDirection );
     vec3  fvViewDirection  = normalize( ViewDirection );
     float fRDotV           = max( 0.0, dot( fvReflection, fvViewDirection ) );
     vec4 specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * 
pow(fRDotV,200.0);

     color =  diffuse + globalAmbient + ambient + specular;
}


Fragment Shader

Code:
uniform vec2 textCoord;
uniform sampler2D baseMap;
uniform vec3 interPos;

varying vec3 Normal;
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);
     vec4 col = texture2D( baseMap, Texcoord ) * color;
     if(dist<radio){
         gl_FragData[0] = texture2D( baseMap, Texcoord ) * color + paintColor;
         gl_FragData[1] = paintColor;
     }
     else{
         gl_FragData[0] = texture2D( baseMap, Texcoord ) * color;
         gl_FragData[1] = vec4(1.0,1.0,1.0,1.0);
     }
}


The question is, is there any way to store gl_FragData [1] data  to get an 
image like texture model and save it in the aplication?

Thank you!

Cheers,
Aitor

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support.

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to