diff --git a/fsl/fslview/gl/gl14/gltensor_rgb_funcs.py b/fsl/fslview/gl/gl14/gltensor_rgb_funcs.py index e386751450b6f5bae6717119e0d6ccdd114eb028..fb2a6250b789ea1c8dc3661a5a189455a506657a 100644 --- a/fsl/fslview/gl/gl14/gltensor_rgb_funcs.py +++ b/fsl/fslview/gl/gl14/gltensor_rgb_funcs.py @@ -83,7 +83,8 @@ def preDraw(self): shape = list(self.image.shape) invshape = [1.0 / s for s in shape] shaders.setFragmentProgramVector(0, shape + [0]) - shaders.setFragmentProgramVector(1, invshape + [0]) + shaders.setFragmentProgramVector(1, invshape + [0]) + shaders.setFragmentProgramMatrix(2, self.imageTexture.voxValXform.T) def draw(self, zpos, xform=None): diff --git a/fsl/fslview/gl/gl21/gltensor_rgb_funcs.py b/fsl/fslview/gl/gl21/gltensor_rgb_funcs.py index 57137e14798fde78a9c020acf27a5abbb66d00b0..83275533dadf59e009184f11e02c744150c67a60 100644 --- a/fsl/fslview/gl/gl21/gltensor_rgb_funcs.py +++ b/fsl/fslview/gl/gl21/gltensor_rgb_funcs.py @@ -43,11 +43,13 @@ def init(self): # parameters for gltensor_rgb_vert.glsl/gltensor_rgb_frag.glsl p['imageTexture'] = gl.glGetUniformLocation(s, 'imageTexture') + p['imageValueXform'] = gl.glGetUniformLocation(s, 'imageValueXform') p['modTexture'] = gl.glGetUniformLocation(s, 'modTexture') p['xColourTexture'] = gl.glGetUniformLocation(s, 'xColourTexture') p['yColourTexture'] = gl.glGetUniformLocation(s, 'yColourTexture') p['zColourTexture'] = gl.glGetUniformLocation(s, 'zColourTexture') p['imageShape'] = gl.glGetUniformLocation(s, 'imageShape') + p['imageDims'] = gl.glGetUniformLocation(s, 'imageDims') p['useSpline'] = gl.glGetUniformLocation(s, 'useSpline') p['displayToVoxMat'] = gl.glGetUniformLocation(s, 'displayToVoxMat') @@ -93,16 +95,25 @@ def preDraw(self): # bind the shader uniform/attribute parameters pars = self.shaderParams useSpline = display.interpolation == 'spline' - imageShape = np.array(self.image.shape, dtype=np.float32) + + imageShape = np.array(self.image.shape, dtype=np.float32) + imageDims = np.array(self.image.pixdim, dtype=np.float32) displayToVoxMat = np.array(display.displayToVoxMat, dtype=np.float32) + imageValueXform = np.array(self.imageTexture.voxValXform.T, + dtype=np.float32) + displayToVoxMat = displayToVoxMat.ravel('C') + imageValueXform = imageValueXform.ravel('C') + gl.glUniform1f( pars['useSpline'], useSpline) gl.glUniform3fv( pars['imageShape'], 1, imageShape) + gl.glUniform3fv( pars['imageDims'], 1, imageDims) gl.glUniform1i( pars['xax'], self.xax) gl.glUniform1i( pars['yax'], self.yax) gl.glUniform1i( pars['zax'], self.zax) gl.glUniformMatrix4fv(pars['displayToVoxMat'], 1, False, displayToVoxMat) + gl.glUniformMatrix4fv(pars['imageValueXform'], 1, False, imageValueXform) gl.glUniform1i( pars['imageTexture'], 0) gl.glUniform1i( pars['modTexture'], 1)