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

Image textures now clamp to edge values, rather than returning 0.

parent b25c9b12
No related branches found
No related tags found
No related merge requests found
...@@ -58,18 +58,18 @@ void main(void) { ...@@ -58,18 +58,18 @@ void main(void) {
/* /*
* Normalise voxel coordinates to (0.0, 1.0) * Normalise voxel coordinates to (0.0, 1.0)
*/ */
voxCoords.xyz = voxCoords.xyz / imageShape.xyz; voxCoords = voxCoords / imageShape;
/* /*
* Look up the voxel value * Look up the voxel value
*/ */
float voxValue; float voxValue;
if (useSpline) voxValue = spline_interp(imageTexture, if (useSpline) voxValue = spline_interp(imageTexture,
voxCoords.xyz, voxCoords,
imageShape, imageShape,
0); 0);
else voxValue = texture3D( imageTexture, else voxValue = texture3D( imageTexture,
voxCoords.xyz).r; voxCoords).r;
/* /*
* Transform the voxel value to a colour map texture * Transform the voxel value to a colour map texture
......
...@@ -14,16 +14,5 @@ bool test_in_bounds(inout vec3 coords, vec3 shape) { ...@@ -14,16 +14,5 @@ bool test_in_bounds(inout vec3 coords, vec3 shape) {
return false; return false;
} }
/*
* Be lenient at voxel boundaries
*/
if (coords.x < 0.0) coords.x = 0.01;
if (coords.y < 0.0) coords.y = 0.01;
if (coords.z < 0.0) coords.z = 0.01;
if (coords.x >= shape.x) coords.x = shape.x - 0.01;
if (coords.y >= shape.y) coords.y = shape.y - 0.01;
if (coords.z >= shape.z) coords.z = shape.z - 0.01;
return true; return true;
} }
\ No newline at end of file
...@@ -437,20 +437,19 @@ class ImageTexture(object): ...@@ -437,20 +437,19 @@ class ImageTexture(object):
gl.GL_TEXTURE_MIN_FILTER, gl.GL_TEXTURE_MIN_FILTER,
interp) interp)
# Make everything outside # Clamp texture borders to the edge
# of the image transparent # values - it is the responsibility
gl.glTexParameterfv(gl.GL_TEXTURE_3D, # of the rendering logic to not draw
gl.GL_TEXTURE_BORDER_COLOR, # anything outside of the image space
np.array([0, 0, 0, 0], dtype=np.float32))
gl.glTexParameteri(gl.GL_TEXTURE_3D, gl.glTexParameteri(gl.GL_TEXTURE_3D,
gl.GL_TEXTURE_WRAP_S, gl.GL_TEXTURE_WRAP_S,
gl.GL_CLAMP_TO_BORDER) gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(gl.GL_TEXTURE_3D, gl.glTexParameteri(gl.GL_TEXTURE_3D,
gl.GL_TEXTURE_WRAP_T, gl.GL_TEXTURE_WRAP_T,
gl.GL_CLAMP_TO_BORDER) gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(gl.GL_TEXTURE_3D, gl.glTexParameteri(gl.GL_TEXTURE_3D,
gl.GL_TEXTURE_WRAP_R, gl.GL_TEXTURE_WRAP_R,
gl.GL_CLAMP_TO_BORDER) gl.GL_CLAMP_TO_EDGE)
# create the texture according to # create the texture according to
# the format determined by the # the format determined by the
......
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