# Is there a way to render strings as a light function?

**URL:** <https://forums.unrealengine.com/t/is-there-a-way-to-render-strings-as-a-light-function/282344>\
**Category:** Rendering\
**Tags:** font, string, text, light-function, unreal-engine, question\
**Created:** [May 2, 2014, 9:53pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-render-strings-as-a-light-function/282344 "2014-05-02T21:53:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SFtheWolf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SFtheWolf](https://forums.unrealengine.com/u/SFtheWolf)\
**Post date:** [May 2, 2014, 9:53pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-render-strings-as-a-light-function/282344/1 "2014-05-02T21:53:10Z")

</div>

I really want to be able to randomly select from a set of predefined text strings at runtime, and then project a material including that text as a light function.

Is there any way to do this, preferably through Blueprints? If not I can just bake each one into a big texture and select the text based on UV coordinates, but being able to type whatever I want right into a parameterized field seems so much more elegant.

---

<div class="post-metadata">

**Author:** ![TechArt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TechArt](https://forums.unrealengine.com/u/TechArt)\
**Post date:** [May 7, 2014, 5:08pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-render-strings-as-a-light-function/282344/2 "2014-05-07T17:08:17Z")

</div>

There is a Render to Texture feature that can be used to create textures from strings. Unfortunately, it’s only available via c++ at the moment.

If the strings are predefined and you are not familiar with c++ I might recommend going with the uv approach.

A material function called debugScalarValues does something similar. It can be found in the material functions folder here: MaterialFunction’/Engine/Functions/Engine\_MaterialFunctions02/Utility/DebugScalarValues.DebugScalarValues’. It manipulates the meshes uvs to display the correct n digit number with only a few texture samples.

If you’re going to make something a bit more straight forward and only have a few strings to display than the “debug scalar value” approach may be overkill. In that case you could create a much simpler version of the same shader to pick from a series of strings that were stored in a texture.

Here is some info regarding the c++ tools I was mentioning earlier:

UE4: Canvas Render Targets

- There is a new C++ class called CanvasRenderTarget2D.
- You can use it to create render targets that are updated every frame by some C++ code that draws to it using the Canvas interface.
- You can then apply the render target texture to 3D models in your scene.
- This gives you a way achieve in “in-world” UI without using TextRenderComponents.
- However, it does not work with Blueprints yet.
