- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
I have found a reproducible error in the GLSL compiler that causes mix() to return incorrect values. The core of the problem seems to be that if mix() is passed an alpha value that is calculated as (1.0 - <variable>), something in the mix() function breaks and the resulting value becomes incorrect. In my case, I was working on a water effect for a game we're developing, and I was calculating the water extinction and then alpha as:
float waterExtinction = exp(-max(waterDepth, 0.0) * waterDensity);
float alpha = 1.0 - waterExtinction;
These values were then used to calculate the final alpha of the scene like this:
fragColor = vec4(surfaceColor.rgb, mix(surfaceColor.a, 1.0, alpha));
This resulted in a very incorrect value in fragColor.a (the output alpha value). When the resulting value should've been very close to 1.0, it ended up being around 0.5 from what I could tell. The shader ran as it should on Nvidia hardware and produced the correct alpha value. I tried flipping around the arguments to mix() and using waterExtinction directly like this to produce the mathematical equivalent:
fragColor = vec4(surfaceColor.rgb, mix(1.0, surfaceColor.a, waterExtinction));
and this actually "solved" the issue, giving me identical results to my Nvidia hardware. Again, it seems like there is some kind of bug in the compiler that causes it to get confused when (1.0 - <variable>) is passed in as the argument to mix.
The bug was found on an unknown modern integrated Intel GPU by one of our testers, and then reproduced and confirmed by me personally on an i5-3450S with an integrated HD Graphics 2500 GPU.
Here's the full shader that reproduces the error: https://pastebin.com/kM2XSsvT
Best regards / Daniel
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Daniel,
Does it happen on newer Intel GPUs? We have no planned driver releases for HD 2500 so if it is a driver issue I can't get a fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
The guy who initially discovered the issue was running an i7-4510U, which seems to contain Intel® HD Graphics 4400 GPU. Are you not maintaining drivers for that one either?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Daniel I. wrote:
The guy who initially discovered the issue was running an i7-4510U, which seems to contain Intel® HD Graphics 4400 GPU. Are you not maintaining drivers for that one either?
Haswell and Broadwell still get drivers every 3 months or so: Support for Intel® HD Graphics 4400
Unfortunately the driver developers always seem to forget (?) to commit new OpenGL fixes to HSW/BDW branch (e.g. here)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page