• Runtimes
  • [UE4] Is it possible to draw to a Render Target via UCanvas?

  • Изменено
Related Discussions
...

Hi all,

I have a question regarding Spine's features in Unreal, and I was wondering if anyone could help me. 🙂

In our game, we have both 3D and 2D gameplay, with the 2D gameplay rendered to a render target. The render target is applied to a material on a mesh so it can appear in the 3D world. It's a bit like the 2D-on-a-wall sections of Super Mario Odyssey.

We're currently using Paper2D for all of our 2D gameplay, using UCanvas functions to manually draw sprites onto the render target every frame.

While Paper2D will do a lot of what we want to do, it quickly runs into problems when it comes to larger animated objects/characters, and so we're looking at using Spine in these instances. However, we have to be able to draw them onto the render targets as part of our current rendering pass, i.e. using Unreal's C++ UCanvas functions.

These are the functions in question: https://docs.unrealengine.com/en-US/API/Runtime/Engine/Engine/UCanvas/index.html

My questions are:

  • Can Spine currently be rendered in this manner?
  • If not, could the renderer in the runtime source be adapted to make it work?

Thanks for any help!
Bidds

We currently don't support rendering to a UCanvas. Looking at the API docs, it should be possible to do using the K2_DrawMaterialTriangle function. https://docs.unrealengine.com/en-US/API/Runtime/Engine/Engine/UCanvas/K2_DrawMaterialTriangle/index.html

I have no experience at all with UCanvas rendering, but maybe the SSpineWidget code can serve as a basis for rendering to a UCanvas? It prepares triangle meshes and materials for submission to the Slate API. https://github.com/EsotericSoftware/spine-runtimes/blob/3.8/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp

We're currently working on finishing our Spine Runtimes 4.0 ports, so we can't implement this ourselfs in the near term. If you want to give it a try, I'd be happy to assist with questions here.

Thanks, Mario. Your assistance would be most appreciated!

I'm not sure if I'm going to attempt this myself yet, or find someone cleverer than me to take a look (I'm just a gameplay coder really), but I suspect I will be back for some help in the future. 🙂