Implementing transfer function for volume classification
In this recipe, we will implement classification to the 3D texture slicing presented before. We will generate a lookup table to add specific colors to specific densities. This is accomplished by generating a 1D texture that is looked up in the fragment shader with the current volume density. The returned color is then used as the color of the current fragment. Apart from the setup of the transfer function data, all the other content remains the same as in the 3D texture slicing recipe. Note that the classification method is not limited to 3D texture slicing, it can be applied to any volume rendering algorithm.
Getting ready
The code for this recipe is in the Chapter7/3DTextureSlicingClassification
directory.
How to do it…
Let us start this recipe by following these simple steps:
Load the volume data and setup the texture slicing as in the Implementing volume rendering using 3D texture slicing recipe.
Create a 1D texture that will be our...