Advertisement

I am developing a game engine but is it bad to import all textures in the project?

Started by November 04, 2023 11:59 AM
9 comments, last by Vilem Otte 1 year ago

Hello, I'm developing a game engine and I'm currently importing all the textures in the Asset folder when the project is opened. But won't this cause problems in large projects? For example, there are 5gb textures in the project and loading all of them is an unnecessary use of memory? Does it make sense to make a dynamic texture loader? That is, loading the textures in the current scene, un-loading all the textures when you switch to another scene and loading only the textures of that scene?

I'm Using DirectX 12

Thanks

If you want to make a general game engine, then yes, streaming in assets at the right time is going to be necessary. Some games have many hundreds of gigs of various assets, most notably textures. On the other hand, if you're making an engine to support a specific small indie game, and you know that the asset size is going to be small, then you can just load them all. As a general rule, supporting general or large games is going to require far more complexity than specific or small games.

Advertisement

@Brian Sandberg Ah thank you! Btw for making general engine, this situations for all asset types right? Meshes, Textures (Loading by scene)

Textures, meshes, audio, anything that might have too large a footprint. Some assets will be small and could be loaded permanently, like a bitmap font or spites for your UI, but if you're implementing dynamic asset loading it's probably the same amount of work no matter how many types you do it for.

Thanks a lot, I started with meta file and UUID system <3

yimx said:
Hello, I'm developing a game engine and I'm currently importing all the textures in the Asset folder when the project is opened.

Do you mean doing this in some kind of editor or in a runtime (which will run the actual project on engine)?

Dynamic asset loading in runtime obviously makes sense - for 2 reasons - first one is, that you don't need to load ALL assets for given game into memory, as they may not fit into memory, and second one is loading times. When loading zillion assets it's also going to take a long time to load anything.

Editor is another thing, and often more problematic decision. First of all - how big are your projects? If they are small enough to easily fit RAM and VRAM, and more importantly you have well defined data formats that are very fast to load, loading ALL files may make sense. The problem is what to do when projects become too big.

  • You may need preview on images/meshes/… - dynamic loading when looking through assets will be necessary
  • You will need to track what is in scene and hold it in RAM and VRAM for use

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

Advertisement

@Vilem Otte Actually im adding setting to my game engine for this (Dynamic Asset Loading or Full Asset Import on Runtime (for small and 2d projects))

I am not building a huge engine but I would like to implement such techniques on my engine xD,

Right now im writing .meta file system. In meta file i have path's, uuid's etc.

When there will be any load operation, all information will be pulled from these meta files.

Whenever there is a scene change, the asset diffs between scenes will be calculated, and load/unload accordingly.

I can shortly describe mine:

Currently the engine's editor loads all the resources in project directory (although it can do so on demand). Basically all resources that are in project directory are referenced (and also watched for changes for hot-loads). They can either be loaded right away (which is what I currently do in editor now), or loaded whenever and object referencing the resource is processed (which is what I do for some assets in runtime).

In the above screenshot you can notice that I'm looking for some texture - opening a texture manager where you can filter through textures by name, and most importantly - you do see how texture looks like. Because the last thing you want to do, is selecting only by name.

I don't use meta files (the necessary data is stored in memory and possibly serialized/deserialized from (non-compiled) scene file). Asset diffs are handled either by directory watcher directly (while running editor) or by scene loading (when opening scene from editor).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

@Vilem Otte So you are loading all textures?

In runtime no, in editor yes. Well… yes for standard textures (virtual textures no - you wouldn't be able to fit them in memory).

This could run into problems when assets are too big - my point is, that it is managed and dynamic (which I guess is what you want). Easy to switch between those 2 approaches technically on asset type level. Also, it's not just textures that are in assets - for some it makes a lot more sense to load them all (shaders, custom components (basically cpp files runtime compiled to dlls), etc.).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

This topic is closed to new replies.

Advertisement