- Home /
Writing a texture from a Mesh Material to a Texture File
I wrote a Mask shader and used it on a plane to create a circular RenderTexture(miniMap) now I want to write the whole texture from the Mesh to a "Texture2D" (or raw Texture). The
Renderer.material.mainTexture only gives the main texture, not the shader'ed(masked) texture itself
Answer by syclamoth · Sep 14, 2011 at 07:11 AM
Are you trying to use the resultant texture with UnityGUI? While there is no way of doing exactly what you are asking for here (as far as I know), there are a few functions you can use that can achieve the same goal through a different method. For example, if you want to draw the texture to a rectangle on the screen, try Graphics.DrawTexture to draw a "shader'ed" texture directly to the screen for one frame. Or, if that doesn't work for you, you can manually move the masked mesh to a point just in front of the camera, and make it a child of the camera so that it stays in the same place at all times. If it clips through terrain or other objects at times, try making a new camera which only shows one layer- and then put the minimap object on that layer! This way you can put the minimap wherever you like on the screen, and if you set the clear flags on the second camera to CameraClearFlags.Nothing and then make sure it always renders after the main camera, then your minimap will display on top of everything else.
Thnx very much! Graphics.DrawTexture did the trick! :))
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
ID multidimensional array to mesh and textures 0 Answers
A node in a childnode? 1 Answer
need help in texturing a city.. 2 Answers
3d text mesh hides plane object 1 Answer