Hi,

Thanks for all the replies. My problem was solved by applying some sort of 
perspective correction to my texture coordinates. 

While creating the geometry I supplied a Vec3Array instead of a Vec2Array as 
tex coord array. The tex coords that stay on short edge of the trapezoid, get a 
z value of (len_short_edge / len_long_edge) whereas the the other tex coords 
got 1.

Before sampling, the fragment shader divided the incoming tex coord vector by 
its z. (In order to obtain a texture coordinate whose z is always 1). 

I changed:
        osg::Vec2Array *t = new osg::Vec2Array;
        t->push_back(osg::Vec2(0, 0));
        t->push_back(osg::Vec2(0, 1));
        t->push_back(osg::Vec2(1, 1));
        t->push_back(osg::Vec2(1, 0));
        geom->setTexCoordArray(0, t);
to:
        osg::Vec3Array *t = new osg::Vec3Array;
        t->push_back(osg::Vec3(0, 0, 1));
        t->push_back(osg::Vec3(0, 0.33f, 0.33f));
        t->push_back(osg::Vec3(0.33f, 0.33f, 0.33f));
        t->push_back(osg::Vec3(1, 0, 1));
        geom->setTexCoordArray(0, t);

and used the following fragment shader:

uniform sampler2D sampler;
void main()
{
  vec3 texCoord = gl_TexCoord[0];
  gl_FragColor = texture2D(sampler, texCoord / texCoord.z);
}

Have a nice day,
Can

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





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

Reply via email to