shader texture calls with varying variables

Discussion in 'Rendering Technology and APIs' started by nirradi, Jun 23, 2009.

  1. nirradi

    Newcomer

    Joined:
    Apr 1, 2009
    Messages:
    30
    Likes Received:
    0
    hello, knowers of all things shady.

    please answer me this: a texture coordinate can be assigned into a varying variable in a vert. program and then used in the fragment program, when the fixed part of the pipeline calculates the level of detail, does it calculate it according to the derivatives of that specific varying variable?

    for example, if i decide to assign a texcoord like this in a vertex program:

    someTexCoord = gl_MultiTexCoord0.xy * scale;

    and then sample during the fragment stage

    float result= texture2D(samplerName, someTexCoord).x;

    so how does the lod look like? is it also scaled by scale?
    can anyone xplain pls? ty.
     
  2. Xmas

    Xmas Porous
    Veteran Subscriber

    Joined:
    Feb 6, 2002
    Messages:
    3,309
    Likes Received:
    139
    Location:
    On the path to wisdom
    The LOD calculation is based on the values passed as texcoords to texture2D(), so the LOD is indeed affected by scale. GPUs generally processes (multiple) blocks of 2x2 fragments (aka quads) in parallel and use the difference between the texture coordinates of those fragments to calculate the LOD for the quad.
     
  3. nirradi

    Newcomer

    Joined:
    Apr 1, 2009
    Messages:
    30
    Likes Received:
    0
    thanx, thats what i suspected, but then that wouild mean that of the original texture was mipmapped with lod = 0.5 (texture is magnified) and the scale was say 64, then the scaled texture will always be minified.

    i'm not so sure if thats what is intended when scaling the texture coordinates - to tell the truth i'm not sure what the significance of this scaling actually is - that would stretch the original texcoords at vertice points, say from 0..1 to 0..64
     
  4. Xmas

    Xmas Porous
    Veteran Subscriber

    Joined:
    Feb 6, 2002
    Messages:
    3,309
    Likes Received:
    139
    Location:
    On the path to wisdom
    Which means that the texture will be repeated 64 times between the vertices, assuming the S and T wrap modes are set to GL_REPEAT. This means each repetition of the texture is a lot smaller on screen, i.e. minified. It all makes perfect sense.
     
  5. nirradi

    Newcomer

    Joined:
    Apr 1, 2009
    Messages:
    30
    Likes Received:
    0
    ok i'm relieved it makes sense :) ty
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...