1

I need to know how to generate a 2D image of a 3D model(w/rotation) during game play. I am working with C# and Unity3D. [Edited for Clarity, I hope...]

After a bit of research: It looks like what I want is RenderTexture. I should be able to create a camera and output the camera's image to the RenderTexture asset then pull the texture from the RenderTexture.

What would be the best way to do this?

My Attempt: Using the Unity editor I have also created a background plane, ceiling plane, and spotlight 100 units below ground. My thinking is that I can make the camera/etc. active, draw the object, save the texture, delete the object, and set the camera/etc. to non-active. My concerns are with the timing of everything...

Z30Dragon
  • 42
  • 6
  • So, what is your question, exactly? Is using `RenderTexture` an optimal way to achieve this and is it widely used? Yes. – Max Yankov May 09 '15 at 21:33
  • Yes, Exactly. It didn't come out that way at all did it.... *editing* ... after doing research I didn't find about generating textures, just something about making camera/monitors using RenderTexture. I wanted to ask on here because I know next to nothing about Unity3D and I didn't wan't to get into it just to find there was an easier way or it doesn't actually work well enough for textures. – Z30Dragon May 10 '15 at 02:44
  • Well, it's always a good idea to check if your way of doing things is the right and/or usual way. – Max Yankov May 10 '15 at 07:17

1 Answers1

1

Yes, it is usually achieved using a RenderTexture. You can actually substitute the target texture of a camera for one frame, render to several textures at once, or use a special camera that you will only activate for one frame. You can find MonoBehaviour methods OnPostRender, OnPreRender, OnWillRenderObject, OnRenderObject and OnRenderImage useful to control the process, as well as Camera's static events onPreRender and onPostRender.

Max Yankov
  • 12,551
  • 12
  • 67
  • 135
  • This is incredibly helpful with the timing of everything. Is there any way to have the rendering happen in an alternate draw space (layer?) So that you can do a sub-render in your function and do this more than once per frame? How would you effectively scale this up? – Z30Dragon May 11 '15 at 20:46