I have read the official UE documentation on render target and several YouTube tutorials, and I want to get a texture from a Material (or Material Instance). My end goal is to collect the materials for the clothes worn by a metahuman-like avatar into a single texture atlas.
I have been successful in extracting a simple material ‘RT_Matertial_00’(See image below) as a texture using render targets, as shown in the documentation and tutorials.
However, extracting the texture from the Material Instance applied to the MetaHuman’s top continues to fail. The render target is only filled with black(not clear color).
The surface material downloaded from QuixelBridge also failed to output to the render target. The render target still outputs only black color.
I applied a material that references a canvas render target to a plane placed in the level. The clear color of this canvas render target is white. I then drew RT_Material_00, the material of MetaHuman’s top, and the surface material downloaded from Quixel Bridge. The result is that only RT_Material_00 is drawn and the rest is black.
I don’t know why this is happening. Why does the ‘Draw material to Render Target’ or ‘Draw Material’ function not work for materials on MetaHuman’s cloth and materials on Quixel Bridge?
On the page below, it says to use the emissive color and base color of the result node.
I tried the solution on the page above, but unfortunately it failed again.
If anyone can give me even the slightest clue as to why this is happening, or how to output MetaHuman clothes or Quixel Bridge materials to a RenderTarget, I would be very happy!
Please explain “why” you are doing this. I assume you are trying to modify/customize the metahuman cloth at runtime for whatever reason.
Caching the “material” would require caching all the textures used by the G-Buffer to be done correctly. However, the Unreal RenderTarget does not do that but instead renders an “unshaded” quad only outputting the emissive color to the RT. Try wiring your output color to your emissive channel. In case of Metahuman you need to go down to the parent shader.
Oh my god, you are my savior!!!
My goal is to have the materials for the avatar’s clothes and accessories, as determined in the game lobby, in one texture atlas at runtime.
I think this will reduce the memory and drawcall burden!
After much searching and experimenting with relevant keywords, I came to the conclusion that to achieve my goal, I needed to pull out Materials as render targets.
Below is the thread I wrote during my search.
It probably could help to create texture “overlays” for your avatar and integrate those into the meta human. Not exactly sure why you need to create your own texture “atlas”.
I personally would refrain from doing too much “performance optimization” with such workarounds as you need to keep caching/mipmaps/lods in mind. Happy to help.
This is because I wanted to include the materials for the outfits of all the other avatars that entered the world in one atlas each!
I thought this would be more efficient because I would only need to generate and hold as many texture atlases at runtime as there are avatars.
The overlay texture thing is something I never thought of, so I’ll have to look into that, thank you so much!
You’ve given me hope
See, this was exactly my concern. If you put all outfits in one atlas, then all outfits will be kept in gpu memory whereas you only need one texture for each avatar.
It’s probably a lot better to create a dynamic instance of your avatar material and pass whatever texture you chose into it. Inside the material you just blend that texture ontop of your base color. You probably don’t even need a rendertarget.
Each part of the avatar’s face, torso, and legs will have a Skeletal Mesh, such as a hat, top, and bottoms, each with its own shape…
Will the texture overlay way work in this situation? I’m doing a keyword search right now, so I don’t know much about it, sorry! ㅠ_ㅠ
Sure. I see absolutely no problem. If you look into the Metahumans you will see separate meshes too with individual materials. Each can be provided with a texture overlay.
I really appreciate the advice.
I’m currently searching for relevant keywords and gathering information that might be helpful (I can see topics like outlining, applying effects, etc.).
I send my thanks to you again, and am in the hopes that I can get some valuable advice when I am once again stuck!