Jump to content
  • Advertisement
Sign in to follow this  
wtherapy

Reading a grid stored in the video card's memory

This topic is 2113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I am working on a simple terrain demo and I have a 256x256 height-map that stores not only height but also other information, each grid point having 8 floats.
I need this grid available in the video card memory ( so I can create a VBO or smth ).
The most important, in the vertex shader, when drawing the terrain, when getting the x and y ( Z is vertical ) of a vertex in the terrain, I will compute the cell grid in which the x-y point lies and then I need to be able to access in the vertex shader those 8 floats that are stored in the closest grid point of the 256x256 points "height map".

If someone has a suggestion on how to do it, any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Im not sure if theres a better solution, but you could use a texture array or some other fancy object like that, and have 8 layers of float textures, so you then just sample each layer separately. (maybe theres a RGBA float format so you only need 2 textures?) Edited by Waterlimon

Share this post


Link to post
Share on other sites
Hi,

thanks for the answer, to make everything more clear, I was using uniforms for this and invoking a vertex shader for each terrain quad that project, in the XY plane, into an original grid location. That was very slow and wasn't taking advantage of the fact that the grid never gets modified.

Share this post


Link to post
Share on other sites
Do you need full 32-bit float precision for all your data in vertex shader?

As Waterlimon told, you can pack this data to textures and sample in vertex shader (using nearest filtering).
If you only ever need 256x256 terrain you can use float textures. But if you think you will eventually need higher resolutions you should try to pack
at least some data elements into 8-bit RGBA textures to conserve some memory.

Share this post


Link to post
Share on other sites
I guess I will try uniform buffer objects, move to OpenGL 3.*. Keep you informed about this if any relevant increase in speed is noticed. Thanks for the answers.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!