This episode we are going to explore our first tutorial, setting up video feed into unity. As of now, We implement digital video into unity through code using the WebCamtexture.
I believe in future versions of Unity this process may become easier, but we may still do it this way by code because of how much control we have.
If you are new to coding, Don’t run away, I will help you here I will hold your hand through this. We do not need to do any abstract coding here, just follow and repeat the code.
If you are coming from the filmmaking world like myself and you think coding is too much, think of it as just like making a video project: ten thousand little steps, we are going to go one by one and before you know it we will have done it.
Coding lets us explore options and ideas in the virtual world that is not possible from a program with a graphical user interface. We have to look at and manipulate raw information.
I learned how to do this from a tutorial by sloan kelly and he is extremely kind to give me his permission to revise this tutorial for you today. Here is a link to his channel, follow his socials and subscribe to his channel.
The first step is we are going to have unity and our code editor of choice setup. If you are new to the series consider watching my unity starter tutorial here.
To setup a camera feed into Unity we are going to need a capture card piece of hardware. Today thanks to overseas manufacturing and Amazon’s competitive dominance, you can get a capture card for as low as 15 bucks. This does really good 720p. Perfect for simple capture and using a camera you might already have as a webcam. Here is a step up to 1080p. We are going to use this. This device also solves a problem with a hdmi in and out.
This product costs about $35 dollars, it’s incredible because until now, this hardware was costing five times more.
To capture HD-SDI, there are two easy options: First, get a good capture card like the time tested blackmagic hdmi and SDI capture card. Problem solved. Secondly, you can try a SDI to HDMI converter.
As of right now, the way to get video into Unity is webcam texture. We setup a webcam button, and an input switcher, and this tutorial is great because the button is built with context in mind.
The first step in this process is creating the object that unity will show the camera video on. Everything in Unity is an object. We make a 2 dimensional plane called a rawimage. Raw means that it will be a plane continually manipulated during runtime. We are now taking the camera of Unity and looking at the 2D image.
In addition I have made my own little ideations. I have added a simple stopwatch in the corner. This is just for fun, it’s just an idea of what could be added as useful tools for a project. Where a new tool can be made from a few lines of code.
When you plug a USB camera option into the PC, and you run the program, Unity will automatically find the camera. This is the same way that we are going to find the camera on a mobile device, whether Android Smartphone or iPhone.
This small line of code here is what Unity reads out as the active camera,
So, important things I want to cover here, I think this system will be replaced entirely in the near future with updates. There are many other workflows to consider for your project, one that we will implement in different situations is sending the video and the unity background and compositing them in a third party computer and system. If you separate operations by computers you can gain more flexibility and versioning, which could alleviate problems.
So give this a shot, Play around with video inside of Unity. With this as the basis of our virtual operations, anything is possible after this.