3D Images

Introduction

3D images can be seen as the assembly of several 2D images in slices. They’re good at capturing volume information and are used a lot in the medical and oil & gas fields. HOOPS Luminate supports 3D images both in the software and hardware renderers. However, such images can be really really big and some graphics hardware may not be able to handle them.

Description

Even if 3D images can be seen as “augmented” 2D images, there are some major differences between the two:

  • Mipmapping is not supported

  • Power-of-two as well as non-power-of-two images are addressed using texture coordinates in the [0,1]x[0,1]x[0,1] interval

Except for those points, 3D images can be seen exactly as 2D images with one more dimension.

Creation of 3D Images

3D image creation does not differ from other image creation methods and is quite simple:

Creating a 3D Image

RED::Object* image_3d;

// Create the image.
RC_TEST( iresmgr->CreateImage3D( image_3d, iresmgr->GetState() ) );

RED::IImage3D* i3d = image_3d->As< RED::IImage3D >();

// Let the engine to allocate the image 256x256x256 pixels array for us.
RC_TEST( i3d->SetLocalPixels( NULL, RED::FMT_RGB, 256, 256, 256 ) );

unsigned char* pixels = i3d->GetLocalPixels();
for( int z = 0; z < 256; ++z )
    for( int y = 0; y < 256; ++y )
        for( int x = 0; x < 256; ++x )
            // Fill in the texture...

// Set the texture content to the renderer.
RC_TEST( i3d->SetPixels( RED::TGT_TEX_3D, iresmgr->GetState() ) );

This code sample creates a 3D image, uses HOOPS Luminate to allocate a local pixel array in the image and uploads the contents of this local pixel array in the engine (therefore on the GPU if HOOPS Luminate uses GPU rendering, and in CPU memory is HOOPS Luminate uses software rendering). The local pixel array remains. It can be deleted if not needed anymore using RED::IImage3D::ClearLocalPixels.

In software rendering mode, any pixel format is supported for 3D images. In Hardware rendering mode, the list of supported pixel formats depends on the graphics card capabilities and may vary from one chipset to the other.

Note

A complete example of real-life 3D image creation and rendering is shown in Volume View.