Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tachi23 · Mar 27, 2016 at 01:24 AM · camerarendertexturepositioningmirrorrotating

RenderTexture Mirror - Camera postion and rotation

Hello,

I'm trying to make mirror using the RenderTexture. Everything works as expected except of one simple detail, which I'm trying to figure out. I've been searching for a long time online now but couldn't find any solution.

From what I've understood after my searching, the Mirror camera should be position exactly at the same position as main camera, but behind the Mirror plane, but this approach doesn't really work for me, because it also draws empty space behind the camera.

I'm posting a video to better understand what I mean : https://youtu.be/d4GxRWS5ZR0

After seeing this problem I've tried to make Mirror camera stick ON the Mirror plane, but now it makes image zoomed.

Again, I've made a video : https://youtu.be/jPhWA9-44To.

Here's code for the camera Update function :

 void Update()
 {
     Vector3 mcforward = cameraMain.transform.TransformDirection(Vector3.forward);
     Vector3 cforward = Vector3.Reflect(mcforward, Vector3.left);
     //Getting camera position and reflection

     Debug.DrawRay(cameraMain.transform.position, mcforward * 20, Color.red);
     Debug.DrawRay(transform.position, cforward * 20, Color.green);
     //Drawing rays

     transform.rotation = Quaternion.LookRotation(cforward);
     //Rotating camera (works as expected)

     Vector3 position = cameraMain.transform.position - _collider.transform.position;
     //transform.localPosition = new Vector3(-position.z, position.y, position.x);
     transform.localPosition = new Vector3(-position.z, position.y, 0);

     //Positioning camera
 }

The _collider variablle is actually Plane with mirror and cameraMain is of course main camera.

Thank you for your help.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eno-Khaon · Mar 27, 2016 at 03:54 AM

In this wiki writeup, you will find numerous complex details of a reflection camera outlined, including specifics such as creating an oblique camera matrix to properly align the camera's view to the surface it's reflecting from.

http://wiki.unity3d.com/index.php/MirrorReflection4

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tachi23 · Apr 10, 2016 at 06:46 PM 0
Share

Thank you for help, works perfectly.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Flip a render texture? 2 Answers

Check if mouse is over GUI element using Rendertexture? 1 Answer

First Person Camera Pixelation 1 Answer

RenderTexture.active for a non-VR camera in a VR project 0 Answers

Steam VR Render object to only one eye 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges