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
0
Question by darkyoddd · Mar 30, 2013 at 06:59 PM · cameramatrix4x4projection-matrix

Custom Camera Projection Matrix that "Horizontally Compresses" worldview

Hello everyone. I'm trying to create a camera with a custom projection matrix that will result in the rendering that it produces to be compressed horizontally, preferably by a factor of two. The reason is that I have a head mounted display and two cameras rendering in each eye, and they take up half the screen; as such, they need to produce a horizontally compressed view of the world in order to render correctly in the head mounted display. I'm terrible with matrices, so what kind of Matrix4x4 would I use to solve this problem? Thanks!

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
Wiki

Answer by xavierwielemans · Jun 17, 2013 at 01:15 PM

Hi Darkyoddd, I suggest that you use the "off-center projection" example from Unity itself: http://docs.unity3d.com/Documentation/ScriptReference/Camera-projectionMatrix.html

It allows you to independently set the opening angles of your rendering cam in the four directions (top, bottom, left and right).

In your particular case, keep left = -right and top = -bottom in all cases, and adjust left and top to match the opening angles you like, in the horizontal and vertical direction. Using a fixed left value, increasing top will compress the rendered image horizontally.

Hope this is what you were looking for...

Cheers!

Willy

PS: be aware that using custom projection matrices will prevent you from using the following: - skyboxes - deferred shadows - render-to-texture (=> several post-processing image effects)

PPS: A much simpler solution might be to just modify Camera.aspect on your cam (no custom proj matrix involved)... http://docs.unity3d.com/Documentation/ScriptReference/Camera-aspect.html

Let me know...

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 maksdesk · Oct 19, 2015 at 03:47 AM 0
Share

Hi Willy, just saw ur old post while searching for answers to my issue, hope you can please help or kindly refer to someone who can: I am using vuforia to render an AR projection of a room over the actual view of the room, and the issue is that both don't match at the far end....the projection begins from the markers beautifully and accurately but the farthest wall of the AR projection appears smaller in size as compared to the actual view... I have posted this issue in the vuforia forum but rcvd no response as yet... i think the core issue is the projection matrix...the Ar projection matrix is rendering the room model in a different manner than the device camera view renders the actual room... how could I align both of them to be exactly the same?... below is something i found in my serach but i am not sure it applies in my case:

    It seems that Vuforia’s AR camera    uses its own specific version of    projection matrix, which defines how    the “world” will be shown on screen.    A simple script solved the issue,    just by applying the AR camera’s    matrix to the UI camera:

    private bool sync = false; void    Update() {    if (!sync)    {
    uiCamera.projection$$anonymous$$atrix = arCamera.projection$$anonymous$$atrix;
    sync = true;    } }

    Only after I applied this change –    the two cameras got synced. Now I    could use the AR camera to detect a    target image in the real world,    attach a 3D object to that image,    then move the object to be the child    of the UI camera without experiencing    any jump cuts. This makes the    object’s new coordinates relate to   the app’s UI, therefore I can move it    around – to the center of the screen,    or anywhere else I want in the app’s    UI layout.

any help please?

avatar image xavierwielemans · Oct 23, 2015 at 05:56 PM 0
Share

Hi @$$anonymous$$aksdesk,

Cool idea! =)

I don't think projection matrices will help you. Vuforia handles it all beautifully, so the rendering camera matches your device camera perfectly, you shoouldn't worry about it.

I think your problem comes more from a physical difference between your device camera capture cone and your projection cone. A few tips:

  • place projector and camera focal points as close to each other as you can

  • try to match, through camera and projector zooms, the opening angles of camera and projector

  • match the camera and projector aspect ratios (might mean changing one of them) and ideally, resolution.

  • most cameras have a symmetrical capture cone, whereas most projectors have a totally assymetric projection cone in the vertical direction. Ttry to find a projector with a symmetrical projection cone (like the Optoma EH503 thanks to its huge vertical lens shift range)

Hope this helps... Let me know if I misunderstood sth. Email me if I you want a fast answer - xavier at tinybigstory dot be

Cheers!

Xavier

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

12 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

Related Questions

Flipping projection matrix problem: It flips everything but the Skybox. How do I fix this? 1 Answer

Generating rays from cameras with custom projection matrices 1 Answer

Setting the camera projection matrix does nothing 0 Answers

How do I calculate a view matrix using Matrix4x4.LookAt? 2 Answers

Does the projection matrix calculation affect the shader? 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