|
Blender V5.0
|
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) |
| #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.
| #define RGBE_EXPONENT_BITS 5 |
Definition at line 57 of file device/cpu/globals.h.
| #define RGBE_MANTISSA_BITS 8 |
Definition at line 56 of file device/cpu/globals.h.
| #define RGBE_MAX 65280.0f |
Definition at line 58 of file device/cpu/globals.h.
| ccl_device RGBE rgb_to_rgbe | ( | float3 | rgb | ) |
Definition at line 60 of file types_rgbe.h.
References __float_as_uint, RGBE::b, ccl_device, e, RGBE::e, fabs(), floor_log2f(), RGBE::g, ldexpf, make_float3(), max, min, power_of_2(), RGBE::r, reduce_max(), RGBE_EXP_BIAS, RGBE_MANTISSA_BITS, RGBE_MAX, round, roundf, v, float3::x, float3::y, and float3::z.
Referenced by film_overwrite_pass_rgbe(), and TEST().
| ccl_device_inline float3 rgbe_to_rgb | ( | const RGBE | rgbe | ) |
Definition at line 92 of file types_rgbe.h.
References RGBE::b, ccl_device_inline, e, RGBE::e, RGBE::f, RGBE::g, ldexpf, make_float3(), or_mask(), RGBE::r, result, RGBE_EXP_BIAS, RGBE_MANTISSA_BITS, and zero_float3().
Referenced by film_get_pass_pixel_rgbe(), kernel_read_pass_rgbe(), and TEST().