0

このチュートリアルに従って、3D シーンでシャドウ マッピングを実行しています。ここで、ARB 拡張を使用してこれを適用する前に、 shadowMapTexture (以下の抜粋を参照)の生のテクセル データを操作したいと考えています。

//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); 
  • 注意: OpenGL 2.1 のみを使用しています。
4

1 に答える 1

0

Tuは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 を無効にすることを忘れないでください。

于 2014-12-22T18:34:20.553 に答える