Is it possible to write the result of a shader to a texture file.

Hello a bit of an odd question here.

I have a shader that takes several inputs and displays the result on the model these can be tweaked to get a desired result. However I would like to take that result and use it as a 2D texture so that I don’t have to do the calculations to get the result every frame and I can just save that texture and use the single resulting 2d texture in a simpler shader.

Thank you for your help.

apparently 4.13 will come with the possibility to write directly to a RenderTarget (without a scene capture actor), so this is probably what you need.
if you need to do this now, you’d need a scene capture actor that writes to a RenderTarget, once and then turn it off

or you can just use the merge actors tool and put the material on a simple plane. you will need to select 2 planes with the same material and then tell it to merge materials and say which material pins to bake, although not all pins can be baked yet.

that sounds like a neat trick, but unfortunately not something that can be done at runtime


Seems not to work as I supposed. It merged them but the material stayed the same with no baking of textures either and no option to bake the diffuse.

You can use a CanvasRenderTarget2D, and only render it once, as opposed to every frame.

Have you had a chance to look at Rama’s Viictory plugin? He has nodes in there for read and writing textures to disk… In theory, you should be able to pipe the different inputs to the materials, base color, spec, metallic, etc. to their own files. If you’re looking for something that merges all those to a single file, then perhaps make your material a material function and then pipe that into his texture writing node… Worth a shot. Cheers,

J^2