Pochi
Pochi

Reputation: 13459

Offsetting the rendered result of a camera in Unity

I am trying to make everything that is rendered by my perspective "Camera A" appear 100 points higher. This is due to the fact that my App has an interface with an open space on the upper part.

My app uses face detection to simulate the face movement into an in game avatar. To do this I compute the "Model-View-Matrix" to set it into the camera's "worldToCameraMatrix".

So far this works well, but everything is rendered with the center as the origin, now i want to move this center origin a certain distance "up" so that it matches my interface.

Is there a way to tell Unity to offset the rendered camera result?

An alternative I thought about is to render into a texture, then I can just move the texture itself, but I thought there must be an easier way.


By the way, my main camera is orthographic, and i use this one to render the camera texture. In this case simply moving the rendering game object quad up does the trick.


I found a property called "pixelRect", the description says:

Where on the screen is the camera rendered in pixel coordinates.

However moving the center up seems to scale down my objects.

Upvotes: 0

Views: 1747

Answers (2)

Swompy
Swompy

Reputation: 1

I know this is ancient but maybe someone stumbles upon this and thinks there is still no easy way but since 2019 unity supports it you just have to enable physical camera in your camera settings and add a lens shift so upwards would be like y 0.1

Upvotes: 0

Chris
Chris

Reputation: 508

You can set the viewport rect/orthosize so that its offset or you can render to a render texture and render that as a overlay with a offset or diffirence in scale.

Cheers

Upvotes: 1

Related Questions