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

GL14 fragmentprogram bounds test is now in a separate file, and is a bit smarter

parent 3cb87363
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,10 @@ PARAM imageValueXform[4] = { program.local[2],
# retrieve the voxel coordinates
MOV voxCoord, fragment.texcoord[1];
# Bail if the voxel coordinate
# is out of the image space
#pragma include test_in_bounds.prog
# Normalise voxel coordinates to
# lie in the range (0, 1), so they
# can be used for texture lookup
......@@ -94,20 +98,6 @@ MUL voxColour, voxColour, { 1.0, 1.0, 1.0, 0.333333 };
# Apply the modulation factor
MUL voxColour, voxColour, modValue ;
# If any of the voxel coordinates are
# less than 0, clear the voxel colour
CMP voxColour.w, voxCoord.x, 0.0, voxColour.w;
CMP voxColour.w, voxCoord.y, 0.0, voxColour.w;
CMP voxColour.w, voxCoord.z, 0.0, voxColour.w;
# If any voxel coordinates are greater than
# the image shape, clear the voxel colour
SUB voxCoord, voxCoord, imageShape;
CMP voxColour.w, voxCoord.x, voxColour.w, 0.0;
CMP voxColour.w, voxCoord.y, voxColour.w, 0.0;
CMP voxColour.w, voxCoord.z, voxColour.w, 0.0;
# Colour the pixel!
MOV result.color, voxColour;
......
......@@ -58,6 +58,10 @@ PARAM voxValXform[4] = { program.local[0],
# by the vertex progarm
MOV voxCoord, fragment.texcoord[1];
# bail if the voxel coordinates
# are out of bounds
#pragma include test_in_bounds.prog
# Normalise voxel coordinates to
# lie in the range (0, 1), so they
# can be used for texture lookup
......@@ -76,19 +80,6 @@ ADD voxValue, voxValue, voxValXform[0].w;
# in the 1D colour map texture
TEX voxColour, voxValue.x, texture[1], 1D;
# If any of the voxel coordinates are
# less than 0, clear the voxel colour
CMP voxColour.w, voxCoord.x, 0.0, voxColour.w;
CMP voxColour.w, voxCoord.y, 0.0, voxColour.w;
CMP voxColour.w, voxCoord.z, 0.0, voxColour.w;
# If any voxel coordinates are greater than
# the image shape, clear the voxel colour
SUB voxCoord, voxCoord, imageShape;
CMP voxColour.w, voxCoord.x, voxColour.w, 0.0;
CMP voxColour.w, voxCoord.y, voxColour.w, 0.0;
CMP voxColour.w, voxCoord.z, voxColour.w, 0.0;
# Colour the pixel!
MOV result.color, voxColour;
......
# Fragment program routine which tests whether a set of voxel
# coordinates is within the bounds defined by the image shape,
# and forces the fragment program to exit if it is.
#
# Inputs:
# voxCoord - 3D voxel coordinates
# imageShape - Shape of the image
#
# Author: Paul McCarthy<pauldmccarthy@gmail.com>
#
TEMP workspace;
# If any of the voxel coordinates are
# less than 0.01, clear the voxel colour
MOV workspace, voxCoord;
MOV workspace, voxCoord;
ADD workspace, workspace, { 0.01, 0.01, 0.01, 999999999999.0};
KIL workspace;
# If any voxel coordinates are greater than
# the image shape (+ 0.01), clear the voxel colour
MOV workspace, imageShape;
SUB workspace, workspace, voxCoord;
ADD workspace, workspace, { 0.01, 0.01, 0.01, 999999999999.0};
KIL workspace;
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