• 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 timrpi · Dec 23, 2014 at 04:43 AM · viewmatrixworld

worldToCameraMatrix updates transformation but not lighting and shader...

Hi, I am setting my own view and projection matrices like this within Update()

     camera.projectionMatrix = mp;
     camera.worldToCameraMatrix = mv;

This works very nicely to position my camera view as I require; however, the rendering is not correct because as I move the camera around with this method, the lighting, shadows and everything with my shader remains constant. It is like the rendering is constantly done from the original camera position even though the camera is obviously being adjusted by my matrices. If I control the camera through translate and rotate, then the shading updates properly.

Any ideas how to fix this?

Comment
Add comment · Show 3
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 timrpi · Dec 24, 2014 at 05:54 PM 0
Share

Alternatively, does anyone know a reliable way to convert a view matrix to the local camera position and rotation?

avatar image Thom Denick · Dec 24, 2014 at 05:59 PM 0
Share

I'm not really sure, but you may be positioning after the renderer has already been run. Have you tried putting the code in LateUpdate() ?

avatar image timrpi · Dec 24, 2014 at 06:44 PM 0
Share

Yes, I tried Update() and LateUpdate(). Both result in the camera view changing based on the worldToCamera$$anonymous$$atrix, but all lighting being constant from the original camera position. Additionally, if I keep changing the worldToCamera$$anonymous$$atrix over subsequent frames, it still maintains the lighting from the original first frame. Thanks

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fprost · May 19, 2015 at 01:44 PM

This is an expected behavior when you manipulate directly the worldToCameraMatrix attribute instead of "moving" the camera using its transform attribute :

If you change this matrix, the camera no longer updates its rendering based on its Transform. This lasts until you call ResetWorldToCameraMatrix. http://docs.unity3d.com/ScriptReference/Camera-worldToCameraMatrix.html

I guess your shaders rely on the transformations applied to the camera which in this case are never updated.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

World View Projection in Shaders 1 Answer

accessing inverse view matrix 1 Answer

Camera View Matrix in Script 1 Answer

Previous Model*View*Projection Matrix 0 Answers

Set World Camera Position in View Matrix 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