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
SVGLoader - self-crossing semi-transparent paths show overlap, while original SVG doesn't #18791
Comments
The problem is that the self-crossing shape produces overlapping triangles. When configuring transparency for the material, the screenshot is the expected outcome. Not sure if the shape can be triangulated differently so the overlapping does not occur. |
This is a self-intersecting shape. I would not consider this a loader issue. This is probably best resolved by using custom blending equations. There are likely a lot of ways to handle this. Here is one way, but you will have to adapt it to your use case. // note: also set alpha:true in renderer constructor
blending: THREE.CustomBlending,
blendEquation: THREE.AddEquation,
blendSrc: THREE.SrcAlphaFactor,
blendSrcAlpha: THREE.OneFactor,
blendDst: THREE.ZeroFactor, updated fiddle: https://jsfiddle.net/m6yawfcu/ |
@WestLangley Thank you for your response.
Yea, you might be right, and it kind of makes sense to render it this way, but IMHO, in a perfect world, it should look exactly as the SVG itself. I've just tried the workaround you came up with, but my problem with that, is that with these settings, blending is completely turned off. I put back the grid helper, so you can see what I mean: If it was possible somehow that the shape doesn't blend with itself, but it blends with everything else, that would be great. Let me explain my use-case: I'm writing a highlighter-pen tool for a webapplication. It used to be based on CSS3DRenderer, and as you moved around the mouse with your mousebutton down, it used to create an svg path in the 3D space, with small (but nonzero) opacity, so it would look similar to how the drawing with a real-life highlighter-pen would look like. Now, we're moving functionalities from the CSS3DRenderer to the WebGLRenderer (for non-related reasons), and currently I'm using the So, in my case, it would be awesome if somehow it was possible to either:
|
Alternatively, depthFunc: THREE.LessDepth,
depthWrite: true, https://jsfiddle.net/ut653xf9/ There are some artifacts if the camera rotates -- may improve if you tighten up the near/far planes. This is not a help site, but maybe someone at the forum can help you if you need more help. |
Okay, thanks |
Hey,
Recently I've been playing around with the SVGLoader, and noticed that self-crossing semi-transparent paths show the overlap (like adding/mixing/blending the color), while the original SVG doesn't do this, see attached pic at the intersection below:
Original SVG:
Same SVG, as loaded with SVGLoader, and rendered with three.js:
Is there any way I could get rid of this "color addition" at the intersection (while keeping the opacity), so it would look more like the original one?
Thank you
Live example:
https://jsfiddle.net/soadzoor/rps8v7a2/13/
Three.js version
Browser
OS
The text was updated successfully, but these errors were encountered: