您可以在顶点着色器中对纹理进行采样吗? [英] Can you look sample a texture in a vertex shader?
问题描述
在着色器模型3.0中,我很确定这不是一个否,但是无论如何我都想问这个问题,
In shader model 3.0, I'm pretty sure this was a no but I want to ask this anyway,
在着色器模型5.0中,可以在顶点着色器中对纹理进行采样吗?
In shader model 5.0, can you sample a texture in a vertex shader?
如果我想为每个顶点提供大量补充信息,我有什么选择?
If I want to make large amounts of supplementary information available per-vertex, what are my options?
显然,可以像此处那样完成顶点纹理提取. ,但是当我在hlsl shader model 5程序中尝试使用时,会出现错误
Apparently it is possible to do a Vertex Texture Fetch, as done here, but when I try it in my hlsl shader model 5 program, I get the error
错误X4532:无法将表达式映射到vs_5_0指令集
error X4532: cannot map expression to vs_5_0 instruction set
推荐答案
Yes, sampling a texture from a vertex shader is very easily done in Shader Model 5.0, using operator[ unint2 ] on any Texture2D
object.
例如,tex0
是着色器模型5 hlsl程序中的Texture2D
对象:
So for example, tex0
is a Texture2D
object in a shader model 5 hlsl program:
Texture2D tex0 : register( t0 );
// in a vertex shader program
uint2 pos_xy = { 0, 1 } ;
texelColor = tex0[ pos_xy ] ;
这篇关于您可以在顶点着色器中对纹理进行采样吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!