I discovered that the draw material to render target function (new in 4.13) doesn’t properly execute when used in begin play.
Note that it works in editor but not in standalone or packaged game.
The workaround is to add a small delay in begin play but I still think this should be fixed… there seems to be more inconsistencies in begin play, for example UE-36132.
I don’t think it’s a bug, but on event begin play, some assets are still loading, therefor, sometimes there is not object or material to project on to. In your event begin play try adding a delay before the draw material to render target.
Btw if you set a delay of 0ms, it will delay it one frame.
I shouldn’t have to add a delay though, the engine should take care of asset loading and whatnot before executing begin play.
Plus it’s inconsistent between editor and standalone so I would say that’s a bug.
Alright, so I have uploaded a test project which also includes a packaged version (under WindowsNoEditor folder) just to make sure we are using the exact same thing.
Also I’m using 4.13.0 from the launcher.
If you launch the packaged game (or run the project in standalone) you should see a black mesh (meaning the render target is black/empty).
But if you start the project in viewport play/editor mode you should see an icon painted on the mesh instead.
I have also noticed that if I use a translucent (or alphaComposite etc.) material to draw to the render target then the game doesn’t even start properly (freezes/black screen on startup)… definitely something weird going on here!
If it works for you the same in both modes then this could be a hardware bug/incompatibility(?)… in which case I will try testing this on another machine.
Thanks for providing the test project as I was able to see what the differences between my own project and yours. I can confirm what you are reporting and have gone ahead and entered a bug report for the issue. You can track the issue following the link below on our new Public Issues Tracker.
Once the issue has been addressed by our engineers, the fix will be added to the release notes for fixed issues within an upcoming full engine or hotfix release.
Let me know if you have further questions or need additional assistance.
I have the same problem in 4.15.1, just a heads up
(edit: if the CanvasRenderTarget2d texture is dynamically created in the blueprint, I don’t have this problem)
The issue tracker (UE-36558) marks the issue as solved in 4.23, but I can confirm the issue is still present in 4.25. If not reproducible, I can upload a sample. The workaround as noted is to add a delay after BeginPlay.