vpShadeTable(3)

✨ vpShadeTable(3) ✨

okay bestie, gather round, because we're about to talk about vpShadeTable β€” the library function that computes the contents of the shading lookup table. it's giving "VolPack's little lighting glow-up station" and honestly? iconic. πŸŽ€


🌸 SYNOPSIS 🌸

#include <volpack.h>

vpResult
vpShadeTable(vpc)
    vpContext *vpc;

πŸ’– ARGUMENTS πŸ’–

  • vpc β€” the VolPack context, aka the lil guy you got from vpCreateContext. she's the whole personality of this call, no cap.

✨ DESCRIPTION ✨

so like, vpShadeTable computes the contents of the shading lookup table that you already specified earlier with vpLookupShader (yes, previously β€” she's not out here inventing tables, she's filling them in πŸ’…).

for every single entry in that table, the Phong shading equation gets evaluated, using:

  • the current lighting properties β€” the ones you set with vpSetLight
  • the current material properties β€” the ones you set with vpSetMaterial
  • the current viewing parameters β€” the ones you set with the view transformation commands

and if you want the whole rundown of how that shading calculation actually goes down, go read vpSetMaterial(3). she spills the tea. πŸ«–

the timing rule, bestie: call this function before rendering a volume if any of the lighting or material properties have changed, or if the viewpoint has changed, since the last time you called vpShadeTable.

and like, do NOT call it if shading is being done with a callback function, or if the shading lookup tables are initialized by a user-defined routine. that's not her job. read the room. πŸ™ˆ

there's one state variable that messes with how vpShadeTable behaves:

  • if VP_CLAMP_SHADE_TABLE is enabled (see vpEnable(3)), then values get clamped to the range 0.0-255.0 before they're stored in the table.
  • if that option is not enabled, then no clamping happens at all. raw. unfiltered. no safety net. 😭

clamping is enabled by default, but you can turn it off to achieve special effects. for example: if all of the voxels in a data set have very low opacity, then the rendered image may be very dark. to brighten it, multiply all of the material parameter coefficients by a constant β€” possibly making the values exceed 1.0 β€” and turn off clamping. main character brightness arc. πŸ‘‘


πŸ¦‹ ERRORS πŸ¦‹

the normal return value is VP_OK. the following error return values are possible:

  • VPERROR_SINGULAR β€” one of the current view transformation matrices is singular. she's flatlining, bestie. πŸ’€
  • VPERROR_BAD_SHADER β€” the shading lookup tables are sized incorrectly, or one of the voxel fields used to index the tables is invalid, or the number of material types is invalid.
  • VPERROR_BAD_SHADOW β€” the angle between the shadow light vector and the viewing direction is too large (must be less than 45 degrees). either change the light direction or disable shadows (see vpSetShadowLookupShader). 45 degrees is the limit and she means it. πŸ“

🌈 SEE ALSO 🌈


and that's the whole page, babe 🫢 this was VolPack, section 3, vpShadeTable(3) β€” go shade something gorgeous and hydrate. mwah. πŸ’œβœ¨πŸ“

πŸ“¦ where this page comes from