SyntaxBomb - Indie Coders

Languages & Coding => BlitzMax / BlitzMax NG => MiniB3D => Topic started by: Kippykip on November 08, 2019, 11:46:35 AM

Title: Alternative NormalMap Function
Post by: Kippykip on November 08, 2019, 11:46:35 AM
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:

Code: [Select]
'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())
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.)
Title: Re: Alternative NormalMap Function
Post by: RemiD on November 08, 2019, 05:55:19 PM
in case you are not aware, take a look at smoothing groups (when modeling a mesh)
SimplePortal 2.3.6 © 2008-2014, SimplePortal