Alternative NormalMap Function

Started by Kippykip, November 08, 2019, 11:46:35

Previous topic - Next topic

Kippykip

Hey guys, I noticed OpenB3D / MiniB3D have a bit of difficulty calculating normals on meshes that have multiple groups.
Such as here (might have to zoom as the images have the scanline filter):

So here's what this alternative function does to the normalmaps instead:


'Custom UpdateNormals equivilant that works on mesh groups better
Function NormaliseNormals(mesh:TMesh)
For Local s:Int = 1 To CountSurfaces(mesh)
Local surf:TSurface = GetSurface(mesh, s)
For Local vert:Int = 0 To CountVertices(surf) - 1
TFormPoint(VertexX(surf, vert), VertexY(surf, vert), VertexZ(surf, vert), mesh, mesh)
VertexNormal(surf, vert, TFormedX(), TFormedY(), TFormedZ())
Next
Next
End Function

It could be optimised better, I added this to my internal mesh loader function (where duplicates use either CopyEntity or CopyMesh, to avoid recalculating and reloading off the hard disk.)

RemiD

in case you are not aware, take a look at smoothing groups (when modeling a mesh)