You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds an optional unified-outline mode that merges overlapping glyphs into a seamless, non-overlapping mesh.
This feature is off by default because, for correctness, each covered font pixel emits an individual quad, which increases mesh-generation cost.
Motivation
Texpix currently generates each glyph independently, which can cause outlines to overlap or create visible seams when glyphs touch or overlap. For example, this happens with negative letter spacing or transparent outlines. These issues prevent the text from appearing as one continuous pixel-art shape.
@ruccho Do you think this feature would be useful? If so, I’d like to work on optimizing it.
@paq
It looks like a very nice feature, but it seems difficult to implement efficiently. While there is likely some room to mitigate the increase in vertex count (mainly uGUI batch creation and GPU cost), I am torn on whether we should accept the cost of scanning the atlas on the CPU, even if it is opt-in.
My alternatives at this point are as follows, none of which are perfect.
A: Outline rendering order
A1: Render in two passes for the outline and the body
cons: Increased cost due to the extra pass, increased complexity of custom shader implementation
A2: Embed adjacent character UVs into vertices and sample the atlas multiple times in the shader
cons: Increased fragment shader load, requires Additional Shader Channels setup, increased complexity of custom shader implementation
B: Translucent overlap
This might be an inevitable issue as long as the mesh overlaps within a single pass.
B1: Generate vertices in advance on the CPU to avoid mesh overlap (as already implemented)
cons: Atlas scanning cost, compatibility with text animations, etc.
B2: Separate the mesh parts that could overlap based on metrics instead of the atlas, and render with multisampling like A2
cons: Compatibility with text animations, etc., increased complexity of custom shader implementation, requires Additional Shader Channels setup
B3: Separate even-numbered and odd-numbered characters into different passes and use stencils to prevent them from interfering with each other
cons: Increased passes, increased complexity of custom shader implementation. Incurs stencil setup and clearing costs. Do we also need to consider compatibility with masks?
Also, an unavoidable issue when changing the vertex structure is compatibility when external sources additionally manipulate vertex information, such as with text animations. This might be solved by adding an API that allows external systems to retrieve the correspondence between vertices and characters, but it would require additional work on the user side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Summary
Motivation
Texpix currently generates each glyph independently, which can cause outlines to overlap or create visible seams when glyphs touch or overlap. For example, this happens with negative letter spacing or transparent outlines. These issues prevent the text from appearing as one continuous pixel-art shape.
@ruccho Do you think this feature would be useful? If so, I’d like to work on optimizing it.