More than a texture patch? (Part 7)


More than a texture patch? (Part 7)

ThielHater | 31 lug 2022

This part is about a new feature of the Gothic Reloaded Mod, which is still in development: The times of day and the weather.

One could also speak of atmosphere, ambience, mood, nature or environment, although I am not satisfied with any of these terms. I wanted the game experience to be more lifelike, more varied and more immersive. I wanted the player to feel the sun during the day, lightning and thunder when raining, see the fog roll in during the evenings, have darker nights and moon phases. However, this was not feasible with the traditional means of Gothic modding - fortunately there is Union now.

The inspiration for this came from newer games like The Witcher, but also from the Atmospheric Mod by Sand47. It was first published for Gothic 2 and then for Gothic 1. While researching for this article, I found that this project seems to have been forgotten. I couldn't find a release thread, just this review. The download is seemingly only possible via the Web Archive. Well then it is my turn to present this project.

Water textures are incredibly difficult to create. In the Atmospheric Mod, the structure, colouring and animation of the water are fantastic. You have the feeling of actually being on an island and looking out to sea. The sky technically consists of an upper and a lower layer. Gothic 2, however, only uses one of them and displays these white, almost comic-like clouds there. In the Atmospheric Mod, on the other hand, both levels are used so that the sky appears higher and wider. The colours of the clouds are also harmonised.

At night, the sky is equally impressive. Compared to Gothic 2, the stars are smaller and of varying brightness, you feel like being a part of the universe. A special effect is that they glitter when the camera moves. This is an interesting effect, but it is due to the fact that the textures do not have mipmaps. The sea is darker and seems more mysterious. But back to the Gothic Reloaded Mod.

Our conquest of the sky began with the dynamic generation of the clouds. First I had to figure out how to change the textures at runtime. As a starting point, I chose the function zCTextureFileFormatInternal::LoadTexture(), which receives a file name, loads the corresponding textures and returns it. I overwrote it and returned an empty, black texture for each call. The result was impressive.

Next I tried to capture the screen content and use it for a specific texture. This worked and resulted in an entertaining picture-in-picture effect.

The clouds are based on random noise, which I obtain from the library FastNoise by Jordan Peck. To generate the clouds, sections of the noise are taken and layered on top of each other with different scaling and opacity.

If you choose the parameters properly, convincing clouds come out. The preview function of FastNoise was very helpful here. As I found out afterwards, the colours were reversed in-game and it was time to replace the texture of the sky instead of the ground.

However, as you can see on the left above the hero, the texture was not tileable. Tiling is when the texture repeats on a surface without being noticed. The solution was to use a different algorithm that generates a periodic noise. I was able to achieve the best results with fractal Perlin noise.

The result is not yet perfect, but it is convincing. The plug-in is not only intended to improve the representation of the weather, but also its control. Therefore, I first taught Gothic to change the weather every second, switching between sunny and clouded weather as well as our dynamically generated sky.

The implementation of moon phases was not a big problem, as the technical hurdles had already been overcome. The most exciting part was the determination of the moon phase, which should correspond to the current moon phase in-game as a little gimmick. To do this, one has to calculate the time distance to a past full moon and can then use the moon's orbital period of 29.53 days to determine where it currently is in its cycle. Then the texture which has been adjusted for the respective moon phase is set.

Another feature is the representation of the sky as a hemisphere like in Gothic 2. However, there are still rendering errors, which I have not yet been able to solve. All in all, the plug-in is still at the beginning of its development, we are still doing basic research, so to speak.