{"id":22,"date":"2010-08-26T09:14:12","date_gmt":"2010-08-26T08:14:12","guid":{"rendered":"http:\/\/www.joesfer.com\/?p=22"},"modified":"2015-05-15T20:20:26","modified_gmt":"2015-05-15T19:20:26","slug":"surface-weathering","status":"publish","type":"post","link":"http:\/\/www.joesfer.com\/?p=22","title":{"rendered":"Surface Weathering"},"content":{"rendered":"<div id=\"attachment_23\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/shaded.jpg\"><img aria-describedby=\"caption-attachment-23\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-23   \" style=\"margin: 10px;\" title=\"weathered object\" src=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/shaded-300x237.jpg\" alt=\"weathered\" width=\"300\" height=\"237\" srcset=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/shaded-300x237.jpg 300w, http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/shaded.jpg 818w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-23\" class=\"wp-caption-text\">resulting textured object combining dirt and rust<\/p><\/div>\n<p>Here is a project I&#8217;ve been working on lately: a<strong> surface weathering simulation<\/strong> prototype.<\/p>\n<p>Surface weathering is usually a type of <a title=\"texture synthesis\" href=\"http:\/\/en.wikipedia.org\/wiki\/Texture_synthesis\" target=\"_blank\">texture synthesis<\/a> which aims to simulate the degradation of an object due to external agents -weather-. The textures are therefore tailor-made for the specific object the simulation is run upon, depending on its topology. Despite the results are seldom good enough on their own (it&#8217;s an automatic process after all), they are a good start for some further hand-tuning.<\/p>\n<p>The simulation method I have implemented is based on the paper called <a href=\"http:\/\/research.microsoft.com\/pubs\/69205\/gamma_ton.pdf\">Visual Simulation of Weathering By \u00ce\u00b3-ton Tracing<\/a> which follows a process consisting on tracing particles carrying <em>stuff <\/em>against the model, and simulate their interaction with the surface. The actual weathering simulation depends on what the particles carry &#8211; <strong>in my case<\/strong> I was interested on simulating dirt and rust over a metallic surface,<strong> but different kinds of degrading processes can be parametrized with this method<\/strong>, depending on the settings.<\/p>\n<p>Conceptually the simulation slightly resembles the <a title=\"photon mapping\" href=\"http:\/\/en.wikipedia.org\/wiki\/Photon_mapping\" target=\"_blank\">photon mapping<\/a> algorithm, but instead of carrying light, we&#8217;re carrying dirt, rust, humidity, and so on&#8230;<\/p>\n<p>The implementation goes as follows:<\/p>\n<ul>\n<li>First we sample the polygonal mesh according to a density, producing a set of points or <em>surfels <\/em>and storing them in a kd-tree. These surfels will hold the current material properties at each point. For the sampling I&#8217;ve opted for shooting rays from each one of the faces of the object&#8217;s bounding box, pointing inwards, evenly distributing their positions via a <a title=\"low-discrepancy sequences\" href=\"http:\/\/www.mathdirect.com\/products\/qrn\/resources\/Links\/QRDemonstration_lnk_3.html\" target=\"_blank\">Halton sequence<\/a>. This is a simple method which works well for the kind of models we&#8217;re using here, but it would have problems with overlapping surfaces. <a title=\"qsplat\" href=\"http:\/\/graphics.stanford.edu\/papers\/qsplat\/qsplat_paper.pdf\">More sophisticated<\/a> sampling methods could be used if need be.\n<p><div id=\"attachment_24\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tons.jpg\"><img aria-describedby=\"caption-attachment-24\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-24  \" style=\"margin-left: 10px; margin-right: 10px;\" title=\"tons\" src=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tons-300x165.jpg\" alt=\"\" width=\"300\" height=\"165\" srcset=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tons-300x165.jpg 300w, http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tons.jpg 432w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-24\" class=\"wp-caption-text\">tons tracing<\/p><\/div><\/li>\n<\/ul>\n<ul>\n<li>Next we start tracing gamma-tons from the hemisphere surrounding the object towards the center of it. Each particle carries an initial set of values describing the dirt and humidity. We use raytracing to determine the hit point of the particle against the polygonal surface, this process is carried out in parallel.<\/li>\n<\/ul>\n<ul>\n<li>For each particle hit, we stochastically decide whether to bounce the particle off, make it flow over the surface, or settle it down. These movements may lead to subsequent traces, which are stacked into the task list. When a particle interacts with the surface, there is a <strong>transfer<\/strong> of substances between the nearest surfels and the particle; for instance, the particle may deposit or remove dirt, and will humidify the surface along its path, which will eventually lead to rust.\n<p><div id=\"attachment_25\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tonstransport.jpg\"><img aria-describedby=\"caption-attachment-25\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-25  \" style=\"margin-left: 10px; margin-right: 10px;\" title=\"tonstransport\" src=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tonstransport-300x68.jpg\" alt=\"\" width=\"300\" height=\"68\" srcset=\"http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tonstransport-300x68.jpg 300w, http:\/\/www.joesfer.com\/wp-content\/uploads\/2010\/08\/tonstransport.jpg 690w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-25\" class=\"wp-caption-text\">tons transport<\/p><\/div><\/li>\n<\/ul>\n<ul>\n<li>After all the particle tracing has finished, we plot the resulting contents of the surfels into several textures, creating <strong>masks <\/strong>which are fed into a HLSL shader rendering the aged metal. Note that this stage relies on having good texture coordinates for the object, which can be sometimes tricky. For the model displayed here I used the <a title=\"XRay unwrap\" href=\"http:\/\/www.raylightgames.com\/xrayunwrap\/index.html\" target=\"_blank\">XRay unwrap<\/a> plugin for 3dsmax, which works pretty nicely.<\/li>\n<\/ul>\n<ul>\n<li>The beauty of this method is that we can perform these steps <em>iterativelly<\/em>, accumulating the results on each pass. This allows us to generate a <strong>sequence <\/strong>of steps depicting the different stages the simulation goes by. I have attached a video below showing 10 steps of a simulation.<\/li>\n<\/ul>\n<p>You can find the application <a href=\"wp-content\/uploads\/programming\/C\/Weathering.rar\">here<\/a> (requires Windows Vista or newer and DirectX. Does not include the <a href=\"http:\/\/www.deespona.com\/3denciclopedia\/models\/satyr.html\" target=\"_blank\">Satyr <\/a>model.)\u00c2\u00a0 you can also see how it works in the following videos:<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/player.vimeo.com\/video\/14436756\" width=\"640\" height=\"512\" frameborder=\"0\" title=\"weathering simulation\" webkitallowfullscreen mozallowfullscreen allowfullscreen><\/iframe><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/player.vimeo.com\/video\/14436664\" width=\"640\" height=\"512\" frameborder=\"0\" title=\"Simulation steps\" webkitallowfullscreen mozallowfullscreen allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A surface weathering simulation prototype. Surface weathering is a type of texture synthesis which aims to simulate the degradation of an object due to external agents. <a class=\"more-link\" href=\"http:\/\/www.joesfer.com\/?p=22\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":23,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[54,14,19,18],"_links":{"self":[{"href":"http:\/\/www.joesfer.com\/index.php?rest_route=\/wp\/v2\/posts\/22"}],"collection":[{"href":"http:\/\/www.joesfer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.joesfer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.joesfer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.joesfer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":0,"href":"http:\/\/www.joesfer.com\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.joesfer.com\/index.php?rest_route=\/wp\/v2\/media\/23"}],"wp:attachment":[{"href":"http:\/\/www.joesfer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.joesfer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.joesfer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}