[osg-users] GL_LINEAR

Guy guy at dvp.co.il
Mon Sep 8 01:41:47 PDT 2008


Hello,

 I have a problem with GL_LINEAR filtering of a float texture.

 

I created a 2D float image with the values

 

100 100

200 200

 

I stretched this image over 300x300 float buffer.

 

The results are defiantly not a linear interpolation of these values.

 

1.	The upper and lower quarters of the image are constants. The
constant value is the value that should have been only in the upper most
and lower most rows. It seems the interpolation of a pixel with 0.001
coordinates for example, takes into consideration values with negative
texture coordinates. (I can't find any other explanation).
2.	Between these quarters, the image SEEMS to be linearly
interpolated, but it is not. I would expect the differences between two
sequential pixels to be constant, but the differences are not the same.

 

 

I had this problem both with OSG1.2 and OSG2.0. I don't believe it has
anything to do with the OSG code, but with the hardware implementation.

 

I used the following code to create the texture:

 

                  image->setImage(  width, 

                                    height,

                                    1,

                                    GL_RGBA16F_ARB, 

                                    GL_RGBA, 

                                    GL_FLOAT,

                                    (unsigned char*)(new
float[4*width*height]),

                                    osg::Image::USE_NEW_DELETE);

 

 

                  osg::Texture2D* rtexture = new osg::Texture2D;

 
//----------------------------------------------------------------------
--

                  // make the texture float texture

 
//----------------------------------------------------------------------
--

                  rtexture->setInternalFormat(GL_RGBA16F_ARB);

                  rtexture->setWrap(osg::Texture2D::WRAP_S,
osg::Texture2D::CLAMP_TO_EDGE);

                  rtexture->setWrap(osg::Texture2D::WRAP_T,
osg::Texture2D::CLAMP_TO_EDGE);

      

 
rtexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

 
rtexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

                  rtexture->setSourceFormat(GL_RGBA);

                  rtexture->setSourceType(GL_FLOAT);

 
//======================================================================
==

                  rtexture->setImage(image);

                  rtexture->setTextureSize(image->s(), image->t());

                  rtexture->setResizeNonPowerOfTwoHint(false);

                  

I also tried it with 32 bit float image.

 

I'm using windows XP and nvidia 8800.

 

Any ideas how to apply a true linear mapping for textures?

 

Thanks,

 Guy.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080908/192ecb75/attachment-0002.htm>


More information about the osg-users mailing list