Geek Culture
Published in

Geek Culture

Unity features 101: Render Textures Part 1 (in-game tv-camera)

Render textures is an awesome feature in Unity that has limitless potential. A render texture is a type of textures that is updated at run time.

You can use it for many cool ideas like an in-game tv-camera or a mini-map. In this article we will see how to create a render texture, its settings, and how to create an in-game tv-camera.

Creating a Render Texture

To create a render texture simply go to Create > Render Texture.

Render Texture Inspector

This will create a new render texture in your project files.

The most important setting in the size which is in pixel which also determines the aspect ration of the texture. In our case it is a 256x256 square render texture. You can also add anti-aliasing and play with depth buffer settings, but these can affect your game’s performance. The other settings are like any other textures.

In-Game Tv-Camera

Start off by creating a new camera in your scene and let’s call it tv camera. Select your tv camera and in the Output section of the camera, you can change the Output Texture. Drag your previously created render texture into the output texture of the camera.

Drag your render texture into the new camera’s output texture

And here is a small gif to demonstrate how to…

Drag your render texture into the new camera’s output texture

If done correctly, choose your render texture and you should see a preview of the what the newly created camera sees.

Now adjust your Tv-Camera to see whatever part of your game you want. Here is a quick tip, choose your tv-camera, then adjust your scene view to what the camera should see, then press “CTRL” + “Shift” + F, this will change change the transform of the camera in order to display what you want.

As you can see, this also changed the preview in the render texture.

Now in order to display this during gameplay, we should add this render texture to a gameobject in the scene.

To do so, let’s create a Qaud to act as our in-game TV, go to Create > 3D > Quad and rename it too Tv Camera Display. Next position and scale this quad into any position you like in your game.

Quad placement

Next let’s create a material that will hold the render texture so we can apply it to the quad. In your project files, go to Create > Material and rename it to Tv-Camera Material.

Now the most important step is to drag your render texture into the “base map” of this material. This will allow the material to render the texture during gameplay.

As you see in the material preview, it is now rendering whatever the tv-camera is seeing onto this material.

Finally, drag this material onto your quad.

In-Game Tv-Camera Renderer

There you have it, as you can see, now we have an in-game tv-camera that you use for any sorts of things like creating a mini security camera system for your game.

Note: the above capture is from a prototype called Adventures of Lea that you can test out through this link: Adventures of Lea | SIMMER.io.

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Eventual Consistency with Spring for Apache Kafka: Part 2 of 2

Phoenix Feature Folders

How to Use Mendeley in Word, Citation & Bibliography

Kubernetes Deployment: Connect Your Front End to Your Back End With Nginx

Tangram Flex Awarded $95M Contract to Support Software Integration And Software Assurance

GSoC-2021 with OpenMRS Week 6

READ/DOWNLOAD*@ Supply Chain Management: Strategy,

How product experts create consistent value

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mohamed Hijazi

Mohamed Hijazi

A knowledge seeking biologist who is following his passion into a full time career in Unity / Game Development. https://www.linkedin.com/in/mohamed-hijazi/

More from Medium

Using LayeredLit shader to mix texture maps in Unity 2020

Creating Fog and Using Particles in Unity3D and the URP

How to the Layered Lit shader to mix Texture Maps in Unity HDRP

Wave System Unity 2D