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

Normalised image textures are now stored as 16 bit, rather than 8

bit. Was getting precision errors in clipping.
parent fb1a598f
No related branches found
No related tags found
No related merge requests found
...@@ -125,21 +125,18 @@ def updateShaderState(self): ...@@ -125,21 +125,18 @@ def updateShaderState(self):
# range, but the shader needs them to be in image # range, but the shader needs them to be in image
# texture value range (0.0 - 1.0). So let's scale # texture value range (0.0 - 1.0). So let's scale
# them. # them.
clipLow = opts.clippingRange[0] * \ xform = self.imageTexture.invVoxValXform
self.imageTexture.invVoxValXform[0, 0] + \ clipLow = opts.clippingRange[0] * xform[0, 0] + xform[3, 0]
self.imageTexture.invVoxValXform[3, 0] clipHigh = opts.clippingRange[1] * xform[0, 0] + xform[3, 0]
clipHigh = opts.clippingRange[1] * \
self.imageTexture.invVoxValXform[0, 0] + \
self.imageTexture.invVoxValXform[3, 0]
gl.glUniform1f(self.clipLowPos, clipLow) gl.glUniform1f(self.clipLowPos, clipLow)
gl.glUniform1f(self.clipHighPos, clipHigh) gl.glUniform1f(self.clipHighPos, clipHigh)
gl.glUniform1f(self.invertClipPos, opts.invertClipping) gl.glUniform1f(self.invertClipPos, opts.invertClipping)
# Bind transformation matrices to transform # Bind transformation matrix to transform
# display coordinates to voxel coordinates, # from image texture values to voxel values,
# and to scale voxel values to colour map # and and to scale said voxel values to
# texture coordinates # colour map texture coordinates
vvx = transform.concat(self.imageTexture.voxValXform, vvx = transform.concat(self.imageTexture.voxValXform,
self.colourTexture.getCoordinateTransform()) self.colourTexture.getCoordinateTransform())
vvx = np.array(vvx, dtype=np.float32).ravel('C') vvx = np.array(vvx, dtype=np.float32).ravel('C')
......
...@@ -227,7 +227,7 @@ class ImageTexture(texture.Texture): ...@@ -227,7 +227,7 @@ class ImageTexture(texture.Texture):
# for signed types. # for signed types.
# Texture data type # Texture data type
if self.__normalise: texDtype = gl.GL_UNSIGNED_BYTE if self.__normalise: texDtype = gl.GL_UNSIGNED_SHORT
elif dtype == np.uint8: texDtype = gl.GL_UNSIGNED_BYTE elif dtype == np.uint8: texDtype = gl.GL_UNSIGNED_BYTE
elif dtype == np.int8: texDtype = gl.GL_UNSIGNED_BYTE elif dtype == np.int8: texDtype = gl.GL_UNSIGNED_BYTE
elif dtype == np.uint16: texDtype = gl.GL_UNSIGNED_SHORT elif dtype == np.uint16: texDtype = gl.GL_UNSIGNED_SHORT
...@@ -246,28 +246,28 @@ class ImageTexture(texture.Texture): ...@@ -246,28 +246,28 @@ class ImageTexture(texture.Texture):
# Internal texture format # Internal texture format
if self.nvals == 1: if self.nvals == 1:
if self.__normalise: intFmt = gl.GL_LUMINANCE8 if self.__normalise: intFmt = gl.GL_LUMINANCE16
elif dtype == np.uint8: intFmt = gl.GL_LUMINANCE8 elif dtype == np.uint8: intFmt = gl.GL_LUMINANCE8
elif dtype == np.int8: intFmt = gl.GL_LUMINANCE8 elif dtype == np.int8: intFmt = gl.GL_LUMINANCE8
elif dtype == np.uint16: intFmt = gl.GL_LUMINANCE16 elif dtype == np.uint16: intFmt = gl.GL_LUMINANCE16
elif dtype == np.int16: intFmt = gl.GL_LUMINANCE16 elif dtype == np.int16: intFmt = gl.GL_LUMINANCE16
elif self.nvals == 2: elif self.nvals == 2:
if self.__normalise: intFmt = gl.GL_LUMINANCE8_ALPHA8 if self.__normalise: intFmt = gl.GL_LUMINANCE16_ALPHA16
elif dtype == np.uint8: intFmt = gl.GL_LUMINANCE8_ALPHA8 elif dtype == np.uint8: intFmt = gl.GL_LUMINANCE8_ALPHA8
elif dtype == np.int8: intFmt = gl.GL_LUMINANCE8_ALPHA8 elif dtype == np.int8: intFmt = gl.GL_LUMINANCE8_ALPHA8
elif dtype == np.uint16: intFmt = gl.GL_LUMINANCE16_ALPHA16 elif dtype == np.uint16: intFmt = gl.GL_LUMINANCE16_ALPHA16
elif dtype == np.int16: intFmt = gl.GL_LUMINANCE16_ALPHA16 elif dtype == np.int16: intFmt = gl.GL_LUMINANCE16_ALPHA16
elif self.nvals == 3: elif self.nvals == 3:
if self.__normalise: intFmt = gl.GL_RGB8 if self.__normalise: intFmt = gl.GL_RGB16
elif dtype == np.uint8: intFmt = gl.GL_RGB8 elif dtype == np.uint8: intFmt = gl.GL_RGB8
elif dtype == np.int8: intFmt = gl.GL_RGB8 elif dtype == np.int8: intFmt = gl.GL_RGB8
elif dtype == np.uint16: intFmt = gl.GL_RGB16 elif dtype == np.uint16: intFmt = gl.GL_RGB16
elif dtype == np.int16: intFmt = gl.GL_RGB16 elif dtype == np.int16: intFmt = gl.GL_RGB16
elif self.nvals == 4: elif self.nvals == 4:
if self.__normalise: intFmt = gl.GL_RGBA8 if self.__normalise: intFmt = gl.GL_RGBA16
elif dtype == np.uint8: intFmt = gl.GL_RGBA8 elif dtype == np.uint8: intFmt = gl.GL_RGBA8
elif dtype == np.int8: intFmt = gl.GL_RGBA8 elif dtype == np.int8: intFmt = gl.GL_RGBA8
elif dtype == np.uint16: intFmt = gl.GL_RGBA16 elif dtype == np.uint16: intFmt = gl.GL_RGBA16
...@@ -385,8 +385,8 @@ class ImageTexture(texture.Texture): ...@@ -385,8 +385,8 @@ class ImageTexture(texture.Texture):
dmax = float(data.max()) dmax = float(data.max())
if dmax != dmin: if dmax != dmin:
data = (data - dmin) / (dmax - dmin) data = (data - dmin) / (dmax - dmin)
data = np.round(data * 255) data = np.round(data * 65535)
data = np.array(data, dtype=np.uint8) data = np.array(data, dtype=np.uint16)
elif dtype == np.uint8: pass elif dtype == np.uint8: pass
elif dtype == np.int8: data = np.array(data + 128, dtype=np.uint8) elif dtype == np.int8: data = np.array(data + 128, dtype=np.uint8)
......
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