x


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

more ▼

asked Sep 14 '11 at 06:59 AM

peter8989 gravatar image

peter8989
16 4 4 5

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Sep 14 '11 at 07:11 AM

syclamoth gravatar image

syclamoth
15k 7 15 80

Thnx very much! Graphics.DrawTexture did the trick! :))

Sep 14 '11 at 07:22 AM peter8989
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3886
x2275
x1404
x207
x78

asked: Sep 14 '11 at 06:59 AM

Seen: 1073 times

Last Updated: Sep 14 '11 at 07:22 AM