November 15, 2019, 09:02:56 AM

Author Topic: Alternative NormalMap Function  (Read 63 times)

Offline Kippykip

  • Full Member
  • ***
  • Posts: 108
    • Kippykip Forums!
Alternative NormalMap Function
« 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.)

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1009
Re: Alternative NormalMap Function
« Reply #1 on: November 08, 2019, 05:55:19 PM »
in case you are not aware, take a look at smoothing groups (when modeling a mesh)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0