• 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
Question by awplays49 · Feb 27, 2016 at 03:35 AM · verticesuvvertex

Issue with UV mapping a cube

Im trying to UV map this cube...

 void GenerateTile (Coord coord) {
         int baseIndex = (coord.z + coord.x * meshDepth + coord.y * meshWidth * meshDepth) * 36;
         vertices [baseIndex] = new Vector3 (coord.x, coord.y, coord.z + 1);
         vertices [baseIndex + 1] = new Vector3 (coord.x + 1, coord.y, coord.z + 1);
         vertices [baseIndex + 2] = new Vector3 (coord.x, coord.y + 1, coord.z + 1);
         vertices [baseIndex + 3] = new Vector3 (coord.x + 1, coord.y + 1, coord.z + 1);
         vertices [baseIndex + 4] = new Vector3 (coord.x, coord.y, coord.z);
         vertices [baseIndex + 5] = new Vector3 (coord.x + 1, coord.y, coord.z);
         vertices [baseIndex + 6] = new Vector3 (coord.x, coord.y + 1, coord.z);
         vertices [baseIndex + 7] = new Vector3 (coord.x + 1, coord.y + 1, coord.z);
         triangles [baseIndex] = triangles [baseIndex + 13] = triangles [baseIndex + 17] = triangles [baseIndex + 24] = baseIndex + 4;
         triangles [baseIndex + 1] = triangles [baseIndex + 5] = triangles [baseIndex + 12] = triangles [baseIndex + 30] = baseIndex;
         triangles [baseIndex + 2] = triangles [baseIndex + 4] = triangles [baseIndex + 20] = triangles [baseIndex + 22] = triangles [baseIndex + 25] = triangles [baseIndex + 29] = baseIndex + 6;
         triangles [baseIndex + 3] = triangles [baseIndex + 18] = triangles [baseIndex + 32] = triangles [baseIndex + 34] = baseIndex + 2;
         triangles [baseIndex + 6] = triangles [baseIndex + 14] = triangles [baseIndex + 16] = triangles [baseIndex + 31] = triangles [baseIndex + 35] = baseIndex + 1;
         triangles [baseIndex + 8] = triangles [baseIndex + 10] = triangles [baseIndex + 19] = triangles [baseIndex + 23] = triangles [baseIndex + 33] = baseIndex + 3;
         triangles [baseIndex + 7] = triangles [baseIndex + 11] = triangles [baseIndex + 15] = triangles [baseIndex + 26] = triangles [baseIndex + 28] = baseIndex + 5;
         triangles [baseIndex + 9] = triangles [baseIndex + 21] = triangles [baseIndex + 27] = baseIndex + 7;
         uvs [baseIndex] = new Vector2 (0, 0.9375f);
         uvs [baseIndex + 1] = new Vector2 (0.0625f, 0.9375f);
         uvs [baseIndex + 2] = new Vector2 (0, 1);
         uvs [baseIndex + 3] = new Vector2 (0.0625f, 1);
         uvs [baseIndex + 4] = new Vector2 (0, 0.9375f);
         uvs [baseIndex + 5] = new Vector2 (0.0625f, 0.9375f);
         uvs [baseIndex + 6] = new Vector2 (0, 1);
         uvs [baseIndex + 7] = new Vector2 (0.0625f, 1);
         uvs [baseIndex + 8] = new Vector2 (0, 0.9375f);
         uvs [baseIndex + 9] = new Vector2 (0.0625f, 0.9375f);
         uvs [baseIndex + 10] = new Vector2 (0, 1);
         uvs [baseIndex + 11] = new Vector2 (0.0625f, 1);
         uvs [baseIndex + 12] = new Vector2 (0, 0.9375f);
         uvs [baseIndex + 13] = new Vector2 (0.0625f, 0.9375f);
         uvs [baseIndex + 14] = new Vector2 (0, 1);
         uvs [baseIndex + 15] = new Vector2 (0.0625f, 1);
         uvs [baseIndex + 16] = new Vector2 (0, 0.9375f);
         uvs [baseIndex + 17] = new Vector2 (0.0625f, 0.9375f);
         uvs [baseIndex + 18] = new Vector2 (0, 1);
         uvs [baseIndex + 19] = new Vector2 (0.0625f, 1);
         uvs [baseIndex + 20] = new Vector2 (0, 0.9375f);
         uvs [baseIndex + 21] = new Vector2 (0.0625f, 0.9375f);
         uvs [baseIndex + 22] = new Vector2 (0, 1);
         uvs [baseIndex + 23] = new Vector2 (0.0625f, 1);
     }

However, since I didn't specify any vertices beyond 7, it doesnt work with uvs beyond 7. How can I fix this? I tried adding:

     vertices [baseIndex + 8] = new Vector3 (coord.x, coord.y, coord.z + 1);
         vertices [baseIndex + 9] = new Vector3 (coord.x + 1, coord.y, coord.z + 1);
         vertices [baseIndex + 10] = new Vector3 (coord.x, coord.y + 1, coord.z + 1);
         vertices [baseIndex + 11] = new Vector3 (coord.x + 1, coord.y + 1, coord.z + 1);
         vertices [baseIndex + 12] = new Vector3 (coord.x, coord.y, coord.z);
         vertices [baseIndex + 13] = new Vector3 (coord.x + 1, coord.y, coord.z);
         vertices [baseIndex + 14] = new Vector3 (coord.x, coord.y + 1, coord.z);
         vertices [baseIndex + 15] = new Vector3 (coord.x + 1, coord.y + 1, coord.z);
         vertices [baseIndex + 16] = new Vector3 (coord.x, coord.y, coord.z + 1);
         vertices [baseIndex + 17] = new Vector3 (coord.x + 1, coord.y, coord.z + 1);
         vertices [baseIndex + 18] = new Vector3 (coord.x, coord.y + 1, coord.z + 1);
         vertices [baseIndex + 19] = new Vector3 (coord.x + 1, coord.y + 1, coord.z + 1);
         vertices [baseIndex + 20] = new Vector3 (coord.x, coord.y, coord.z);
         vertices [baseIndex + 21] = new Vector3 (coord.x + 1, coord.y, coord.z);
         vertices [baseIndex + 22] = new Vector3 (coord.x, coord.y + 1, coord.z);
         vertices [baseIndex + 23] = new Vector3 (coord.x + 1, coord.y + 1, coord.z);
Comment

People who like this

0 Show 1
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 awplays49 · Feb 27, 2016 at 10:13 PM 0
Share

I have been stuck on this all day:(

1 Reply

  • Sort: 
avatar image

Answer by tanoshimi · Feb 27, 2016 at 10:31 PM

"since I didn't specify any vertices beyond 7, it doesnt work with uvs beyond 7"

So why don't you add vertices beyond 7 then...? If you want "hard edges" and don't want to interpolate textures across faces (which it sounds like you don't), then they can't share vertices. So have 24 vertices, 24 uvs.

Comment

People who like this

0 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 awplays49 · Feb 28, 2016 at 04:04 PM 0
Share

Becuause I've tried adding those vertices and it doesn't seem to work. I feel like this is one of those things where you need example code to learn. Could you pose some code?

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

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

Related Questions

How do you make a submesh properly? 0 Answers

Why does my script-made mesh only look visible from one side??? 1 Answer

vertices in current camera view 1 Answer

Mesh breaks apart when using vertex displacement with shadergraph. 3 Answers

drawing vertices 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