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

Clipping can be inverted in GL14 implementation

parent 9788dc49
No related branches found
No related tags found
No related merge requests found
...@@ -108,12 +108,13 @@ class ClusterPanel(fslpanel.FSLViewPanel): ...@@ -108,12 +108,13 @@ class ClusterPanel(fslpanel.FSLViewPanel):
opts = self._displayCtx.getOpts(zstats) opts = self._displayCtx.getOpts(zstats)
zthres = float(overlay.thresholds()['z']) zthres = float(overlay.thresholds()['z'])
# Set some display parameters if
# we have a z value threshold
if zthres is not None: if zthres is not None:
absmax = max(map(abs, (opts.dataMin, opts.dataMax))) absmax = max(map(abs, (opts.dataMin, opts.dataMax)))
# Set clipping range
opts.cmap = 'Render3' opts.cmap = 'Render3'
opts.invertClipping = True opts.invertClipping = True
opts.displayRange.x = -absmax, absmax opts.displayRange.x = -absmax, absmax
......
...@@ -31,8 +31,12 @@ ...@@ -31,8 +31,12 @@
# #
# program.local[5] - Vector containing clipping values - voxels with a # program.local[5] - Vector containing clipping values - voxels with a
# value below the low threshold (x), or above the # value below the low threshold (x), or above the
# high threshold (y) will not be shown. Assumed to # high threshold (y) will not be shown. The (z)
# be normalised to the image texture value range. # component determines the clipping direction - pass
# in -1 for the above behaviour, or +1 to invert
# this behaviour (i.e. to clip values that are within
# the range). Clipping values are assumed to be
# normalised to the image texture value range.
# #
# #
# Outputs: # Outputs:
...@@ -43,7 +47,8 @@ ...@@ -43,7 +47,8 @@
# #
TEMP voxCoord; TEMP voxCoord;
TEMP voxClip; TEMP voxClipLo;
TEMP voxClipHi;
TEMP voxValue; TEMP voxValue;
PARAM imageShape = program.local[4]; PARAM imageShape = program.local[4];
...@@ -67,16 +72,29 @@ MOV voxCoord, fragment.texcoord[1]; ...@@ -67,16 +72,29 @@ MOV voxCoord, fragment.texcoord[1];
# from 3D image texture # from 3D image texture
TEX voxValue, fragment.texcoord[0], texture[0], 3D; TEX voxValue, fragment.texcoord[0], texture[0], 3D;
# If the voxel value is outside the
# clipping range, don't draw it
# Test the low clipping range # Test the low clipping range
SUB voxClip, voxValue.x, clipping.x; SUB voxClipLo, voxValue.x, clipping.x;
KIL voxClip;
# And the high clipping range # And the high clipping range
SUB voxClip, clipping.y, voxValue.x; SUB voxClipHi, voxValue.x, clipping.y;
KIL voxClip;
# Multiply the low/high results - after
# this, voxClipLo will be positive if
# the value is outside of the clipping
# range, or negative if the value is
# within the clipping range
MUL voxClipLo, voxClipLo, voxClipHi;
# Multiply by the clipping.z setting -
# this will invert the sign if normal
# clipping is active
MUL voxClipLo, voxClipLo, clipping.z;
# If the voxel value is outside
# the clipping range (or inside,
# if clipping is inverted), don't
# draw it
KIL voxClipLo;
# Scale voxel value according # Scale voxel value according
# to the current display range # to the current display range
......
...@@ -99,18 +99,19 @@ def updateShaderState(self): ...@@ -99,18 +99,19 @@ def updateShaderState(self):
# And the clipping range, normalised # And the clipping range, normalised
# to the image texture value range # to the image texture value range
clipLo = opts.clippingRange[0] * \ invClip = 1 if opts.invertClipping else -1
clipLo = opts.clippingRange[0] * \
self.imageTexture.invVoxValXform[0, 0] + \ self.imageTexture.invVoxValXform[0, 0] + \
self.imageTexture.invVoxValXform[3, 0] self.imageTexture.invVoxValXform[3, 0]
clipHi = opts.clippingRange[1] * \ clipHi = opts.clippingRange[1] * \
self.imageTexture.invVoxValXform[0, 0] + \ self.imageTexture.invVoxValXform[0, 0] + \
self.imageTexture.invVoxValXform[3, 0] self.imageTexture.invVoxValXform[3, 0]
shaders.setVertexProgramVector( 0, shape + [0]) shaders.setVertexProgramVector( 0, shape + [0])
shaders.setFragmentProgramMatrix(0, voxValXform) shaders.setFragmentProgramMatrix(0, voxValXform)
shaders.setFragmentProgramVector(4, shape + [0]) shaders.setFragmentProgramVector(4, shape + [0])
shaders.setFragmentProgramVector(5, [clipLo, clipHi, 0, 0]) shaders.setFragmentProgramVector(5, [clipLo, clipHi, invClip, 0])
gl.glDisable(arbvp.GL_VERTEX_PROGRAM_ARB) gl.glDisable(arbvp.GL_VERTEX_PROGRAM_ARB)
gl.glDisable(arbfp.GL_FRAGMENT_PROGRAM_ARB) gl.glDisable(arbfp.GL_FRAGMENT_PROGRAM_ARB)
......
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