Rendering text in a material

Hi, I hope this is the right forum for asking this question.
I’m new to the engine and I’m trying to build a simple puzzle game.
what I’m trying to achieve is to spawn a certain number of blocks, each box will have its own number (i.e from 1-8).
Each block would have the number displayed on one of the faces of that box.
How can I achieve this using the material editor/engine editor.
I have no idea on how to project text on an object, also I would like it to be one material for all the cubes and have the text given as a parameter.

I assume its a pretty easy task for an experienced user.

I would really appreciate your help,


Doing this in material only is not easy task, so if you insist (or if its really that you need it as material, we can dig into that later)

There is “render text” component. You could make your block plus render text actor as single blueprint, expose on spawn text to render. Then manipulate those blueprint actors instead off blocks.
To make this work: create new blueprint, lets say BP_Block, add 2 components to it: block and render text. Create variable that holds text to display, and maybe second for text color etc. Expose them to editor and on spawn.
Now to add those actors from another bp: you spawn actor from class and use BP_Block as its class.

But if you want more than 200-300ish of those blocks then indeed you need single mesh with material per one.
So if you really need that display digit material:

  • give me exact shape of block, ie dimensions if its box,
  • which faces and orientation you want to have digits displayed, this is needed for uv mapping of mesh

If i have time this weekend i can make mesh, material for it and uv layout texture.

I added an image that shows what I’m trying to achieve.
Basically for starters I want it to be as simple as I can in order to distinguish between the tiles so I can test my game logic.
Later on I might want to change the size of the puzzle and the material for the tiles and board (have different sets) and maybe even replace the text with parts of an image.

What do you think would my the simpler choice in order to get this working as fast as I can?


Ahh so you need instanced material with x,y for face. Then you need picture that has all pieces of image (or numbers).
Brute force method is making 16 boxes each covering different part of image, but that’s lame and inefficient.
Keywords you are looking for (to use in google) are “unreal atlas material”

Your case is the simplest version of it all.

Basically make master material, make nodes as those:

  1. [texture coordinate U=.25,V=.25] > [Panner U=1,V=0] and > [panner u=0, V=1]
  2. 2 scalar parameters [U_scroll], [V_scroll]
  3. [scalar value .25] multiply both scalar parameters by it to get separate results
  4. connect texture coordinate to both panners, connect multiply results to time pin of panners, U_scroll to u=1,v=0 panner V_Scroll to other.

now when you set paramaters to 0…3 it should show correct piece/cell of texture

When this works, in content browser create instance material out of this master one.
apply instanced to boxes, play with paramteres so each box display correct piece.

ok, I thought about using a texture atlas with number on it, but since its just numbers in my case I thought there might be a simpler solution so I can change the label on the box later on if I wanted to.
for example replace and numbers with letters.
I guess if I make this a texture atlas I can use a texture atlas for the numbers and a different texture for the wood for example and combine them both somehow.

I guess I should really watch some basic materials tutorials. Up until now I only focused on programming and blueprints.

For your game, if you use render text actors, you are stuck with text.
If you make material you can have any picture as puzzle.
That is why i suggested material way.

You can always skip whole material panning trickery.
Make array of your boxes in 3d application, select them all and apply 1uv space to top surfaces
You get picture nicely cut and apply do top surfaces.
But material atlas is more flexible.

btw. There may be some dedicated material function now that does what i described.

special material function for material atlas?

You could use a FlipBook texture and instead of connecting it to a progessing time, feed a static value to access the desired picture…

Any tutorial I can read that shows me how to do that?

If I look at the memory game example they used a different material for each animal, I guess they should have used an atlas in order to make it more elegant and efficient.

ok so I tried to follow your instructions, this is what I have so far, I assume when you wrote scalar values I should just input them in the multiply box.
How do I proceed from here? I’m not sure

I appreciate the help

p.s attached the numbers texture I made, I used a transparent background so I can somehow combine it with wood texture.

Now add together both panner outputs, and feed it to your texture sample 2d.
Feed its output to emmisive or diffuse of material.

Something is still missing

ok now the cube is all black, I assume its because my digits are black and transparent background produces a black color.
so in order to solve this I should combine with another color or a wood texture?

Anything else I might be missing?

You forgot to put your numbers texture into that texture node.
Also expand all nodes (small grey triangle) so i can see what is inside.
Unless you want to change that numbers material from instance, you do not need texture as parameter, simple texture node will do fine.

ps. Follow material tutorials, you lack some basic knowledge here. Watch at least basic tuts.

Starting to look like something

I used subtract because I had the numbers in black on a transparent background, should I change the texture file and do it a different way?


You can use “one minus” node to flip texture.
Then you can use that flipped texture as mask that holds numbers.

With mask, you can either multiply it by color,
Or even better Linear interpolate between wood texture and some other texture.

You really should follow some basic material tutorials. :wink:

Yeah I really should and I’m going to start on that tomorrow.
I’m a programmer but I took a course in 3D modeling 8 years ago so its not all new to me but its been a while .

Thanks for the help, I can now start to work more easily on the game logic now while I start with the material tutorials :slight_smile:

ok so I watched the materials tutorial, what I’m still missing is so basic understanding of how UV layout works in unreal.
I tried to use my material on the blocks and as you can see in the picture, the numbers are on the bottom side of the cube, how can I change this without rotating the cube?
can someone recommend a good tutorial for these UV layout issues?




Just make new cubes with numbers facing up. Or rotate them in unreal (ie. spawn rotated upwards).
Uv layouts work in unreal same way they work in blender or 3d max.

For you best cubes would be ones with 3 materials:
0 - for top surface with digit
1 - for bottom surface
2 - for the sides

This way you can swap each material separately.

how do I give each face different material? this is what I couldn’t find.
I’m not even sure what to search for.

Also I’m setting the material for the digit from blueprints according to the index, can I do it when there are more than one material on the mesh and keep the other materials the same?
How can I do this?