Hi,

I'm trying to implement a simple model painter. I detect the intersection with 
the mouse and loaded model, and I applied a red color to the area:

[Image: http://img818.imageshack.us/img818/9672/painting.jpg ]

You can see the selected point on the texture image.  I edit the texture image 
with Qt. 
But I want to save all changes to a new texture. It can be done in the fragment 
shader? I can think ...

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

varying vec4 color;
varying vec2 Texcoord;
varying vec3 position;

void main( void )
{
    float radio = 8.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_FragColor = texture2D( baseMap, Texcoord ) * color + paintColor;
        //editedMap = texture2D( baseMap, Texcoord ) * color + paintColor;
    }
    else{
        gl_FragColor = texture2D( baseMap, Texcoord ) * color; 
        //editedMap = texture2D( baseMap, Texcoord ) * color;   
    }
    
}



Thank you!

Cheers,
Aitor
Code:




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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to