How to render text?

I am rendering a cutscene using path tracing, it needs an overlay with text but my textmesh pro object attached to the camera no longer works when PT is enabled (it works fine using non PT, so the textmesh pro shader is not supported in PT apparently).

As a workaround I suppose I need to render text directly to the target rendertexture somehow. Any idea how to do this, or any other workaround to get text rendered ?

Have you tried using the UI version of TextMeshPro as well? maybe that one works…

That doesnt render into the target rendertextture which I will output to the video generator

Ok, I figured it out, given the target rendertexture in tex:

        Vector2 size = new Vector2(192, 108);
        //Save settings
        GL.PushMatrix();
        GL.LoadIdentity();
        Matrix4x4 proj = Matrix4x4.Ortho(-size.x / 2.0f, size.x / 2.0f, -size.x / 2.0f, size.y / 2.0f, -10, 100);
        GL.LoadProjectionMatrix(proj);
        RenderTexture currentActiveRT = RenderTexture.active;

        Graphics.SetRenderTarget(tex);
        textmeshPro.renderer.material.SetPass(0);
        Graphics.DrawMeshNow(textmeshPro.mesh, Matrix4x4.identity);
       
        //Restoresettings
        GL.PopMatrix();
        RenderTexture.active = currentActiveRT;

Renders whatever is in the given textmeshpro object into the rendertexture

1 Like