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 NeweieUnityDev · Feb 05, 2016 at 04:12 PM · shaderlabmatrixprojection

Unity MVP coordinate exchange

I use below code work on mobile protrait, but if set to landscape-left, it can't set right texture on 3d model. i try change P(projection) degree, but also have problem Code:

     // get MVP matrix
                 Matrix4x4 P = GL.GetGPUProjectionMatrix(Camera.main.projectionMatrix, false);
                 Matrix4x4 V = Camera.main.worldToCameraMatrix;
                 // use plane to get texcoords for target
                 Matrix4x4 M = mPlane.GetComponent<MeshRenderer>().localToWorldMatrix;
                 Matrix4x4 MVP = P * V * M;

ShadeLab:

 // calculate new uv in camera image
             float4 uvTmp;
             uvTmp = mul(_MATRIX_MVP, float4(IN.uv_MainTex.x-0.5f,IN.uv_MainTex.y-0.5f,0,1));
             uvTmp.x = uvTmp.x/uvTmp.w;
             uvTmp.y = uvTmp.y/uvTmp.w;
             uvTmp.z = uvTmp.z/uvTmp.w;
      
              // some swap for different coordinate system
             uvTmp.x = (uvTmp.x + 1)/2.0f;
             uvTmp.y = (uvTmp.y + 1)/2.0f;
             IN.uv_MainTex.x = ((1-uvTmp.y)-0.5f)*_xScale+0.5f;
             IN.uv_MainTex.y = ((1-uvTmp.x)-0.5f)*_yScale+0.5f;

i have two question: 1.whether we change the P(projection) can adapter the lanscape-left 2.if the first can't solve, how can i change the shader

(Don't let this issuse dead. balabala....)

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
0

Answer by NeweieUnityDev · Feb 17, 2016 at 07:17 AM

i have solved

Comment
Add comment · Show 1 · 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 xfy · Sep 12, 2016 at 06:15 AM 0
Share

Hello, how did you solve it?

avatar image
0

Answer by xfy · Sep 17, 2016 at 09:33 AM

@NeweieUnityDev

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Non-perpendicular near clip plane 0 Answers

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

Find border of Matrix (east, west, north, south) 0 Answers

How could I change and save position of objects in the Unity with a projector in real time 0 Answers

After upgrading to version 5.3.4f1, my terrain shader no longer works 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