#Marching Cubes surface UVs and normals

16 messages · Page 1 of 1 (latest)

cinder pecan
#

Hello. I have implemented the algorithm and the shape drawing works fine. But I have no idea how to calculate the normals and UVs for each mesh. Current grid test is very unoptimized, I quickly made it for getting the textures to work. I'd appreciate any help

https://github.com/difof/MarchingCubesExample

GitHub

Contribute to difof/MarchingCubesExample development by creating an account on GitHub.

nimble pasture
#

Thanks for sharing your code but how to run it? Main scene is not set and running grid_debug gives errors.

Awesome cube_debug 🙂

cinder pecan
nimble pasture
#

How? AKA what should I do?

cinder pecan
nimble pasture
#

Got it 😮

cinder pecan
nimble pasture
#

Reading https://docs.godotengine.org/en/4.0/tutorials/3d/procedural_geometry/immediatemesh.html you have to add uv and normals before.

I see weird planes so am not sure what you need.

[edit]: your first link You can calculate normals if you have a (real) triangle by cross product (p1-p0) x (p2-p1) no?

cinder pecan
#

that configuration should look like this, not sure why it's messed up on your end 😅

about the stackoverflow, what's the face's normal? Is it pointing out of the cube?

cinder pecan
#

Sorry my algebra is a bit weak

#

That stackoverflow answer says use the normalized average normals of adjacent faces. Since for each vertex there's always two adjacent faces, I just divide the midpoint by 2 and normalize that. But it's not correct, not sure what's off

cinder pecan
nimble pasture
#

Second link partly
What is the idea ... marching cubes has triangles .. do you have some link showing the purpose?

nimble pasture
nimble pasture