AstrorEnales / blender_magicavoxel

Addon for the Blender 3D modeling software for loading MagicaVoxel VOX files
MIT License
32 stars 4 forks source link

Weird light behaivour in engines? (could just be Godot 4.2.1 issue) #10

Closed ZsoltHevesi closed 5 months ago

ZsoltHevesi commented 6 months ago

When trying to use this addon to create large maps, I noticed the lights cause some weird behaviour on meshes (in Godot, Blender does not have this issue with its lights). However, it only seems to be happening on the large MagicaVoxel models. Screenshot (396) Screenshot (397)

Both of these models where imported using Voxel size of 0.5, Greedy, and Material Per Colour, then exported to OBJ: magicaVox_files.zip

If anyone has used this addon and did something similar but on a different (or same) engine that didn't have this issue, please let me know and I'll create an issue for Godot instead.

AstrorEnales commented 6 months ago

Hi, i'm currently travelling so i will test it thoroughly end of march. But as all normal generation in the addon is the same for all settings this is likely a godot issue. But you can verify this quite easily by visualising the normals in blender for both models. If they look alright (facing outwards in the correct angle) after import in blender, something needs to be changed in godot settings

ZsoltHevesi commented 6 months ago

Yeah I'd be led to believe this is the case, but strangely, other voxel style meshes don't have this issue. Even if it's not an issue per se with the addon, it's definitely influencing something to do with the mesh, but I don't have enough experience in this field to find out what.

AstrorEnales commented 6 months ago

@ZsoltHevesi I tested this today and could reproduce the issue in Godot 4.2.1 and as i thought it's not an issue with the addon but rather with Godot. However, i found what Godot is missing in order for the models to be lit correctly: UVs. When using for example "material per color" no UVs are generated during import and the obj in godot looks wrong. After doing a "UV unwrap in blender after import and then loading an obj into Godot, the model is lit correctly. So i recommend doing a UV unwrap after import and before exporting the obj in blender. I will still investigate whether there is an easy addition to the addon to have this work out of the box, rather than generating uv maps in every mode that usually wouldn't require it. If there is not, i will consider that instead.

AstrorEnales commented 6 months ago

Luckily there was an easy solution in just adding a UV layer during import (no real UVs needed) and the exported obj is lit correctly in Godot. Please test the latest release and let me know if it worked for you as well :) https://github.com/AstrorEnales/blender_magicavoxel/releases/tag/v1.5.3