godot-llightmap icon indicating copy to clipboard operation
godot-llightmap copied to clipboard

windows 10 BUG: File queued for import, but can't be imported!

Open beetbeet opened this issue 3 years ago • 26 comments

Hello,

I am trying to use your build godot_titat_editor_013_win64, after settin uvmaps and trying to bake lightmap i have these errors:

Lightmap mesh
	num_bounces 0
	bounce_power 1
Found 2 lights.
Scene Create
voxels dims : 20, 3, 19
FillVoxels : Num AABBs 14400
NumTris 14400
plane mins : (-15.699133, -0.203871, -15.820528)
plane maxs : (15.700865, 5.2, 19.130901)
SceneCreate took 51 ms
PrepareImageMaps
PrepareImageMaps took 14 ms
ProcessTexels
ProcessTexels took 1122 ms
Dilating image
Overall took : 1270
 editor\editor_file_system.cpp:1766 - BUG: File queued for import, but can't be imported!
 editor\editor_file_system.cpp:1767 - Method failed

beetbeet avatar Sep 10 '20 08:09 beetbeet

Hmm, it is just possible that this is a path issue, windows can have slightly different paths to linux (which I'm developing on). I'll try and take a look! :+1:

Also is the final lightmap file created, i.e. can you see a png or exr file that has been made where you set the output files? (You need to set the filenames for the output files in the LLightmap inspector, I'm assuming it would error out earlier if these were not set).

I'll also try and test this in WINE.

lawnjelly avatar Sep 10 '20 08:09 lawnjelly

there is an empty lightmap file

beetbeet avatar Sep 10 '20 08:09 beetbeet

there is an empty lightmap file

Ok. I'll try and work out what might be happening. :+1:

lawnjelly avatar Sep 10 '20 08:09 lawnjelly

I will be grateful for your help because your addon is only way to have packed lightmaps in godot<4 (i dont want to have 1000 map files at my project :) )

beetbeet avatar Sep 10 '20 08:09 beetbeet

I will be grateful for your help because your addon is only way to have packed lightmaps in godot<4 (i dont want to have 1000 map files at my project :) )

Yup, I probably wouldn't have made it if the core lightmapper did all this. Necessity is the mother of invention! :smile:

Don't worry we'll get it working for you!

Also if you can attach a minimum reproduction project that will help me find out why it isn't working for you.

lawnjelly avatar Sep 10 '20 08:09 lawnjelly

Ok a simple test works for me creating a lightmap in WINE so it's probably something in the inspector settings / the level file that isn't set up right. This is not your fault as a beginner, it is something I need to make sure there are helpful error messages for at every stage to guide you.

If you can zip up a small project that you are trying to lightmap this will enable me to pinpoint the problem, but the process should be roughly as follows:

Level scene

Create a scene for your level, call it 'Level.tscn', store it in a folder 'Level'.

Just create a box mesh instance under a spatial for this scene, and make sure the box is set to 'use in baked' in the mesh instance -> geometry section of the inspector.

Main scene

  1. For your main scene, create a spatial called 'Root', link the level scene as a child.
  2. Add a LLightmap node also as a child of Root.
  3. Add another spatial child to root called 'Lights', and place an omni light as a child of this, and make sure the omni is set to bake mode 'indirect' or 'all' in the inspector (I think it defaults to indirect).

LLightmap inspector settings

Set up all the links to nodepaths and files that are needed in the LLightmap inspector.

  • Main->Mesh assign this to your Level node
  • Main->Light assign this to your Lights node

Create a folder 'Lightmaps' to store your lightmaps in your project directory (this isn't necessary but should make things clearer).

  • Files->Lightmap Filename : set this to a file that will be called 'Lightmaps/Lights.exr'
  • Files->AO Filename : set this to a file that will be called 'Lightmaps/AO.exr'
  • Files->Combined Filename : set this to a file that will be called 'Lightmaps/Combined.png'

In UVUnwrap section:

  • UV Filename : Set this to 'Level/Level_unwrapped.tscn'

Screenshot from 2020-09-10 10-25-23

Unwrapping

  • Make sure everything is saved, then set LLightmap Main->BakeMode to UVMap.
  • Click Bake lightmap.
  • Have a look at the output log, check for any errors.
  • Close the main scene, then reopen it (this is important to flush the godot cache).
  • Delete the old level from the scene, then replace it with a link to your new 'Level/Level_unwrapped.tscn' file.
  • Save the main scene again.

Lightmapping

  • Set the Bake mode to 'Lightmap'.
  • Save the main scene.
  • Click bake.

Examine to see if the Combined.png has been created.

As well as creating the lightmaps you would need to set appropriate shaders to use the lightmap, but this should be all that is needed to create a first lightmap.

lawnjelly avatar Sep 10 '20 09:09 lawnjelly

ok, still don't works, grab that simple project: https://github.com/beetbeet/godot-llightmap-testscene.git

also tehre is no way to set name for combained file (there is an error request: "Alert! Must use a valid extension."

beetbeet avatar Sep 10 '20 10:09 beetbeet

Ah maybe there is some usability issues there, or something peculiar to windows. The combined file should have a .png or .exr extension (probably .png as I haven't tested .exr in a while!).

lawnjelly avatar Sep 10 '20 10:09 lawnjelly

sure, but there is no problem with that name setting, please look at my minimal project

beetbeet avatar Sep 10 '20 10:09 beetbeet

i am trying to do every step as you with my scene and i have godot hangout after press bake lightmap (last step)

beetbeet avatar Sep 10 '20 10:09 beetbeet

i am trying to do every step as you with my scene and i have godot hangout after press bake lightmap (last step)

There very probably is a bug and it might be windows only. I'll try your testscene. :grin:

lawnjelly avatar Sep 10 '20 10:09 lawnjelly

I keep my fingers crossed that you will help me, your extension would make it much easier for me to develop my game

beetbeet avatar Sep 10 '20 10:09 beetbeet

Getting there. There were a few things in the setup that weren't right, and there was a schoolboy error in my texture reading code (for reading the texture for the light bounces).

Sorry you will have to bear with me as only the very first users are trying it and there will be some initial bugs.

I'll fix it and see if I can get it working then put up the modified files and also a fixed build of titan. :+1: :smile:

lawnjelly avatar Sep 10 '20 10:09 lawnjelly

if you manage to improve and create a new build under windows, I will be happy to drink beer with you via skype ;)

beetbeet avatar Sep 10 '20 10:09 beetbeet

lightmap_working

Got it working. Yes a combination of some misunderstandings of the settings, and most importantly a bug in the texture sampler.

I'll make some fixed builds of titan and update this repository.

lawnjelly avatar Sep 10 '20 10:09 lawnjelly

https://github.com/lawnjelly/godot-titan/releases/tag/v0.14-alpha

lawnjelly avatar Sep 10 '20 11:09 lawnjelly

There seemed to be 2 suspect things, first you were using the proxy scene. Don't worry about that file it is an intermediate for debugging, I should probably auto remove it.

Your UVmap file was not set (this is far down in the inspector in the UVMap section for LLightmap). Perhaps I should add this to the files section to make it more obvious, yes I think I will do that.

And also as you say your combined file had not been set, so it had nowhere to output. At the moment you have to manually add the extension (png or exr). I guess this is because in the godot selection box it can have either extension so maybe it can't add one for you automatically. I'll have a look and see if this can be made more user friendly.

I'll see if I can upload the fixed project here.

godot-llightmap-testscene-master-fixed.zip

What I will try and do this afternoon is make a demo video showing the whole process step by step, that should make it easier. But these are great areas you have pointed out I can improve the user friendliness. :+1:

lawnjelly avatar Sep 10 '20 11:09 lawnjelly

great, it works but it also destroys scene structure (take a look at double collider nodes etc) in unwrapped scene and i need to manual add baked lightmap to every material

beetbeet avatar Sep 10 '20 11:09 beetbeet

in yours version of my project when i move a light somewhere and try to bake again lightmap i have in console error: "Saving EXR failed. Error: Cannot write a file", but it looks that lightmap is baked

beetbeet avatar Sep 10 '20 11:09 beetbeet

great, it works but it also destroys scene structure (take a look at double collider nodes etc) in unwrapped scene and i need to manual add baked lightmap to every material

Yes it has to rebuild the meshes from scratch. I'll see if I can do this without affecting the scene structure that you have (this has not been a priority so far as it's just been at the getting it working phase! :smile: ).

Yes the lightmap texture needs to be set on the materials, I've so far been only using a few materials (and it only needs to be done once, save the materials and they are used on all meshes that use those materials). This can be automatically assisted though if needed.

lawnjelly avatar Sep 10 '20 11:09 lawnjelly

"Saving EXR failed. Error: Cannot write a file", but it looks that lightmap is baked

Ah yes, I hadn't noticed that. I don't think it is a problem, it's just a historical thing, I'll remove the warning. It's probably because you are only baking a lightmap and not AO and the original version expected both to be baked at the same time in all cases.

lawnjelly avatar Sep 10 '20 11:09 lawnjelly

great, it works but it also destroys scene structure (take a look at double collider nodes etc) in unwrapped scene and i need to manual add baked lightmap to every material

Yes, just to make clear, in order to add UV second layer mapping to all objects, they have to be made unique, i.e. any shared scenes in your original level file become separate meshes. This is common in most lightmapping solutions (and also happens with gridmap in the core lightmapper I believe).

The UV mapping process (xatlas) doesn't just add UVs, it actually adds and deletes geometry in order to create the seams required for UV islands. So the number of vertices before and after mapping will not necessarily match. But hopefully what you see on screen should match.

For this reason, you should be maintaining the original level file for editing, and only producing and lightmapping the uvmapped level at the final stage. There's no easy way around this in a module I don't think.

For the material, all I had to do was double click the material in the project tree, and drag the lightmap texture into the parameter slot and save, and it was applied to all the meshes that used that material.

Also I noticed there seemed to be some duplicate faces in the level, i.e.

wall_001
    wall_001
        wall_001 mesh
            wall_001 static
                shape0
    wall_002 mesh

Duplicate faces will be accepted but you'll tend to get rendering errors because the ray tracer can't decide between them.

lawnjelly avatar Sep 10 '20 12:09 lawnjelly

great, i will test it, thank you so much

beetbeet avatar Sep 10 '20 12:09 beetbeet

in yours version of my project when i move a light somewhere and try to bake again lightmap i have in console error: "Saving EXR failed. Error: Cannot write a file", but it looks that lightmap is baked

Turned out I'd simply made a mistake set the wrong filename in the LLightmap inspector, and that folder didn't exist hence why it wasn't writing the intermediate EXR file.

This isn't a problem when just baking lightmap, but would be a problem when merging (as merging uses the previous intermediates rather than creating them each time). I'll try and put a more helpful error message just in case this happens again. :smiley:

lawnjelly avatar Sep 10 '20 17:09 lawnjelly

Your add-on is an absolutely essential tool for someone who is currently creating a 3d godot game, like me. Only thanks to you you can have your lightmaps packed into atalases instead of a few thousand files. Thanks a lot and I keep my fingers crossed that you will develop your add-on. It will take a lot of time before the stable version of godot 4.0 comes out and I still don't know if it will support simpler devices, i.e. the current gles2 mode, which I just need to use.

beetbeet avatar Sep 10 '20 17:09 beetbeet

Your feedback has got me to add proper error checking now for wrong inspector settings for files and nodepaths.

Now if the files cannot be written or loaded it will give a message box with the filename and a suggestion to check whether the folder is present. It should be in the next version. :+1:

It also similarly checks the dimensions of loaded lights and AO intermediate files when merging, if they don't match it gives message box.

Also I made a video tutorial for making the simplest lightmap to get started: https://www.youtube.com/watch?v=QfNuHoRUwUo

It is not very amazing but hopefully better than nothing. I will try and make a better one in time with a voiceover. :smiley:

lawnjelly avatar Sep 10 '20 18:09 lawnjelly