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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to