WebGL: Incorrect polygon and disc fill color

Avatar
  • updated
  • Unity's Fault

Issue: Polygon components change their fill color when canvas is resized. Notice that when the viewport is narrow scene appears as intended.
Video: https://cratebeforeattack.com/bug-report-shapes/video.mp4

Expected behavior: fill color of Polygon components appear the same with any canvas size.

Reproducable on:
* Chrome (88.0.4324.146) / Windows on NVIDIA GTX 660 (457.30, 461.40).

Failed to reproduce on:
* Chrome (88.0.4324.146) / Linux on NVIDIA GTX 660 (455.45).
* Chrome (88.0.4324.146) / Window / Linux on Intel HD4400 (Mesa 20.2.1).
* Firefox (85.0) / Windows on NVIDIA GTX 660
* Native Windows builds

Reproduction steps:
* Checkout minimal reproduction case: https://github.com/koalefant/bug-report-shapes
* Add Shapes to Assets folder.
* Make WebGL build
* Use index.html from Build/index.html to have canvas resized with the window.

Ready-to-run build: https://cratebeforeattack.com/bug-report-shapes/

I also observe similar issue with Discs in my project, but these are not included in the reproduction case.

Reporting a bug? please specify Unity version:
2020.2.2f1
Reporting a bug? please specify Shapes version:
2.3.2
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
Freya Holmér
  • Answer
  • Unity's Fault

this is super strange, it does unfortunately look like this is in Unity's hands, so you might want to report a bug with them

I don't have any platform specific code, and yet somehow it seems to fail on that specific windows/chrome combination :(

Avatar
Freya Holmér
  • Under Review

does this happen when objects are not marked as static?

Shapes doesn't support static batching, so it shouldn't happen regardless - batching should be forced off by the shader :c

Avatar
Koalefant

The Static option is not set on any of the GameObjects. What I meant by "static" is that there is no code manipulating Shape components in any way. Unfortunate wording on my side.

Avatar
Freya Holmér
  • Answer
  • Unity's Fault

this is super strange, it does unfortunately look like this is in Unity's hands, so you might want to report a bug with them

I don't have any platform specific code, and yet somehow it seems to fail on that specific windows/chrome combination :(

Avatar
Koalefant

Thank you for checking it so quickly.

Avatar
Koalefant

Some additional random observation:

This issue goes away when I disable GPU instancing by means of commenting out in Polygon shaders:

//#pragma multi_compile_instancing


I did capture with Spector.js. Apart from uniform offsets the difference that I noticed was changing length of

UNITY_UNIFORM PropsArray_Type PropsArray[32                                 ];

between 32 (working) and 64 (broken).

Avatar
Koalefant

And unrelated to the issue itself: in Polygon Core.inc there is an assignment of v.vertex to itself, it seems to be there to silence a shader compiler warning "use of potentially uninitialized warning". That later one goes away when GetFillCoords is restructured to have just a single return statement in the end.

Avatar
Koalefant

I have this issue with version 3.0 as well and the same workaround applies there:

//#pragma multi_compile_instancing


Avatar
Freya Holmér
Quote from Koalefant

Unity's QA was able to reproduce the issue:
https://issuetracker.unity3d.com/issues/webgl-third-party-plugins-shapes-dot-polygon-component-has-visual-artifacts-when-resizing-the-player-canvas-slash-browser

Happy to see some progress despite issue-ID having 7 digits.

I'm glad! and thanks for taking the time to report it :)

Avatar
Koalefant

Another workaround for this: disabling "Auto Graphics API" in Player settings and forcing Graphics APIs to WebGL1 (removing WebGL2 from the list).

Avatar
Koalefant

Unity has closed the ticket:

Google already has a fix CL. https://chromium-review.googlesource.com/c/angle/angle/+/2790518
The bug was in their GL to DX translation, Angle, where they weren't padding the uniform block properly, causing the data alignment issue. The Chrome bug report is at https://bugs.chromium.org/p/chromium/issues/detail?id=1193170#c3

I'll close this case. It will take some time for the Chrome fix to make it to the stable branch, and in the meantime you can turn off instancing in the shader, or use WebGL1.