I’m trying to render a material into Texture Render Target 2D from the content browser.
I made an “AssetActionUtility”, a function that takes selected assets and renders the first material into the first Texture Render Target 2D from the list.
I believe “Draw Material to Render Target” doesn’t require light, but the result I’m getting seems to be due to lack of light; please correct me if I’m wrong.
Edit: I tried making the same thing with Editor Utility Widget and Actor Action Utility, none of the “Utility” classes managed to correctly render/bake the material.
Yes, with “Draw Material to Render Target” only emissive will be written. There’s an option in the material to also output alpha (goes into opacity), then you can output RGBA in one pass.
You could render in multiple passes, however you somehow need to redirect e.g. the basecolor to the emissive channel. This can be done by assembling a new material, which is somewhat involved.
Another option would be to render your material on a quad, then a camera with post process material filters by scenecolor(basecolor). Also a translucent quad in front with post process mat applied would work.
This is however a standard feature since I believe 4.27. Any actor has a button with bake material or bake texture or something…
If you are still interested in doing this in blueprint you can watch this somewhat older video which goes into detail how to redirect the material passes to the emissive output. Starts at around the 44 minutes mark. Project files are also available.
Though I had to go into the textures and change the compression to VectorDisplacementMap to keep the resolution the same as the source, it works pretty well on every channel except Normal; it turns out only blue.