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

Thread: vertex textures and glsl

  1. #1
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    vertex textures and glsl

    guys, i'm having a whale of a time getting acceleration with texture fetches in my vertex shaders

    to be clear, it works, but it's not accelerated.

    i've got:

    nearest filtering

    clamp wrap

    tried these formats:
    GL_LUMINANCE_FLOAT32_ATI
    GL_RGBA_FLOAT32_ATI
    GL_RGBA32F_ARB
    GL_LUMINANCE32F_ARB

    using texture2DLod(s, xy, 0.0) for sampling.

    it seem some folks have had success with fiddling with the texture format, but try as i might i can't get it to budge.

    the opengl vertex texturing demo from nvidia works nicely, but uses nv_vertex_program3.

    3dlabs validate says all is ok. infologs are clean. no opengl errors either :-)

    p.s. it strikes me as incredibly freaky to need a 3rd party tool to tell me what my own compiler should :-)

    system:
    geforce 6800 gs
    forceware 82.12 and 83.90 (beta, no official drivers exist for this board, yet)
    glsl 1.10 via cg 1.3 compiler
    windows xp sp2

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: vertex textures and glsl

    On GeForce 6600 I used GL_LUMINANCE_FLOAT32_ATI, GL_NEAREST filtering but I used texture2D instead of texture2DLod.

    My hints for you:
    1. use texture2D instead of texture2DLod
    2. do not use mipmaps on this texture (you said you use nearest filtering - I assume you don't have mipmaps)
    3. make sure you have set GL_NEAREST to both min and mag filter

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: vertex textures and glsl

    thank you for the hints, k_szczech.

    it doesn't seem to make any difference. i've tried all sorts of permutations with 2D: lod/no lod, and mips/no mips, even fiddled with texenv (GL_REPLACE seemed reasonable, but it doesn't seem to matter).

    vertex texture fetching works like a charm in hlsl and cg on this board with these drivers, so i'm betting it's a glsl implementation thing with the cg compiler... or something.

    just updated to the beta 83.90 drivers to no avail. ah well, such is life.

    by the way, i'm just rendering a single spinning quad :-)

    p.s. i'm using the 2.0 core entry points: would that make a difference?

  4. #4
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: vertex textures and glsl

    This is how I create texture:
    Code :
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_FLOAT32_ATI, sizeX, sizeY, 0,
                   GL_LUMINANCE, GL_FLOAT, data);
    This is how I use it from vertex shader:
    Code :
    vec4 pos = gl_Vertex;
    pos.y += texture2D( myTexture, myTexCoord).r;
    gl_Position = gl_ModelViewProjectionMatrix * pos;
    Everything else is left default (so wrap is GL_REPEAT). As you can see I really don't care about anything except that I turn off texture filtering.

    It makes no difference what kind of texenv or blending you use - there are per-fragment operations.

    I use OpenGL 1.5 entry points but this should really make no difference.

    My next hint - check if you have your sampler2D uniform variable initialized properly - if you accidentally fetch sample from wrong texture unit in your vertex shader then you may end up trying to fetch from texture not supported by hardware.

    If it's not the case then simplify your shader/application to minimum. Such approach worked for me when I ran into ATI's linker bug recently (I posted it 2 days ago).

    If it still doesn't help then I'm gonna ask you to post some fragments of code - maybe this way I would be able to help.

    Thee solution is out there...

    PS. I've just checked clamping - works with GL_REPEAT, GL_CLAMP and GL_CLAMP_TO_EDGE on GeForce7800

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: vertex textures and glsl

    My next hint - check if you have your sampler2D uniform variable initialized properly - if you accidentally fetch sample from wrong texture unit in your vertex shader then you may end up trying to fetch from texture not supported by hardware.
    bingo. glGetUniformLocation isn't returning what i first assumed. you've earned your keep my friend. i'm going to tinker with this some more and i'll post results later.

    by the way, does texture2DLod throw you into software on that 6600?

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: vertex textures and glsl

    well, it seems this has all been an unfortunate chain of blunders and missteps on my part. first was forgetting to convert my unicode names to ansi for glGetUniformLocation, and second was assuming that opengl would raise an error on supplying a -1 location to glUniform*, which it quietly ignores (sigh).

    for the record, this works fine with all the texture formats listed (and perhaps others), with mipmaps or no, clamp or repeat wrap modes, and with texture2D and texture2DLod.

    thanks

    edit: this document outlines vertex texture use on nvidia hardware with gl 2.0:
    http://download.nvidia.com/developer....0_Support.pdf

Posting Permissions

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