Recalculates vertex normals with flat shading (hard edges, per-face normals). Takes mesh (mesh entity handle). Returns nothing. Validates entity exists and type is ENTITY_MESH. Validates mesh is surface-based. For each triangle, calculates face normal using cross product of edge vectors. Assigns the same face normal to all three vertices of that triangle (no averaging across faces). Normalizes each face normal vector. Marks surfaces and mesh as needing GPU update. Silently returns on errors.
Recalculates vertex normals with flat shading (hard edges, per-face normals). Takes mesh (mesh entity handle). Returns nothing. Validates entity exists and type is ENTITY_MESH. Validates mesh is surface-based. For each triangle, calculates face normal using cross product of edge vectors. Assigns the same face normal to all three vertices of that triangle (no averaging across faces). Normalizes each face normal vector. Marks surfaces and mesh as needing GPU update. Silently returns on errors.
This function creates flat/hard shading where each face has uniform lighting across its entire surface. Unlike b3dUpdateNormals (which averages normals across shared vertices for smooth shading), this function assigns per-face normals without averaging. Essential for: (1) Flat-shaded objects (cubes, boxes, architectural geometry), (2) After vertex welding on flat shapes (welding merges vertices which breaks flat shading - use this to restore it), (3) Low-poly aesthetic (hard edges, faceted appearance), (4) After unwelding vertices (b3dUnweldVertices duplicates vertices, this sets their normals).
Compare to b3dUpdateNormals: b3dUpdateNormals accumulates face normals at shared vertices and averages them (smooth shading). b3dUpdateNormalsFlat assigns face normal directly without averaging (flat shading). Use b3dUpdateNormals for smooth organic shapes (spheres, characters). Use b3dUpdateNormalsFlat for hard-edged geometry (cubes, buildings).
Visual difference: Smooth normals create gradual lighting transitions across surfaces. Flat normals create sharp lighting transitions at edges. Flat shading makes individual faces clearly visible. Performance: O(n) iteration over triangles. Does not trigger GPU operations (deferred until unlock/render). Coordinate system: right-handed, Y-axis up, normals point outward from front face (counter-clockwise winding).
Example
Example.bam
; Create a cube and ensure flat shading after weldingLocal cube:Int = b3dCreateCube(1, 0, 0)
b3dLockMesh(cube)
b3dWeldVertices(cube, 0.01) ; Merge duplicates
b3dUnweldVertices(cube) ; Split back for flat shading
b3dUpdateNormalsFlat(cube) ; Calculate per-face normals
b3dUnlockMesh(cube)
; Result: Cube has proper flat shading with hard edges