vpScanlineNormals(3)
π vpScanlineNormals β the vpScanlineNormals(3) page, but make it make sense π
okay bestie, pull up a chair, we're in section 3 of the library functions manual and we're about to compute surface normal vectors AND gradient magnitudes for a single scanline. yes. both. she does it all. π
β¨ NAME β¨
vpScanlineNormals β compute surface normal vectors and gradient magnitudes for a scanline
π¦ SYNOPSIS π¦
#include <volpack.h>
vpResult
vpScanlineNormals(vpc, length, scalar_data, scalar_minus_y,
scalar_plus_y, scalar_minus_z, scalar_plus_z, voxel_data,
scalar_field, grad_field, norm_field)
vpContext *vpc;
int length;
unsigned char *scalar_data;
unsigned char *scalar_minus_y, *scalar_plus_y;
unsigned char *scalar_minus_z, *scalar_plus_z;
void *voxel_data;
int scalar_field;
int grad_field;
int norm_field;
like. look at that parameter list. she's serving π
πΈ ARGUMENTS πΈ
vpcβ the VolPack context, the one you got fromvpCreateContext. your whole world basically.lengthβ size of thescalar_dataarray, in bytes.scalar_dataβ a 1D array of scalar samples. the main character of this scanline.scalar_minus_yβ 1D array of scalar samples sitting right next toscalar_datain the -Y direction.scalar_plus_yβ same vibe, but 1D array of scalar samples adjacent toscalar_datain the +Y direction.scalar_minus_zβ 1D array of scalar samples adjacent toscalar_datain the -Z direction.scalar_plus_zβ 1D array of scalar samples adjacent toscalar_datain the +Z direction.voxel_dataβ 1D array of voxels, where the results go to live. it's giving storage unit.scalar_fieldβ voxel field number telling us which field to store the scalar samples in.grad_fieldβ voxel field number for storing the gradient magnitudes of the scalar samples.norm_fieldβ voxel field number for storing encoded surface normal vectors. encoded! not raw! remember that.
π DESCRIPTION π
so vpScanlineNormals is your precompute girlie π. she crunches values for voxel fields that get used by classification and shading algorithms. the input is a whole collection of 5 adjacent 1D arrays of scalar values. and yes, there's a separate routine for when you've got a full 3D array of voxel data β go check vpVolumeNormals(3), she's right there.
why would you want the scanline version? because it's useful for loading large volumes into memory scanline-by-scanline and precomputing voxel fields incrementally, instead of loading a complete copy of the 3D scalar array on top of the voxel array. no cap, that's a lot of memory you're saving. in every other respect this routine is identical in function to vpVolumeNormals.
okay, rules of the road:
- the 1D scalar arrays must be arrays of 8-bit values β other sizes are not currently supported π«
- the
lengthparameter tells you both the size and the number of elements in each of the scalar arrays. vpScanlineNormalsdoes the exact computation described invpVolumeNormals(3), but only for the single scanline specified byscalar_data.- the other four scanline arguments must be the immediately adjacent scanlines, because they're what we use to compute the gradient. no skipping rows, bestie.
where do results go? into voxel_data, which has to have space for the same number of voxels as the length of one scalar scanline. and listen:
you must specify the size of a voxel withvpSetVoxelSizebefore callingvpScanlineNormals. but it is not necessary to callvpSetRawVoxels. write that down. π
the scalar_field, grad_field and norm_field arguments say which voxel fields the computed quantities get stored into. these field numbers have to correspond to appropriately-sized voxel fields you already specified with vpSetVoxelField.
and here's the fun part β any of these arguments can be the constant VP_SKIP_FIELD, in which case the corresponding quantity is simply not computed or copied. skip era, we love her.
size requirements, pay attention:
- the voxel field for the scalar value must be a one-byte field
- the voxel field for the gradient magnitude must be a one-byte field
- the voxel field for the surface normal vector must be a two-byte field
the constants VP_SCALAR_MAX, VP_GRAD_MAX and VP_NORM_MAX give the maximum value that might be stored in each field, respectively.
and finally, iconic detail: the value stored in the surface normal vector field is actually an encoded surface normal. see vpNormalIndex(3). iykyk β¨
π ERRORS π
the normal return value is VP_OK. but she can also hand you these:
VPERROR_BAD_VALUEβ one or more of the voxel fields 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 have been incorrectly specified.
π SEE ALSO π
VolPack(3), vpCreateContext(3), vpNormalIndex(3), vpVolumeNormals(3), vpSetClassifierTable(3), vpSetLookupShader(3)
and that's the whole page, bestie π«Ά this one comes to you from VolPack, straight out of the library functions manual β go forth, compute those normals, and stay encoded. periodt. π
π¦ 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