https://bugs.winehq.org/show_bug.cgi?id=41827
Bug ID: 41827 Summary: Wrong specular rendering with some applications Product: Wine Version: 1.9.24 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d Assignee: wine-bugs@winehq.org Reporter: davyaxel@free.fr Distribution: ---
Created attachment 56242 --> https://bugs.winehq.org/attachment.cgi?id=56242 Handy test app
I was investigating this gallium nine bug: https://github.com/iXit/Mesa-3D/issues/253
And strangely with that game (School Mate), both wine ogl and gallium nine do render a blue wall (for traces taken on windows or taken with gallium nine, because on wine the game hits a fallback path since swvp is not supported). Windows doesn't have that blue wall.
My investigation shows that both wine ogl and gallium nine have an issue with specular. The problem is best shown when the material power is 0 (like in the game).
I include the following test app (which I couldn't find the original link) which enables to test the behaviour:
For example you can test with:
. Take the sphere . Set SPECULARENABLE to TRUE . Set 0 for the diffuse material colors and increase the specular material colors . Set the material power to 0 (or any low value) . play with the direction of the light. Compare on windows and observe output is different. . Play with LOCALVIEWER. On wine the outputs changes a bit, whereas on windows it doesn't.
https://bugs.winehq.org/show_bug.cgi?id=41827
--- Comment #1 from Axel D davyaxel@free.fr --- A bit more information found with the test app:
. localviewer does make a difference when specular is not saturated. However when specular is saturated, the zone of the sphere lit should be exactly the same than the zone lit when diffuse is saturated. On wine it is a different zone.
The behaviour is the same for POINT and DIRECTIONNAL (didn't tested SPOT)
Here is the wine related wine code: shader_addline(buffer, "diffuse += clamp(dot(dir, normal), 0.0, 1.0)" " * ffp_light[%u].diffuse.xyz;\n", i); /* TODO: In the non-local viewer case the halfvector is constant * and could be precomputed and stored in a uniform. */ if (settings->localviewer) shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n"); else shader_addline(buffer, "t = dot(normal, normalize(dir + vec3(0.0, 0.0, -1.0)));\n"); shader_addline(buffer, "if (t > 0.0) specular += pow(t, ffp_material.shininess)" " * ffp_light[%u].specular;\n", i);
. The fact that when specular is not saturated, wine has the correct behaviour seems to show that the formulat for t is ok. . The fact that when saturated it should be same than diffuse saturated shows that the test "if (t > 0.0)" should be replaced by "if (dot(dir, normal) > 0.0)"
Then I guess pow(t, ffp_material.shininess) should be replaced by pow(abs(t), ffp_material.shininess), but that is just a guess.
https://bugs.winehq.org/show_bug.cgi?id=41827
--- Comment #2 from Matteo Bruni matteo.mystral@gmail.com --- Thank you for the bug report.
(In reply to Axel D from comment #1)
. The fact that when specular is not saturated, wine has the correct behaviour seems to show that the formulat for t is ok. . The fact that when saturated it should be same than diffuse saturated shows that the test "if (t > 0.0)" should be replaced by "if (dot(dir, normal) > 0.0)"
I just checked the FFP lighting equation in the OpenGL spec and it turns out that it contains a factor (fi) exactly matching your proposed change. In general OpenGL and D3D don't entirely agree about how to do FFP lighting (D3D does not even agree with itself between different versions) but this one sounds like it should match.
Then I guess pow(t, ffp_material.shininess) should be replaced by pow(abs(t), ffp_material.shininess), but that is just a guess.
It's more likely that we want max(t, 0.0) there.
Do you want to have a go at extending / modifying test_specular_lighting() to check for this edge case?
https://bugs.winehq.org/show_bug.cgi?id=41827
--- Comment #3 from Axel D davyaxel@free.fr --- (In reply to Matteo Bruni from comment #2)
It's more likely that we want max(t, 0.0) there.
The problem is then the behaviour of 0^0
Do you want to have a go at extending / modifying test_specular_lighting() to check for this edge case?
It'd be a good thing to do, but I have spent already a lot of time on that bug, and I'm not willing to spend more time on it.
https://bugs.winehq.org/show_bug.cgi?id=41827
--- Comment #4 from Axel D davyaxel@free.fr --- Also I recommand using the test app to find other bugs.
For example the part with is_invalid_op seems wrong, because when testing on windows, if there is an invalid stage (reading the texture), it seems to disable subsequent stages.
https://bugs.winehq.org/show_bug.cgi?id=41827
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
https://bugs.winehq.org/show_bug.cgi?id=41827
Matteo Bruni matteo.mystral@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED Fixed by SHA1| |c329ee5673c5c9864611d9276e8 | |92abdf1d1a852
--- Comment #5 from Matteo Bruni matteo.mystral@gmail.com --- This should be fixed since c329ee5673c5c9864611d9276e892abdf1d1a852. Resolving fixed, reopen if specular lighting still doesn't work right.
(In reply to Axel D from comment #4)
Also I recommand using the test app to find other bugs.
For example the part with is_invalid_op seems wrong, because when testing on windows, if there is an invalid stage (reading the texture), it seems to disable subsequent stages.
We stick to one issue per bug report. Please open separate bug reports for additional issues, if they are still present with current Wine.
https://bugs.winehq.org/show_bug.cgi?id=41827
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #6 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 2.17.