A year or so back I was planning on writing a congratulatory article to show my appreciation to Dave Airlie for fixing a long standing bug in Mesa that prevented users of older AMD Radeon HD cards from enjoying Trine Enchanted Edition on the free graphics stack. Bug 91808 resulted in a variety of graphical artifacts which, while not interfering with the gameplay, still put me off using that version of Trine.
After several years and a great deal of evident frustration on his part, Airlie was able to track down the root of the problem and at long last was able to push a fix to master in May 2018. Airlie and developers like him are often the unsung heroes of FOSS development, and I wanted to give him a well deserved public pat on the back for his effort in fixing a bug which would only have affected such a small number of people.
Unfortunately my research into this led me down an entirely different rabbit hole when I discovered the report for Bug 66067. A much more subtle misrendering of the game's colours and lighting, this bug is present in both Trine 2 and Trine Enchanted Edition. Unlike the previous instance where it was an issue in the drivers that was the culprit, this issue is present in the game binaries themselves.
Trine Enchanted Edition when affected by Mesa bugs 91808 and 66067.
Unlike the proprietary vendor drivers provided by Nvidia and AMD, the free Mesa stack as a rule does not implement application specific fixes and instead adheres more strictly to the standards outlined by Khronos Group and other similar bodies. There are a number of reasons for this, mostly relating to adhering to a higher standard of code quality, and thus limiting the maintenance overhead for the FOSS developers.
In developing their games Frozenbyte made certain mistakes related to texture sampling and shadow sampling which were not technically in line with specifications, but are still accommodated for by most vendor drivers. The result is that the game will only render correctly for AMD users on Mesa when provided with specific patches that allow it to mimic the same incorrect behaviour found in the proprietary blob.
Applying these patches is nontrivial for the uninitiated, but through the use of Arch Build System I was able to spin my own Mesa packages to play through my copies of both Trine Enchanted Edition and Trine 2: Complete Story as the developer originally intended. The proper solution would be for Frozenbyte to patch their games to adhere to the correct Cg standard, but that now seems very unlikely.
Trine Enchanted Edition rendering correctly with a patched Mesa.
Frozenbyte was an early adopter of Linux, first through the porting house Alternative Games and then later through their own in-house development starting with Trine 2. The Humble Frozenbyte Bundle in April 2011 was the first Humble Bundle I ever purchased, and I got a lot of enjoyment from their games through the first half of our soon to close decade. As recently as 2016 their game Shadwen was released with full Linux support.
Since then a lot has changed over at Frozenbyte. The studio no longer has the same depth of Linux savvy programmers it once had, and following the release of Shadwen has been teaming up with publishers more intent on the console market. Its last three titles have all lacked Linux support, and with the release of Trine 4: The Nightmare Prince last month, the series is no longer fully represented on our platform.
Lacklustre Linux sales and internal restructuring following the lukewarm reception on all fronts to the third release in the franchise Trine 3: The Artifacts of Power appear to have taken Frozenbyte out of the Linux market for good. With even their old games struggling to run well on the Mesa graphics stack, it marks a sad end to a series that once provided so much colour to our platform.
UPDATE: Daniel Scharrer got in touch in the comments to provide some technical clarifications and share his LD_PRELOAD hack that solves the problem at the application rather than the driver level.
Those wanting to try the series can find Trine: Ultimate Collection on either GOG.com or Steam. Note that as stated before Trine 4: The Nightmare Prince does not currently have Linux support.
I am a software developer, and I see more developers getting into Linux all the time. Even the ones that do not use it are somewhat familiar with it because of servers or the WSL environment on Windows.
QuoteIn developing their games Frozenbyte made certain assumptions related to shadow sampling which were not technically in line with specifications, but are still accommodated for by most vendor drivers.
The source of this problem is not an assumption on Frozenbyte's part but Nvidia Cg language where texture sampling and shadow sampling use the same function name but take a 3 an 4 component vector respectively so it's really easy to use the shadow version by mistake. This is not a problem on Nvidia hardware where the shadow test is not enabled by the shader code but by the texture (sampler) state.
This also affects many games than just Trine, but the sourced is not always the Cg compile:
- Portal 2 and Portal 2 based games (at least Portal Stories: Mel is affected, probably others).
- Never Alone (Kisima Ingitchuna)
- The Book of Unwritten Tales: The Critter Chronicles (other installments in the series are fine IIRC)
The Critter Chronicles is interesting because it ships the Cg sources for its shaders. I reported all shaders that were (likely) affected to KING Art.
Btw I made some hackish LD_PRELOAD libraries that either replace all shadow sampling instructions with non-shadow ones or replace shaders outright:
https://github.com/dscharrer/void/blob/master/hacks/trinefix.c
https://github.com/dscharrer/void/blob/master/hacks/neveralonefix.c
However this really should be worked around in Mesa since this problem is so widespread, but I never got around to creating a proper fix.
QuoteFrozenbyte was an early adopter of Linux, first through the porting house Alternative Games and then later through their own in-house development starting with Trine 2.
After 14 years of using Linux, and at least a decade of starting Windows only for gaming (and work), Trine 2 was the first professional game I bought and played on Linux, in late 2012. When I started it, it took quite some seconds to come out of a black screen, so I thought it wouldn't work. I wasn't vastly disappointed at that moment, because I had that feeling, trained in a long time, that Linux just isn't a gaming system. So it was a pleasant surprise when it left the black screen and I could play it. So, still thanks, Frozenbyte!
Quoting: dscharrerThe source of this problem is not an assumption on Frozenbyte's part but Nvidia Cg language where texture sampling and shadow sampling use the same function name but take a 3 an 4 component vector respectively so it's really easy to use the shadow version by mistake. This is not a problem on Nvidia hardware where the shadow test is not enabled by the shader code but by the texture (sampler) state.
Cheers for the clarifications. I have updated the article to better reflect this.
Quoting: HamishQuoting: vskyeThat's sad. I have Trine and Trine 2 in my library and have enjoyed them, and was looking forward to trying out the rest of the series.Just to be clear, Trine 3 does have Linux support at least. I have not played it though due to still having an older graphics card without OpenGL 4 support.
i played 1-3 and 3 does not have workshop support on linux, so it is better to play it with proton anyways
First two games were fantastic, but it is sad that they have dropped linux now.
Last edited by Maath on 20 November 2019 at 4:56 pm UTC
See more from me