View Full Version : 16samples via 4 tex lookups
12-29-2004, 10:24 AM
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.
12-30-2004, 10:06 AM
Do you have linear filter enabled?
12-30-2004, 01:09 PM
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.
01-03-2005, 06:13 AM
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.
01-04-2005, 06:38 PM
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.
01-05-2005, 05:55 AM
Oops, right that's what I meant :p
I think the setup should be OK:
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.
pong->BindRelease(true); //bind the pbuffer to the texture object.
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.
01-05-2005, 08:46 PM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.