When going through the source code of some platform games I have noticed they use .png and .jpeg images in their source code for the sprites and various animations. I was curious if modern first person shooter games use the same strategy or do they just rely on a game engine such as Unreal or Rockstar Game Engine to render their graphics.
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
You may have looked at the install directory of a major 3D game and wondered where all of the texture files are.
Almost all 3D games do come with image files that are loaded from the game data, just like a 2D game engine could load a PNG image; But there are some major differences between how 2D and 3D game engines work that lead to PNG files being less useful than other formats to store the image data in.
Some of the reasons that 3D games do not use PNG or JPEG files in particular:
- Number of textures used:
In a 3D perspective, you have the potential to display hundreds of textures in one frame. Loading all of these textures from a PNG file and then copying them to the GPU can take a long time. It is quicker to load a compressed image that the GPU can directly use.
- Textures can have additional "layers":
Bump maps, Normal maps, Specular Maps, etc. All of these are additional images that have to be lined up and combined properly to render a surface. Since these textures need to be bundled together, the file type they are stored in takes care of this too.
- To prevent user tampering/modding:
This is especially true for multiplayer games; Imagine if you could simply replace a wall texture with a transparent PNG image!
- To save space:
Even if there were PNG files included in the game data, games often ship with a compressed resource library that contains all of the game assets in a single or handful of files.
Despite these reasons to not use regular image files, game engines usually support loading these types of files and engines with resource managers such as Unity and Unreal will convert them automatically to the format that is optimal for that engine when you build the game.