像素着色器功能tex1D对Texture2d做了什么 [英] What does the pixel shader function tex1D do with a Texture2d

查看:163
本文介绍了像素着色器功能tex1D对Texture2d做了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我从我的像素着色器在已初始化为texture2d的纹理上调用tex1d,它将把数据视为一维数组,然后仅将元素放在您指定的任何位置吗?

If I call tex1d from my pixel shader on a texture that has been initialized as a texture2d will it treat the data as a one dimensional array and then just take the element at whichever position you specify?

例如,如果您有一个10 x 10的纹理(这将是一维数组,长度为100个元素),并且您调用tex1d(mySampler,0.95),它将返回95个元素吗?

For instance if you have a 10 x 10 texture(that would be a one dimensional array 100 elements in length) and you call tex1d(mySampler, 0.95) will it give you back element 95?

推荐答案

我认为您会发现以下引用(关于DirectNA 9,这是XNA的基础):

I think you will find this quote (regarding DirectX 9, which is what XNA is built on) relevant:

由于运行时不支持1D纹理,因此编译器将在知道y坐标不重要的情况下使用2D纹理.由于tex1D(s,t)(DirectX HLSL)是作为2D纹理查找实现的,因此编译器可以自由地以有效方式选择y分量.

Because the runtime does not support 1D textures, the compiler will use a 2D texture with the knowledge that the y-coordinate is unimportant. Since tex1D(s, t) (DirectX HLSL) is implemented as a 2D texture lookup, the compiler is free to choose the y-component in an efficient manner.

换句话说:您指定X坐标,并且未定义Y坐标.

In other words: you specify the X coordinate, and the Y coordinate is undefined.

此处.

所以,不,它不会解开索引.但是您

So, no, it won't unwrap the indices. But you already got an answer about how to do that.

这篇关于像素着色器功能tex1D对Texture2d做了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆