Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 nikudy · Jan 11, 2012 at 04:04 PM · uv

How to get the position of a pixel(texel) in world space ?

I want to calculate the corresponding position in 3d space(world space), for a position from uv space.

EDIT:

I want to find the world space position corresponding to a point in uv space( not screen space ) for an arbitrary geometry. I'm considering the simplest case, when there's only one point corresponding to a point in uvspace(ie no overlapping uvs).

For example:

I have a texture that's entirely black except for a single pixel that's white. I apply this texture on a geometry i created in a 3d modeling package(Maya, 3ds max etc ), that has the UVs unfolded with no tiling and no overlaping. How can i calculate the coordinates in 3d space for the point on the geometry, where the white pixel is displayed ?

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
2

Answer by DMGregory · Jan 29, 2014 at 06:42 PM

There's no built-in function for this, because in the general case (not the specific example you're giving):

  1. Any one UV coordinate could be mapped to multiple polygons on a single mesh. (So there could be multiple object-space coordinates for a single UV coordinate)

  2. There could be multiple models using that mesh in the scene. (So there could be multiple world-space coordinates for a single object-space coordinate)

I think the only way you can get this information is to use the Mesh class. You would need to iterate over every triangle in the mesh (or just the submesh(es) you need), and check whether the triangle formed by its vertices' UV coordinates contains the UV point in which you're interested.

Once you find a triangle that contains the point, you can find its position in object space by interpolating the vertices' spatial coordinates, using the barycentric position of the UV coordinate within the UV triangle.

Then you'd transform it using the GameObject's Transform to finally get it into world space.

Note that this doesn't take animation into account.

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
avatar image
-4

Answer by rabbitfang · Jan 12, 2012 at 05:31 AM

In the future, please take the time to actually read the documentation or doing a search instead of just asking a new question.

Comment
Add comment · Show 4 · 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 nikudy · Jan 12, 2012 at 08:05 AM 0
Share

I'm sorry i didn't make myself clear enough. I am aware of the Camera.ScreenToWorldPoint method, but what i want is different. I did search the forums and Unityanswers but didn't find anything.

I want to find the world space position corresponding to a point in uv space( not screen space ) for an arbitrary geometry. This point might have a position in uvspace outside of the 0-1 interval that the screenspace allows( ex. [2.3 ; 1.4] ). I'm considering the simplest case, when there's only one point corresponding to a point in uvspace(ie no overlapping uvs).

avatar image nikudy · Jan 12, 2012 at 09:00 PM 0
Share

I edited my first post with a simplified case of what i'm trying to calculate. I'm trying to use this concept for a gameplay mechanic that's way more complex and harder to explain , but the essence is there.

avatar image quitebuttery · Feb 08, 2013 at 06:29 AM 0
Share

The question makes perfect sense. He wants to get the 3D world space coordinate of a texel on the surface of a polygon. I actually have a use for this myself. I was thinking especially in your case you could use a custom shader--since you know the color you are looking for.

avatar image RendergonPolygons · Nov 04, 2021 at 06:58 PM 0
Share

the question is clear enough, what's your problem to direct to the documentation?

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

9 People are following this question.

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

Related Questions

Assigning UV Map to model at runtime 0 Answers

Problems with Textures, Cinema4D to Unity 3 Answers

Voxel texturing with single texture instead of texturesheet? 0 Answers

Error in ONE PARTICULAR scene: "Mesh doesn't have albedo UVs. Please create them in your modelling package." 1 Answer

Can I feed ShaderGraph a UV map? 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