Bug 95466 - SSAO doesn't work as expected in Supertuxkart
Summary: SSAO doesn't work as expected in Supertuxkart
Status: RESOLVED WONTFIX
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-17 23:12 UTC by Deve
Modified: 2016-05-27 09:25 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
intel-wall (662.38 KB, image/png)
2016-05-17 23:12 UTC, Deve
Details
intel-wall-ssao (232.75 KB, image/png)
2016-05-17 23:13 UTC, Deve
Details
nvidia-wall (666.47 KB, image/png)
2016-05-17 23:14 UTC, Deve
Details
nvidia-wall-ssao (224.99 KB, image/png)
2016-05-17 23:14 UTC, Deve
Details

Description Deve 2016-05-17 23:12:57 UTC
Created attachment 123851 [details]
intel-wall

I am debugging it on STK side, but without success (at least for now).

You can look at the screenshots. It looks badly, especially when you are near the walls.

It works fine with other drivers, it's just a problem with intel.

You need STK version from current git to reproduce it, because in older versions there was a problem with compute shaders, which are needed for bilinear filtering. Or you can probably disable compute shaders extension and then use STK 0.9.1.

This is rather old bug, initially reported in 2014:
https://github.com/supertuxkart/stk-code/issues/1751

Here is the ssao shader that is used:
https://github.com/supertuxkart/stk-code/blob/master/data/shaders/ssao.frag

It certainly affects intel HD4000. I can't really say if it affects also newer hardware because I have no possibility to check it.
Comment 1 Deve 2016-05-17 23:13:37 UTC
Created attachment 123852 [details]
intel-wall-ssao
Comment 2 Deve 2016-05-17 23:14:05 UTC
Created attachment 123853 [details]
nvidia-wall
Comment 3 Deve 2016-05-17 23:14:26 UTC
Created attachment 123854 [details]
nvidia-wall-ssao
Comment 4 Deve 2016-05-26 00:48:15 UTC
I was able to make it working properly by this patch:

diff --git a/data/shaders/ssao.frag b/data/shaders/ssao.frag
index 641e3f9..91e528b 100644
--- a/data/shaders/ssao.frag
+++ b/data/shaders/ssao.frag
@@ -40,7 +40,7 @@ void main(void)
     float bl = 0.0;
     float m = log2(r) + 6 + log2(invSamples);
 
-    float theta = 2. * 3.14 * tau * .5 * invSamples + phi;
+    float theta = radians(mod(degrees(2. * 3.14 * tau * .5 * invSamples + phi), 360.));
     vec2 rotations = vec2(cos(theta), sin(theta)) * screen;
     vec2 offset = vec2(cos(invSamples), sin(invSamples));
 



It looks that intel drivers doesn't like to have very big cosinus and sinus angles. I needed to use modulo to make it smaller. Originally the theta value was something around 10000...
Comment 5 Kenneth Graunke 2016-05-26 07:45:08 UTC
That's correct.  I believe it goes haywire outside of the range [-2000pi, +2000pi].  A number of GPUs use approximations for sin/cos that eventually go haywire at really large angles - it'd probably be wise to have STK do a range reduction.

You can just mod(x, 6.283185307179586) rather than converting to degrees and back.
Comment 6 Deve 2016-05-27 08:13:08 UTC
Ok, it's fixed in current git STK using mod(x, 6.283185307179586) as you suggested.

I'm not sure if you want to handle this specific case on your side, or just close this bug report as invalid.
Comment 7 Kenneth Graunke 2016-05-27 09:25:18 UTC
Cool.  I'll close this as WONTFIX for now.  I'd like to avoid working around the hardware's input range problem because it's going to be expensive, and it seems to be OK without it for most applications (this is the second I've seen in 6 years, and the first non-demo).


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.