我正在尝试针对DirectX9和着色器模型2编译一个非常简单的效果着色器。我试图直接传递顶点位置的屏幕坐标,而不是乘以世界,视图和投影矩阵,因此我改用POSITIONT语义VertexShaderInput结构中POSTION0语义的含义。但是,当我尝试使用编译着色器时

fxc.exe /Od /Zi /T fx_2_0 /Fo simple.fxo simple.fx


我收到以下错误:“错误X4502:无效的输入语义-POSITIONT0”

由于某种原因,它似乎自动在语义末尾添加了0。这似乎对我来说是个错误,因为POSITIONT在这里清楚地描述为有效的输入语义:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb509647(v=vs.85).aspx#PS

并且它是唯一一个不允许在语义末尾附加额外整数的整数。

编辑:我刚刚发现,如果我将POSITIONT更改为POSITIONT1,则可以正常工作。这似乎与上面的文档描述相反。

simple.fx的内容:

struct VertexShaderInput
{
  float4 Position : POSITIONT;
  float4 Color : COLOR0;
};

struct VertexShaderOutput
{
  float4 Position : POSITION0;
  float4 Color : COLOR0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
  VertexShaderOutput output;
  output.Position = input.Position;
  output.Color = input.Color;
  return output;
}


float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
  return input.Color;
}

technique Ambient
{
  pass Pass1
  {
    VertexShader = compile vs_2_0 VertexShaderFunction();
    PixelShader = compile ps_2_0 PixelShaderFunction();
  }
}

最佳答案

对于旧版Direct3D9,有一个特殊的D3DDECLUSAGE_POSITIONT意味着只跳过顶点处理。因此,您只能在PIXEL SHADER输入中使用POSITIONT-即它根本不能在VERTEX SHADER中使用。

将着色器更改为使用POSITIONPOSITION0

关于c++ - 这是DirectX9 Effect Compiler中的错误吗? “无效的输入语义-POSITIONT0”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31796875/

10-10 16:29
查看更多