[英]Metal shader interpolate values in buffer
I need to pass a buffer to Metal fragment shader which is an array of N float values. 我需要将缓冲区传递给Metal片段着色器,该片段是N个float值的数组。 But I want the shader to interpolate values if the width of the texture to which it is drawn is more than N pixels.
但是,如果着色器绘制到的纹理的宽度大于N个像素,我希望着色器插入值。 If I use a texture, it is easy to use sampler and set linear filtering, but it's not clear if interpolation can be setup on an arbitrary buffer in fragment shader.
如果使用纹理,则很容易使用采样器并设置线性过滤,但是尚不清楚是否可以在片段着色器中的任意缓冲区上设置插值。
No, it's not possible to make Metal interpolate over values in a buffer for you. 不,不可能让Metal对您的缓冲区中的值进行插值。 Metal has no way of knowing that the buffer has an associated "geometry".
金属无法知道缓冲区具有关联的“几何形状”。 For example, an array of N float values could be N horizontal elements, N vertical elements, 5 rows of N/5 elements, etc. Interpolation requires knowledge of which elements are neighbors of a given element, which requires knowledge of geometry.
例如,N个浮点值的数组可以是N个水平元素,N个垂直元素,5行N / 5个元素等。插值需要了解哪些元素是给定元素的邻居,这需要了解几何。
You can, of course, do the interpolation yourself in the shader. 当然,您可以自己在着色器中进行插值。
You can also create a texture from a buffer using the -newTextureWithDescriptor:...
/ makeTexture()
method of MTLBuffer
. 您还可以创建使用从缓冲纹理
-newTextureWithDescriptor:...
/ makeTexture()
的方法MTLBuffer
。 Then you can sample from that texture. 然后,您可以从该纹理采样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.