• 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
1
Question by squirlhntr · May 28, 2012 at 03:50 AM · meshproceduralnormalsclipping

Procedural Mesh, Strange Clipping

So I've generated a mesh from code ala Minecraft and have this strange clipping problem that I can't figure out. I've checked and re-checked the vertices, the winding order of the triangles, the UVs, and the normals (whether manually or via RecalculateNormals()), and everything looks correct, however, I feel like I've missed an obvious step.

Any advice on where to look?

Here's a video: http://player.vimeo.com/video/42946293

Here's some example code for one face of a cube:

             # check to the right of a spot and see if it needs squares built upwards (i.e. the spot to the right is higher)
             if (x+1 < len(chunkHeights, 0)):
                 if (chunkHeights[x,y] < chunkHeights[x+1, y]): # if the block to the right is higher...
                     total_blocks_up = chunkHeights[x+1,y]  - chunkHeights[x,y]
                     for b in range(total_blocks_up): # block to the right could be several spots higher
                         # vertices for square
                         vertex_list.Push(Vector3(x+1, h+1*b, y+1))
                         vertex_list.Push(Vector3(x+1, h+1*b, y))
                         vertex_list.Push(Vector3(x+1, h+1+1*b, y))
                         vertex_list.Push(Vector3(x+1, h+1+1*b, y+1))
                           # uvs. (16 textures per side in the texture sheet)          
                         uv_list.Push(Vector2(0/16.0, 15/16.0))
                         uv_list.Push(Vector2(1/16.0, 15/16.0))
                         uv_list.Push(Vector2(1/16.0, 1))
                         uv_list.Push(Vector2(0/16.0, 1))
                          # normals point due left. this is also what's generated by RecalculateNormals()
                         normal_list.Push(Vector3(1,0,0))
                         normal_list.Push(Vector3(1,0,0))
                         normal_list.Push(Vector3(1,0,0))
                         normal_list.Push(Vector3(1,0,0))
                         # triangle list in proper order

                         
                         triangle_list.Push(1+i*4)
                         triangle_list.Push(0+i*4)
                         triangle_list.Push(3+i*4)
                         triangle_list.Push(3+i*4)
                         triangle_list.Push(2+i*4)
                         triangle_list.Push(1+i*4)
                         i += 1 # keep track of triangle order in a big list


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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Datael · May 28, 2012 at 05:29 AM

Looks to me like your shader is the problem; it seems to not be writing to the ZBuffer. Try using a different shader and see if that helps. Also, +1 for using a video to demonstrate the problem!

Comment
Add comment · Show 3 · 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 squirlhntr · May 28, 2012 at 03:03 PM 0
Share

Thank you, that was spot on. I didn't even notice that I had the shader set to Diffuse/Transparent. Whoops!

avatar image Datael · May 29, 2012 at 07:23 AM 0
Share

Great. I'm glad that was it. If it wasn't I wouldn't have known where to go next :D

avatar image Fattie · May 29, 2012 at 09:00 AM 0
Share

Today's "psychic answer" great work! :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Determine whether or not model is "inside out" 2 Answers

Using the PaintVertices code from the Procedural Mesh example project, the sphere normals get messed up 0 Answers

Mesh: faces clipped and/or not being rendered? 3 Answers

Trying to create a hard edged procedural torus mesh 2 Answers

Seam on Procedural Mesh 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