Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Riley D. · Aug 05, 2010 at 02:01 PM · camerarenderingrendertexturedrawtexture

How to get the rendered texture from a camera, save for later display on another camera?

There have been a few threads about this, but no one seems to have come up with a concrete answer.

I basically want to be able to "playback" the entire game. It would seem that the most efficient way to do this would be to just save all of the pre-rendered frames that the game is already generating, and then play those back in reverse order. I only need about a 5 - 10 second window of possible "rewind", so I won't be recording hours of video to the memory.

It seems like a possible way to do this might be to use:

// We should only read the screen bufferafter rendering is complete yield WaitForEndOfFrame();

// Create a texture the size of the screen, RGB24 format var width = Screen.width; var height = Screen.height; var tex = new Texture2D (width, height, TextureFormat.RGB24, false); // Read screen contents into the texture tex.ReadPixels (Rect(0, 0, width, height), 0, 0); tex.Apply ();

Then to save the tex var in an array. Then when I want to play back the scene, perhaps use:

GUI.DrawTexture (position : Rect, image : Texture, scaleMode : ScaleMode = ScaleMode.StretchToFill, alphaBlend : bool = true, imageAspect : float = 0)

Where the position rect would fill up the entire screen, and the image would be the previously-saved texture.

However, when texting the first part of this (the texture-saving), the game slows way, way down. I haven't even tested the GUI.DrawTexture function yet, but I'm sure it's not going to fair much better. It seems like saving all of those textures eats up a ton of memory (going from 400 MB to well over 1.4 GB while running in the Unity Editor on my Mac), as well.

Any thoughts on how to optimize this?

I also know that Unity Pro has the RenderToTexture functions. Perhaps those are better optimized (i.e. I could save the Texture created by the RenderToTexture calls and then use GUI.DrawTexture?) Has anyone tried anything similar to this with those functions?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Aug 05, 2010 at 02:39 PM

There's no way you can save actual frames in real-time in a performant way. You're much better off recording objects' positions instead, which will be far faster and use far less RAM.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Riley D. · Aug 05, 2010 at 03:01 PM 0
Share

Thanks, that's what I was thinking, but it was helpful to have someone else confirm my suspicions.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Rendering the same Render Texture differently to separate cameras 0 Answers

RenderTexture captured from camera with post effects only shows the emission pass. 1 Answer

RenderTexture and Readpixels android problem. 2 Answers

Graphics.DrawTexture vs GUI.DrawTexture vs Graphics.Blit 0 Answers

Fading in one camera over another as an overlay with RenderTexture and GUI.DrawTexture. Any way to control pixel clearing? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges