-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate UV2 and define a lightmap size hint to allow lightmap baking #15
Comments
…ping to see if it works with that. #15 Also fixing bug that returns incorrect occluder vertex indices introduced by shift to using face-vertex indexing.
The latest head should have code that generates lightmap coordinates on UV2, but I can't get lightmapping to work in Godot. Not just for Cyclops, but even with ordinary mesh objects. Could you test to see if lightmap generation is working? |
I can get lightmapping to work in the following scene with only primitive meshes in 4.0.2: test_lightmap.zip Make sure to use the Forward+ rendering method, as baking lightmaps with the Compatibility rendering method is not supported and lightmap sampling is broken in the Forward Mobile rendering method. Also, if using primitive meshes like I did in the test project, you'll have to enable Add UV2 in the PrimitiveMesh inspector. |
Looks like LightmapGI only works in Forward+ mode. I'm using ImmediateMesh to generate the geometry, so I don't think the UV2 layer needs to be explicitly enabled. I'm not sure what to specify for lightmap_size_hint. It looks like the lightmap system uses a default if you leave it blank, so maybe that's good enough? |
I was able to get your test scene to work. Looks like I can only use Forward+ to generate lightmapGI data. I don't seem to be able to bake with my blocks, though. I'm getting an error that says |
Is the MeshInstance's bake mode set to Static? This is the default since 4.0, but double-check to make sure. That said, I don't know if baking lightmaps onto ImmediateMeshes is supported. Logically, it should work if they have UV2, but I don't know if something else in the engine would prevent lightmaps to appear on them. |
I just rewrote the mesh generation to use ArrayMesh instead of ImmediateMesh. LightmapGI baking is still failing. The MeshInstance3D has bake mode set to static and I compared both the MeshInstance3D and the ArrayMesh to an imported mesh from Blender to make them as similar as possible. Nothing is working. The only thing close to a |
Looks like lightmaps cannot be baked to nodes unless their MeshIntance3D exists in the scene at edit time. |
Currently, lightmaps can't be baked on a Cyclops level (although VoxelGI, SDFGI and ReflectionProbe all work as expected). This is because no UV2 is generated for the shapes, and no lightmap size hint is set for the meshes either.
Godot doesn't expose xatlas (which is internally used to create UV2 for imported 3D scenes), so a custom method must be used here. Fortunately, shapes are usually quite simple and guaranteed to be convex, so this should be less complex than xatlas.
A lightmap scale project setting or CyclopsGlobalScene node should also be added to control the lightmap size multiplier. This can be used to make lightmaps more detailed or more coarse, depending your needs (in terms of bake times and file size).
The text was updated successfully, but these errors were encountered: