{"id":2209,"date":"2025-01-05T14:25:39","date_gmt":"2025-01-05T05:25:39","guid":{"rendered":"https:\/\/remoooo.com\/?p=2209"},"modified":"2025-01-05T18:37:20","modified_gmt":"2025-01-05T09:37:20","slug":"hair-rendering-with-mitsuba-3-english","status":"publish","type":"post","link":"https:\/\/remoooo.com\/en\/hair-rendering-with-mitsuba-3-english\/","title":{"rendered":"Hair Rendering with Mitsuba 3 (English) Unfinished\u2026"},"content":{"rendered":"<p>Mitsuba3 provides SOTA for pbr. This article focuses on using Mitsuba&#039;s <code>principled_hair<\/code> BSDF and custom adjustments for high-fidelity hair rendering.<\/p>\n\n\n\n<p>Firstly, defining the scene and hair BSDF. <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-blur-enabled cbp-highlight-hover\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * 1rem);--cbp-line-highlight-color:rgba(234, 191, 191, 0.2);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import mitsuba as mimi.set_variant('cuda_rgb')# Define the hair scene with a principled hair BSDFscene_dict = {    &quot;type&quot;: &quot;scene&quot;,    &quot;integrator&quot;: {&quot;type&quot;: &quot;volpath&quot;},    &quot;sensor&quot;: {        &quot;type&quot;: &quot;perspective&quot;,        &quot;film&quot;: {&quot;type&quot;: &quot;hdrfilm&quot;, &quot;width&quot;: 1024, &quot;height&quot;: 768}    },    &quot;hair_object&quot;: {        &quot;type&quot;: &quot;ply&quot;,        &quot;filename&quot;: &quot;..\/scenes\/hair_model.ply&quot;,        &quot;bsdf&quot;: {            &quot;type&quot;: &quot;principled_hair&quot;,            &quot;melanin_concentration&quot;: 0.6,            &quot;sigma_a&quot;: [0.1, 0.05, 0.02],            &quot;roughness&quot;: 0.3,            &quot;azimuthal_roughness&quot;: 0.2        }    },    &quot;light&quot;: {        &quot;type&quot;: &quot;point&quot;,        &quot;intensity&quot;: {&quot;type&quot;: &quot;spectrum&quot;, &quot;value&quot;: 150.0},        &quot;position&quot;: [2.0, 2.0, 2.0]    }}# Load and render the scenescene = mi.load_dict(scene_dict)image = mi.render(scene, spp=512)# Display the rendered imageimport matplotlib.pyplot as pltplt.axis('off')plt.imshow(image ** (1.0 \/ 2.2))plt.show()\" style=\"color:#D4D4D4;display:none\" aria-label=\"copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C586C0\">import<\/span><span style=\"color: #D4D4D4\"> mitsuba <\/span><span style=\"color: #C586C0\">as<\/span><span style=\"color: #D4D4D4\"> mi<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">mi.set_variant(<\/span><span style=\"color: #CE9178\">&#039;cuda_rgb&#039;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #6A9955\"># Define the hair scene with a principled hair BSDF<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">scene_dict = {<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;scene&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #CE9178\">&quot;integrator&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;volpath&quot;<\/span><span style=\"color: #D4D4D4\">},<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #CE9178\">&quot;sensor&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;perspective&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;film&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;hdrfilm&quot;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;width&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #B5CEA8\">1024<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;height&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #B5CEA8\">768<\/span><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    },<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #CE9178\">&quot;hair_object&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;ply&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;filename&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;..\/scenes\/hair_model.ply&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;bsdf&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;principled_hair&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #CE9178\">&quot;melanin_concentration&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #B5CEA8\">0.6<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #CE9178\">&quot;sigma_a&quot;<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">0.1<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">0.05<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">0.02<\/span><span style=\"color: #D4D4D4\">],<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #CE9178\">&quot;roughness&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #B5CEA8\">0.3<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #CE9178\">&quot;azimuthal_roughness&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #B5CEA8\">0.2<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        }<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    },<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #CE9178\">&quot;light&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;point&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;intensity&quot;<\/span><span style=\"color: #D4D4D4\">: {<\/span><span style=\"color: #CE9178\">&quot;type&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #CE9178\">&quot;spectrum&quot;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;value&quot;<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #B5CEA8\">150.0<\/span><span style=\"color: #D4D4D4\">},<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #CE9178\">&quot;position&quot;<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">2.0<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">2.0<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">2.0<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line cbp-line-highlight cbp-no-blur\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\"># Load and render the scene<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">scene = mi.load_dict(scene_dict)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">image = mi.render(scene, <\/span><span style=\"color: #9CDCFE\">spp<\/span><span style=\"color: #D4D4D4\">=<\/span><span style=\"color: #B5CEA8\">512<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\"># Display the rendered image<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">import<\/span><span style=\"color: #D4D4D4\"> matplotlib.pyplot <\/span><span style=\"color: #C586C0\">as<\/span><span style=\"color: #D4D4D4\"> plt<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">plt.axis(<\/span><span style=\"color: #CE9178\">&#039;off&#039;<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">plt.imshow(image ** (<\/span><span style=\"color: #B5CEA8\">1.0<\/span><span style=\"color: #D4D4D4\"> \/ <\/span><span style=\"color: #B5CEA8\">2.2<\/span><span style=\"color: #D4D4D4\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">plt.show()<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">Python<\/span><\/div>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Mitsuba3 provides SOTA for pbr. This article focuses on [&hellip;]<\/p>","protected":false},"author":1,"featured_media":2210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[],"class_list":["post-2209","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/posts\/2209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/comments?post=2209"}],"version-history":[{"count":3,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/posts\/2209\/revisions"}],"predecessor-version":[{"id":2238,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/posts\/2209\/revisions\/2238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/media\/2210"}],"wp:attachment":[{"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/media?parent=2209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/categories?post=2209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/remoooo.com\/en\/wp-json\/wp\/v2\/tags?post=2209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}