Skip to content
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

Terrain scene will not load #438

Open
rslonake opened this issue Apr 29, 2024 · 5 comments
Open

Terrain scene will not load #438

rslonake opened this issue Apr 29, 2024 · 5 comments

Comments

@rslonake
Copy link

Started this morning... I have been working on this terrain for months and now when I try to open the terrain.tscn I get the following error...

"No loader found for resource: res://terrain_data/data.hterrain (expected type: )"

I pasted the text of my data.hterrain file below... it looks empty. I opened an older version of the project and the data.hterrain is much larger... it looks like the attached file is corrupted???

Is it safe to say I have lost all my work since my last version save?

Here is the contents of my data.hterrain file:

{
"maps": [
[
{
"id": 0
}
],
[
{
"id": 0
}
],
[
{
"id": 0
}
],
[
{
"id": 0
}
],
[],
[],
[],
[]
],
"version": "0.11"
}

@Zylann
Copy link
Owner

Zylann commented Apr 29, 2024

No loader found for resource: res://terrain_data/data.hterrain (expected type: )

That sounds somewhat related to the years-long issue #232, but from your perspective the problem has happened already and you're only seeing a consequence. There is an infuriatingly elusive heisenbug in Godot that makes save/load randomly fail when GDScript plugins use custom savers/loaders. Godot is litterally failing to find the HTerrain loader (which is right here) and simply fails with an unhelpful, bogus message telling it expected "" (empty string). (assuming you didn't see any other errors in your log?).
To this day, he cause still hasn't been found (and to my knowledge nobody is investigating it).

However if you say you've been working on it for months, it definitely got saved at least once, so I wouldn't expect your work to be corrupted.

I pasted the text of my data.hterrain file below... it looks empty

Regular terrain metadata may look like that, it's not empty.

I opened an older version of the project and the data.hterrain is much larger

Not sure what could possibly cause this, other than deleting some detail layers maybe, or changing the shader, though I understand you might not have done that.

Is it safe to say I have lost all my work since my last version save?

It's not lost, the plugin doesn't delete things. It saves regular images next to your data.hterrain, so if you still have them, then your work isn't lost. All data.hterrain does is to reference those images under specific IDs matching a naming convention of the images:

image

id is used to decouple the file itself from its ID in terrain data. id is incremented by 1 if you have multiple maps (like multiple splatmaps or detailmaps), except in eventual cases where you could have deleted one in the middle, in which case the index in the array will not match with id (this removes the need to rename files or remove them just because you might have reordered layers or removed a layer).

Example of a terrain with multiple splatmaps and one detail map:

{
	"maps": [
		[
			{
				"id": 0
			}
		],
		[
			{
				"id": 0
			}
		],
		[
			{
				"id": 0
			},
			{
				"id": 1
			},
			{
				"id": 2
			},
			{
				"id": 3
			}
		],
		[
			{
				"id": 0
			}
		],
		[
			{
				"id": 0
			}
		],
		[],
		[],
		[]
	],
	"version": "0.11"
}

So maybe it could be edited to link back the images from your older version (if you use Git, it help).

However if the plugin/Godot failed to save the terrain last time, then your progress might have been lost after you closed Godot last time.
If the images themselves have reverted, then unless you have them versionned somewhere, they might be lost. The only way I know that this could happen, is if you actually overwrote them with a new terrain (but who knows, I've seen fuckups happen in Godot where it's half of the time user's fault without noticing, and other half Godot being buggy or error-prone). Again, versionning is very important to prevent this.

There is unfortunately nothing I can do to fix whatever issue it might be, especially without any way to reproduce this. Every time I see someone having issues loading/saving, I jump into my test project and try saving/loading a bunch of test scenes, and nothing ever goes wrong... I don't know what happened in your case. All the plugin does is listen to Godot requesting the HTerrainData resource to be saved, and similar in order to load. As mentionned in #232, the sparse evidence we have so far points towards a bug somewhere in Godot that happens randomly, making it incredibly difficult to know what is going on (asuming it is related).

@rslonake
Copy link
Author

Thanks for the feedback. I will keep investigating. By the way, I really like this plug-in and thank you for all the time that you've spent working on it. And for getting back to me so quickly about this issue.

@rslonake
Copy link
Author

Quick question... as I mentioned, I have an older version of this project on my computer. I believe most of the changes are not terrain related. If I drag my terrain data folder from the old version to the new version do you think that it should load?

In other words, all terrain data is in the terrain data folder, correct?

@Zylann
Copy link
Owner

Zylann commented Apr 29, 2024

all terrain data is in the terrain data folder, correct?

Yes. Properties such as selected shader or LOD distance are stored in the scene, but the actual terrain data such as heights, splatmaps or detail layer maps, are stored in the terrain data folder.

@rslonake
Copy link
Author

Good news... I was able to get my terrain back. I was just about to give up and scrap the project and go back to my previous version, but I thought, "Let's try one last thing." I deleted the terrain addon and reinstalled... readded the hterrain node and there it was! Just needed to rescale and add reimport the textures. (The texture maps were there but everything was white - once I reimported the textures it filled in the map).

Thanks again for your advice and help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants