-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Shading rendering artefacts #6305
Comments
There are two kinds of problems, the "white spots" and the "extra side stuff". The white spots in the middle for the CIB file are likely because the shadings are only approximated by the use of a triangle mesh for each type 6 (coons) patch. See here for an explanation by Shaola Ren who developed it as part of GSoC2014: PDFBox uses this method and it seems PDF.js does it too, based on some comments I've seen in the code. Here's a file with type 7 (tensor) that is rendered nicely with the released version (likely because only flag 0 is used), although with some white spots: I'll create a PR for tonight for type 7, however it doesn't solve the lamp_cairo.pdf file, but it solves another file I created. You can see that the current rendering has a similar problem than the CIB file before the change. I'll try to find a file that I didn't create myself and that renders fully nicely with the change to prove my point. another: |
This is an absolutely minimal example of type 4 (Gouraud) shading for debugging which I just created. It has a single triangle, RGB, and no function. But in rendering it shows a vertical line in the same color as one of the corners, it is outside of the triangle, and even outside of the bounds rectangle. If anybody wants to make slight changes for debugging, here's the postscript code, which can be converted to PDF with ghostscript:
Coons and Tensor patches are made of many triangles, so this could result in many "extra" lines like seen with the lamp_cairo.pdf file or my coons test file. Another one for the list of artefacts |
I searched on 250000 PDF files (the digitalcorpora files) and had about 50 files with ShadingType 7, but none with flags other than 0. The lamp_cairo.pdf file does also not use these flags. So PR #6310 will be visible only for the two test files mentioned. |
pi is an index in the stream and is explained on page 201 of the 32000-spec (however 1-based there), and ps is an index to something in PDF.js. I used the code from flag 0 (which works) to understand which is which. It is also important to understand that for flags 1,2 and 3, the stream is always assigned to the same coordinates and colors. What changes is which "old" coordinates and colors are assigned to what is "missing" in the stream. This is why for these flags, the code is identical except for the assignments in the first "row". (Same principle as in mozilla#6304). Note that this change will not improve the lamp_cairo.pdf file, only the two files mentioned in mozilla#6305.
From the two bottom PDFs in #6305 (comment) only very minor differences with rendering in Adobe Acrobat/Reader remain after #6310, but they are quite insignificant. |
Hi :) I know this a very old issue, but since we currently experience something very similar with some of the pdfs of a client, I just wanted to check if there are any plans to fix this in the near future? I could also provide a sample pdf if that helps! Is there maybe something we could do to prevent this otherwise? I am absolutely no expert here, so maybe there is something that can be changed in pdf generation to prevent this from the beginning? Thanks! |
Tracking issue after #6304 landed:
The text was updated successfully, but these errors were encountered: