Jump to content

  • Log In with Google      Sign In   
  • Create Account

Reading a grid stored in the video card's memory


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 wtherapy   Members   -  Reputation: 117

Like
0Likes
Like

Posted 05 October 2012 - 10:18 AM

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.

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2638

Like
0Likes
Like

Posted 05 October 2012 - 10:22 AM

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, 05 October 2012 - 10:22 AM.

o3o


#3 wtherapy   Members   -  Reputation: 117

Like
0Likes
Like

Posted 05 October 2012 - 10:28 AM

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.

#4 Lauris Kaplinski   Members   -  Reputation: 841

Like
0Likes
Like

Posted 05 October 2012 - 04:07 PM

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.
Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

#5 wtherapy   Members   -  Reputation: 117

Like
0Likes
Like

Posted 06 October 2012 - 11:23 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS