PDA

View Full Version : Simple convolution question



newbiecow
12-21-2012, 12:30 AM
Now, I stuck on another point of convolution.

I have written the following code:



GLubyte convolutionTable3x3[3][3]=
{
{1,1,1},
{1,1,1},
{1,1,1}
};

glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glConvolutionFilter2D(GL_CONVOLUTION_2D,GL_LUMINAN CE,3,3,GL_LUMINANCE,GL_UNSIGNED_BYTE,convolutionTa ble3x3);
glEnable(GL_CONVOLUTION_2D);
glWindowPos2i(0,0);
glDrawPixels(512,512,GL_STENCIL_INDEX,GL_UNSIGNED_ BYTE,pboImageStore);
glDisable(GL_CONVOLUTION_2D);


The buffer pboImageStore has some value set 0 and some 2.
The result seems that the stencil buffer has all been set to zero.

Even when I set


GLubyte convolutionTable3x3[3][3]=
{
{0,0,0},
{0,1,0},
{0,0,0}
};


The result seems that the stencil buffer has all been set to zero.

How can this be so? I just want to do some convolution on my stencil buffer.
Thanks in advance!

newbiecow
12-21-2012, 05:39 AM
Why nobody answers? Is this a hard question? Impossible!


Best Regards,


newbiecow

Dark Photon
12-21-2012, 07:33 AM
glConvolutionFilter2D(GL_CONVOLUTION_2D,GL_LUMINAN CE,3,3,GL_LUMINANCE,GL_UNSIGNED_BYTE,convolutionTa ble3x3);
glEnable(GL_CONVOLUTION_2D);


Why nobody answers? Is this a hard question? Impossible!

Consider one reason might be that nobody that's read your post has ever used it. A few net searches reveal this was part of the OpenGL 1.2 "imaging subset", which was always optional, and has had spotty cross-vendor support over the years. As a random sample, check out this Mesa3D thread: link (http://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg03044.html)

Try net-searching for tutorials using that function. For instance:

* Chapter 7 :Imaging with OpenGL (http://www.kmitl.ac.th/~kcnoppor/cg248/chap7.pdf)

Nowadays, consider using your own shader to do this.

newbiecow
12-21-2012, 06:34 PM
Consider one reason might be that nobody that's read your post has ever used it. A few net searches reveal this was part of the OpenGL 1.2 "imaging subset", which was always optional, and has had spotty cross-vendor support over the years. As a random sample, check out this Mesa3D thread: link (http://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg03044.html)

Try net-searching for tutorials using that function. For instance:

* Chapter 7 :Imaging with OpenGL (http://www.kmitl.ac.th/~kcnoppor/cg248/chap7.pdf)

Nowadays, consider using your own shader to do this.



Thanks, Dark Photon.

This extension feature convolution, where in my code represented as "glConvolutionFilter2D", is definitely supported by my graphics card, because I have correctly run another program with "glConvolutionFilter2D" and produced the desired effect. But where you did not notice is, here in this program, I wrote the result into the stencil buffer. Can you tell me if such feature is supported by modern graphics cards such as Nvidia or ATI, doing something of convolution and write the result into the stencil buffer. Or if I can write a shader to store the result in the stencil buffer for further rendering of the color buffer with mask operation of the former produced result in the stencil buffer.


Best Regards,


newbiecow

Dark Photon
12-21-2012, 07:16 PM
Dunno. Hopefully someone else will chime in if they've done something like this.

newbiecow
12-22-2012, 01:15 AM
Dunno. Hopefully someone else will chime in if they've done something like this.


So do you think this question is already not a biginner's one and should I post this question in the advanced opengl forum?


Best Regards,


newbiecow

Dark Photon
12-22-2012, 05:48 PM
Go for it. This is a pretty old API, but can't hurt to ask.