프로그램을 지연 렌더링으로 설정했습니다. 나는 깊이에서 위치를 재구성하는 것에 찬성하여 나의 포지션 텍스처를 제거하는 과정에있다. 전에 아무 문제없이이 작업을 수행했지만 지금은 어떤 이유 때문에 유니폼을 통과하는 행렬에 액세스하려고 할 때 segfault가 발생합니다!프로그램에서 sefault가 발생하는 GLSL 유니폼 액세스
내 단편 쉐이더 (관련이없는 버텍스 쉐이더) :
#version 430 core
layout(location = 0) uniform sampler2D depth;
layout(location = 1) uniform sampler2D diffuse;
layout(location = 2) uniform sampler2D normal;
layout(location = 3) uniform sampler2D specular;
layout(location = 4) uniform mat4 view_mat;
layout(location = 5) uniform mat4 inv_view_proj_mat;
layout(std140) uniform light_data{
// position ect, works fine
} light;
in vec2 uv_f;
vec3 recontruct_pos(){
float z = texture(depth, uv_f);
vec4 pos = vec4(uv_f * 2.0 - 1.0, z * 2.0 - 1.0, 1.0);
//pos = inv_view_proj_mat * pos; //un-commenting this line causes segfault
return pos.xyz/pos.w;
}
layout(location = 3) out vec4 lit; // location 3 is lighting texture
void main(){
vec3 pos = reconstruct_pos();
lit = vec4(0.0, 1.0, 1.0, 1.0); // just fill screen with light blue
}
그리고이 segfault의 원인이되는 코드를 볼 수는 reconstruct_pos()
기능에 표시됩니다.
왜 이것이 segfault를 유발합니까? 응용 프로그램 내에서 데이터를 검사했는데 정확합니다.
편집 :
내 매트릭스 유니폼을 업데이트하는 데 사용하는 코드 : 나의 빛 버퍼를 할당 할 때
// bind program
glUniformMatrix4fv(4, 1, GL_FALSE, &view_mat[0][0]);
glUniformMatrix4fv(5, 1, GL_FALSE, &inv_view_proj_mat[0][0]);
// do draw calls
'light' uniform의'glGetUniformLocation'은 무엇입니까? –
그냥 체크해 보도록하겠습니다. hmmmm – CoffeeandCode
@BrettHale 아무 문제 없습니다. 나는'4294967295'를 얻는다. – CoffeeandCode