shipyard-games / SCNText2D

Rendering text in SceneKit using SDF fonts.
MIT License
14 stars 3 forks source link

How to create new font atlases? #5

Open KTRosenberg opened 4 years ago

KTRosenberg commented 4 years ago

I would like to add new sdf ttf fonts to use with your library. What is the pipeline for generating the required assets?

On a related note, I would also like to use plain metal instead of scenekit. Would you have any tips for converting your library? It looks like you already use custom shaders and vertex data generation, which helps.

Thank you.

tsharju commented 4 years ago

I've experimented with few different tools for generating the SDF font atlases. The tool I've used in master branch had some issues with quality. There's a branch called fontue that hasn't yet been merged to master, that adds support for tool called "fontue" that generates SDFs with quite good quality. It is part of the React VR project. The process of adding fonts is the same as in React VR. Here's a blog post on how to do that. https://medium.com/@zvona/how-to-add-custom-fonts-on-react-vr-project-246c1a9b2984 I'll try to merge the branch and add some instructions at some point.

Regarding using Metal instead of SceneKit. The shaders are Metal shaders so they should work directly. You just need to make sure the data passed to the shader (vertices, textures) is in the same format or modify the shaders accordingly. If you start from scratch I'd recommend using SceneKit. If you already have renderer written in Metal then that might be the way to go.

KTRosenberg commented 4 years ago

Thanks. What you described sounds reasonable to me.