Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Bilinear interpolation texture rendering

  1. #1
    Intern Contributor
    Join Date
    Aug 2000
    Location
    Haifa, ISRAEL
    Posts
    82

    Bilinear interpolation texture rendering

    How do make my own fragment shader that draw a smooth texture?
    I know I have to read 4 texels and interpolate them according to the texture coordinates and the value of the 4 texels but don't know the details.
    In general I wan't to make my own filter.

    Many thanks,

    Yossi

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    555

    Re: Bilinear interpolation texture rendering

    Here's a Cg function that does bilinear filtering of a rectangular texture.

    Code :
    float4 texRECTBilinear(samplerRECT texture, float2 uv)
    {
        float2 weight = frac(uv);
     
        float4 bottom = lerp(texRECT(texture, uv),
                             texRECT(texture, uv + float2(1, 0)),
                             weight.x);
     
        float4 top = lerp(texRECT(texture, uv + float2(0, 1)), 
                          texRECT(texture, uv + float2(1, 1)), 
                          weight.x);
     
        return lerp(bottom, top, weight.y);
    }
    Should be fairly simple to translate to GLSL.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •