-
Notifications
You must be signed in to change notification settings - Fork 150
Prevent outline from mixing with the fill color #372
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
base: main
Are you sure you want to change the base?
Conversation
|
Without adding uniforms, and for basic materials, it's possible to calculate everything on the js side and pass it to the Text / Batched Text and it works just fine with opacity etc But for other type of material, there is no way around adding a uniform ( or reusing an existing one, I'm not that familiar with the current uniforms used yet ) @lojjic I'm willing to implement that in a way that match your vision, what do you think about this ? |
|
@AlaricBaraou I think this is fantastic. 😄 The reason I didn't go with this to begin with was due to the Both behaviors seem desired in different circumstances, so I'm open to adjusting the API to allow both. Options off the top of my head:
Thoughts? |
|
Good point, the shadow option should be preserved indeed. I like 2. because it gives a clear choice to the user. And I see that the current packing strategy has two empty spot ready for this. I'll give it a try |
|
Thinking out loud here. When the outline pass include the inside of the glyph, the pixels located on the edge will end up fully colored as the outline color, while with my solution of drawing exclusively outside the glyph they have a degree of transparency based on how much of the pixel area is outside the glyph. This difference will affect the final color of the pixels located on the edge and therefore the composition once merged with the fill render pass. On highly scaled font it's not noticeable but if we zoom on the pixels of the edge we can see how the final color of the pixels located on the edges are closer in color to the outline color than the fill color. I guess a name / description for this boolean parameter could be. bool filledOutline I was trying to figure out a way to have this readability improvement work with everything but it's not possible. |
…g the outline within the fill.
|
@lojjic I pushed a first draft that follow the logic of 2. fillOutlineDemo2.mp4In this video we can see how it prevent the outlines from "bleeding" too much over the fill color when the text is displayed small. Comparison at the pixel level The white of the fill is less affected by the outline, resulting in a text much closer that what a SVG text would produce in term of readability like shown in this previous comment #372 (comment) Let me know if you'd like me to make any adjustment, I tried to update the documentation and example to reflect the change. Thank you! |
|
I noticed that my current example only works when the canvas background is white. Edit: instead of blending the outline with the background, I might be able to blend it with the expected fill color and get the same result as above. Maybe by changing the render order or something 🤔 |









Currently, the outline is drawn inside the glyph + outlineWidth.
This work perfectly fine if fillOpacity is 1.
But when fillOpacity is less than one, the fill color will blend with the outline color while I would expect for it to blend with the rest of the scene only.
I don't know if the previous way was the expected behavior, but in my case I need to be able to set the fill opacity without it being affected by the outline color.
There might be a better way to achieve this but this is the most minimalist approach I could come up with.
It might even be worth changing to
if (uTroikaEdgeOffset > 0.0 && fillRGBA.a < 1.0) {in order to run it only for the outline pass when the fill have some transparency.Before
fillOpacityBefor.mp4
After
fillOpacityAfter.mp4
It works well with the current BatchedText too.
I'm happy to make edit to this PR if needed, feel free to edit it yourself too if it's more convenient for you.
I can implement this directly in my repo but it feels like something other users might want too.