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

GL14 volume supports separate clip image.

parent b3098871
No related branches found
No related tags found
No related merge requests found
...@@ -35,8 +35,10 @@ ...@@ -35,8 +35,10 @@
# component determines the clipping direction - pass # component determines the clipping direction - pass
# in -1 for the above behaviour, or +1 to invert # in -1 for the above behaviour, or +1 to invert
# this behaviour (i.e. to clip values that are within # this behaviour (i.e. to clip values that are within
# the range). Clipping values are assumed to be # the range). The (w) component is a boolen flag which
# normalised to the image texture value range. # indicates whether the image texture is to be used
# as the clip texture. Clipping values are assumed to
# be normalised to the image texture value range.
# #
# program.local[6] - Negative colour map control. The (x) component # program.local[6] - Negative colour map control. The (x) component
# is a boolean flag controlling whether the negative # is a boolean flag controlling whether the negative
...@@ -57,10 +59,12 @@ TEMP voxCoord; ...@@ -57,10 +59,12 @@ TEMP voxCoord;
TEMP voxClipLo; TEMP voxClipLo;
TEMP voxClipHi; TEMP voxClipHi;
TEMP voxValue; TEMP voxValue;
TEMP clipValue;
TEMP posColour; TEMP posColour;
TEMP negColour; TEMP negColour;
TEMP useNegCmap; TEMP useNegCmap;
TEMP negVoxValue; TEMP negVoxValue;
TEMP negClipValue;
PARAM imageShape = program.local[4]; PARAM imageShape = program.local[4];
PARAM clipping = program.local[5]; PARAM clipping = program.local[5];
...@@ -81,8 +85,15 @@ MOV voxCoord, fragment.texcoord[1]; ...@@ -81,8 +85,15 @@ MOV voxCoord, fragment.texcoord[1];
#pragma include test_in_bounds.prog #pragma include test_in_bounds.prog
# look up image voxel value # look up image voxel value
# from 3D image texture # and clipping value from 3D
TEX voxValue.x, fragment.texcoord[0], texture[0], 3D; # image/clipping textures
TEX voxValue.x, fragment.texcoord[0], texture[0], 3D;
TEX clipValue.x, fragment.texcoord[0], texture[3], 3D;
# If the image texture is the clip
# texture, overwrite the clip value
# we just looked up.
CMP clipValue.x, clipping.w, clipValue.x, voxValue.x;
# Figure out which negative colour map # Figure out which negative colour map
# should be used for this fragment. # should be used for this fragment.
...@@ -108,16 +119,27 @@ MUL useNegCmap.x, useNegCmap.x, -1; ...@@ -108,16 +119,27 @@ MUL useNegCmap.x, useNegCmap.x, -1;
ADD negVoxValue.x, negCmap.y, negCmap.y; ADD negVoxValue.x, negCmap.y, negCmap.y;
SUB negVoxValue.x, negVoxValue.x, voxValue.x; SUB negVoxValue.x, negVoxValue.x, voxValue.x;
# And do the same for the clip value -
# this is necessary if the image texture
# is the clipping texture.
ADD negClipValue.x, negCmap.y, negCmap.y;
SUB negClipValue.x, negClipValue.x, clipValue.x;
# If we're using the negative colour # If we're using the negative colour
# map, replace the original voxel # map, replace the original voxel
# value with the inverted one. # value with the inverted one.
CMP voxValue.x, useNegCmap.x, negVoxValue.x, voxValue.x; CMP voxValue.x, useNegCmap.x, negVoxValue.x, voxValue.x;
# And do the same to the clip value if
# the image texture is the clip texture.
CMP negClipValue.x, useNegCmap.x, negClipValue.x, clipValue.x;
CMP clipValue.x, clipping.w, clipValue.x, negClipValue.x;
# Test the low clipping range # Test the low clipping range
SUB voxClipLo, voxValue.x, clipping.x; SUB voxClipLo, clipValue.x, clipping.x;
# And the high clipping range # And the high clipping range
SUB voxClipHi, voxValue.x, clipping.y; SUB voxClipHi, clipValue.x, clipping.y;
# Multiply the low/high results - after # Multiply the low/high results - after
# this, voxClipLo will be positive if # this, voxClipLo will be positive if
......
...@@ -93,19 +93,23 @@ def updateShaderState(self): ...@@ -93,19 +93,23 @@ 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
invClip = 1 if opts.invertClipping else -1 invClip = 1 if opts.invertClipping else -1
useNegCmap = 1 if opts.useNegativeCmap else 0 useNegCmap = 1 if opts.useNegativeCmap else 0
imageIsClip = 1 if opts.clipImage is None else -1
xform = self.imageTexture.invVoxValXform
clipLo = opts.clippingRange[0] * xform[0, 0] + xform[3, 0] imgXform = self.imageTexture.invVoxValXform
clipHi = opts.clippingRange[1] * xform[0, 0] + xform[3, 0] if opts.clipImage is None: clipXform = imgXform
texZero = 0.0 * xform[0, 0] + xform[3, 0] else: clipXform = self.clipTexture.invVoxValXform
clipLo = opts.clippingRange[0] * clipXform[0, 0] + clipXform[3, 0]
clipHi = opts.clippingRange[1] * clipXform[0, 0] + clipXform[3, 0]
texZero = 0.0 * imgXform[ 0, 0] + imgXform[ 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, invClip, 0]) shaders.setFragmentProgramVector(5, [clipLo, clipHi, invClip, imageIsClip])
shaders.setFragmentProgramVector(6, [useNegCmap, texZero, 0, 0]) shaders.setFragmentProgramVector(6, [useNegCmap, texZero, 0, 0])
gl.glDisable(arbvp.GL_VERTEX_PROGRAM_ARB) gl.glDisable(arbvp.GL_VERTEX_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