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 /
  • Help Room /
avatar image
4
Question by ElijahShadbolt · Nov 10, 2016 at 08:44 AM · c#cameramatrixmatrix4x4projectionmatrix

Camera Frustum with Custom Near Plane (Get a Projection Matrix given NearClip Plane Vertices)

As my first Question on these forums, I'm quite pleased that it is about pretty advanced stuff. Thanks in advance for any advice or help you can give!

I have a secondary camera that needs to have exactly the same frustum as the Main camera (yet it will be in a different position and rotation), but I want to render only the parts that are beyond a 3D plane in world space (similar to the near clip plane of a normal frustum, but not parallel to the far clip plane).

I would like to 'cut off' the front part of the Camera's default frustum, to create a frustum as illustrated by the black 'Result Frustum' in the image below. I would like to create a Projection Matrix for this.

Camera Frustums

I've got the camera (and its position, rotation, etc), the plane (and its normal, etc), the four blue vectors coming from the Camera's position (which are in the direction of the outgoing edges of the default frustum), and the black points where the blue vectors intersect the plane, and I know the distance from the camera to the far clip plane.

Is it possible to set up a projection matrix for this sort of effect? If so, how?

I expect I'm just at the end of figuring it out, but I can't quite get it. I do not know much about Projection or Transformation Matrices. I've tried it with the example code here, but I think that assumes the near plane is parallel to the far plane, which is not what I want.

camerafrustums-01.png (20.0 kB)
Comment
Add comment · Show 4
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 Desoxi · Nov 10, 2016 at 10:59 AM 0
Share

I think you would have to write some fancy custom stuff to create a working projection matrix with a non-parallel near plane, because as far as i know there is a division of the x and y parts with the z parts of the near/far plane to compute the w parts of the corresponding matrix (i may be wrong, because its a long time ago i learned this stuff :D).

Couldnt you achive that what you want with a shader and/or layers?

avatar image ElijahShadbolt · Nov 10, 2016 at 09:03 PM 0
Share

Well, I am trying to make a game similar to the classic game Portal, so I want the secondary portal cameras to look exactly like the main camera (use the same clipping layers, FOV, etc), so I'm not sure how using layers would work without losing quality or having to recreate the entire scene in multiple layers. Also, I'm not very good with shaders.

avatar image crazyfox55 · Apr 30, 2017 at 12:08 AM 0
Share

I am working on the exact same problem. Did you find a solution?

avatar image ElijahShadbolt crazyfox55 · Apr 30, 2017 at 09:08 AM 0
Share

Negative. The closest I have come to a good solution is this unity portal effect by Adaszewski. It uses z-index shaders ins$$anonymous$$d of changing the camera frustum, which is nice, but it does not account for skyboxes, near clipping plane, etc., so it is far from perfect (and the teleportation equations are messed up).

I will post more, if and when I find my own solution to creating Portals in Unity.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ElijahShadbolt · Nov 23, 2017 at 02:00 AM

Quick update:

Tom Hulton-Harrop successfully solved this problem in 2015, in his blog post Portal Rendering with Offscreen Render Targets. He used shaders, render textures, and oblique projection matrices.

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

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

269 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Calculation behind camera.ScreenToWorldPoint 1 Answer

Please help :( Matrix4x4.MultiplyPoint process compared to standard dot product matrix Matrix4x4.MultiplyPoint3X4 0 Answers

Rotate camera when colliding 0 Answers

Camera Rotation Around Player 1 Answer

uNet hitboxes and movement. 0 Answers


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