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

Renamed glvolume_frag.glsl variable voxValXform to img2CmapXform,

because I will otherwise have a naming collision in the vector stuff.
parent 8509b1bd
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,18 @@ uniform sampler1D colourTexture;
*/
uniform sampler1D negColourTexture;
/*
* Matrix which can be used to transform a texture value
* from the imageTexture into a texture coordinate for
* the colourTexture.
*/
uniform mat4 img2CmapXform;
/*
* Shape of the imageTexture/clipTexture.
*/
uniform vec3 imageShape;
/*
* Flag which tells the shader whether
* the image and clip textures are actually
......@@ -42,23 +54,11 @@ uniform bool imageIsClip;
*/
uniform bool useNegCmap;
/*
* Shape of the imageTexture/clipTexture.
*/
uniform vec3 imageShape;
/*
* Use spline interpolation?
*/
uniform bool useSpline;
/*
* Transformation matrix to apply to the voxel value,
* so it can be used as a texture coordinate in the
* colourTexture.
*/
uniform mat4 voxValXform;
/*
* Clip voxels below this value. This must be specified
* in the image texture data range.
......@@ -163,7 +163,7 @@ void main(void) {
* Transform the voxel value to a colour map texture
* coordinate, and look up the colour for the voxel value
*/
normVoxValue = voxValXform * vec4(voxValue, 0, 0, 1);
normVoxValue = img2CmapXform * vec4(voxValue, 0, 0, 1);
if (negCmap) gl_FragColor = texture1D(negColourTexture, normVoxValue.x);
else gl_FragColor = texture1D(colourTexture, normVoxValue.x);
......
......@@ -55,26 +55,20 @@ def compileShaders(self):
vertShaderSrc = shaders.getVertexShader( self)
fragShaderSrc = shaders.getFragmentShader(self)
self.shaders = shaders.compileShaders(vertShaderSrc, fragShaderSrc)
shaderVars = {}
vertUniforms = []
vertAtts = ['vertex', 'voxCoord', 'texCoord']
fragUniforms = ['imageTexture', 'clipTexture', 'colourTexture',
'negColourTexture', 'imageIsClip', 'useNegCmap',
'imageShape', 'useSpline', 'voxValXform',
'imageShape', 'useSpline', 'img2CmapXform',
'clipLow', 'clipHigh', 'texZero',
'invertClip']
for va in vertAtts:
shaderVars[va] = gl.glGetAttribLocation(self.shaders, va)
for fu in fragUniforms:
if fu in shaderVars:
continue
shaderVars[fu] = gl.glGetUniformLocation(self.shaders, fu)
self.shaderVars = shaderVars
self.shaders = shaders.compileShaders(vertShaderSrc, fragShaderSrc)
self.shaderVars = shaders.getShaderVars(self.shaders,
vertAtts,
vertUniforms,
fragUniforms)
def updateShaderState(self):
......@@ -98,18 +92,16 @@ def updateShaderState(self):
clipHigh = opts.clippingRange[1] * xform[0, 0] + xform[3, 0]
texZero = 0.0 * xform[0, 0] + xform[3, 0]
# Bind transformation matrix to transform
# from image texture values to voxel values,
# and and to scale said voxel values to
# colour map texture coordinates
vvx = transform.concat(self.imageTexture.voxValXform,
self.colourTexture.getCoordinateTransform())
vvx = np.array(vvx, dtype=np.float32).ravel('C')
# Create a single transformation matrix
# which transforms from image texture values
# to voxel values, and scales said voxel
# values to colour map texture coordinates.
img2CmapXform = transform.concat(
self.imageTexture.voxValXform,
self.colourTexture.getCoordinateTransform())
img2CmapXform = np.array(img2CmapXform, dtype=np.float32).ravel('C')
# bind the current interpolation setting,
# image shape, and image->screen axis
# mappings
gl.glUniform1f( svars['useSpline'], opts.interpolation == 'spline')
gl.glUniform3fv(svars['imageShape'], 1, np.array(self.image.shape,
dtype=np.float32))
......@@ -121,7 +113,7 @@ def updateShaderState(self):
gl.glUniform1f(svars['useNegCmap'], opts.useNegativeCmap)
gl.glUniform1f(svars['imageIsClip'], opts.clipImage is None)
gl.glUniformMatrix4fv(svars['voxValXform'], 1, False, vvx)
gl.glUniformMatrix4fv(svars['img2CmapXform'], 1, False, img2CmapXform)
# Set up the colour and image textures
gl.glUniform1i(svars['imageTexture'], 0)
......
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