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.
Reading a grid stored in the video card's memory
Started by wtherapy, Oct 05 2012 10:18 AM
4 replies to this topic
#2 Members - Reputation: 1007
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.
The lack of awesome free resource gathering building sandbox games capable of running an user made 8 bit computer in the world disturbs me.
#3 Members - Reputation: 117
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.
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 Members - Reputation: 841
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.
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/
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/






