Blender V5.3
gbuffer Namespace Reference

Namespaces

namespace  detail

Classes

struct  AdditionalInfo
struct  ClosurePacking
struct  Header
struct  InputClosures
struct  Layers
struct  Packed
struct  Packer
struct  PackParameters
struct  Reader
struct  Reflection
struct  ReflectionColorless
struct  Refraction
struct  RefractionColorless
struct  Subsurface
struct  ThinRefraction
struct  ThinRefractionColorless

Typedefs

using Header = gbuffer::Header
using ClosurePacking = gbuffer::ClosurePacking

Functions

G-buffer Write
ClosurePacking pack_closure (const PackParameters &srt, ClosureUndetermined cl)
float3 closure_data_dither_round_to_nearest (float3 data, float3 noise)
float4 closure_data_dither_round_to_nearest (float4 data, float3 noise)
float3 closure_data_dither_flush_to_zero (float3 data, float3 noise)
float4 closure_data_dither_flush_to_zero (float4 data, float3 noise)
float3 closure_dither_noise (float2 texel, uint layer_id, float3 offset)
float4 closure_data_layer_dither_round_to_nearest (float4 data, float2 texel, uint layer_id, float3 offset)
float4 closure_data_layer_dither_flush_to_zero (float4 data, float2 texel, uint layer_id, float3 offset)
Packed pack (const PackParameters &srt, InputClosures cl_data, float3 Ng, packed_float3 surface_N, Thickness thickness, bool use_object_id)

Utilities

enum  GBufferMode : uchar {
  GBUF_NONE = 0u , GBUF_DIFFUSE = 1u , GBUF_REFLECTION = 2u , GBUF_REFLECTION_COLORLESS = 3u ,
  GBUF_UNLIT = 4u , GBUF_TRANSMISSION_BIT = 1u << 3u , GBUF_REFRACTION = 0u | GBUF_TRANSMISSION_BIT , GBUF_REFRACTION_COLORLESS = 1u | GBUF_TRANSMISSION_BIT ,
  GBUF_TRANSLUCENT = 2u | GBUF_TRANSMISSION_BIT , GBUF_SUBSURFACE = 3u | GBUF_TRANSMISSION_BIT , GBUF_THIN_REFRACTION = 4u | GBUF_TRANSMISSION_BIT , GBUF_THIN_REFRACTION_COLORLESS = 5u | GBUF_TRANSMISSION_BIT
}
GBufferMode closure_type_to_mode (ClosureType type, bool is_grayscale)
ClosureType mode_to_closure_type (uint mode)
bool color_is_grayscale (float3 color)
bool closure_is_empty (ClosureUndetermined cl)

Pack / Unpack Utils

static constexpr float closure_10bit_unit = (1.0f / 1023.0f)
static constexpr float ior_packed_lt_1_scale = (511.0f * closure_10bit_unit)
static constexpr float ior_packed_eq_1 = (512.0f * closure_10bit_unit)
static constexpr float ior_packed_gt_1_bias = (510.0f * closure_10bit_unit)
float2 normal_pack (float3 N)
float3 normal_unpack (float2 N_packed)
float ior_pack (float ior)
float ior_unpack (float ior_packed)
float thickness_pack (Thickness thickness)
Thickness thickness_unpack (float thickness_packed)
float4 closure_color_pack (float3 color)
float3 closure_color_unpack (float4 color_packed)
float4 sss_radii_pack (float3 sss_radii)
float3 sss_radii_unpack (float4 sss_radii_packed)
float object_id_f16_pack (uint object_id)
uint object_id_f16_unpack (float object_id_packed)
uint geometry_normal_pack (float3 Ng, float3 N)
float3 geometry_normal_unpack (uint data, float3 N)

Detailed Description

G-buffer: Packing and unpacking of G-buffer data.

See #GBuffer for a breakdown of the G-buffer layout.

There is two way of indexing closure data from the GBuffer:

  • per "bin": same closure indices as during the material evaluation pass. Can have none-closures.
  • per "layer": gbuffer internal storage order. Tightly packed, will only have none-closures at the end of the array.

Indexing per bin is better to avoid parameter discontinuity for a given closure (i.e: for denoising), whereas indexing per layer is better for iterating through the closure without dealing with none-closures.

Typedef Documentation

◆ ClosurePacking

using gbuffer::ClosurePacking = gbuffer::ClosurePacking

Definition at line 558 of file eevee_gbuffer_types.bsl.hh.

◆ Header

using gbuffer::Header = gbuffer::Header

Definition at line 71 of file eevee_gbuffer_read.bsl.hh.

Enumeration Type Documentation

◆ GBufferMode

Enumerator
GBUF_NONE 

None mode for pixels not rendered.

GBUF_DIFFUSE 
GBUF_REFLECTION 
GBUF_REFLECTION_COLORLESS 
GBUF_UNLIT 

Used for surfaces that have no lit closure and just encode a normal layer.

GBUF_TRANSMISSION_BIT 

Special bit that marks all closures with refraction. Allows to detect the presence of transmission more easily. Note that this left only 2^3 values (minus 0) for encoding the BSDF. Could be removed if that's too cumbersome to add more BSDF.

GBUF_REFRACTION 
GBUF_REFRACTION_COLORLESS 
GBUF_TRANSLUCENT 
GBUF_SUBSURFACE 
GBUF_THIN_REFRACTION 
GBUF_THIN_REFRACTION_COLORLESS 

Definition at line 57 of file eevee_gbuffer_types.bsl.hh.

Function Documentation

◆ closure_color_pack()

float4 gbuffer::closure_color_pack ( float3 color)

Pack color with values in the range of [0..8] using a 2 bit shared exponent. This allows values up to 8 with some color degradation. Above 8, the result will be clamped when writing the data to the output buffer. This is supposed to be stored in a 10_10_10_2_unorm format with exponent in alpha.

Definition at line 219 of file eevee_gbuffer_types.bsl.hh.

References closure_color_pack(), exp2, max, float3::x, float3::y, and float3::z.

Referenced by closure_color_pack(), pack_closure(), and sss_radii_pack().

◆ closure_color_unpack()

float3 gbuffer::closure_color_unpack ( float4 color_packed)

◆ closure_data_dither_flush_to_zero() [1/2]

◆ closure_data_dither_flush_to_zero() [2/2]

float4 gbuffer::closure_data_dither_flush_to_zero ( float4 data,
float3 noise )

Definition at line 147 of file eevee_gbuffer_write.bsl.hh.

References closure_data_dither_flush_to_zero(), and noise().

◆ closure_data_dither_round_to_nearest() [1/2]

◆ closure_data_dither_round_to_nearest() [2/2]

float4 gbuffer::closure_data_dither_round_to_nearest ( float4 data,
float3 noise )

Definition at line 135 of file eevee_gbuffer_write.bsl.hh.

References closure_data_dither_round_to_nearest(), and noise().

◆ closure_data_layer_dither_flush_to_zero()

float4 gbuffer::closure_data_layer_dither_flush_to_zero ( float4 data,
float2 texel,
uint layer_id,
float3 offset )

◆ closure_data_layer_dither_round_to_nearest()

float4 gbuffer::closure_data_layer_dither_round_to_nearest ( float4 data,
float2 texel,
uint layer_id,
float3 offset )

◆ closure_dither_noise()

float3 gbuffer::closure_dither_noise ( float2 texel,
uint layer_id,
float3 offset )

◆ closure_is_empty()

bool gbuffer::closure_is_empty ( ClosureUndetermined cl)

Definition at line 137 of file eevee_gbuffer_types.bsl.hh.

References closure_is_empty(), CLOSURE_NONE_ID, and CLOSURE_WEIGHT_CUTOFF.

Referenced by closure_is_empty().

◆ closure_type_to_mode()

◆ color_is_grayscale()

bool gbuffer::color_is_grayscale ( float3 color)

Definition at line 131 of file eevee_gbuffer_types.bsl.hh.

References all(), color_is_grayscale(), and equal.

Referenced by color_is_grayscale(), and pack_closure().

◆ geometry_normal_pack()

uint gbuffer::geometry_normal_pack ( float3 Ng,
float3 N )

◆ geometry_normal_unpack()

float3 gbuffer::geometry_normal_unpack ( uint data,
float3 N )

◆ ior_pack()

◆ ior_unpack()

◆ mode_to_closure_type()

◆ normal_pack()

float2 gbuffer::normal_pack ( float3 N)

◆ normal_unpack()

◆ object_id_f16_pack()

float gbuffer::object_id_f16_pack ( uint object_id)

Definition at line 247 of file eevee_gbuffer_types.bsl.hh.

References float, and object_id_f16_pack().

Referenced by object_id_f16_pack().

◆ object_id_f16_unpack()

uint gbuffer::object_id_f16_unpack ( float object_id_packed)

Definition at line 254 of file eevee_gbuffer_types.bsl.hh.

References object_id_f16_unpack().

Referenced by object_id_f16_unpack().

◆ pack()

◆ pack_closure()

◆ sss_radii_pack()

float4 gbuffer::sss_radii_pack ( float3 sss_radii)

◆ sss_radii_unpack()

float3 gbuffer::sss_radii_unpack ( float4 sss_radii_packed)

◆ thickness_pack()

float gbuffer::thickness_pack ( Thickness thickness)

◆ thickness_unpack()

Thickness gbuffer::thickness_unpack ( float thickness_packed)

Variable Documentation

◆ closure_10bit_unit

float gbuffer::closure_10bit_unit = (1.0f / 1023.0f)
staticconstexpr

Definition at line 170 of file eevee_gbuffer_types.bsl.hh.

◆ ior_packed_eq_1

float gbuffer::ior_packed_eq_1 = (512.0f * closure_10bit_unit)
staticconstexpr

Definition at line 172 of file eevee_gbuffer_types.bsl.hh.

Referenced by ior_pack(), and ior_unpack().

◆ ior_packed_gt_1_bias

float gbuffer::ior_packed_gt_1_bias = (510.0f * closure_10bit_unit)
staticconstexpr

Definition at line 173 of file eevee_gbuffer_types.bsl.hh.

Referenced by ior_pack(), and ior_unpack().

◆ ior_packed_lt_1_scale

float gbuffer::ior_packed_lt_1_scale = (511.0f * closure_10bit_unit)
staticconstexpr

Definition at line 171 of file eevee_gbuffer_types.bsl.hh.

Referenced by ior_pack(), and ior_unpack().