OpenGL 3.2에서 간단한 직사각형을 완성 했으므로 이제 조명 지원을 추가하고 싶습니다. 그러나 프래그먼트 셰이더로 내 법선을 이동하려고 할 때마다 아무 것도 나타나지 않습니다. 그 줄을 주석 처리하면, 그것은 완벽하게 다시 작동합니다. 이것을 일으키는 원인은 무엇입니까? 오류 로그에 아무 것도 나타나지 않습니다.버텍스 쉐이더에서 변수 설정시 빈 화면 얻기
버텍스 쉐이더 :
#version 150
in vec4 position;
in vec3 inNormal;
out vec3 varNormal;
uniform mat4 modelViewProjectionMatrix;
void main()
{
//varNormal = inNormal; //If I uncomment this line, nothing shows up
gl_Position = modelViewProjectionMatrix * position;
}
조각 쉐이더 :
#version 150
in vec3 varNormal;
out vec4 fragColor;
void main()
{
fragColor = vec4(1, 1, 1, 1);
}
그리고 통과하는 법선 :
GLuint posAttrib = 0;
GLuint normalAttrib = 1;
glBindAttribLocation(program, posAttrib, "position");
glBindAttribLocation(program, normalAttrib, "normalAttrib");
//Building the VAO's/VBO's
GLfloat posCoords[] =
{
-10, 0.0, -10,
-10, 0.0, 10,
10, 0.0, 10,
10, 0.0, -10,
};
GLfloat normalCoords[] =
{
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1
};
glGenVertexArrays(1, &vaoName);
glBindVertexArray(vaoName);
GLuint posBuffer;
glGenBuffers(1, &posBuffer);
glBindBuffer(GL_ARRAY_BUFFER, posBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(posCoords), posCoords, GL_STATIC_DRAW);
glEnableVertexAttribArray(posAttrib);
glVertexAttribPointer(posAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLuint normalBuffer;
glGenBuffers(1, &normalBuffer);
glBindBuffer(GL_ARRAY_BUFFER, normalBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(normalCoords), normalCoords, GL_STATIC_DRAW);
glEnableVertexAttribArray(normalAttrib);
glVertexAttribPointer(normalAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
내가 내 위치 및 일반 좌표의 모든 퍼팅 시도하지 않은 하나의 VBO지만, 나는 그 방법에 의지하지 않는 것을 선호한다.
그들은 이미 문자열 배열을 사용하여 선언되었으므로 필요하지 않다고 생각하여 코드 조각에 포함하지 않았습니다. 그리고 사복과 유니폼은 서로 다른 두 가지가 아닌가? – TheAmateurProgrammer