doing a textureCube() texturelookup in GLSL takes the reflectionray as lookup coordinate.
GLSL 4.2 introduced imageLoad/imageStore that aparently also works with cubemaps.
But the load/store functions
imageStore(gimagecube image, ivec3 p, vec4 data)
take integer coordinates to access the respective texel.
How are those coordinates interpreted and how can they be calculated based onthe direction of the reflection ray?
Basically, cube-maps with image load/store work like a 6-element array texture. The z-component of the texture coordinate specifies which face to look at. The order of the faces is the same order as the enumerators for cube map faces, which is the same as for layered rendering.
As for how to calculate them for a direction, you can do that by using the algorithm detailed in the spec. Section 3.9.10 of GL 4.2 core explains how OpenGL takes a direction and converts it into a particular face and texture coordinate. It’s a bit more complex than I’d want to explain in a post, and it would really just be a copy-and-paste of some text.
The general idea is that the largest component defines which face to use, based on table 3.17. The S and T texture coordinates are then taken from that table, and a little math is applied to them to convert them into [0, 1] texture coordinates.