Use RenderTexture to achieve 3D vision

As shown in the picture above, a 2D scene is used and the camera is modified to make it look like a 3D effect. 

  1. In the newly released "Super Mario" on Nintendo Switch, some levels mix 2D and 3D graphics.

Generally speaking, the camera will render directly to the computer screen; how can I make the camera see the content and display it on another object? The camera has one property: Target Texture.

 

You can create a new render texture ( Render Texture) and add it to the camera.

Create -> Render Texture to create a new rendering texture

 

Then drag this object to the Camera's Target Texture property, so that the camera will render all the images it queues to this texture.

If you enter the game at this time, you will find that the game screen is completely black, and there is no renderer that is activated to receive images from the camera.

 

Now, let's add a new camera to the scene. The camera's Projection property is set to Perspective. Add a 3D object in front of the camera, for example, a cylinder.

Then create a new Texture, set its Shader attribute to "Unlit/Texture", and then drag the rendering material just to the MainTexture of which material this material is.

The material of this cylinder determines its displayed content.

 

We create a new material, set the Shader to Unlit/Texture, and connect the previously created texture and material.

The Shader of this material must be selected correctly:

 

 

The penultimate step is to add the rendering texture just created to the newly created texture.

In this way, the content of the camera is rendered to this material.

Then we set this material to the material of the cylinder, so that the content is displayed on the cylinder.

 

You can also see from the material preview that we have converted the 2D picture into 3D content.

Try to control the movement, the effect is quite interesting.

The key is the understanding of Material and Texture. Especially the understanding of these two concepts in the 3D environment.

Finally, this cylindrical visual effect came out.

Guess you like

Origin blog.csdn.net/grf123/article/details/132393516