PDA

View Full Version : Problems using Pbuffer for water rendering.



iceworld
09-08-2009, 07:48 AM
I managed to using pbuffer to take screen shot and save to a tga file according to the camera's position.
So I implement CreateReflectionPlane(&camera);CreateRefractionPla ne(&camera);
two functions for rendering reflection and refraction texture for water rendering, i test it , it works.
However, it seems in my shader i can't bind these two pbuffer textures.
here is my rendering function:

ShaderCreator::getSingletonPtr()->ChooseShader("Simple");
water->CreateReflectionPlane(&camera);
water->CreateRefractionPlane(&camera);

PBUFFER *pbuffer,*pbuffer2;
pbuffer = RenderToTextureMgr::getSingletonPtr()->getBuffer("Reflection");
pbuffer2 = RenderToTextureMgr::getSingletonPtr()->getBuffer("Refraction");
mWindow.MakeCurrent();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
SkyBox::Render(texarray);
ShaderCreator::getSingletonPtr()->ChooseShader("Water");
GLuint eye3 = glGetUniformLocation(ShaderCreator::getSingletonPt r()->GetShader("Water"),"eyePosition");
glUniform3f(eye3,camera.Position().x,camera.Positi on().y,camera.Position().z);
glActiveTexture(GL_TEXTURE0);
pbuffer->MakeCurrent();
glBindTexture(GL_TEXTURE_2D,pbuffer->pbufferTexture);
//wglBindTexImageARB(pbuffer->hBuffer, WGL_FRONT_LEFT_ARB);
GLuint loc = glGetUniformLocation(ShaderCreator::getSingletonPt r()->GetShader("Water"),"refMap");
glUniform1i(loc,pbuffer->pbufferTexture);
glActiveTexture(GL_TEXTURE1);
pbuffer2->MakeCurrent();
glBindTexture(GL_TEXTURE_2D, pbuffer2->pbufferTexture);
//wglBindTexImageARB(pbuffer2->hBuffer, WGL_BACK_LEFT_ARB);
GLuint loc2 = glGetUniformLocation(ShaderCreator::getSingletonPt r()->GetShader("Water"),"fraMap");
glUniform1i(loc2,pbuffer2->pbufferTexture);
...

Can some one give some suggestions? I am frustrated now.

Jan
09-08-2009, 07:54 AM
Nobody uses PBuffers anymore. Use "Framebuffer Objects" (FBO).


http://www.gamedev.net/reference/articles/article2331.asp
http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt

Jan.

iceworld
09-08-2009, 08:08 AM
i know a little about FBO and GPGPU. But I don't know if it's supported by old graphics card, Pbuffer is supported by quite old cards,i suppose.

Jan
09-08-2009, 09:47 AM
Oh well, depends on HOW old. FBOs are definitely support from Geforce 5 / Radeon 9700 on. On even older cards i don't know.

But then again, when you use shaders, you can't use older hardware than that anyway, so i'd say all hardware that you can use shaders on will also support FBOs (with not-so-ancient drivers).

Jan.


BTW: FBOs are not linked to GPGPU. You CAN use them to do GPGPU stuff, but they are not meant for that.

aqnuep
09-08-2009, 09:52 AM
FBO is at least supported on DX9 class hardware (aka GeForce FX, Radeon 9500 and later). These are the same hardware which first support GLSL. So Jan is right, you should use FBO instead of pbuffers because it's deprecated (and also because it's much easier :D).

iceworld
09-08-2009, 10:20 AM
Thank you, i will give a try for that.