{"id":320,"date":"2021-01-14T11:33:23","date_gmt":"2021-01-14T11:33:23","guid":{"rendered":"https:\/\/ben.stevuliak.net\/?p=320"},"modified":"2021-02-14T23:34:03","modified_gmt":"2021-02-14T23:34:03","slug":"3d-specialism-instancing","status":"publish","type":"post","link":"https:\/\/ben.stevuliak.net\/index.php\/2021\/01\/14\/3d-specialism-instancing\/","title":{"rendered":"3D Specialism &#8211; Instancing"},"content":{"rendered":"\n<p>In total, the scene I sent to the render farm consisted of approximately 215000 objects. Most of these were instances of houses, trees, the glass roof, windows and other models. I used SideFX Houdini to lay out the points, and then copied the instances to them.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Glass roof<\/h4>\n\n\n\n<p>The glass roof was the setting stone for the instances underneath, as it set a proportion of how big the blocks of houses were. Naturally, I laid it out first. I created a tube sop, and rotated every second row of it to create a base point cloud for instancing. These instances were packed in the CopyToPoints SOP. <\/p>\n\n\n\n<ul class=\"wp-block-gallery columns-2 wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"598\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing_wireframe-1024x598.png\" alt=\"\" data-id=\"321\" data-link=\"https:\/\/ben.stevuliak.net\/?attachment_id=321\" class=\"wp-image-321\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing_wireframe-1024x598.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing_wireframe-300x175.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing_wireframe-768x448.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing_wireframe.png 1333w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Base points used for instancing<\/figcaption><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"597\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing-1024x597.png\" alt=\"\" data-id=\"322\" data-link=\"https:\/\/ben.stevuliak.net\/?attachment_id=322\" class=\"wp-image-322\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing-1024x597.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing-300x175.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing-768x448.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing.png 1353w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Instanced object<\/figcaption><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"353\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing1-1024x353.png\" alt=\"\" data-id=\"324\" data-link=\"https:\/\/ben.stevuliak.net\/?attachment_id=324\" class=\"wp-image-324\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing1-1024x353.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing1-300x103.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing1-768x265.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/glass_roof_instancing1.png 1381w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Instanced object<\/figcaption><\/figure><\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Houses<\/h4>\n\n\n\n<p>There are 21 variants of the houses in four categories &#8211; small, medium, wide and large. They were imported from a kitbash in Maya. I used VEX to categorize them and to create a variant attribute, used when copying the houses to an appropriately scaled lot. The lots were created using Chain SOP, which deformed a simple grid on a hexagonal curve. The scale of the houses copied was determined by hand using groups, however I imagine this could have easily been set up procedurally.<\/p>\n\n\n\n<ul class=\"wp-block-gallery columns-2 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"888\" height=\"732\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hex.png\" alt=\"\" data-id=\"325\" data-link=\"https:\/\/ben.stevuliak.net\/?attachment_id=325\" class=\"wp-image-325\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hex.png 888w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hex-300x247.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hex-768x633.png 768w\" sizes=\"(max-width: 888px) 100vw, 888px\" \/><figcaption>Block variant<\/figcaption><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"803\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hexnode-1024x803.png\" alt=\"\" data-id=\"326\" data-link=\"https:\/\/ben.stevuliak.net\/?attachment_id=326\" class=\"wp-image-326\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hexnode-1024x803.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hexnode-300x235.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hexnode-768x602.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/hexnode.png 1062w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Block variant node setup<\/figcaption><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"529\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/variantshex-1024x529.png\" alt=\"\" data-id=\"327\" data-link=\"https:\/\/ben.stevuliak.net\/?attachment_id=327\" class=\"wp-image-327\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/variantshex-1024x529.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/variantshex-300x155.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/variantshex-768x397.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/variantshex.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>The result using multiple lots <\/figcaption><\/figure><\/li><\/ul>\n\n\n\n<p>These lots were projected on the ground plane using Ray SOP, and cleaned up of pieces that contained less than four points per primitive.<\/p>\n\n\n\n<p>For randomizing which variant of the house from its respective category goes on its lot, I used this VEX snippet: <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>i@variant = fit(rand(@ptnum *chf(\"Seed\")),0,1,0,6) ;<\/code><\/p><\/blockquote>\n\n\n\n<p>on the point groups I created earlier. This randomized the variant number, which the CopyToPoints SOP took as an input when instancing.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1677\" height=\"763\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/houseinstance.png\" alt=\"\" class=\"wp-image-328\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/houseinstance.png 1677w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/houseinstance-300x136.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/houseinstance-768x349.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/houseinstance-1024x466.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/houseinstance-1568x713.png 1568w\" sizes=\"(max-width: 1677px) 100vw, 1677px\" \/><figcaption>CopyToPoints SOP operation<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/render_test.png\" alt=\"\" class=\"wp-image-331\"\/><figcaption>An early render test of house instancing.<\/figcaption><\/figure>\n\n\n\n<p>After a few iterations I was happy with the result.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Trees<\/h4>\n\n\n\n<p>I used a similar approach when loading the trees and categorized them based on their size. The only difference is that I used the AttributePaint SOP to create a mask for instancing.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1780\" height=\"727\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treemask.png\" alt=\"\" class=\"wp-image-329\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treemask.png 1780w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treemask-300x123.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treemask-768x314.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treemask-1024x418.png 1024w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treemask-1568x640.png 1568w\" sizes=\"(max-width: 1780px) 100vw, 1780px\" \/><figcaption>AttributePaint mask<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1423\" height=\"714\" src=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treescatter.png\" alt=\"\" class=\"wp-image-330\" srcset=\"https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treescatter.png 1423w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treescatter-300x151.png 300w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treescatter-768x385.png 768w, https:\/\/ben.stevuliak.net\/wp-content\/uploads\/2021\/02\/treescatter-1024x514.png 1024w\" sizes=\"(max-width: 1423px) 100vw, 1423px\" \/><figcaption>Instanced trees<\/figcaption><\/figure>\n\n\n\n<p>A VEX snippet I found myself using repeatedly while instancing:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default is-layout-flow wp-block-quote-is-layout-flow\"><p><code>for (int i = 0; i &lt; @numpt; i++) {<br>f@posy = @P.y; vector a = set(0,@posy,0);@N = normalize(a-@P);<br> }<\/code><\/p><\/blockquote>\n\n\n\n<p>This orients every point&#8217;s normal at X,Z origin. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In total, the scene I sent to the render farm consisted of approximately 215000 objects. Most of these were instances of houses, trees, the glass roof, windows and other models. I used SideFX Houdini to lay out the points, and then copied the instances to them. Glass roof The glass roof was the setting stone [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":331,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,10],"tags":[18,14,12,17],"class_list":["post-320","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-3d-cr6001","category-yr3","tag-arnold","tag-cr6001","tag-escape-studios","tag-houdini","entry"],"_links":{"self":[{"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/posts\/320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/comments?post=320"}],"version-history":[{"count":3,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/posts\/320\/revisions\/333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/media\/331"}],"wp:attachment":[{"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/media?parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/categories?post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ben.stevuliak.net\/index.php\/wp-json\/wp\/v2\/tags?post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}