I’m working on manipulating text dynamically using shaders.
Each letter in the text needs to be randomly assigned to one of five groups, which will gradually blur out over time with a GLSL shader.
While the blur shader isn’t causing issues, I’m unsure about the most efficient way to split the text. Initially, I thought about generating an SVG dynamically and then applying it as a texture over a Sprite.
However, I couldn’t get it to work smoothly – the SVG elements weren’t in the correct order, and the spacing was off. Any suggestions on how to approach this?
Thanks for your reply. I might have misunderstood or perhaps I didn’t explain my idea clearly.
I have a dynamically changing text string. My goal is to randomly assign each letter to one of four groups, ensuring that each letter is entirely assigned to a single group. Later, I want to blur all the letters within a specific group (text should be 2D).
From what I understand, atlas maps are used to project textures onto objects.
Would you recommend creating an atlas map dynamically and then mapping it to a Sprite?
I would greatly appreciate your advice on the best approach to take.
Thanks for clarifying, but unfortunately, I’m still not entirely sure how to approach this.
The script should work for any given text, regardless of length, and each letter should be assigned to one of four groups (layers). Each layer, with its letters, will then be animated separately.
From what I understand, you’re suggesting using the texture atlas. However, I’m not clear on how that would help in this context.
For example, if we have the string “Hello World, how are you?”, the script should assign each letter to one of the four groups/layers so that a different shader can be applied to each group.
It’s crucial that the spacing of the letters remains consistent, as if the text were typed normally. This is where I’m struggling. I can’t figure out how to place randomly selected letters from the string on different layers without altering the position of each individual letter.
I’m not entirely sure how to use atlas maps to solve this challenge.
Made this quick example, using a sprite pool to reuse the sprites and only update the canvas with the new letter, check drawLetter, to see how to draw the letter into the canvas. (Doesn’t exactly fit what you’ve described, but you can easily adapt it!)