Created
September 16, 2025 18:27
-
-
Save preddy5/03184df0a07337544b8746e86ef7e5bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import vedo | |
| import numpy as np | |
| # Load or create a mesh | |
| mesh = vedo.Sphere(res=50).triangulate() | |
| # Compute normals | |
| mesh.compute_normals() | |
| normals = mesh.pointdata["Normals"] | |
| # Map normals from [-1,1] to [0,1] for RGBA coloring | |
| normals_col = (normals + 1) / 2.0 | |
| normals_col = ((normals + 1) / 2.0 * 255).astype(np.uint8) | |
| normals_col = np.concatenate([normals_col, np.ones_like(normals_col[:, :1])*255], axis=-1) | |
| mesh.pointcolors = normals_col | |
| # Create a Plotter | |
| plt = vedo.Plotter(offscreen=True) # offscreen allows saving without GUI | |
| plt.show(mesh, "Mesh with Normal Map Coloring", axes=1) | |
| # # Save screenshot | |
| plt.screenshot("mesh_normals.png") | |
| plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment