Sign in to follow this  
fpsgamer

[GPGPU] Reading a floating point buffer in a vertex shader...

Recommended Posts

I have a 2-d buffer of single floating point values. I would like to read this buffer from a GLSL vertex shader. Should I be using vbo's or fbo's? If fbos, which combination of texture formats am I supposed to use to get the behavior I want?

Share this post


Link to post
Share on other sites
You don't have to use VBOs or FBOs. You can use a standard texture if you want as it is shown here
http://www.opengl.org/wiki/Vertex_Texture_Fetch


uint vertex_texture;
glGenTextures(1, &vertex_texture);
glBindTexture(GL_TEXTURE_2D, vertex_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
//Linear filter might cause a fallback to software rendering so we are using GL_NEAREST
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//Linear filter might cause a fallback to software rendering so we are using GL_NEAREST_MIPMAP_NEAREST
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
//Make sure your GPU support mipmaps with floating point textures
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAPS, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE32F_ARB, width, height, 0, GL_LUMINANCE, GL_FLOAT, data);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this