-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
SVG Backend gouraud_triangle Correction #11378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Great! Can you investigate why the tests are failing? We seem to have lost the pep8 checking on master, there are some issues (trailing white space, too long lines) that will need to be cleaned up. |
@tacaswell Checked and corrected the PEP8 test issues. |
@tacaswell The "travis-ci" test suite contains a pcolormesh test in test_axis which uses SVG backend for gouraud shading. Due to the wrong implementation, the expected SVG image is generating the failure. Expected SVG Output (Incorrect)Corrected Fix Output |
The "Corrected Fix Output" has some strange pixels in the rightmost image. Are they expected? In how far is this "more correct" than the current output? |
@ImportanceOfBeingErnest The rightmost image is using Gouraud shading in SVG. The strange pixels are due to limitations of SVG features. Most of the triangle edges are dissolved (compared to flat shading) due to use of 3 colors per triangle and filtering them. But some of them would remain visible as there is no direct method to implement Gouraud shading in SVG. |
I wonder if the current implementation, while academically incorrect, would give smoother results, one should not stick to it? |
@ImportanceOfBeingErnest Current implementation is not giving smoother results. You misread it. The SVG gouraud shading (implemented in the paper: http://www.svgopen.org/2005/papers/Converting3DFaceToSVG/index.html) works well for smoother input images. |
@avinashmnit30 can you update the svg image (the easiest way is to run the tests locally and then commit the svg)? is the Agg version of the test so the updated one is certainly closer. We are also looking an png versions of the svg file the 'hot' pixel may be a rendering artifact (not a feature of the svg file). |
@tacaswell Completed the SVG image update. |
@ImportanceOfBeingErnest |
In Firefox, the svg still renders as flat vertices, though the annoying dashes between facets goes away. In Illustrator both the old and new versions look bad. So,... what is the canonical SVG viewer? I don't see that either the ones I use manage to make gouraud shading look correct... Old FirefoxNew Firefox |
@avinashmnit30 If you get a chance could you rebase and squash this into 1 or 2 commits? |
As far as I know there is not a 'canonical' svg viewer, just a specification document. |
pcolormesh.svg update
@tacaswell I have rebased it to single commit now. |
Thanks @avinashmnit30 ! |
PR Summary
As pointed out in #11321, the SVG backend does not render Gouraud shading correctly. ts mentioned that SVG backend is following http://www.svgopen.org/2005/papers/Converting3DFaceToSVG/index.html paper. But the Gouraud triangle implementation is incorrect. This pull request fixes the implementation.
Code for reproduction: https://matplotlib.org/2.0.1/examples/pylab_examples/quadmesh_demo.html
SVG Backend Orignal Output:

Using correct implementation:
