vpVolumeNormals(3)
π vpVolumeNormals(3) β the Library Functions Manual glow-up π
okay bestie, gather round, because this one is a VolPack classic from the Library Functions Manual and it's literally the girl who precomputes your normals so your renders can eat π
β¨ NAME β¨
vpVolumeNormals β compute surface normal vectors and gradient magnitudes for a volume π¦
πΈ SYNOPSIS πΈ
#include <volpack.h>
vpResult
vpVolumeNormals(vpc, scalar_data, length, scalar_field, grad_field,
norm_field)
vpContext *vpc;
unsigned char *scalar_data;
int length;
int scalar_field;
int grad_field;
int norm_field;
π ARGUMENTS π
vpcβ the VolPack context, the one you got fromvpCreateContext. your main character β¨scalar_dataβ a 3D array of scalar samples. the raw material, the vibe source πlengthβ how big thescalar_dataarray is, in bytes. yes, bytes. no cap.scalar_fieldβ the voxel field number that says where to stash the scalar samples.grad_fieldβ the voxel field number that says where to stash the gradient magnitudes of those scalar samples.norm_fieldβ the voxel field number that says where to stash the encoded surface normal vectors. the glow-up field π
π DESCRIPTION π
so vpVolumeNormals is the precompute girlie π«Ά she crunches values for voxel fields that get used later in classification and shading algorithms. the input is a 3D array of scalar values β and if you've got scanlines of voxel data instead, there's a whole separate routine for that, see vpScanlineNormals(3).
for every single voxel, she computes an approximation of the gradient of the scalar field (using a central-difference operator, iconic technique, no notes). from that vector she can then work out:
- the magnitude of the gradient β lowkey essential for some classification schemes, check
vpSetClassifierTable(3) - a surface normal vector pointing in the direction of the gradient vector β this is the one that makes lighting models happen, see
vpShadeTable(3)π₯
and then the scalar value, the gradient magnitude and the surface normal vector all get stored into the fields of the voxel array. and yes β that voxel array is separate from the array of scalar values. two different girlies, two different jobs π
okay now the rules, and you need to hear these:
- the scalar array must be an array of 8-bit values. other sizes are not currently supported, periodt. π
- the dimensions of the array must match the volume dimensions you already set with
vpSetVolumeSize. - the
sizeargument exists to make sure the array has the correct size. she's checking. she's always checking. π - the voxel array must also be initialized by calling
vpSetRawVoxelsbefore you callvpVolumeNormals. do it before, bestie, not after, i'm begging π
now the three voxel field number arguments β they tell her which voxel fields the computed info goes into, and which field the scalar samples get copied to. the field numbers must correspond to appropriately-sized voxel fields you already specified with vpSetVoxelField.
any of these three arguments can be the constant VP_SKIP_FIELD β and in that case the corresponding quantity is just not computed or copied. skipping is valid. skipping is self-care. π
the sizing rules, fr fr:
- the voxel fields for the scalar value and the gradient magnitude must be one-byte fields.
- the field for the surface normal vector must be a two-byte field.
and the maximums? they're giving constants:
VP_SCALAR_MAXβ the max value that might be stored in the scalar fieldVP_GRAD_MAXβ the max value that might be stored in the gradient magnitude fieldVP_NORM_MAXβ the max value that might be stored in the norm field
respectively. respectively!! π
and heads up β the value stored in the surface normal vector field is actually an encoded surface normal, not the raw thing. see vpNormalIndex(3) for the decode lore. π§
π ERRORS π
the normal return value is VP_OK. slay. β¨
but here are the possible error return values, and they are not the vibe:
VPERROR_BAD_SIZEβ the size of the scalar array does not match the volume dimensions. she measured. it didn't fit. πVPERROR_BAD_VALUEβ one or more of the voxel fields you specified is invalid, or the corresponding voxel field has the wrong size.VPERROR_BAD_VOXELβ the voxel size or the voxel fields have not been specified, or they've been specified incorrectly. incorrect specification is a crime, unfortunately. π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.
π SEE ALSO π
the whole friend group, go say hi:
VolPack(3)vpCreateContext(3)vpNormalIndex(3)vpScanlineNormals(3)vpSetClassifierTable(3)vpSetLookupShader(3)
and that's the whole page, bestie π«Ά this was VolPack, manual page vpVolumeNormals(3), and she ate, she left no crumbs, she is the moment πβ¨π
π¦ where this page comes from
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- Copyright (c) 1995-2008, Stanford University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms