Quantcast
Channel: Latest Questions by Monko
Viewing all articles
Browse latest Browse all 34

Apply texture to a mesh on all 3 sides

$
0
0
I am working on a marching cubes terrain, and I need to apply a texture to it. The problem is, I don't know how to apply the texture so the mesh looks "normal" from any angle. Right now, Ive been doing this: uvs = new Vector2[mesh.vertices.length]; for (var i=0; i < uvs.Length; i+=1) { uvs[i] = Vector2(mesh.vertices[i].x,mesh.vertices[i].z); } mesh.uv = uvs; This code works, but the mesh doesn't draw right when a part of the mesh is completely straight up. That is because my code only applys the texture onto the x and z plane. I've been looking online for solutions, and couldn't find any source code. But I have learned that there is a way to apply texture on all 3 of the xyz planes, and simply blend the result together. Unfortunately, I have no idea how to do this. If anyone out there knows how to apply a texture onto a mesh, please let me know. ( I know it will involve UVs and normals) After doing further research, ive learned that what im trying to do is called triplanar texturing.

Viewing all articles
Browse latest Browse all 34

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>