纹理内存中具有大内核的 GLSL 卷积
我对 GLSL 很陌生,但我正在尝试在片段着色器中编写卷积内核以进行图像处理。当我的内核很小(3x3)时,使用常量矩阵我能够很好地做到这一点。然而,现在我想使用大小为 9x9 的内核。或者对于任意大小的问题。我最初的想法是设置一个包含卷积核的纹理内存。然后使用 2Dsampler 读取内核的纹理内存并将其与图像的纹理内存(也是 2Dsampler)进行卷积。这是解决这个问题的正确方法吗?
我想您还可以创建一个包含系数的任意大小的数组。这可能适用于 81 个系数,但如果您想要更大的系数会怎样?比如 20x20?
一般来说,如果您需要在 GLSL 中访问多个大型对象,正确的策略是什么?谢谢! 谢谢,
D
I'm very new to GLSL, but I'm trying to write convolution kernel with in a fragment shader for image processing. I was able to do this just fine when my kernel was small (3x3) using a constant matrix. Now, however, I'd like to use a kernel of size 9x9. Or for that matter of arbitrary size. My initial thought was to setup a texture memory containing the convolution kernel. Then using a 2Dsampler I'd read the texture memory of the kernel and convolve it with the texture memory of the image (also a 2Dsampler). Is this the right way to go about this?
I suppose you could also make an array of arbitrary size that contains coefficients. This might work for 81 coefficients, but what happens if you want something larger? Like say a 20x20?
In general if you need to access multiple large objects in GLSL what's the proper strategy? Thanks!
Thanks,
D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
顺序访问:
随机访问:
Sequential access:
Random access:
是的,由于均匀且恒定的空间是有限的,因此使用纹理作为替换是一个很好的策略。
Yes, since uniform and constant space is limited, using a texture as replacement is a good strategy.