- Home /
Save two textures in one. (merge _MainTex and _DecalTex)
Hi people!
I have the following issue, you see, I have a material with a decal shader. In the mainTexture I have a photo and in the decal texture another photo.
If I drop this material over a plane everything seems perfect I can see both textures very well. Now, What I want is to save a png of the whole image being displayed in the plane. ( using Texture2D.EncodeToPNG() method ).
The thing is I dont know how to do this.
If I use gameObject.renderer.material.mainTexture, I get only the _MainTex texture, if I use GetTexture I can get _DecalTex, but I dont know how to get both textures merged in only one texture.
another things I have tried are getting the pixels of the decal texture and use SetSprite to paint them over the main texture, but the png generated from the texture seems to be with artifacts and it looks bad.
Some guidelines about this? My main issue here is to fin a way to save two textures in one.
Answer by Julien-Lynge · May 23, 2013 at 03:52 PM
Look at the script reference for Texture2D. Specifically GetPixels(), SetPixels(), and EncodeToPNG().
Your answer
Follow this Question
Related Questions
Decal render only one object at time 0 Answers
Decal Question 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Change material GameObject locally 1 Answer
Decals in Unity 5? 0 Answers