tag:blogger.com,1999:blog-7285736713606919795.post536482806792663179..comments2024-02-06T06:38:09.910-07:00Comments on The Legend of GameDev: Bones and Automatic Vertex WeightsLegend of Gamedevhttp://www.blogger.com/profile/06278402110409103690noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-7285736713606919795.post-53573625562818847262013-07-12T09:22:39.977-07:002013-07-12T09:22:39.977-07:00Awesome, looks good! Glad I could help!Awesome, looks good! Glad I could help!Legend of Gamedevhttps://www.blogger.com/profile/06278402110409103690noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-43232665535487925412013-07-11T04:12:53.136-07:002013-07-11T04:12:53.136-07:00Thanks for the help David! I was able to get it to...Thanks for the help David! I was able to get it to work. Here is an example.<br /><br /><a href="http://forum.unity3d.com/attachment.php?attachmentid=59784&d=1373511177" rel="nofollow">Upper arm heat map</a><br /><br />Hopefully soon I will write up a full blog post, where you will be credited :)Anonymoushttps://www.blogger.com/profile/13993678204012369823noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-59863226507687582502013-07-11T04:11:36.710-07:002013-07-11T04:11:36.710-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/13993678204012369823noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-52449108776359051112013-07-10T10:42:08.783-07:002013-07-10T10:42:08.783-07:00What I did was draw the bone as a line of 0 in the...What I did was draw the bone as a line of 0 in the image (zero distance to the bone), set pixels adjacent to 0 to 1, pixels adjacent to 1 to 2, etc until the whole image had an approximate distance to the bone (this is done with something like Dijkstra's algorithm, placing the 1 pixels into a queue, then setting all empty adjacent pixels to 2 and placing them in the queue, etc). Then, just looking up the pixel where the vertex was would tell the distance from the vertex to the bone (and since there are a LOT more vertices than bones, this lookup being fast is important). This is manhattan distance to the bones, since I work with adjacent pixels and not diagonals, but you could perform a laplace operator on the image to get a euclidean distance to the bones if you wanted (not worth it in my opinion).<br /><br />The reason I use an image and not work directly on the vertices is two reasons. First, working on vertices requires more computation per vertex (not just a lookup in the image once the distance field is computed) - which for high vertex meshes may end up slower. Second, working directly on the vertices is also very approximate (depending how dense the mesh is), as sometimes the shortest path doesn't go from vertex to vertex to reach the bone.Legend of Gamedevhttps://www.blogger.com/profile/06278402110409103690noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-86682959364551962572013-07-09T12:42:33.283-07:002013-07-09T12:42:33.283-07:00Thanks David! That was helpful. Ok just a few more...Thanks David! That was helpful. Ok just a few more questions I promise.<br /><br />Here you say:<br /><br />"take a discretized version of the model (in 3D, they need to use a voxel-grid, but in 2D, we can simply use our alpha-thresholded image)"<br /><br />I'm having trouble understanding what the underlying purpose of this is, as opposed to running the algorithm on the raw verts themselves? Does it make it simpler/faster if everything is laid out on a grid and the distance between everything is 1?<br /><br />I have a 1st version of Dijkstra's algorithm working. Many of the examples I found use it for path finding, with a source point and target point. Since we aren't trying to find a specific path, would it be safe to say we are trying to find the shortest path possible path from the bone and every single voxel/pixel? <br /><br />Thanks!<br />Anonymoushttps://www.blogger.com/profile/13993678204012369823noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-7343671205753749232013-07-07T19:44:48.256-07:002013-07-07T19:44:48.256-07:00I explain how I generate the mesh from the images ...I explain how I generate the mesh from the images in this post: http://david.fancyfishgames.com/2012/07/introduction-to-vide.html . Since I use an image as a base, I already have the pixels defined, but you could rasterize your mesh (at lower resolutions to save computation time - the lower the resolution, the more approximate the distance) and compute the distance on that. You could also attempt a different distance metric, but you really need geodesic distance and not euclidean or else you'll get bone bleeding (there are other algorithms to approximate geodesic distance, but none of them are cheap/easy). Running this on mobile will be slow (5-15 seconds per mesh), if you're generating a lot of characters you wont be able to do this real time. If a lot of the characters have the same general shape, you could compute the bones/weights once, and then use an alpha texture to change the appearance of different characters (reusing the bones).<br /><br />Hope that helped! Let me know if you have more questions.Legend of Gamedevhttps://www.blogger.com/profile/06278402110409103690noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-8022445464420046072013-07-06T11:27:12.234-07:002013-07-06T11:27:12.234-07:00One question I had, I'm working on a mesh that...One question I had, I'm working on a mesh that is procedurally generated. Looks like this http://forum.unity3d.com/threads/185377-Procedural-mesh-skinning?p=1290503#post1290503<br /><br />In your post you refer to pixels. So the algorithm runs on the pixels and calculates the distance that way, then the vertices look up the distance by matching their location to a pixel using the pixel grid? . This post never shows the underlying mesh so I was just curious.<br /><br />I ask this because I'm working with Unity on mobile and doing anything with pixels is really slow so I am trying to avoid that.<br /><br />Thanks!Anonymoushttps://www.blogger.com/profile/13993678204012369823noreply@blogger.comtag:blogger.com,1999:blog-7285736713606919795.post-32561638743222261672013-07-06T09:47:01.335-07:002013-07-06T09:47:01.335-07:00Just wanted to say this post was extremely informa...Just wanted to say this post was extremely informative and helpful. I'm working on something similar so the technical talk really helped!Anonymoushttps://www.blogger.com/profile/13993678204012369823noreply@blogger.com