imageStore

Hi

I have two questions.

1.When I use imageStore to write to a image3D
layout (binding=0) uniform image3D myVol;

imageStore(myVol,TexCoord,vec4(1,0,0,0));

Here vec3 TexCoord are just coordinates generated by me based on some condition like position in a volume and it is a vector tuple of floating values.

I get an error saying:
error C1115: unable to find compatible overloaded function "imageStore(struct image3D,vec3,vec4):

I noticed that the definition of imageStore goes:
void imageStore(gimage3D image, ivec3 P, gvec4 data);

Does ivec3 mean that the coordinates are integers only? And if so, can i never be able to fill in values at intermediate coordinates like (0.3,0.3,0.3)?

2.I go through a grid and generate some vertices. I compute the texccordinates of the vertices alongside with the logic:
texcoord.x = vertex position.x/ length of grid in x axis
texcoord.y = vertex position.y/ length of grid in y axis
texcoord.z = vertex position.z/ length of grid in z axis

Is there a better way to compute the texture coordinates than doing it manually?

Yes. Use e.g.


    imageStore(myVol,ivec3(TexCoord*imageSize(myVol)),vec4(1,0,0,0))

to store a value in the cell containing the specified texture coordinates.

Fractional coordinates are only meaningful for sampling, where you could be using bilinear interpolation and/or mipmaps.

[QUOTE=driver;1254885]
2.I go through a grid and generate some vertices. I compute the texccordinates of the vertices alongside with the logic:
texcoord.x = vertex position.x/ length of grid in x axis
texcoord.y = vertex position.y/ length of grid in y axis
texcoord.z = vertex position.z/ length of grid in z axis

Is there a better way to compute the texture coordinates than doing it manually?[/QUOTE]
Well, there’s no need to do it one component at a time; you can just use e.g.


texcoord = position / grid_length;

where all 3 variables are 3-element vectors.