본문 바로가기

Graphics Note

automatic linking the first out variable of fragment shader

glsl 3 이었나, 이후부터 gl_ 형식의 미리 정의된 변수가 없어졌다.

대신 셰이더 사용자가 어트리뷰트부터 프레그먼트 출력변수까지 하나하나 바인딩해줘야하는데 여간 신경쓰이는게 아니다.

조금 일반적인 셰이더프로그램 클래스를 만들고싶어도 그러기 쉽지 않은 요인이 된다.

 

스택오버플로를 통해 어트리뷰트는 프로그램 링킹 이전에 미리 정의한 어트리뷰트 시멘틱으로 바인딩시켜주는 방법이 있다는것을 알았다.

그 후 사용할 어트리뷰트에 한해서만 glEnableVertexAttribArray 해주면 되었다.

 

프래그먼트 출력에 대해서도 미리 변수명을 고정해야 하나 고민하는데 다행히 그럴 필요가 없어졌다.

 

"In this program we are relying on the fact that the linker will automatically link our only fragment output variable to color number zero"

(http://www.packtpub.com/article/tips-tricks-getting-started-with-opengl-glsl-4)

 

프래그먼트 셰이더의 처음 정의한 out 변수가 출력 컬러로 자동 할당된단다.

물론 명시적인 바인딩을 위해서는 glBindFragDataLocation 를 해야겠지만, 일단은 수고를 던 셈이다.

'Graphics Note' 카테고리의 다른 글

rigid body collision 2  (0) 2014.04.21
rigid body collision 1  (0) 2014.04.21
[Mathematics] quaternion interpolation  (0) 2014.03.28
[Mathematics] rotation quaternion details  (0) 2014.03.28
device context and rendering context  (0) 2014.02.24