Hello,
I’ve been searching high and low on Unity site, hoping to find a question like mine with an answer, but couldn’t find one. So i’m posting my question :
- I have a simple Plane
- A main camera with FPS movements (no collisions or physics).
- A Camera named Render 1, which renders on renderTexture (yes, i’m using Unity Pro, at work only though u_u).
- And a few random prefabs placed randomly to have something to compare the resulting scene with previous results.
What i want to do is have a realistic mirror using renderTexture with the Plane and Render 1 camera : Render 1 renders on renderTexture, which is a texture for Plane. I somehow made Render 1 move along MainCamera so that the image MainCamera gets from Plane is realistic. I did it by getting the relative position of MainCamera to the Plane then calculating the relative position of Render 1, the using LookAt(Plane.position) on Render 1.
I know it’s not very realistic since Render 1 always looks at the center of Plane, but my main concern was the fact i don’t know how to make Render 1 not render anything else beside what is beyond Plane. What happens is when Render 1 begins reaching the edge of Plane, i can see the objects that are behind Plane, which isn’t supposed to be visible.
I’m a noob at Unity (only been on it for a few weeks), so i’m not sure how to do this. Does anyone have an idea as how to solve this problem?
Edit :
Thanks for your answers.
@Meltdown : I’m sorry but as a unity newb i fail to see how those can help me do what i want with the camera. Can you be a bit thorough with your idea?
@syclamoth : I already read a bit about matrixes, but it’s still a bit confusing for me. I’ll try to see how i can use them to customize the camera.
All in all, i think i wasn’t clear enough in my explanation of what i want to do with the camera, so i made simple schema to explain it :
On the left you have a green circle representing the camera, with 2 black lines being the FoV. In blue is the simple plane that is supposed to be the mirror. Red and orange are, respectivly, the NearClipPlane and the FarClipPlane. The figure represents how the camera renders when i give it the distance “from Camera to Plane”.
On the right, with same colors representing same things, and purple line representing the FoV of the camera like i want it to be. As the figure shows it, when the camera isn’t orthogonal to the plane, the FoV shows more than it should, since the NearClipPlane rotates with the camera (i know it’s an obvious thing). But what i want is, either changing the FoV so it doesn’t go further than the edges of the plane, or somehow making the NearClipPlane overlap with the Plane used for making the mirror. Is either of those possible?
