Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Sliders99 · Sep 04, 2016 at 12:16 PM · animationrenderingcutscene

How to render a cinematic or a cutscene in Unity?

A while back i wanted to create a cinematic completely in Unity, Something akin to an epic like Blacksmith. What i created was far from epic Amazons Sparring.

The biggest problem was rendering the movie itself. After spending days googling for any info i gave up, created a build and used Fraps to record it. Lost a bunch of frames, somehow my colors lost saturation (this could be related to my encoding the video for YouTube).

A few days ago i stumbled across WaitForEndOfFrame function. I modified the code a bit and was able to capture images of my frames.

 using System.IO;
 using UnityEngine;
 using System.Collections;
 
 
 public class ExampleClass : MonoBehaviour {
     private int count = 1;
 
     // Take a shot immediately
     void Awake() 
     {
         StartCoroutine(UploadPNG());
     }
 
     void Update()
     {
         StartCoroutine(UploadPNG());
     }
 
     IEnumerator UploadPNG() {
         // We should only read the screen buffer after rendering is complete
         yield return new WaitForEndOfFrame();
 
         // Create a texture the size of the screen, RGB24 format
         int width = Screen.width;
         int height = Screen.height;
         Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
 
         // Read screen contents into the texture
         tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
         tex.Apply();
 
         // Encode texture into PNG
         byte[] bytes = tex.EncodeToPNG();
         Destroy(tex);
 
         // For testing purposes, also write to a file in the project folder
 
         File.WriteAllBytes(Application.dataPath + "/../SavedScreen" + count + ".png", bytes);
         count++;
     }
 }

To get editor PlayMode to display itself in full screen used Full Screen On Play script.

This allowed me to capture frames in full screen resolution directly from the editor. But my PC isn't powerful enough so I lost frames. I thought of slowing down the game itself to allow for every frame to be rendered, so i tweaked TimeManager default values ( Edit>Project Settings>Time) by lowering them as far as they would go. This worked and i was to able capture every frame, until the Editor froze.So i created the build and ran it. It worked up to a point then it froze too.

Every frame i captured at 1920x1080 was a bit over 3MB, and when everything stopped working i had about 6GB of images.

I'm stuck and out of ideas.

Can anyone offer a solution?

Comment
Add comment · Show 2
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 ScaniX · Sep 04, 2016 at 12:21 PM 0
Share

If I would want to record a video, I would switch from a time based animation to a frame based.

I'd have a singleton Video$$anonymous$$anager class or something like that which would increase a frame counter and wait for the scene to render, then save the image and increase the counter. All animations and stuff that used Time.time before will use Video$$anonymous$$anager.frame / 60f (for 60 frames per second) afterwards. If you were using the Unity animation system, you would need to set the frame or time there manually as well.

This way your machine has endless time to render and write the images and there is no need for coroutines. The result will still be some GB (depending on the length of the recording) of still images which you will have to drag into the video editor of your choice to render a video from it.

avatar image Sliders99 ScaniX · Sep 06, 2016 at 02:43 PM 0
Share

Thx for the advice. Gonna try it

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D Undertale like Cutscenes / Animations,2D Undertale type cutscenes / animations. 0 Answers

Would a Cinema 4d model keep good graphics when imported into Unity? 1 Answer

Is it okay to use the animator with cutscenes ?!,is it okay to make cutscenes with animator ? 1 Answer

Is "Animations" stat in Rendering Statistics Window only an incremental value? 0 Answers

How to create a cutscene on a specific spot in the game environment using cinemachine and timeline? 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