Commit 5be9010b authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

ENH: Implemented blend by intensity toggle in GL14, while trying to figure out

why blending differs between 14 and 21. It looks like the POW instruction
simply does not produce the same results as the glsl pow function
parent 4ce83083
......@@ -15,7 +15,9 @@ OPTION ARB_precision_hint_nicest;
# {{ param_negCmap }}
#
# {{ param_screenSize }} - First two components contain the screen width
# and height in pixels.
# and height in pixels. Third component determines whether to modulate
# samples by voxel intensity (blendByIntensity, +1), or whether to
# only use the blend factor (-1).
#
# {{ param_rayStep }} - xyz is a vector defining how far to move through
# the volume texture space on each ray-casting iteration.
......@@ -213,21 +215,33 @@ MAD tempVar.x, tempVar.x, 2.0, -1;
MIN skipTest.x, skipTest.x, tempVar.x;
# Adjust the sample opacity - it is
# a function of the (normalised)
# voxel intensity and the blend factor:
# Adjust the sample opacity -
# if blendByIntesnity (screenSize.z),
# it is a function of the (normalised)
# voxel intensity and the blend factor
# (stored in tempVar.y):
#
# a = 1 - pow(1 - clamp(voxValue, 0, 1), 1 - blendFactor);
#
# Otherwise it is just a function of
# the blend factor (stored in tempVar.x):
#
# a = 1 - blendFactor;
# a = 1 - pow(1 - clamp(voxValue, 0, 1), 1 - blendFactor);
SUB tempVar.x, 1, {{ param_settings }}.x;
# Clamp voxValue to [0, 1]
# (MOV_SAT does not work for me)
MIN colour.a, voxValue.x, 1;
MAX colour.a, colour.a, 0;
MIN tempVar.y, voxValue.x, 1;
MAX tempVar.y, tempVar.y, 0;
SUB tempVar.y, 1, tempVar.y;
SUB tempVar.z, 1, {{ param_settings }}.x;
POW tempVar.y, tempVar.y, tempVar.z;
SUB tempVar.y, 1, tempVar.y;
# blend by intensity or just blend by blend factor
CMP colour.a, {{ param_screenSize }}.z, tempVar.x, tempVar.y;
SUB colour.a, 1, colour.a;
SUB tempVar.x, 1, {{ param_settings }}.x;
POW colour.a, colour.a, tempVar.x;
SUB colour.a, 1, colour.a;
MUL colour.rgb, colour, colour.a;
# Blend the sample into the
......
......@@ -141,13 +141,9 @@ class Volume3DOpts(object):
# maximum possible amount of
# smoothing, as GL14 fragment
# programs cannot be too large.
#
# Also disable blendByIntensity,
# as it is not implemented on gl14
if float(fslgl.GL_COMPATIBILITY) < 2.1:
smooth = self.getProp('smoothing')
smooth.setAttribute(self, 'maxval', 6)
self.disableProperty('blendByIntensity')
self.clipPosition[:] = 10 * [50]
self.clipAzimuth[:] = 10 * [0]
......
......@@ -230,7 +230,11 @@ def draw3D(self, xform=None, bbox=None):
vertices = np.array(vertices, dtype=np.float32).ravel('C')
outerLoop = opts.getNumOuterSteps()
screenSize = [1.0 / w, 1.0 / h, 0, 0]
screenSize = [
1.0 / w,
1.0 / h,
1 if opts.blendByIntensity else -1,
0]
rayStep = list(rayStep) + [0]
texform = texform[2, :]
settings = [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment