Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
4
Question by frankyboy450 · Nov 24, 2012 at 09:04 PM · cameraeffectflip

Mirror flip camera?

hi I found this script on the Wiki called InvertCamera

 // EXAMPLE WITH CAMERA UPSIDEDOWN
 function OnPreCull () {
     camera.ResetWorldToCameraMatrix ();
     camera.ResetProjectionMatrix ();
     camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(Vector3 (1, -1, 1));
 }
  
 function OnPreRender () {
     GL.SetRevertBackfacing (true);
 }
  
 function OnPostRender () {
     GL.SetRevertBackfacing (false);
 }
  
 @script RequireComponent (Camera)

"This script inverts the view of the camera. So everything rendered by the camera is flipped. This will help you to implement a rear mirror camera."

It makes every think look up side down basically. But I'm trying to make it get flipped vertical. will this even be possible?

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

4 Replies

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

Answer by GerryM · Nov 24, 2012 at 11:18 PM

Just change the matrix (line 5 of your code) to flip the x axis instead of the y axis:

   camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(Vector3 (-1, 1, 1));
Comment
Add comment · Show 2 · 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 frankyboy450 · Nov 25, 2012 at 01:17 AM 0
Share

Thanks Sir. that did the job. I feel stupid for not seeing that. $$anonymous$$any thanks again.

-Frank

avatar image PearShapedCode · Oct 02, 2013 at 12:14 AM 0
Share

Out of all the posts I've been scouring over the past 9 months here regarding Unity, this one has single handedly fixed all my inverse Z positioning co-ords I've been having to use. Now my procedural meshes are correctly aligned position-wise, but also uv's are mapped as they're meant to be and my triangle ordering can go back to clockwise! Although the editor mesh filter navigator thinks my meshes are inside out, I know they're not! Thankyou every so much :-)

avatar image
3

Answer by JamsCenter · Oct 05, 2019 at 02:07 AM

For the next coming on this post. C# version of it. (Tested in 2019.1.14f )

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 public class FlipCamera : MonoBehaviour
 {
 
     public Camera m_camera;
     void OnPreCull()
     {
         m_camera.ResetWorldToCameraMatrix();
         m_camera.ResetProjectionMatrix();
         m_camera.projectionMatrix = m_camera.projectionMatrix * Matrix4x4.Scale(new Vector3(-1, 1, 1));
     }
 
     void OnPreRender()
     {
         GL.SetRevertBackfacing(true);
     }
 
     void OnPostRender()
     {
         GL.SetRevertBackfacing(false);
     }
     
 }

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 Sludgemonster · Oct 17, 2019 at 02:48 PM 0
Share

All good - except Unity (2019.2.9f1) is saying GL.SetRevertBackfacing is deprecated and to use GL.invertCulling ins$$anonymous$$d. So I replaced GL.SetRevertBackfacing(bool) with GL.invertCulling = bool.

avatar image
1

Answer by hydrix · May 12, 2016 at 08:03 AM

the above approach messes up with occlusion culling so here's an approach that worked for me: copy paste the main camera, flip it, then enable it and disable the other at runtime on that button down, and reinitialize the camera. On the standard assets RigidBodyFirstPersonController this is mouseLook.Init (transform, cam.transform);

Comment
Add comment · 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
0

Answer by SylverLocks · Mar 10, 2017 at 07:18 AM

Or just rotate the camera 180 degrees on the Z axis.

Comment
Add comment · Show 2 · 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 hatless · Aug 28, 2017 at 03:50 AM 4
Share

Nerd doesn't get question, doesn't test solution, is consumed by gagging need to establish superiority over topic they don't understand.

The internet, everyone.

avatar image wbknox · Jul 27, 2018 at 04:51 PM 0
Share

A 180 degree rotation is not equivalent to a vertical flip. After a 180 degree rotation, a horizontal flip would be needed to result in the equivalent of a vertical flip.

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

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera Effects binoculars 2 Answers

Create a break screen effect 0 Answers

Flip/Mirror > Camera? 6 Answers

effect on clipping plane 1 Answer

Post processing effect on depth only camera. 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