[osg-users] Why is my texture flipped when written to .osg file?
robert.osfield at gmail.com
Mon Mar 2 01:34:24 PST 2009
On Sun, Mar 1, 2009 at 4:13 PM, BjÃ¶rn Giesler <osgforum at tevs.eu> wrote:
> I'm writing a textured model to a .osg file, referencing a jpg file as the texture. In my program, this renders perfectly, but when I open the resulting file with osgviewer, the texture is upside-down. I've tried experimenting with osg::Image::setOrigin(), but that doesn't change anything.
> Can someone tell me what I'm doing wrong?
Which way up the image will be when textured onto a geometry is down
to the texture coordinates on the geometry. The OSG's itself stikes
to OpenGL conventions which has the origin at the lower left by
default, while most image formats include jpeg have an origin at the
top left, because of this difference the OSG image plugins typically
do a flip to make sure the image data is the same way round to the
For moving data on typically doesn't want to do this flip as it's
expensive to do for every new movie frame, so instead we use the
Image::set/getOrigin() to help tell the app which way up the image is
and to adjust the tex coords to handle this.
In your case I can't really say what exactly is happening - I don't
know how you've loaded the jpg file, I don't know how you've set up
your scene graph...
More information about the osg-users