我正在使用OpenGL中的billboarding effect在世界空间上显示文本。
正常显示:
具有广告牌效果,文本四边形不会跟随红点。奇怪的是,当点沿x轴时,它的确跟随。我认为更改viewModel矩阵的前三列会扭曲相机对象的位置。
如何从viewModel矩阵中提取正确的四边形坐标?
//billboard code
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
out vec2 TexCoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
//gl_Position = projection * view * model * vec4(aPos, 1.0f);
mat4 mv = view*model; //viewModel matrix
mv[0][0] = 1.0;
mv[0][1] = 0.0;
mv[0][2] = 0.0;
mv[1][0] = 0.0;
mv[1][1] = 1.0;
mv[1][2] = 0.0;
mv[2][0] = 0.0;
mv[2][1] = 0.0;
mv[2][2] = 1.0;
//mv[3][0] = model[3][0];
//mv[3][1] = model[3][1];
//mv[3][2] = model[3][2];
gl_Position = projection * mv * vec4(aPos, 1.0f);
TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}