Skip to content
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

There is a problem in the rendering process for gradient colors. #68

Open
hh0525 opened this issue Sep 15, 2023 · 3 comments
Open

There is a problem in the rendering process for gradient colors. #68

hh0525 opened this issue Sep 15, 2023 · 3 comments

Comments

@hh0525
Copy link

hh0525 commented Sep 15, 2023

I initialized 2048 paths, with half of them filled with solid colors, and the other half filled with gradient colors (including linear and radial gradient). I optimized the SVG using L2 loss. When I open the final SVG with a browser like Edge, it appears to be full of color patches as below.
iter_499
However, the final PNG rendering result is great.
iter_499
I use render_svg.py in diffvg/apps folder to convert SVG to PNG and I get the same result: SVG is poor but PNG is great.
What is the problem? I hope someone can help me.

@c1enyang
Copy link

Hi, I have the same problem. Did you solve it now?

@hh0525
Copy link
Author

hh0525 commented Dec 14, 2023

image
I found that the problem came from the color sampling process of forward rendering. The parameter pt passed in this function is the coordinate of the point in the image space (canvas_width*canvas_height), but in fact it should be the relative position of the point in the path, similar to begin and end in linearGradient.

@c1enyang
Copy link

image I found that the problem came from the color sampling process of forward rendering. The parameter pt passed in this function is the coordinate of the point in the image space (canvas_width*canvas_height), but in fact it should be the relative position of the point in the path, similar to begin and end in linearGradient.

Great! Can you tell me how to solve the color sampling problem? I am not familiar with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants