Render Normal map

The two results of python and blender are quite different. The result of blender is a bit better. How can I modify the code to achieve the result of blender?

    from vedo import *
    import numpy as np

    mesh = Mesh("CWom0012-HD2-O02P13-S-1.obj").computeNormals()

    normals = mesh.getPointArray("Normals")
    # print(np.linalg.norm(normals, axis=1))

    normals[:, 0] = normals[:, 0] / (2.0)
    normals[:, 1] = normals[:, 1] / (-2.0)
    normals[:, 2] = normals[:, 2] / (2.0)
    normals = ((normals + 0.5) * 255).astype(np.int)
    # normals = 100 * 0.5 + normals * 0.5
    # print(normals)

    mesh.addPointArray(normals, 'mynorms').mapPointsToCells()
    cellsRGB = mesh.getCellArray('mynorms')
    mesh.cellIndividualColors(cellsRGB).computeNormals()

    show(mesh, axes=0)

result of code:

result of Blender:

1 Like

I don’t have any knowledge about scripting to help, maybe you should ask in scripting section.

i guess this was inverted for directx or other engines with inverted green channel

just delete the minus to get (2.0)

normgreen1