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