- Home /
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
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!
Thank you, that was spot on. I didn't even notice that I had the shader set to Diffuse/Transparent. Whoops!
Great. I'm glad that was it. If it wasn't I wouldn't have known where to go next :D
Your answer
Follow this Question
Related Questions
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
Meshes flipping on procedural generation 0 Answers