2015-02-23 48 views
0

嗨如果在一幀中有3個攝像頭處於活動狀態,我在應用後期效果方面遇到了很多麻煩。如何在多臺攝像機上正確應用後期處理效果?

第一臺攝像機 - 渲染遊戲的遊戲部分。 第二個攝像頭 - 圖形用戶界面層。 第三個相機 - 背景和動畫。

在這裏,我試圖應用後處理效果,如第一臺相機上的模糊和綻放,這工作正常,但這裏出現的問題,而啓用後效果GUI,背景動畫不可見,但我相信他們繪製。 如果我將所有相機作爲輸入渲染目標,那麼我可以看到該場景中的所有對象。

不知道爲什麼會發生這種情況,任何人都可以請解釋我可能是什麼原因謝謝。 在這裏我添加Opengl通話記錄,看看我在做什麼。

問題發生在Stats_layer和HudPage_layer上,它們在啓用後期效果後不顯示。

Marker: SceneBegin: ClearCamera 


glBindFramebufferEXT(GL_FRAMEBUFFER, 2) 
glClearColor(0, 0, 0, 1) 
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) 
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, {1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_PROJECTION) 
glLoadMatrixf({2.7457316, 0, 0, 0} {0, 0, 1.0001999, 1} {0, 1.8304877, 0, 0} {0, 0, -0.20001999, 0}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 

Marker: RenderGroup: ClearCamera - Opaque 

Marker: RenderGroup: ClearCamera - Immediate 

Marker: RenderGroup: ClearCamera - Transparent 

Marker: RenderGroup: ClearCamera - Overlay 

Marker: PostProcess: PMaterial_GodRays_RadialBlur__2 


glBindFramebufferEXT(GL_FRAMEBUFFER, 2) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_PROJECTION) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glColor4f(0, 0, 0, 1) 
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, {0, 0, 0, 1}) 
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, {0, 0, 0, 1}) 
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, {0, 0, 0, 1}) 
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0) 
glActiveTexture(GL_TEXTURE0) 
glDisable(GL_TEXTURE_2D) 
glBindTexture(GL_TEXTURE_2D, 0) 
glMatrixMode(GL_TEXTURE) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glUniform2fv(0, 1, {0.5, 0.49836433}) 
glUniform1fv(1, 1, {0.050000001}) 
glActiveTexture(GL_TEXTURE1) 
glBindTexture(GL_TEXTURE_2D, 88) [Context 1 - Texture 88: Context 1 - Texture 88] 
glUniform1i(2, 1) 
glBindBuffer(GL_ARRAY_BUFFER, 163) 
glEnableClientState(GL_VERTEX_ARRAY) 
glVertexPointer(3, GL_FLOAT, 32, 0x00000000) 
glEnableClientState(GL_NORMAL_ARRAY) 
glNormalPointer(GL_FLOAT, 32, 0x0000000C) 
glClientActiveTexture(GL_TEXTURE0) 
glEnableClientState(GL_TEXTURE_COORD_ARRAY) 
glTexCoordPointer(2, GL_FLOAT, 32, 0x00000018) 
glEnableVertexAttribArray(0) 
glVertexAttribPointer(0, 3, GL_FLOAT, FALSE, 32, 0x00000000) 
glEnableVertexAttribArray(1) 
glVertexAttribPointer(1, 2, GL_FLOAT, FALSE, 32, 0x00000018) 
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 164) 
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0x00000000) 
glDisableClientState(GL_VERTEX_ARRAY) 
glDisableClientState(GL_NORMAL_ARRAY) 
glClientActiveTexture(GL_TEXTURE0) 
glDisableClientState(GL_TEXTURE_COORD_ARRAY) 
glDisableVertexAttribArray(0) 
glDisableVertexAttribArray(1) 

Marker: SceneBegin: ClearCamera 

glBindFramebufferEXT(GL_FRAMEBUFFER, 3) 
glClearColor(0, 0, 0, 1) 
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) 
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, {1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_PROJECTION) 
glLoadMatrixf({2.7457316, 0, 0, 0} {0, 0, 1.0001999, 1} {0, 1.8304877, 0, 0} {0, 0, -0.20001999, 0}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 


Marker: RenderGroup: ClearCamera - Opaque 

Marker: RenderGroup: ClearCamera - Immediate 

Marker: RenderGroup: ClearCamera - Transparent 

Marker: RenderGroup: ClearCamera - Overlay 

Marker: PostProcess: PMaterial_GodRays_RadialBlur__3 


glBindFramebufferEXT(GL_FRAMEBUFFER, 3) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_PROJECTION) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glColor4f(0, 0, 0, 1) 
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, {0, 0, 0, 1}) 
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, {0, 0, 0, 1}) 
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, {0, 0, 0, 1}) 
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0) 
glActiveTexture(GL_TEXTURE0) 
glDisable(GL_TEXTURE_2D) 
glBindTexture(GL_TEXTURE_2D, 0) 
glMatrixMode(GL_TEXTURE) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glUniform2fv(0, 1, {0.5, 0.49836433}) 
glUniform1fv(1, 1, {0.1}) 
glActiveTexture(GL_TEXTURE1) 
glBindTexture(GL_TEXTURE_2D, 87) [Context 1 - Texture 87: Context 1 - Texture 87] 
glUniform1i(2, 1) 
glBindBuffer(GL_ARRAY_BUFFER, 163) 
glEnableClientState(GL_VERTEX_ARRAY) 
glVertexPointer(3, GL_FLOAT, 32, 0x00000000) 
glEnableClientState(GL_NORMAL_ARRAY) 
glNormalPointer(GL_FLOAT, 32, 0x0000000C) 
glClientActiveTexture(GL_TEXTURE0) 
glEnableClientState(GL_TEXTURE_COORD_ARRAY) 
glTexCoordPointer(2, GL_FLOAT, 32, 0x00000018) 
glEnableVertexAttribArray(0) 
glVertexAttribPointer(0, 3, GL_FLOAT, FALSE, 32, 0x00000000) 
glEnableVertexAttribArray(1) 
glVertexAttribPointer(1, 2, GL_FLOAT, FALSE, 32, 0x00000018) 
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 164) 
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0x00000000) 
glDisableClientState(GL_VERTEX_ARRAY) 
glDisableClientState(GL_NORMAL_ARRAY) 
glClientActiveTexture(GL_TEXTURE0) 
glDisableClientState(GL_TEXTURE_COORD_ARRAY) 
glDisableVertexAttribArray(0) 
glDisableVertexAttribArray(1) 


Marker: SceneBegin: STATS_LAYER 

wglMakeCurrent(0x8C0119F2, 0x00010000) 
glBindFramebufferEXT(GL_FRAMEBUFFER, 0) 
glViewport(0, 0, 640, 960) 
glScissor(0, 0, 640, 960) 
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) 
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, {1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_PROJECTION) 
glLoadMatrixf({1, 0, 0, 0} {0, 0, 0.0066666668, 0} {0, 0.66666669, 0, 0} {0, 0, -0.33333334, 1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 


Marker: RenderGroup: STATS_LAYER - Opaque 
Marker: RenderGroup: STATS_LAYER - Immediate 
Marker: RenderGroup: STATS_LAYER - Transparent 
Marker: RenderGroup: STATS_LAYER - Overlay 
Marker: SceneBegin: HUDPAGE_LAYER 

wglMakeCurrent(0x8C0119F2, 0x00010000) 
glBindFramebufferEXT(GL_FRAMEBUFFER, 0) 
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) 
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, {1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 
glMatrixMode(GL_PROJECTION) 
glLoadMatrixf({1, 0, 0, 0} {0, 0, 0.0066666668, 0} {0, 0.66666669, 0, 0} {0, 0, -0.33333334, 1}) 
glMatrixMode(GL_MODELVIEW) 
glLoadMatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {0, 0, 0, 1}) 


Marker: RenderGroup: HUDPAGE_LAYER - Opaque 
Marker: RenderGroup: HUDPAGE_LAYER - Immediate 
Marker: RenderGroup: HUDPAGE_LAYER - Transparent 
+1

你在用什麼遊戲引擎?有沒有相關的代碼? – ryanpattison 2015-02-23 14:04:56

+0

@rpattiso是的,它是一個專有引擎,但我實際上可以給你一些opengl日誌 – RockyRocks 2015-02-25 09:43:14

+0

,這與Lua有什麼關係? – Kamiccolo 2015-02-26 20:50:44

回答

0

與上述問題的問題是與我的方式繪製對象一次/應用後過程。

例如,如果我有2次:

  1. 不透明。
  2. 透明。

然後我應繪製在不透明通和在以後的一個透明者不透明對象。

但是,由於某種原因(Noob me!)我正在透明通道中繪製不透明的對象。

我不得不做很多調試才能找到根本問題。 我想如果我們想要做圖形,我們已經把事情按正確的順序,然後開始添加效果和東西。

雖然學到了一個教訓(希望我可以通過做一個示例項目解釋這種情況,很快發佈一個答案)。

相關問題