### Godot version

4.0.dev (f581f21dd61a8fb581b80d07755cdf60c95d146d)

### System information

Windows 10 - Ryzen 7 - 4070ti

### Issue description

When using the threaded resource loader, textures on materials are lost.

This is the scene being loaded in the IDE:
![image](https://github.com/godotengine/godot/assets/1945449/232dd16b-81c4-49cf-a980-3efcfa97ff79)

This is the result in runtime:
![image](https://github.com/godotengine/godot/assets/1945449/235176d3-6058-4bed-8fbe-cad14a5e0d32)


### Steps to reproduce

Use code such as the following to load a scene:
```
func _load_scene(p_scene_path):
	var new_scene : PackedScene
	if ResourceLoader.has_cached(p_scene_path):
		# Load cached scene
		new_scene = ResourceLoader.load(p_scene_path)
	else:
		# Start the loading in a thread
		ResourceLoader.load_threaded_request(p_scene_path)

		# Loop waiting for the scene to load
		while true:
			var progress := []
			var res := ResourceLoader.load_threaded_get_status(p_scene_path, progress)
			if res != ResourceLoader.THREAD_LOAD_IN_PROGRESS:
				break;

			_progress_bar = progress[0]
			await get_tree().create_timer(0.1).timeout

		# Get the loaded scene
		new_scene = ResourceLoader.load_threaded_get(p_scene_path)
	
	$CanvasLayer.visible = false
	add_child(new_scene.instantiate())
```

Now create a scene to load that has a material with a texture.

### Minimal reproduction project

[TestResourceLoader.zip](https://github.com/godotengine/godot/files/11549692/TestResourceLoader.zip)

code += "	vec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb+detail_tex.rgb,detail_tex.a);\n";
			} break;
			case BLEND_MODE_SUB: {
				code += "	vec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb-detail_tex.rgb,detail_tex.a);\n";
			} break;
			case BLEND_MODE_MUL: {
				code += "	vec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb*detail_tex.rgb,detail_tex.a);\n";
			} break;
			case BLEND_MODE_MAX:
				break; 
		}
		code += "	vec3 detail_norm = mix(NORMAL_MAP,detail_norm_tex.rgb,detail_tex.a);\n";
		code += "	NORMAL_MAP = mix(NORMAL_MAP,detail_norm,detail_mask_tex.r);\n";
		code += "	ALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n";
	}
	code += "}\n";
	ShaderData shader_data;
	shader_data.shader = RS::get_singleton()->shader_create();
	shader_data.users = 1;
	RS::get_singleton()->shader_set_code(shader_data.shader, code);
	shader_map[mk] = shader_data;
	RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
}
void BaseMaterial3D::flush_changes() {
	MutexLock lock(material_mutex);
	while (dirty_materials.first()) {
		dirty_materials.first()->self()->_update_shader();
	}
}
void BaseMaterial3D::_queue_shader_change() {