2014-12-22 15 views
0

this tutorial에 뒤이어 3D 장면에서 그림자 매핑을 수행하고 있습니다. 지금은이 사용 ARB 확장OPENGL Texture2D 조작을 직접 또는 간접으로

//Textures 
GLuint shadowMapTexture; 
... 
... 

**CopyTexSubImage2D** is used to copy the contents of the frame buffer into a 
texture. First we bind the shadow map texture, then copy the viewport into the 
texture. Since we have bound a **DEPTH_COMPONENT** texture, the data read will 
automatically come from the depth buffer. 

//Read the depth buffer into the shadow map texture 
glBindTexture(GL_TEXTURE_2D, shadowMapTexture); 
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowMapSize, shadowMapSize); 
  • N.B.을 적용 전에 (아래 발췌 참조) shadowMapTexture의 원시 텍셀 데이터를 조작 을 원한다 OpenGL 2.1 만 사용하고 있습니다.
+2

정확히 알고 싶습니까? – derhass

+0

* CopyTexSubImage2D *의 텍셀을 수정하는 방법 data [i] = data [i] * beta [i]. 여기서 beta [i]는 외부 변조 함수입니다. –

+0

그리고 우리는 어떤 종류의 수정을하고 있습니까? 사용중인 자습서는 _ancient_입니다. 요즘 우리는 직접 텍스쳐를 렌더링하고 그러한 복사본이 전혀 필요 없습니다. 데이터 수정은 텍스처에 다시 렌더링하거나 적용 할 수정 유형에 따라 일부 셰이더 기반 후 처리 단계를 추가하여 수행 할 수 있습니다. – derhass

답변

0
화는 2 가지 방법으로 그것을 할 수

:

float* texels = ...; 
glBindTexture(GL_TEXTURE_2D, shadowMapTexture); 
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y,w,h, GL_DEPTH_COMPONENT, GL_FLOAT, texels); 

또는

을 (쓰기) 프레임 버퍼로 shadowMapTexture을 연결하고 전화 :

float* pixels = ...; 
glRasterPos2i(x,y) 
glDrawPixels(w,h, GL_DEPTH_COMPONENT, GL_FLOAT, pixels); 

잊지 마세요 는 비활성화 먼저 위의 메소드에서 depth_test.