Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.66k stars 250 forks source link

Normals on cube geometry #208

Open wrathofrathma opened 3 years ago

wrathofrathma commented 3 years ago

Whenever I apply a normal map to blocky terrains the scene just stops being lit. I checked both demos and neither include normal maps for their terrain and the getting started is more geared towards Sdf/VoxelLodTerrain.

I've tried just about every combination possible with the below stuff Mesh

Normals

Godot Builds

It only seems to work when I enable Triplanar under Uv1, but that messes up the UV mapping on blocky terrains.

The only thing I haven't really tried is exporting the material with the object in blender with normals applied, but wherever possible I would prefer to use the provided cubic geometry since it runs 15-20x faster than godot's CubeMesh & blender exported cubes.

How should I go about applying normal maps to blocky voxels?

Zylann commented 3 years ago

I think normal mapping requires tangents and these aren't included in the mesh batching process. So even if your source meshes have tangents, they will be discarded...

wrathofrathma commented 3 years ago

So I've about 70% implemented it on a fork.

Cube mesher with normals & texture (no atlas tested yet) with_normals

Cube mesher without normals without_normals

I somehow created this visual glitch on the Godot cube mesh on the custom geometry & blocky mesher(Seems to get worse when I use blender objects). But the normals work!

custom_mesh custom_mesh_normals

Woo. On the right path.

wrathofrathma commented 3 years ago

Visual glitch was apparently pre-existing or user-error(I clean compiled and tested it off of master). So submitted a pull request.