Mirror sharing

Hey All,

we are doing a 3d apartment in unity and we’d like to have reflection on the floor. FOr this I have use a mirror script, found herehttp://www.unifycommunity.com/wiki/index.php?title=MirrorReflection2

Each room in our apartment has a different floor material and is in its own separate object. Instead of rendering a reflection texture for each object I thought I could just render it once and then apply it to each of the other floor objects.

When I do this, however, the perspective does not seem correct. All floor objects lie in the same reflection plane so it nshould be possible to share one reflection texture. Its just that the whole projection matrix thing is like voodoo to me so perhaps someone can explain to me why I don’t see a sphere reflected on plane B?

Anyone?

Perhaps a link to a good article on projection matrices could be good too. :slight_smile:

http://aras-p.info/texts/matrices.html

The script makes a new camera, moves it to the proper position, then renders that camera to a render texture that is then applied to the plane. You’re not going to see the sphere in plane B because the camera created by the script is still getting positioned at plane A and creating the reflection for plane A.

The distortion is because it’s transforming the UVs from object space into screen space (according to the comments), and plane B has different screen coordinates than plane A.

So you can’t do it the way you are trying to do it. If only one room of the apartment is visible at a time, then you could modify the script so that it takes a gameObject/transform instead of using the transform of the object it is attached to, then changing that variable to whatever room you happen to be in. Or you could join all the floors into one object and attach the script to the big single object. That would cause it to be fairly low resolution though, since it would be stretched across all the rooms floors.

The sphere IS rendered into the reflection texture, it’s just not visible because the reflection coordinates for plane B need to be adjusted somehow, I just don’t know how.

I am pretty certain that this is possible, as long as all floor objects lie in the same plane.

Hmm, have you tried creating one huge plane that encompasses all the smaller planes and attaching the script to that and then see if it applies correctly to the separate small planes?

Yes, that doesn’t work. The problem is not the reflection texture, its the projection matrix that needs to be somehow adjusted.

At least thats my theory.