[osg-users] GL_LINEAR

Guy guy at dvp.co.il
Mon Sep 8 02:33:25 PDT 2008


Thanks.

-----הודעה מקורית-----
מאת: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users-bounces at lists.openscenegraph.org] בשם J.P. Delport
נשלח: Monday, September 08, 2008 12:16 PM
אל: OpenSceneGraph Users
נושא: Re: [osg-users] GL_LINEAR

Hi,

AFAIK sampling in OpenGL occurs at pixel centers. That would explain 
your "quarter" effect.

As for the inconsistency in the center of the output, I can only speculate.

Things I would try:
Use TextureRectangle instead of normal texture (coordinates are then 
closer to pixel values)
Try various output sizes to see if it is a sampling/math problem in the 
card implementation.
Use a shader to do the sampling to see what is going wrong where.

jp

Guy wrote:
> 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.
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.

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



More information about the osg-users mailing list