Removes detail texture layer (frees slot, compacts remaining layers, returns 1=success 0=not found).
Takes entityHandle (mesh/terrain entity handle), textureHandle (texture handle identifying which layer to remove).
Returns 1 (TRUE) if layer removed successfully, 0 (FALSE) if texture not found or error.
3D Graphics
Parameters & Returns
Parameters
entityHandleInt
textureHandleInt
Returns
Int
Quick Summary
Removes detail texture layer (frees slot, compacts remaining layers, returns 1=success 0=not found).
Takes entityHandle (mesh/terrain entity handle), textureHandle (texture handle identifying which layer to remove).
Returns 1 (TRUE) if layer removed successfully, 0 (FALSE) if texture not found or error.
Technical Exegesis...
Removes detail texture layer (frees slot, compacts remaining layers, returns 1=success 0=not found). Takes entityHandle (mesh/terrain entity handle), textureHandle (texture handle identifying which layer to remove). Returns 1 (TRUE) if layer removed successfully, 0 (FALSE) if texture not found or error. Finds detail layer containing textureHandle, removes it, shifts higher layers down to compact array (no gaps), clears last slot. Mesh and terrain entities only.
This function removes detail layers.
Removes detail texture layer (frees slot, compacts remaining layers, returns 1=success 0=not found). Takes entityHandle (mesh/terrain entity handle), textureHandle (texture handle identifying which layer to remove). Returns 1 (TRUE) if layer removed successfully, 0 (FALSE) if texture not found or error. Finds detail layer containing textureHandle, removes it, shifts higher layers down to compact array (no gaps), clears last slot. Mesh and terrain entities only.
This function removes detail layers. Layer identification: searches detailTextureIndex[0-2] for matching textureHandle (finds which layer contains this texture), returns 0 if not found (texture not in any detail layer, already removed or never added). Layer compaction: shifts remaining layers down to fill gap (if removing layer 0 then layer 1 becomes 0, layer 2 becomes 1, layer 2 cleared, if removing layer 1 then layer 2 becomes 1, layer 2 cleared, if removing layer 2 just clear layer 2), ensures no gaps in layer array (always layers 0, 1, 2 filled from left with empty slots at right). Slot clearing: last layer (layer 2 after compaction) set to detailTextureIndex=-1, detailBlendFactor=0.0 (marks as empty, ready for new texture). Material handling: surface-based meshes (procedural shapes) update all surface materials directly (returns 1 if any surface succeeded), loaded meshes (GLB models) update mesh.materialIndex material (single material for entire mesh), terrain entities update terrain.materialIndex material. Use cases: (1) Dynamic detail management (remove detail when no longer needed, add different detail), (2) Slot reuse (remove to free slot for new detail texture when all 3 occupied), (3) Conditional details (remove detail based on game state, distance, quality settings), (4) Cleanup (remove temporary decals after timeout), (5) Layer swapping (remove old detail, add new detail for variation). Common patterns: remove layer result = b3dRemoveEntityDetailTexture(entity, detailTex) if result = 0 then print "Detail not found", swap detail b3dRemoveEntityDetailTexture(entity, oldDetail) then b3dSetEntityDetailTexture(entity, newDetail), cleanup loop for detail in detailTextures then b3dRemoveEntityDetailTexture(entity, detail). Typical usage: remove when detail no longer needed (free slot for different texture), remove to reduce rendering cost (fewer texture samples in shader), remove before freeing texture (clean references to avoid dangling handles), remove for dynamic layer management (swap details based on conditions). Compaction example: before removal [dirt, scratches, decal], remove scratches, after removal [dirt, decal, -1] (decal shifted down from layer 2 to 1, layer 2 cleared). Layer order preservation: remaining layers maintain relative order (if had [A, B, C] remove B results [A, C, -1], C still after A), important if shader blending depends on layer order. Material layer arrays: detailTextureIndex[3] stores texture handles, detailBlendFactor[3] stores opacities (both compacted together, factor follows texture to new slot). Not found return: returns 0 if textureHandle not in any layer (safe, allows removing without checking if present first, idempotent operation). Performance: O(1) for loaded mesh or terrain (finds layer, shifts at most 2 elements), O(N) for procedural mesh with N surfaces (all surfaces updated), compaction is trivial (2 shifts maximum). Shader impact: fewer active detail layers reduces texture sampling cost (if all 3 slots empty shader skips detail sampling, if 1 slot used only 1 extra sample), removal improves performance if detail no longer visible. Return value semantics: 1 (TRUE) if texture found and removed from any layer, 0 (FALSE) if texture not found in any layer (already removed or never added), 0 (FALSE) on error (invalid handle, no material). Multiple calls: calling multiple times with same textureHandle safe (first call removes and returns 1, subsequent calls return 0 not found, no error). Validation: prints error if invalid entity handle, invalid texture handle, entity is not mesh or terrain, entity has no material, returns 0 for all errors. Related: b3dSetEntityDetailTexture adds detail layer (inverse operation, allocates slot), b3dSetEntityDetailAlpha adjusts layer opacity (alternative to removal, set alpha=0.0 to hide without removing), b3dFreeTexture frees texture GPU memory (call this after removing from all entities).