The current vertex declaration does not include all the elements required by the current vertex shader. Tangent0 is missing.

xna4.0,ps2.0,PC平台使用hlsl定义结构体:

struct VS_INPUT  {     
float4 Position : POSITION0;     
float2 TexCoord : TEXCOORD0;     
float3 Normal : NORMAL0;     
float3 Tangent : TANGENT0;     
float4 BoneIndices : BLENDINDICES0;     
float4 BoneWeights : BLENDWEIGHT0;
}
载入一个简单的贴图mesh,调用Bump相关pass时,运行时在
mesh.Draw();
处跳出异常:
The current vertex declaration does not include all the elements required by the current vertex shader. Tangent0 is missing.
 

问题就在于这个切线数据Tangent丢失。

外事不决问google,找到答案

到Content项目中将默认为false的“Generate Tangent Frames”项目置为true,编译后约多出10%容量,问题解决。

貌似3.1时默认是开启的,可能因为大多数model不用到切线数据,所以4.0不再默认生成。找了一下午真够坑爹的。

各种效果:

cube2

posted @ 2011-11-02 20:14  风海迷沙  阅读(829)  评论(3编辑  收藏  举报