Peeking in a GPU generated Cube Map

I have a sphere (call if a planet if you wish) and I would like to displace the vertexes using a height map. This height map however is a cube map texture generated on the GPU using shaders. It does not change, it is simply generated once.

I basically want the equivalent of sampling the cube map in the vertex shader and displacing my vertexes accordingly. Texture samples in the vertex shader are not generally supported though, and I really should only do the sampling once per vertex, not every frame anyway.

I tried to get the ram image, but I got a 0 pointer which I guess indicates it could not get a ram image. Thus I tried makeRamImage which seems to work (at least returns a pointer I might be able use for something) but causes a Segmentation Fault to occur a bit later.

So how can I sample a cube map generated on the GPU on the CPU?

Neither getRamImage() nor makeRamImage() will copy the texture data from the GPU. To do that, try:


Then you should be able to examine the data via getRamImage().


Thanks. It seems to have worked. Now, any tips for converting a vector to cube map u,v,w? I know how to get which face it is (+x,-x,-y…) and some coordinates on that face, but how do I know which face is which index (0-5) and which way u and v go (to get the right rotation and not mirrored). Guess and check?

Edit: I found which should help me with my cube map decoding. I’ll be back If I can’t sort it out.

Edit2: All working. I displaced my vertexes with the cube map. The result is crummy, but that the fault of having no LOD :slight_smile: