Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Feb 15, 2013 at 08:59 PM by MountDoomTeam for the following reason:

answered

avatar image
1
Question by MountDoomTeam · Feb 15, 2013 at 05:40 PM · uvmappingprojectionseams

Box Projection UV Mapping on single vertex mesh?

I'm making a procedural generator, for example in the picture doing some caves, and I'm texturing using box projection/cubic projection, which is awesome, but it leaves a line of triangles with wonky texture.

you can see the areas below the yellow dots are UVmapped with a side texture and areas above the red dots are mapped to a top texture.

I want to make a 2nd vertex on all the red dots so that the distance between the yellow dots and the red dot is 0, and there is a seam at that point.

Do you have a clear mind about what the task is? do I have to make a new triangle for every wonky triangle? And a new vertex for each corner of the triangle? how could I measure it, and make the triangles, and do all the comparisons? are there some tricks I could use? alt text

   //Box Projection textures
     var mesh : Mesh = GetComponent(MeshFilter).mesh;
     var vertices : Vector3[]  = mesh.vertices;
     var normals : Vector3[]  = mesh.normals;
     var uvs : Vector2[] = new Vector2[vertices.Length];
 
     for (var i = 0 ; i < uvs.Length; i++){
     if ( Mathf.Abs(normals[i].x) > Mathf.Abs(normals[i].y) && Mathf.Abs(normals[i].x) > Mathf.Abs(normals[i].z) ){ 
         uvs[i] = Vector2 (vertices[i].y, vertices[i].z);}
         
     if ( Mathf.Abs(normals[i].y) > Mathf.Abs(normals[i].x) && Mathf.Abs(normals[i].y) > Mathf.Abs(normals[i].z) ){ 
         uvs[i] = Vector2 (vertices[i].x, vertices[i].z);}
         
     if ( Mathf.Abs(normals[i].z) > Mathf.Abs(normals[i].x) && Mathf.Abs(normals[i].z) > Mathf.Abs(normals[i].y) ){ 
         uvs[i] = Vector2 (vertices[i].x, vertices[i].y);}
         
     Debug.Log(  " vertex  "+vertices[i] +  " uvs " +uvs[i] );                
 
     mesh.uv = uvs;
 }


vtxbox.jpg (1.9 MB)
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 MountDoomTeam · Feb 15, 2013 at 08:58 PM 0
Share

sorry I understood now! Triangles aren't so complicated! I have to go through the triangles and find the ones which have different facing vertices, and change the top vertex of each one to a new vertex which is a copy of the old top vertex, keeping the same aspect is lower vertices. I'm so happy I love these puzzles!!! alt text

avatar image KenneyWings · Jun 30, 2017 at 02:17 PM 1
Share

Having the same problem as you had, by your comment it seems you have solved it. Would you be willing to share the fixed code or give a few pointers to how to solve it? Thanks!

avatar image Ellandar · Jul 01, 2017 at 02:06 AM 0
Share

Hi @$$anonymous$$enneyWings , it looks like he went through every triangle searching for vertices with incorrect locations (ie belonged to another triangle) and duplicated it and replaced it with a correctly located UV.

Does this help?: https://stackoverflow.com/questions/22773066/texture-stretching-ins$$anonymous$$d-of-tiling-when-applied-to-a-mesh

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Procedurally Generated UVs Seams 0 Answers

Projection Mapping a texture, into UV of objects 0 Answers

UV Mapping / Lightmap Problem 1 Answer

Textures - n00b questions 3 Answers

Is it possible for a player to add upload/import photo/map? 2 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