vpCreateMinMaxOctree(3)
β¨ vpCreateMinMaxOctree β from the Library Functions Manual β¨
okay bestie, gather round, we're doing octrees today and it's gonna be so good π
πΈ NAME πΈ
vpCreateMinMaxOctree, vpMinMaxOctreeThreshold, vpDestroyMinMaxOctree β the trio that creates and destroys a min-max octree, which is the whole vibe behind optimized rendering π¦
π SYNOPSIS π
#include <volpack.h>
vpResult
vpCreateMinMaxOctree(vpc, root_node_size, base_node_size)
vpContext *vpc;
int root_node_size, base_node_size;
vpResult
vpMinMaxOctreeThreshold(vpc, param_num, range)
vpContext *vpc;
int param_num, range;
vpResult
vpDestroyMinMaxOctree(vpc)
vpContext *vpc;
π ARGUMENTS π
vpcβ your VolPack context, the one you got fromvpCreateContext. she's the main character here πroot_node_sizeβ how many voxels per side live in the top level (aka the largest nodes) of the octree. not currently used, so likeβ¦ she's there, she's just not doing anything rn πbase_node_sizeβ voxels per side in the bottom level (the smallest nodes). must be a power of 2, no cap, that's the rule.param_numβ the identifying number of one parameter of the opacity transfer function.rangeβ the range threshold for one parameter of the opacity transfer function. if an octree node spans a larger range than this, bestie, it gets subdivided. periodt.
π DESCRIPTION π
These routines create and destroy a min-max octree β an internal data structure that speeds up classifying and rendering volume data in a 3D voxel array. it's giving β¨optimizationβ¨. The octree is a hierarchical data structure holding minimum and maximum values for each voxel field. lowkey important: it does not duplicate the data in the voxel array. and heads up β the octree is not used with preclassified volumes (go read vpClassifyVolume(3) for that lore).
So before you can create an octree, you gotta declare a 3D voxel array using vpSetVolumeSize, vpSetVoxelSize, vpSetVoxelField and vpSetRawVoxels, and then initialize the parameters for the opacity transfer function by calling vpSetClassifierTable. Then you initialize the voxel data in the array. π«Ά and no, the lookup tables for the opacity transfer function do not need to be initialized. we're chill like that.
Now, call vpMinMaxOctreeThreshold once for each parameter to the opacity transfer function. The parameter number is literally the same number you'd pass to vpClassifierTable. The range argument specifies a "small" range of values for the corresponding parameter β the opacity of a voxel shouldn't vary much for voxels within this range of parameter space. Choosing a value that's too small or too large may result in a reduced performance benefit during rendering π so choose wisely. You can use the function vpOctreeMask to visualize how effective your various parameter ranges actually are β vibe check your choices fr.
β οΈ note that you must choose the voxel field associated with each opacity transfer function parameter in advance of creating the octree (by calling vpSetClassiferTable), but the opacity transfer function itself doesn't need to be known, since the lookup tables don't need to be initialized.
And in the current implementation, all of the parameters must be one- or two-byte voxel fields. four-byte fields are not allowed. sorry babe π
Finally, call vpCreateMinMaxOctree to actually compute the octree. The arguments specify the largest and smallest node size, and you can use these values to trade off storage size of the octree for increased resolution β iconic tradeoff behavior. The octree is stored in the rendering context and gets used automatically in subsequent calls to vpClassifyVolume and vpRenderRawVolume. π Only one octree may be stored in a context at a time. If an octree already exists when vpCreateMinMaxOctree is called, then the old octree is destroyed. out with the old, in with the new π
π¨ if the data in the voxel array changes, then the min-max octree must be explicitly recomputed by callingvpCreateMinMaxOctreeagain before the next call tovpClassifyVolumeorvpRenderRawVolume. no skipping this step, bestie.
vpDestroyMinMaxOctree destroys the current min-max octree and frees the associated storage. she's done, she's free, we love a clean exit π
β STATE VARIABLES β
The current octree parameters can be retrieved with the following state variable codes (see vpGeti(3)):
VP_CLASSIFY_FIELD_COUNTVP_CLASSIFY_FIELDSVP_MMOCTREE_THRESHOLDSVP_MMOCTREE_SIZE
π ERRORS π
The normal return value for all three functions is VP_OK. π«Ά
vpMinMaxOctreeThreshold can return the following error value:
VPERROR_BAD_VALUEβ the parameter number is invalid. that number? not it. π
vpCreateMinMaxOctree can return the following error values:
VPERROR_BAD_VALUEβ the node size arguments are not a power of two. we said power of two, babe!!VPERROR_BAD_VOXELβ the voxel size or the voxel fields have not been specified, or have been incorrectly specified, or the number of parameters to the opacity transfer function has been incorrectly specified.VPERROR_BAD_VOLUMEβ the volume array or volume dimensions have not been specified, or the size of the volume array doesn't match the volume dimensions. mismatch energy, we hate to see it πVPERROR_BAD_CLASSIFIERβ the fields specified as parameters to the opacity transfer function are invalid or don't have valid sizes.VPERROR_LIMIT_EXCEEDEDβ the volume is too large, so the maximum size of the octree has been exceeded. the fix? change the constantVP_MAX_OCTREE_LEVELSinvolpack.hand recompile the VolPack library. literally just go edit the header, you got this π₯
π¦ SEE ALSO π¦
VolPack(3), vpCreateContext(3), vpClassifyVolume(3), vpOctreeMask(3), vpRenderRawVolume(3)
okay that's the whole page, bestie, you ate that π this was vpCreateMinMaxOctree(3) from the VolPack source, and that's the sign-off β slay, go build your octree, ily πβ¨π
π¦ where this page comes from
- debian bookworm: libvolpack1-dev 1.0b3-9 Β· BSD-3-Clause
- debian trixie: libvolpack1-dev 1.0b3-10 Β· BSD-3-Clause
- ubuntu jammy: libvolpack1-dev 1.0b3-9 Β· BSD-3-Clause
- ubuntu noble: libvolpack1-dev 1.0b3-9.1 Β· BSD-3-Clause
- ubuntu questing: libvolpack1-dev 1.0b3-11
- ubuntu resolute: libvolpack1-dev 1.0b3-11build1 Β· BSD-3-Clause
- ubuntu stonking: libvolpack1-dev 1.0b3-11build1 Β· BSD-3-Clause
- Copyright (c) 1994 The Board of Trustees of The Leland Stanford
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms