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
0
Question by JJJohan1 · Sep 29, 2015 at 04:46 AM · cameraworldspacematrixscreenspace

What is the matrix equivalent to Camera.WorldToScreenPoint?

Hello,

I'm trying to perform Worldspace to Screen Space operations on a very large number of points. Unfortunately compute shaders are not an option as WebGL is one of the required target platform.

However in the meantime I'd like to use a threaded solution. Although this is not a WebGL supported feature either, it may well be in the future, even if distant. I will need to be able to use an alternative to Camera.WorldToScreenPoint and Camera.ScreenToWorldPoint as they are not thread-safe.

From what i could gather I'd be able to perform a similar solution by doing:

 Matrix4x4 screen2World = Camera.main.projectionMatrix * Camera.main.cameraToWorldMatrix;
 Matrix4x4 world2Screen = screen2World.inverse;
 
 Vector3 point = new Vector3(123, 456, 789); // World space
 Vector3 screenSpace = world2Screen.MultiplyPoint(point); // <-- I want to get the screen space point
 /* Do something with the screen space point */
 point = screen2World.MultiplyPoint(screenSpace); // Convert back to world space

However I am not getting the same results. Is there something I'm missing here?

Any help is much appreciated.

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
2

Answer by fguinier · Sep 30, 2015 at 09:03 AM

Hi JJJohan1,

At first glance this would be better :

  Matrix4x4 world2Screen = Camera.main.projectionMatrix * Camera.main.worldToCameraMatrix;
  Matrix4x4 screen2World = world2Screen.inverse;

Hope it helps :)

Florent

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

30 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

Related Questions

Calculation behind camera.ScreenToWorldPoint 1 Answer

Find a World Position Of an Object inside Canvas 0 Answers

Get the relative dimensions of two different canvases 0 Answers

c# RTS style snapping of game objects 0 Answers

Global direction (e.g. Vector3.forward, Vector3.right) from Mouse drag 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