REDsdk textures and images

Image and texture management is a key part in REDsdk. Textures are needed to reach a high visual quality, and images in general can be processed by REDsdk for a variety of purposes. In the rest of this book as in the REDsdk API documentation, we'll refer indifferently to texture or images as the same type of object.

A texture is generally a source image loaded somehow from the computer disk and intended to be applied to an object for its rendering (a wood texture on a wooden shelf for instance, a marble texture, etc...). An image is the generic term designating an array of pixels, that can be used for any purpose. In REDsdk we'll switch between terms depending on the way they get used, but in the end this is the same object under the hood.

Image types

REDsdk supports different types of images:

Image typeInterfaceDescription
2D imagesRED::IImage2DThis is the most common image kind found. REDsdk supports both POTD (Power-Of-Two-Dimensioned) and NPOTD (Non-Power-Of-TwoDimensioned) 2D images. POTD images can benefit of hardware rendering modes that NPOTD images can't use. NPOTD images have a wider range of available pixel formats than POTD images do have. This category covers 1D images (color ramps) as well.
Render imageRED::IImage2DRender images is one of the most important 2D images types in REDsdk, as render images capture the rendering results of an auxiliary RED::IViewpointRenderList to an off-screen buffer. Render images are 2D images.
3D imagesRED::IImage3DGiven one more dimension, REDsdk can store 3D images as blocks of texels, and provides a ( u, v, w ) sampling access to these images.
Cube imagesRED::IImageCubeCube images define 6 faces of a cube and are commonly used for spherical or cubical environmental mapping display.
Composite imagesRED::IImageCompositeA composite image is a REDsdk specific image. A composite image is a 2D image that is generated by user-defined (or built-in) REDsdk programs. A composite image can be used to implement a complete hierarchical shading tree that results in a single 2D image that can then be reused by a shader.
Readback imagesRED::IImageReadbackThe readback is another specific image kind in REDsdk. A readback image provides the application with a direct channel from the GPU video memory by reading pixels back to the CPU. This image kind should be used by high performance applications that need to retrieve data from the video board.

Image pixel formats

Various image pixel formats are supported in REDsdk. These are defined by the RED::FORMAT enumeration. These formats are divided in two categories:

REDsdk also features a special anti-aliased HDR format (the RED::FMT_FLOAT_RGBA_AA format). This is a special REDsdk compressed format storing anti-aliasing and background information in a HDR image. This format authorizes dynamic edition of post-processing settings during and even after the rendering has completed.

Please, refer to the chapters dedicated to each image type for in-depth explanations.

The image target

Each image has a target which can be any of the RED::TARGET enumeration entries. This describes the usage we can make of the image. However, when using software rendering, targets are relaxed a little bit as RED::TGT_TEX_1D is a special case of RED::TGT_TEX_2D while there is no difference between RED::TGT_TEX_2D and RED::TGT_TEX_RECT.

When writing hardware shaders you need to be careful to make your texture sampling code to match the target of the input textures (especially power-of-two 2d textures need texture coordinates in [0,1]x[0,1] while RECT 2d textures need texture coordinates in [0, texture width]x[0, texture height]). This is fully covered in Using images as textures.