Part of the Khronos Group

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
    Haifa, ISRAEL

    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,


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

    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)),
        float4 top = lerp(texRECT(texture, uv + float2(0, 1)), 
                          texRECT(texture, uv + float2(1, 1)), 
        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