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 hknylt · Jul 04, 2019 at 05:30 PM · camerarenderingshadersportalprojection-matrix

Does the projection matrix calculation affect the shader?

I'm working on a portal game with Unity. For the portal camera to see the world correctly, I do a matrix calculation like the one I see in github. I also tried the matrix calculation used in the water script of unity and the MirrorReflection4 script in the unity wiki. The result has not changed.

The portal camera calculates the projection matrix correctly, but does not render certain materials correctly.
alt text
If I don't change the projection matrix of the camera, there is no problem.
alt text
I need to use a projection matrix for the portal camera. Otherwise, the camera displaying the portal can see the walls behind the portal and similar objects. But when I use the projection matrix, I encounter the problem mentioned above. Does anyone have an idea for the cause and solution of this problem?

I've uploaded a video to better understand my problem.

I still haven't found a solution :(

Comment
Add comment · Show 2
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 Bunny83 · Jul 04, 2019 at 11:24 PM 0
Share

Sorry but your images do not work. Your text isn't really clear what materials are not rendered correctly. There shouldn't be any issues. However If you try to make the mirror reflection script working with your portal script, that wouldn't be so simple because both scripts do replace the projection matrix and calculate a custom oblique near clipping plane, but a totally different one. The mirror script sets the mirror plane as clipping plane and the portal script the portal plane.


You can not have two different near clipping planes. However you can add a manual clipping plane to a shader (requires just two vectors, a position and a normal) to additionally clip the scene at the specified plane. To test if a fragment is before or behind the clipping plane, just subtract the clipping plane position from the fragment worldspace position and calculate the dot product between the resulting vector and the plane normal. If the result is below 0, discard the fragment.


ps: Before someone tries to correct me: Yes it's possible to define the clipping plane just with a single Vector4 by using the usual normal form of a plane. This is probably a bit cheaper in the fragment shader.

avatar image hknylt Bunny83 · Jul 04, 2019 at 11:55 PM 0
Share

Sorry. I updated the images. The projection matrix calculation in the reflection script was an example. I made a calculation like the github link I specified for the portal. I didn't use the reflection script for the portal.

I would like to explain the problem again: The shader that works correctly on the main camera does not work correctly on a camera where I calculate the projection matrix. $$anonymous$$y problem is not the miscalculation of the portal projection matrix (water reflection, etc.). I calculate the projection matrix correctly with the portal's clipping plane. But the camera doesn't render the shaders correctly. These shaders are unity's standard shaders (Glass refraction and Toon shaders).

I guess I don't know much about the Shaders. I don't understand what you're talking about in the second paragraph. I think you thought I wanted to cut the mesh according to the clipping plane.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hknylt · Jul 06, 2019 at 10:15 PM

Also, the projection matrix is reset when I use a post processing stack. I have learned that there is no solution yet. So my question is: how can I set up the F***ing portal camera with these restrictions? How will the portal camera work without using a projection matrix? :((

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

191 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

Related Questions

Need some help with portal rendering 2 Answers

Disabling AA Changes how SS Effects Work 1 Answer

Setting the camera projection matrix does nothing 0 Answers

How to make a custom GrabPass-like sampler2D in MRT shader? 0 Answers

Applying full screen image effects to UI only 2 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