Filtered fonts in the game engine #29882
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#29882
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
%%%This patch makes anti-aliasing of fonts in the game engine better. It does this by generating mipmaps for the glyphs, and enabling linear filtering. This is important for games because a single rendering of text can be viewed at different resolutions and even with perspective.
This patch also fixes a z-order bug with overlapping text; see screenshots.%%%
Changed status to: 'Open'
%%%Attaching a (hopefully) Tortoise-friendly version of the patch.%%%
%%%Trying the svn conversion thing again.%%%
%%%I like the aliasing, it's looking great here.
Now for the z-order bug:
I still have some glitches in some tilted texts (extreme ones, no real production examples yet). See alias_problem.png.
But I believe your twist code solves the most common case of texts parallel to the camera overlapping each other.
assigning to Diego (and deleting the git/wrong svn fils)%%%
%%%Hello!
The next three or four days are really busy for me, but as soon I have a little of time I will check the patch (I think for the next tuesday), sorry but a lot of work :(%%%
%%%Hi Dalai,
Actually I think what you're seeing is not a z-order issue. There are two separate problems:
The way I understand it, the glyph textures map into a larger image. The white artefacts you see on the edge of the glyphs in "AntiAlias" are because the higher mipmap levels are bleeding in characters from other parts of the base image. There's a .pad member of GlyphCache; maybe if we increase that there will be greater spacing between the glyphs and it could solve this issue.
The remaining aliased edges of the glyphs, e.g. the top edge of the T, are due to the texture being drawn right to the edge of the quad. In that case, mipmapping and filtering won't help. Enabling FSAA should fix it. Alternatively we could adjust the UV mapping to give a bit of spacing around the glyph in its quad. But we would also need to adjust the spacing between glyphs to compensate for that.
As you say, the second issue doesn't show up when the text is aligned to the camera.%%%
%%%Attaching a new version of the patch (blf_aa_2_svn.patch) that fixes issue 1 in the previous comment. In the new version, the padding around glyphs is increased when mipmapping is in use.%%%
%%%Added files to demonstrate the difference padding has on the artefacts:
%%%blf_aa_3_svn.patch: only "twist" the leading edge of each glyph. This prevents the trailing edge from disappearing when the text is coplanar with a face.%%%
%%%Hi Diego, Dalai showed me the conversation you two had in IRC the other day. You are right about the padding, and the twist:
I tried making the twist optional, but I think it makes the code more complicated than it's worth - especially if Z is compressed in the normal GUI matrix. The twist code should be pretty fast. So it's still not optional in this patch, but I can add the option back if you want.%%%
%%%Hi Alex,
As I say to Dalai, the twist is ok, the Z is always clip when the UI is drawing in 2D, there is no problem there!.
I will talk with Dalai today, I think the patch is ready for trunk, sorry that take so long time!! and thank for the hard work!! :)
%%%
%%%Hi Diego,
Thanks for that! ... I'd like to commit this myself, if that's ok :)%%%
%%%Hi Alex,
Sure! go ahead! :)%%%
%%%Patch committed, r43876 (version 3 of the patch, see above for details).%%%
%%%There is something still strange with this patch (the committed one).
The problem for me happens when the text object is parented by an object that is parented to another, ...
Check this out: http://www.pasteall.org/pic/25805 (it's not a typo, the j can't be seen).
Looking at the KX_FontObject.cpp code I tried to fix this with this patch:
http://www.pasteall.org/28797/diff
This fix it, but all the texts seem over blurred (http:*www.pasteall.org/pic/25806) AND the text is missing as well: http:*www.pasteall.org/pic/25807
For my test (real file actually) I'm using a orthographic camera%%%
%%%Hmm, didn't we figure out that was something slightly different? I'm not sure how this commit would affect that. Text that sits exactly on a plane will probably show issues like this, even with twisting, depending on the scene setup. Suggestions:
Actually, we had the same problem with non-text objects in the game we made at the game jam. The solution was to bring the objects closer to the camera.
Can you post a test file?%%%
%%%Alex please see attached file (packed font Papyrus included) - blf_bug.blend
(If you need I can send some screenshots)
With my patch (to use Nodal global Scaling instead of m_size- [x]) makes both lines to display all letters and are the same size. They are blurry though so there is yet something else wrong.%%%
%%%As discussed in IRC, I can't reproduce the missing J in blf_bug.blend with an nVidia card. But the bug is present when using my ATI card. Attaching a screenshot (missing-j.png) - the left image is with this patch disabled; the right shows the patch enabled: the text is blurry and the J is missing.
Note that the blurriness is expected in this case. The text simply has the wrong resolution, as shown in the image on the left: without the patch, it's blocky. If that is a bug, then it's unrelated to this patch. The missing J, however, is a concern. And the fact that it only shows up on ATI cards makes me think this will be difficult to fix.%%%
Changed status from 'Open' to: 'Resolved'
%%%patch reverted on rev. 44011. Let's have it bright and shinning after 2.62 is out.
%%%
%%%I uploaded my modified version of this patch (blf_aa_3_HG1.patch).
This patch should fix flowing problems:
%%%
%%%New patch (blf_aa_4_HG1.patch).
Fixed implicit type conversion.%%%
@hg1, how does your new version of the patch fix the issue with the J? I can't see what the difference is in the code. Was it fixed by another commit?
I think the J was clipped by the ATI card. So the increased twist (0.0002 to 0.0004) has fixed the problem.
Hello!! there!
I have a machine with an ATI card here, so tomorrow I'm going to update my git repo and try the patch!!
Added subscriber: @ideasman42
Cool, here's a new version that applies against HEAD. Note that this reverts commit
7c6d52e
which stopped initialisation of the font image; initialisation is actually required for glyph padding when using mipmapping. Thanks to @ideasman42 for assistance with this update.blf_aa_5.patch
And this version adds alpha clipping, reducing artefacts for kerned (overlapping) letters.
blf_aa_6_alphaclip.patch
In the new patches there is a printf left.
Oops, you're right - but it's only printed when creating a cache (very infrequently). It will be removed before committing, but you can test with the patch as-is.