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

Interrupted vector opts cmap to add the ability to VolumeOpts to clip by

another image - this will be needed by VectorOpts cmap, if I want to
re-use the GLVolume fragment shader.
parent 2537e9f1
No related branches found
No related tags found
No related merge requests found
......@@ -9,10 +9,15 @@
#pragma include test_in_bounds.glsl
/*
* image data texture.
* image data texture, used for colouring.
*/
uniform sampler3D imageTexture;
/*
* image data texture, used for clipping.
*/
uniform sampler3D clipTexture;
/*
* Texture containing the colour map.
*/
......@@ -23,6 +28,14 @@ uniform sampler1D colourTexture;
*/
uniform sampler1D negColourTexture;
/*
* Flag which tells the shader whether
* the image and clip textures are actually
* the same - if they are, set this to true
* to avoid an extra texture lookup.
*/
uniform bool imageIsClip;
/*
* Flag which determines whether to
* use the negative colour map.
......@@ -30,7 +43,7 @@ uniform sampler1D negColourTexture;
uniform bool useNegCmap;
/*
* Shape of the imageTexture.
* Shape of the imageTexture/clipTexture.
*/
uniform vec3 imageShape;
......@@ -86,6 +99,7 @@ varying vec3 fragTexCoord;
void main(void) {
float voxValue;
float clipValue;
vec4 normVoxValue;
bool negCmap = false;
vec3 voxCoord = fragVoxCoord;
......@@ -109,6 +123,15 @@ void main(void) {
else voxValue = texture3D( imageTexture,
fragTexCoord).r;
if (imageIsClip) clipValue = voxValue;
else if (useSpline) clipValue = spline_interp(clipTexture,
fragTexCoord,
imageShape,
0);
else clipValue = texture3D( clipTexture,
fragTexCoord).r;
/*
* If we are using a negative colour map,
* and the voxel value is below the negative
......@@ -122,11 +145,12 @@ void main(void) {
voxValue = texZero + (texZero - voxValue);
}
/*
* Clip out of range voxel values
*/
if ((!invertClip && (voxValue < clipLow || voxValue > clipHigh)) ||
( invertClip && (voxValue >= clipLow && voxValue <= clipHigh))) {
if ((!invertClip && (clipValue < clipLow || clipValue > clipHigh)) ||
( invertClip && (clipValue >= clipLow && clipValue <= clipHigh))) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
return;
......
......@@ -59,11 +59,12 @@ def compileShaders(self):
shaderVars = {}
vertAtts = ['vertex', 'voxCoord', 'texCoord']
fragUniforms = ['imageTexture', 'colourTexture', 'negColourTexture',
'useNegCmap', 'imageShape', 'useSpline',
'voxValXform', 'clipLow', 'clipHigh',
'texZero', 'invertClip']
vertAtts = ['vertex', 'voxCoord', 'texCoord']
fragUniforms = ['imageTexture', 'clipTexture', 'colourTexture',
'negColourTexture', 'imageIsClip', 'useNegCmap',
'imageShape', 'useSpline', 'voxValXform',
'clipLow', 'clipHigh', 'texZero',
'invertClip']
for va in vertAtts:
shaderVars[va] = gl.glGetAttribLocation(self.shaders, va)
......@@ -111,16 +112,18 @@ def updateShaderState(self):
gl.glUniform3fv(svars['imageShape'], 1, np.array(self.image.shape,
dtype=np.float32))
gl.glUniform1f(svars['clipLow'], clipLow)
gl.glUniform1f(svars['clipHigh'], clipHigh)
gl.glUniform1f(svars['texZero'], texZero)
gl.glUniform1f(svars['invertClip'], opts.invertClipping)
gl.glUniform1f(svars['useNegCmap'], opts.useNegativeCmap)
gl.glUniform1f(svars['clipLow'], clipLow)
gl.glUniform1f(svars['clipHigh'], clipHigh)
gl.glUniform1f(svars['texZero'], texZero)
gl.glUniform1f(svars['invertClip'], opts.invertClipping)
gl.glUniform1f(svars['useNegCmap'], opts.useNegativeCmap)
gl.glUniform1f(svars['imageIsClip'], 1)
gl.glUniformMatrix4fv(svars['voxValXform'], 1, False, vvx)
# Set up the colour and image textures
gl.glUniform1i(svars['imageTexture'], 0)
gl.glUniform1i(svars['clipTexture'], 0)
gl.glUniform1i(svars['colourTexture'], 1)
gl.glUniform1i(svars['negColourTexture'], 2)
......
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