Skip to content
Snippets Groups Projects
Commit d2617c50 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Fixed texture coordinate offset for both line vectors and volumes

parent 8e1208ee
No related branches found
No related tags found
No related merge requests found
...@@ -16,8 +16,14 @@ varying vec3 fragTexCoord; ...@@ -16,8 +16,14 @@ varying vec3 fragTexCoord;
void main(void) { void main(void) {
// TODO check voxel +0.5 offset // TODO check voxel +0.5 offset
// Round the vertex position to the nearest integer -
// this gives us the corresponding voxel coordinates
fragVoxCoord = floor(vertex + 0.5); fragVoxCoord = floor(vertex + 0.5);
fragTexCoord = fragVoxCoord / imageShape;
// Transform the voxel coordinates to texture
// coordinates, adding 0.5 to centre them
fragTexCoord = (fragVoxCoord + 0.5) / imageShape;
gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex, 1); gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex, 1);
} }
...@@ -601,7 +601,12 @@ def slice2D(dataShape, xax, yax, zpos, voxToDisplayMat, displayToVoxMat): ...@@ -601,7 +601,12 @@ def slice2D(dataShape, xax, yax, zpos, voxToDisplayMat, displayToVoxMat):
vertices[:, zax] = zpos vertices[:, zax] = zpos
voxCoords = transform.transform(vertices, displayToVoxMat) voxCoords = transform.transform(vertices, displayToVoxMat)
texCoords = voxCoords / dataShape
# offset by 0.5, because voxel coordinates are by
# default centered at 0 (i.e. the space of a voxel
# lies in the range [-0.5, 0.5]), but we want voxel
# coordinates to map to the effective range [0, 1]
texCoords = (voxCoords + 0.5) / dataShape
return vertices, voxCoords, texCoords return vertices, voxCoords, texCoords
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment