Blender V5.0
types_rgbe.h File Reference
#include "util/math_fast.h"
#include "util/math_float3.h"
#include "util/types_base.h"

Go to the source code of this file.

Classes

struct  RGBE

Macros

#define RGBE_EXP_BIAS   15
#define RGBE_MANTISSA_BITS   8
#define RGBE_EXPONENT_BITS   5
#define RGBE_MAX   65280.0f

Functions

ccl_device RGBE rgb_to_rgbe (float3 rgb)
ccl_device_inline float3 rgbe_to_rgb (const RGBE rgbe)

Macro Definition Documentation

◆ RGBE_EXP_BIAS

#define RGBE_EXP_BIAS   15

RGBE format represents an RGB value with 4 bytes.

The original implementation by Greg Ward uses 8 bits for RGB each, plus 8 bits shared exponent. It has the same relative precision as the 0 to 255 range of standard 24-bit image formats, but offers extended intensity range: https://www.graphics.cornell.edu/~bjw/rgbe.html GL_EXT_texture_shared_exponent uses 9 bits for RGB and 5 bits for exponent instead, with smaller range but higher precision: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_shared_exponent.txt

Our implementation is mostly based on GL_EXT_texture_shared_exponent, but uses 8 bits for RGB each, and adds 3 sign bits to represent negative values. The memory layout is as follows:

   xxxxxxxx  xxxxxxxx  xxxxxxxx  xxx  xxxxx
     m(R)      m(G)      m(B)    sgn   exp

Each float component is interpreted as sgn exp - bias f = (-1) * 0.m * 2

We choose a bias of 15, so that the largest representable value is RGBE_MAX = 0.11111111 * 2^(31 - 15) = 65280, and the smallest positive representable value is RGBE_MIN = 0.00000001 * 2^(0 - 15) = 1.1920929e-7

Definition at line 55 of file device/cpu/globals.h.

◆ RGBE_EXPONENT_BITS

#define RGBE_EXPONENT_BITS   5

Definition at line 57 of file device/cpu/globals.h.

◆ RGBE_MANTISSA_BITS

#define RGBE_MANTISSA_BITS   8

Definition at line 56 of file device/cpu/globals.h.

◆ RGBE_MAX

#define RGBE_MAX   65280.0f

Definition at line 58 of file device/cpu/globals.h.

Function Documentation

◆ rgb_to_rgbe()

◆ rgbe_to_rgb()