vpGetImage(3)

πŸ’– vpGetImage β€” get a field of the intermediate image πŸ’–

okay bestie, sit down, hydrate, and let's talk about vpGetImage(3) from the VolPack library, aka your little backstage pass to the messy middle of the render pipeline ✨


🌸 NAME 🌸

vpGetImage β€” literally just: get a field of the intermediate image 🫢


✨ SYNOPSIS ✨

#include <volpack.h>

vpResult
vpGetImage(vpc, image, width, height, scan_bytes, pixel_type,
        image_type)
    vpContext *vpc;
    void *image;
    int width, height;
    int scan_bytes;
    int pixel_type, image_type;

πŸŽ€ ARGUMENTS πŸŽ€

  • vpc β€” your VolPack context, the one you got from vpCreateContext. your main character.
  • image β€” a 2D array where the result image goes to live. it's the destination, it's the moment.
  • width β€” width of that array, in pixels.
  • height β€” height of that array, in pixels.
  • scan_bytes β€” how many bytes per scanline in the array. yes it's bytes not pixels, read the name bestie.
  • pixel_type β€” a code that says what format each pixel in the array is in.
  • image_type β€” a code that says where the image data is coming from. your two options are VP_IMAGE_BUFFER or VP_SHADOW_BUFFER. that's it, that's the menu.

πŸ‘‘ DESCRIPTION πŸ‘‘

so this one is a debugging function, no cap. it's here so you can peek at one of the temporary rendering buffers used while rendering β€” specifically the intermediate image or the shadow buffer. πŸ’…

here's the lore: rendering happens in two stages. first the volume gets resampled and composited into the intermediate image, which gives you a distorted volume rendering. then that intermediate image gets warped into the final image. and if shadows are enabled, the shadow buffer gets used during that first stage to incrementally compute which voxels are lit up by the light source. πŸ’‘

what this function hands you is the images produced during the first stage, before the final warp. so like, the behind-the-scenes cut, not the final edit. 🎬

you can call this after calling one of the rendering routines (see vpRenderRawVolume(3)).

  • if image_type is VP_IMAGE_BUFFER, data gets copied from the intermediate image. the pixel_type argument says what info to copy and what format to store it in the output array. the possible values for pixel_type are the same as for the pixel_type argument to vpSetImage. for instance, use VP_LUMINANCE to extract the grayscale intensity (assuming the current shader produces grayscale pixels).
  • if image_type is VP_SHADOW_BUFFER, data gets copied from the shadow buffer instead. and here's the catch: the only valid option for pixel_type is VP_ALPHA, because there's literally no color information stored in the shadow buffer. so don't try it. πŸ™ˆ

for the details on the pixel formats, the layout of the output array, and the remaining arguments β€” go read vpSetImage. she has the answers, I'm just the messenger. πŸ“¬

and to figure out how big your result array needs to be, use vpGeti with:

  • the VP_INTERMEDIATE_WIDTH and VP_INTERMEDIATE_HEIGHT options (when image_type is VP_IMAGE_BUFFER), or
  • the VP_SHADOW_WIDTH and VP_SHADOW_HEIGHT options (when image_type is VP_SHADOW_BUFFER).

get the size first, then allocate. order of operations, periodt. πŸ’―


😭 ERRORS 😭

the normal return value is VP_OK. everything's fine, we're thriving, slay. 🌈

the following error return values are possible:

  • VPERROR_BAD_SIZE β€” the destination array size is incorrect, OR there is no intermediate image. either way, not the vibe. πŸ’€
  • VPERROR_BAD_OPTION β€” the field argument is invalid. 🚫

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page bestie!! πŸ₯³ this one comes to you from the VolPack library manual β€” Library Functions Manual energy, vpGetImage(3) forever, mwah πŸ’– go get those intermediate images, you've got this 🫢✨

πŸ“¦ where this page comes from