Sets texture atlas region size for surface baking (must be power-of-2, 16-2048).
Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), size (atlas region dimension in pixels, integer).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
meshInt
surfaceInt
sizeInt
Returns
Void
Quick Summary
Sets texture atlas region size for surface baking (must be power-of-2, 16-2048).
Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), size (atlas region dimension in pixels, integer).
Returns nothing.
Technical Exegesis...
Sets texture atlas region size for surface baking (must be power-of-2, 16-2048). Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), size (atlas region dimension in pixels, integer). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, and surface index valid. Validates size is power-of-2 (16, 32, 64, 128, 256, 512, 1024, 2048). Sets surface->atlasRegionSize=size. Silently returns on validation errors.
Sets texture atlas region size for surface baking (must be power-of-2, 16-2048). Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), size (atlas region dimension in pixels, integer). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, and surface index valid. Validates size is power-of-2 (16, 32, 64, 128, 256, 512, 1024, 2048). Sets surface->atlasRegionSize=size. Silently returns on validation errors. Size determines UV mapping space when mesh baked to texture atlas.
This function configures surface's allocation size in texture atlas during mesh baking. Texture atlas baking combines multiple materials into single texture (b3dBakeMesh, b3dSaveMeshBaked) - each surface gets rectangular region. Region size controls quality vs memory tradeoff: larger regions = higher resolution textures = more detail, smaller regions = lower resolution = atlas fits more surfaces. Power-of-2 requirement: GPU texture filtering and mipmap generation optimized for power-of-2 dimensions - enforced for performance. Valid sizes: 16x16 (minimal, low detail), 32x32 (low detail), 64x64 (medium-low), 128x128 (medium), 256x256 (high), 512x512 (very high), 1024x1024 (ultra), 2048x2048 (maximum). Default size if not set: typically 256x256 or atlas_packer default. Use cases: (1) Quality control (important surfaces get 512x512, minor details get 64x64), (2) Memory optimization (balance atlas size by assigning appropriate region sizes), (3) LOD baking (different region sizes for different detail levels), (4) Uniform texel density (calculate region size based on surface area for consistent pixel density). Atlas bin-packing: baking algorithm packs regions into single square texture - total atlas size determined by sum of region areas and packing efficiency. Common workflow: create mesh with multiple surfaces, assign different region sizes based on importance, call b3dBakeMesh to generate atlas texture, use baked texture for rendering. Region size vs surface geometry: size is texture space only - doesn't affect vertex positions or triangle count. UV remapping: during baking, original UVs (0-1 range) scaled and offset to fit assigned atlas region. Non-power-of-2 rejected: attempting 100x100 or 300x300 fails silently (size not set, uses default). Atlas overflow: if total region sizes exceed maximum atlas dimensions (typically 4096x4096 or 8192x8192), baking may fail or reduce quality. Typical usage: b3dSetSurfaceRegionSize(mesh, 0, 512) for primary surface, b3dSetSurfaceRegionSize(mesh, 1, 128) for secondary details. Alternative: accept defaults if all surfaces have similar importance, manually create texture atlas in image editor.