我有以下GLSL頂點着色器:GLSL,添加一行使得沒有畫
attribute vec3 a_vTangent;
attribute vec3 a_vBinormal;
attribute vec2 a_vCustomParams;
varying vec3 i_vTangent;
varying vec3 i_vBinormal;
varying vec4 i_vColor;
varying vec2 i_vCustomParams;
void main()
{
i_vTangent = a_vTangent;
i_vBinormal = a_vBinormal;
i_vColor = gl_Color;
//i_vCustomParams = a_vCustomParams;
gl_Position = gl_Vertex;
}
如果我取消對該行i_vCustomParams = a_vCustomParams;
,沒有任何與這個shader渲染吸引了,沒有GL錯誤,不着色器編譯或鏈接錯誤。這令我感到驚訝,因爲幾何着色器甚至不使用i_vCustomParams,而且另外兩個頂點屬性(a_vTangent
和a_vBinormal
)工作得很好。
我知道這是正確的,但無論如何提供的是我的頂點設置
layout = new VertexLayout(new VertexElement[]
{
new VertexPosition(VertexPointerType.Short, 3),
new VertexAttribute(VertexAttribPointerType.UnsignedByte, 2, 3), //2 elements, location 3
new VertexColor(ColorPointerType.UnsignedByte, 4),
new VertexAttribute(VertexAttribPointerType.Byte, 4, 1), //4 elements location 1
new VertexAttribute(VertexAttribPointerType.Byte, 4, 2), //4 elements, location 2
});
爲此頂點結構:
struct CubeVertex : IVertex
{
public ushort3 Position;
public byte2 Custom;
public byte4 Color;
public sbyte4 Tangent;
public sbyte4 Binormal;
}
任何想法,爲什麼出現這種情況?
您定位的是什麼GLSL版本?平臺和GL實施供應商? – genpfault 2011-04-25 21:12:58