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 4 of 4

Thread: using mipmap textures in glsl

  1. #1
    Intern Newbie
    Join Date
    May 2005
    Location
    Austria
    Posts
    49

    using mipmap textures in glsl

    Hi there,

    I need a simple sample of accessing mipmap levels of a single texture (float) inside a fragment shader. I know that I have to use the bias parameter, but it doesn't work. I created all mipmap levels for a texture 64x64 downto 1x1 with different color settings, but when I try to access another level than 0, with:

    col = texture2D( inputTexture, uv, 2.0 );

    it doesn't work.
    What's the range for the bias parameter?
    Do I have to add something in the vertex shader to make mipmap access work in the fragment shader?
    Is the mapping for the bias parameter 1.0 -> level 1, 2.0 -> level 2, etc. or something els?

    thanks,
    benjamin

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: using mipmap textures in glsl

    Quote directly from the GLSL spec
    For a fragment shader, if bias is present, it is added to the calculated level of
    detail prior to performing the texture access operation.
    so the bias value would displace the miplevel, a bias of 1 would pull it down a notch, but you can't be 100% sure it's the correct mip level.
    It's not until glsl spec 1.2 you get access to the lod functions in the fragment shader.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2006
    Location
    Moscow, Russia
    Posts
    23

    Re: using mipmap textures in glsl

    In reality, it is possible to access lod functions (texture2DLod()) in the fragment shaders. For NVIDIA cards, simply use the texture2DLod() function in the fragment shader. It will compile (and work OK, as I think, but I have not tested thus far). For ATI hardware, you have to use the GL_ATI_shader_texture_lod extension. Just add the following line to the beginning of your shader

    #extension GL_ATI_shader_texture_lod : require

    and use texture2DLod() functions in the fragment shader.

    However, I do not know any way to make something like this on other cards.

  4. #4
    Intern Newbie
    Join Date
    May 2005
    Location
    Austria
    Posts
    49

    Re: using mipmap textures in glsl

    Thanks, I'll try that one

Posting Permissions

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