Implementing support for outlines in the SignedDistanceField shader

Hello,
I’m new to Heaps and I’m trying to add outlines to a Text object, but instead of using the Outline shader I know I can use SDF for that instead. Heaps comes with a Signed Distance Field shader built-in but it doesn’t supports outlines, which is a bit odd omission since outlines are pretty trivial to implement once you have SDFs.
Which is why I tried implementing the same shader myself by just coping the code from SignedDistanceField class and adding the extra bit needed for outlines. Unfortunately this (when added through addShader) results in an error with a Base2d and missing texture - not sure what that means.
So my question is how should I go about replacing the existing SDF shader used in Text with my own that has additional support for outlines? I know how to modify the fragment shader to create outlines in the SDF, but I don’t know how to actual add it to Text in a “proper” manner.

So after some trails and errors I’ve finally came up with a solution that I’m happy with. In case anyone else is interested in the same thing, I’ve uploaded my custom made extension to the Text class that supports outlines through a dedicated SDF shader here: https://github.com/4as/heaps-msdf-text

1 Like