• 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
12
Question by noflyzone · Sep 19, 2011 at 06:07 AM · screen

Screen VS Viewport What is the difference

In unity3d, what is the "Screen", "Viewport"? "Screen" image is not on the "Viewport" is a Camera on it? Learn unity3d friends, to explain, in unity3d in, "Screen", "Viewport", respectively, what is meant by the concept? "Screen Point", "Viewport Point", "World Point", What is the difference? Camera.ViewportToScreenPoint (), Camera.WorldToScreenPoint () What is the difference (in my opinion is the same, all the points in 3D space projected on the Screen, oh no difference?)

Screen VS Viewport What is the difference

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

2 Replies

· Add your reply
  • Sort: 
avatar image
39

Answer by Paulius-Liekis · Sep 19, 2011 at 07:58 AM

Screen and Viewport represent same area - on screen, but they have different coordinate systems (IIRC):

  • Screen: from [0,0] to [Screen.width, Screen.height]

  • Viewport: from [0,0] to [1,1]

World point is a point in world space.

edit(Bunny83)
I just fixed the Viewport coordinates. It's [0,0] to [1,1] and not [-1,-1] to [1,1]. The latter are homogeneous device coordinates. T$$anonymous$$s is the space where the GPU actually clips the geometry against the frustum. The result of the projection matrix outputs homogeneous coordinates.

A simplified version of the pipeline is:

 local space   [-inf, -inf] to [+inf, +inf]
     \/                                     -- localToWorld (Model)
 world space   [-inf, -inf] to [+inf, +inf]
     \/                                     -- worldToCamera (View)
 camera space  [-inf, -inf] to [+inf, +inf]
     \/                                     -- projectionMatrix (Projection)
 clip space    [  -1,   -1] to [   1,    1]
     \/                                     
 view space    [   0,    0] to [   1,    1] \
     \/                                      -- handled by GPU / driver
 screen space  [   0,    0] to [   W,    H] /

In all cases [0,0] is the bottom left. T$$anonymous$$s only handles normal geometry. The GUI space is a special case where the camera space has to invert the y axis, hence it starts at the top left.

Comment
Add comment · Show 8 · 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 noflyzone · Sep 19, 2011 at 09:19 AM 0
Share
avatar image Paulius-Liekis · Sep 19, 2011 at 11:29 AM 1
Share
avatar image syclamoth · Sep 19, 2011 at 11:49 AM 1
Share
avatar image RedRival · Dec 19, 2012 at 03:44 AM 7
Share
avatar image Jonathan-Bro · Dec 08, 2016 at 04:58 AM 1
Share
Show more comments
avatar image
3

Answer by Priyanka-Rajwanshi · Mar 03, 2020 at 06:05 PM

Screen point is defined in pixels. The bottom-left of the screen is (0,0); bottom-right of the screen is (Screen.width,0), left-top is (0, Screen.height) and the right-top is (Screen.width,Screen.height).

A viewport space point is normalized and relative to the Camera. The points on the screen range between 0 and 1. You can determine the the x-coordinate by dividing the screenPoint.x by Screen.width and the y-coordinate by dividing the screenPoint.y by Screen.height.

For more information, check out the link http://codesaying.com/understanding-screen-point-world-point-and-viewport-point-in-unity3d/

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Scaling GUI Components to Screensize 1 Answer

Raycasting Accurately with gun 2 Answers

RenderTexture to capture an area bigger than Screen on IOS 0 Answers

How do you clamp a camera by mobile width? 2 Answers

Get the borders of screen 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