Tuesday, October 13, 2015

unity - How to render multiple projections of an object?


I want to display multiple projection of an object on the same screen. The projection should also change as the body rotates, kind of a dynamic projection of the body.



I am trying to make a character for pyramid hologram (as it has been named) which needs the projections.


Here is an example found on the Internet:


Example


(Image source)



Answer



One blunt way to do this in Unity is to set up 4 cameras surrounding your object with your desired size/field of view/etc.


In your Assets folder (or a suitable subfolder), create 4 RenderTextures for the 4 views. Assign each camera's Target Texture to one of the RenderTextures.


Now drag the 4 RenderTextures into your scene and arrange them into the pattern you want the displayed on the screen. Add a 5th camera to frame & capture this layout, setting this camera's depth to render after the other 4.


You can also skip the RenderTextures and simply have each camera render straight to the framebuffer, using the Viewport Rect properties to control which part of the screen each one renders in, and rotating the cameras themselves to orient each view of the object.


Here's a quick example of this method: Unity Scene with pyramid rendering setup



Here I still have one extra camera, rendering before all the others to clear the background to black.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...