Farmsim Forensics: The Mystery Pixel

Kim Brandwijk
Farmsim Forensics
Published in
3 min readApr 30, 2020

Welcome to the second episode in a new series of blogs and tutorials for Farming Simulator 19 modding: ‘Farmsim Forensics’. In this series, we take a deep dive into some of the more advanced concepts and techniques used in making maps, buildings, vehicles and implements for Farming Simulator.
This is not a beginners series. Basic knowledge of the various tools used for modding, like GIANTS Editor, Blender, Photoshop or similar is assumed.

Our Mystery Pixel

In this episode, we are going to zoom in on a single pixel. This pixel lives in a file well known to FS19 map makers: the height map.
All texture files that FS19 uses are always dimensioned as a power of 2: 1024 by 1024, 2048 by 2048, etc.
Except for the height map (or ‘dem file’ as it’s sometimes affectionately called). Ask any map maker, and they’ll tell you: the heightmap is always ‘a power of 2, plus 1’, so 1025 instead of 1024, or 2049 instead of 2048.
Ask them why, and in most cases, you’ll hear ‘because that’s the way it is in the base maps’. You can’t really blame them either, we FS modders learn by example, we copy/paste, we do what works for others, out of lack of documentation, and out of lack of a deeper understanding of what’s actually going on with all of these files.
So let’s find out why!

Don’t be a parrot. Investigate, and learn!

The Terrain Mesh

First of all, let’s recap what our FS terrain actually is. It is a triangulated mesh, with a 1 meter resolution. The base map terrains are 2048 by 2048 meter. All the different map files, weight files, density files, the height map, etc. store different pieces of information about this terrain, so the game engine knows how to visualize your terrain, with elevation, foliage, fields and everything else.

Visualization of a small terrain mesh

Storing terrain information

Most of the files mentioned above store information about the faces of our terrain. Faces are the little squares (or triangles) that the terrain is made of. When you paint grass on your map, that information is stored in a weight file, and each pixel in that file corresponds to a square piece of terrain.

RavenPort’s grass weight map, the inset is enlarged to show the individual pixels

The Height Map

The height map is a little bit different though. It works the same as all the other files, it stores information about the terrain in pixels of the image. The difference is however, that the height map does not store information about the terrain faces, instead it stores information about the terrain vertices, so the points that make up the terrain mesh. Let’s have a look what happens when you try to store information about vertices instead of faces.

Each point of the terrain is centered on a pixel of the underlying image

As you can see in the image above, when you want to store information about the points of the terrain, you will need one additional pixel in both directions. That way, every pixel can store the elevation of each point in the terrain.

So there he is, our mystery pixel. And now you know why he’s there.

Each pixel in the heightmap moving a vertex of the terrain.

If you have any questions, or topics you would like to see in a future article, feel free to leave a comment.

Enjoy modding, enjoy gaming, and stay tuned for new articles!

--

--