This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Is there a way in Godot 4 to load textures at runtime from outside the res:// file system without importing them into Godot beforehand?

I've already tried a lot, but somehow I can't get any further and either get the error that resources have to be imported beforehand or, in the case of DDS textures, the error: Unrecognized or unsupported color layout in DDS.

Edit: External textures added for completeness can be loaded in both 3.5 and 4 as dds with the ResourceLoader. I had good results with the BC1/DXT1 format without mip maps.
For example, textures created under Godot 4 can be packed into a resource package with the PCKPacker at runtime, which can then be loaded at runtime and the dds textures contained therein can be used.

Godot version Godot 4 Beta7
in Engine by (12 points)
edited by

2 Answers

0 votes

Not really sure why you would want to load textures from outside the godot file system but in any case as far as I am aware it isnt possible. There is however a resource loader you can use to import the textures into the godot file system, details can be seen here

by (3,328 points)

Thanks for the answer. Yes, this is exactly the part that gives me troubles with Godot 4. In the meantime I have tried it under 3.5, where images can be loaded without any problems. Only under Godot 4 it doesn't seem to work.
I'll play around with this a bit and maybe post it as a issue later.

Ahh yes sorry i am in fact still using godot v3.5 as I dont want to port my whole game to 4 so it might be the case that there is some difference or error on godot 4.

0 votes

I've had success with this code loading .png in Godot 4.0 stable.
There is an example in docs for ImageTexture

var image = Image.load_from_file(path)
var texture = ImageTexture.create_from_image(image)
brush.texture = texture

Here, path is an absolute path received by FileDialog picker, with file in the desktop folder, brush is a TextureRect
Tried on Windows 10. Seems to work in exported project also.

by (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.