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

Thread: 16samples via 4 tex lookups

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    570

    16samples via 4 tex lookups

    something funky has happened to the GLSL forum, I can't see previous posts. Anyway:

    a few weeks back I was trying to generate a 'glow' by blurring a texture (the texture is a scene rendered to a pbuffer target).

    Someone was telling me that if i sample at the texel border the hardware will automatically sample average the neighboring texels effectively giving me 16 samples for only 4 texture lookups. I've messed around with it but I can't get it to work.

    Could someone please advise and/or have a conversation with me about this? I sort of need to get this working.

    Thanks.

  2. #2
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: 16samples via 4 tex lookups

    Do you have linear filter enabled?

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: 16samples via 4 tex lookups

    If your pbuffer texture is 16 bits per component, only the GeForce 6000 series can filter these textures. GeForce 5000 and all current Radeons only do nearest-sample filtering from deep texture sources.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    570

    Re: 16samples via 4 tex lookups

    Linear filter is enabled.
    my pbuffer is 32 bits per component (24 RGB, 8 A - this is what you're referring to, right?)

    If all of this is in order, what's confusing me is the value of the texture coordinates to use in the fragment shader.

    suppose I'm rendering to a 256x256 pbuffer/texture.

    that means that whatever texture coordinate comes into the fragment shader, the neighboring one should be at +/- 1/256, right? In order to sample the texel at the border (so that the board does some averaging for me) I would actually sample at +/- 1/256 +/- .5(1/256). Am I on the right track?

    oh, the board I'm using is an nVidia 6800 ultra.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: 16samples via 4 tex lookups

    my pbuffer is 32 bits per component (24 RGB, 8 A - this is what you're referring to, right?)
    That's actually 8 bits per component. But that should filter just fine.

    Are you sure that the MIN_FILTER and MAG_FILTER are both set to LINEAR _after_ you have activated the pbuffer texture object?

    Also, try rendering to a 2x2 texture. Make the top-left pixel be white, the bottomr-right black, and the other two yellow and blue. Test different values of the texture coordinates. (0.25,0.25) should be the center of one pixel (exact color); (0.5,0.5) would blend each of them equally. Try a regular (non-pbuffer) texture first; then make that work for pbuffer. Then grow the pbuffer to the size you actually want.

    Yes, for a texture of size N, every multiple of 1/N is between two texels, and every multiple of 1/N plus 0.5/N is at the center of a texel.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    570

    Re: 16samples via 4 tex lookups

    Oops, right that's what I meant
    I think the setup should be OK:
    Code :
    ping->BindRelease(false); //allow rendering to the pbuffer
    ping->MakeCurrent();	  //and make it current.
     
    m_pGLSLBlurProgram->Use();	  //use the blur.frag fragment shader
     
    glClear(GL_COLOR_BUFFER_BIT);	//clear any previous blur texture rendered to this pbuffer.
     
     
    glBindTexture(pong->TexTarget(),pong->GetTexName());
    pong->BindRelease(true); //bind the pbuffer to the texture object.
     
     
    pGL->TexParameteri(ping->TexTarget(),GL_TEXTURE_WRAP_S,GL_CLAMP);
    pGL->TexParameteri(ping->TexTarget(),GL_TEXTURE_WRAP_T,GL_CLAMP);
    pGL->TexParameteri(ping->TexTarget(),GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    pGL->TexParameteri(ping->TexTarget(),GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    I make the pbuffer context current, and after the pbuffer tex is bound i set these parameters.

    I'll try what you suggested about the 4x4 texture, thanks.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: 16samples via 4 tex lookups

    Your code is setting the texture env mode of "ping" but texturing out of "pong". However, as they likely live on the same texture target, that's probably not causing you any problems.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

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