本文介绍了OpenGL/GLSL-纹理过滤的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自己在GLSL着色器中实现纹理过滤(最小和磁过滤器)(因为我想使用image_load_and_store而不是采样器,并且我想以特殊方式处理未定义的像素),我正在寻找用于讨论过滤过程的文章.

我可以回想起如何从我曾经写过的raytracer中实现纹理过滤-我认为您需要考虑每个像素的UV梯度,并取决于那些以某种方式缩放采样栅格的长度.一个49个样本的圆形内核,我认为这太重了.

我认为我可以使用dFdx()和dFdy()获得UV渐变-但我想知道什么样的内核openGL用于过滤,并以相同的方式在我的glsl着色器中实现. /p>

还-如何区分是否需要应用minfilter或magfilter?过滤过程是否不同?

最后但并非最不重要的一点:如果将其缩小过滤,如何根据UV梯度选择合适的mipmap级别?

解决方案

Codeproject上有一篇文章,该文章在GLSL中实现了不同的过滤器(包括双线性过滤器):链接

I would like to implement texture filtering (min and magfilter) myself in a GLSL shader (as i want to use image_load_and_store and not a sampler, and also I want to handle undefined pixels in a special way) and I'm looking for an article or so that discusses the filtering process.

I can recall on how to implement texturefiltering from a raytracer I once wrote - I think you need to take into consideration the UV gradients at each pixel and depending on the length of those somehow scale your sampling raster.. but there I used a 49-samples circular kernel, I think that's too heavy.

I think the UV gradients i can get using dFdx() and dFdy() - but I'd like to know how what kind of kernel openGL is using for the filtering and implement it in my glsl shader the same way.

also - how to distinguish whether a minfilter or a magfilter needs to be applied? and is the filtering process different?

last but not least: if its minification filtering, how to choose the appropriate mipmap level based on the UV gradients?

解决方案

There's an article over at Codeproject which implements different filters (among them bi-linear) in GLSL: link

这篇关于OpenGL/GLSL-纹理过滤的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:27