Elaztek Developer Hub
Blamite Game Engine - blam!  00453.06.08.26.0624.blamite
The core library for the Blamite Game Engine.
materials.cpp File Reference
+ Include dependency graph for materials.cpp:

Classes

struct  pbr_uniform_data
 
struct  unlit_uniform_data
 

Macros

#define PBR_SLOT_PARAMS_0   0
 
#define PBR_SLOT_PARAMS_1   1
 
#define PBR_SLOT_PARAMS_2   2
 
#define PBR_SLOT_PARAMS_3   3
 
#define PBR_SLOT_CLEAR_COAT   4
 
#define PBR_SLOT_DETAIL_PARAMS   5
 
#define PBR_SLOT_UV_ALBEDO   6
 
#define PBR_SLOT_UV_NORMAL   7
 
#define PBR_SLOT_UV_METAL_ROUGH   8
 
#define PBR_SLOT_UV_OCCLUSION   9
 
#define PBR_SLOT_UV_EMISSIVE   10
 
#define PBR_SLOT_UV_SPECULAR   11
 
#define PBR_SLOT_UV_DETAIL_0   12
 
#define PBR_SLOT_UV_DETAIL_1   13
 
#define PBR_SLOT_UV_DETAIL_2   14
 
#define PBR_SLOT_UV_DETAIL_3   15
 
#define PBR_SLOT_UV_DETAIL_NORM_0   16
 
#define PBR_SLOT_UV_DETAIL_NORM_1   17
 
#define PBR_SLOT_UV_DETAIL_NORM_2   18
 
#define PBR_SLOT_UV_DETAIL_NORM_3   19
 
#define PBR_SLOT_UV_DETAIL_WEIGHT   20
 
#define SET_PACKED_SLOT(slot_idx, x_, y_, z_, w_)
 

Functions

material_filter_modes resolve_min_filter (material_filter_modes material_filter, bitmap *bitmap_tag)
 Resolves the effective minification filter mode by combining the material's requested filter mode with the bitmap tag's filter mode and force flag. More...
 
material_filter_modes resolve_mag_filter (material_filter_modes material_filter, bitmap *bitmap_tag)
 Resolves the effective magnification filter mode using the same inheritance rules as resolve_min_filter, but consulting the magnification-specific tag fields and force flag. More...
 
material_filter_modes resolve_mip_filter (material_filter_modes material_filter, bitmap *bitmap_tag)
 Resolves the effective mip filter mode using the same inheritance rules as resolve_min_filter, but consulting the mip-specific tag fields and force flag. More...
 
uint64_t build_sampler_flags (material_filter_modes min_filter, material_filter_modes mag_filter, material_filter_modes mip_filter, material_wrap_modes wrap_x, material_wrap_modes wrap_y, material_wrap_modes wrap_z)
 Computes the bgfx sampler flag bits that correspond to the requested min/mag/mip filter modes and wrap modes for one texture. More...
 
uint64_t compute_sampler_flags_for_texture (material_filter_modes material_min, material_filter_modes material_mag, material_filter_modes material_mip, material_wrap_modes wrap_x, material_wrap_modes wrap_y, material_wrap_modes wrap_z, bitmap *bitmap_tag)
 Computes the final bgfx sampler flags for one material texture binding. More...
 

Macro Definition Documentation

◆ PBR_SLOT_CLEAR_COAT

#define PBR_SLOT_CLEAR_COAT   4

◆ PBR_SLOT_DETAIL_PARAMS

#define PBR_SLOT_DETAIL_PARAMS   5

◆ PBR_SLOT_PARAMS_0

#define PBR_SLOT_PARAMS_0   0

◆ PBR_SLOT_PARAMS_1

#define PBR_SLOT_PARAMS_1   1

◆ PBR_SLOT_PARAMS_2

#define PBR_SLOT_PARAMS_2   2

◆ PBR_SLOT_PARAMS_3

#define PBR_SLOT_PARAMS_3   3

◆ PBR_SLOT_UV_ALBEDO

#define PBR_SLOT_UV_ALBEDO   6

◆ PBR_SLOT_UV_DETAIL_0

#define PBR_SLOT_UV_DETAIL_0   12

◆ PBR_SLOT_UV_DETAIL_1

#define PBR_SLOT_UV_DETAIL_1   13

◆ PBR_SLOT_UV_DETAIL_2

#define PBR_SLOT_UV_DETAIL_2   14

◆ PBR_SLOT_UV_DETAIL_3

#define PBR_SLOT_UV_DETAIL_3   15

◆ PBR_SLOT_UV_DETAIL_NORM_0

#define PBR_SLOT_UV_DETAIL_NORM_0   16

◆ PBR_SLOT_UV_DETAIL_NORM_1

#define PBR_SLOT_UV_DETAIL_NORM_1   17

◆ PBR_SLOT_UV_DETAIL_NORM_2

#define PBR_SLOT_UV_DETAIL_NORM_2   18

◆ PBR_SLOT_UV_DETAIL_NORM_3

#define PBR_SLOT_UV_DETAIL_NORM_3   19

◆ PBR_SLOT_UV_DETAIL_WEIGHT

#define PBR_SLOT_UV_DETAIL_WEIGHT   20

◆ PBR_SLOT_UV_EMISSIVE

#define PBR_SLOT_UV_EMISSIVE   10

◆ PBR_SLOT_UV_METAL_ROUGH

#define PBR_SLOT_UV_METAL_ROUGH   8

◆ PBR_SLOT_UV_NORMAL

#define PBR_SLOT_UV_NORMAL   7

◆ PBR_SLOT_UV_OCCLUSION

#define PBR_SLOT_UV_OCCLUSION   9

◆ PBR_SLOT_UV_SPECULAR

#define PBR_SLOT_UV_SPECULAR   11

◆ SET_PACKED_SLOT

#define SET_PACKED_SLOT (   slot_idx,
  x_,
  y_,
  z_,
  w_ 
)
Value:
state->packed_pbr_data[(slot_idx) * 4 + 0] = (x_); \
state->packed_pbr_data[(slot_idx) * 4 + 1] = (y_); \
state->packed_pbr_data[(slot_idx) * 4 + 2] = (z_); \
state->packed_pbr_data[(slot_idx) * 4 + 3] = (w_)

Function Documentation

◆ build_sampler_flags()

uint64_t build_sampler_flags ( material_filter_modes  min_filter,
material_filter_modes  mag_filter,
material_filter_modes  mip_filter,
material_wrap_modes  wrap_x,
material_wrap_modes  wrap_y,
material_wrap_modes  wrap_z 
)

Computes the bgfx sampler flag bits that correspond to the requested min/mag/mip filter modes and wrap modes for one texture.

The output is the bitwise-OR of bgfx's BGFX_SAMPLER_* macros, suitable for passing to bgfx::setTexture's flags parameter. Filter modes that match bgfx's defaults (linear filtering, wrap addressing) contribute no bits.

"none" filter is treated as point filter since bgfx doesn't have a true "no filter" concept and point is the closest equivalent.

Parameters
min_filter- The resolved minification filter mode.
mag_filter- The resolved magnification filter mode.
mip_filter- The resolved mip filter mode.
wrap_x- Wrap mode for the U/X texture coordinate.
wrap_y- Wrap mode for the V/Y texture coordinate.
wrap_z- Wrap mode for the W/Z texture coordinate (used by 3D/cube textures).
Returns
A uint64_t containing the bitwise-OR of all applicable BGFX_SAMPLER_* bits.
Author
Claude (Opus 4.7)
+ Here is the caller graph for this function:

◆ compute_sampler_flags_for_texture()

uint64_t compute_sampler_flags_for_texture ( material_filter_modes  material_min,
material_filter_modes  material_mag,
material_filter_modes  material_mip,
material_wrap_modes  wrap_x,
material_wrap_modes  wrap_y,
material_wrap_modes  wrap_z,
bitmap bitmap_tag 
)

Computes the final bgfx sampler flags for one material texture binding.

Resolves the inherit_from_bitmap and force_*_filtering_mode logic between the material's per-texture sampler settings and the bitmap tag's settings, then maps the resolved filter and wrap modes to bgfx flag bits.

Parameters
material_min- The material's requested minification filter mode.
material_mag- The material's requested magnification filter mode.
material_mip- The material's requested mip filter mode.
wrap_x- Wrap mode for the U/X texture coordinate.
wrap_y- Wrap mode for the V/Y texture coordinate.
wrap_z- Wrap mode for the W/Z texture coordinate.
bitmap_tag- The bitmap being sampled (may be nullptr if not resolved).
Returns
The complete sampler flag set for bgfx::setTexture.
Author
Claude (Opus 4.7)
+ Here is the call graph for this function:

◆ resolve_mag_filter()

material_filter_modes resolve_mag_filter ( material_filter_modes  material_filter,
bitmap bitmap_tag 
)

Resolves the effective magnification filter mode using the same inheritance rules as resolve_min_filter, but consulting the magnification-specific tag fields and force flag.

Parameters
material_filter- The material's per-texture filter mode setting.
bitmap- Pointer to the bitmap tag (or nullptr if no bitmap was found).
Returns
The resolved filter mode that should actually be used.
Author
Claude (Opus 4.7)
+ Here is the caller graph for this function:

◆ resolve_min_filter()

material_filter_modes resolve_min_filter ( material_filter_modes  material_filter,
bitmap bitmap_tag 
)

Resolves the effective minification filter mode by combining the material's requested filter mode with the bitmap tag's filter mode and force flag.

If the bitmap has its force_min_filtering_mode flag set OR the material asks to inherit, the bitmap's filter mode wins. Otherwise the material's choice wins. Used by compute_sampler_flags_for_texture.

Parameters
material_filter- The material's per-texture filter mode setting.
bitmap- Pointer to the bitmap tag (or nullptr if no bitmap was found).
Returns
The resolved filter mode that should actually be used.
Author
Claude (Opus 4.7)
+ Here is the caller graph for this function:

◆ resolve_mip_filter()

material_filter_modes resolve_mip_filter ( material_filter_modes  material_filter,
bitmap bitmap_tag 
)

Resolves the effective mip filter mode using the same inheritance rules as resolve_min_filter, but consulting the mip-specific tag fields and force flag.

Parameters
material_filter- The material's per-texture filter mode setting.
bitmap- Pointer to the bitmap tag (or nullptr if no bitmap was found).
Returns
The resolved filter mode that should actually be used.
Author
Claude (Opus 4.7)
+ Here is the caller graph for this function:
state
sock planetquake com All rights reserved Quake III Arena is a registered trademark of id Inc This level may be electronically distributed only at NO CHARGE to the recipient in its current state
Definition: chiropteraDM.txt:94