<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[_nkpd's Blog]]></title><description><![CDATA[I'm now a graduated Visual Effects student who is interested in coding, designing, animation, and many other things—especially technical stuff.]]></description><link>https://blog.nkpd.moe</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 11:20:41 GMT</lastBuildDate><atom:link href="https://blog.nkpd.moe/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[มาอัดคลิปโมเดลให้เป็นพื้นหลังใสกัน !]]></title><description><![CDATA[เอ๊ะ แล้วมันต่างกับการใช้ Green/Blue Screen ยังไงอะ ?
ที่ต่างกันหลักๆ คือไฟล์ที่ได้ออกมาจะไม่มีพื้นหลังเลย (มี Alpha Channel) ไม่จำเป็นต้องนำไป Key ออกก่อน สามารถนำไปทำงานต่อได้เลย ทำให้ไม่ต้องกังวลว่า ตรงนี้จะหายไหมนะ หรือ สีจะเพี้ยนไหมนะ แต่ว่าไฟล์...]]></description><link>https://blog.nkpd.moe/obs-transparent-recording</link><guid isPermaLink="true">https://blog.nkpd.moe/obs-transparent-recording</guid><category><![CDATA[obs]]></category><category><![CDATA[VTuber ]]></category><category><![CDATA[recording]]></category><category><![CDATA[VTubeStudio]]></category><dc:creator><![CDATA[Minami Kanako]]></dc:creator><pubDate>Wed, 27 Sep 2023 09:07:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1695805818255/c3895b07-9bfa-45c7-83de-5868f373fe5e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-greenblue-screen">เอ๊ะ แล้วมันต่างกับการใช้ Green/Blue Screen ยังไงอะ ?</h1>
<p>ที่ต่างกันหลักๆ คือไฟล์ที่ได้ออกมาจะไม่มีพื้นหลังเลย (มี Alpha Channel) ไม่จำเป็นต้องนำไป Key ออกก่อน สามารถนำไปทำงานต่อได้เลย ทำให้ไม่ต้องกังวลว่า ตรงนี้จะหายไหมนะ หรือ สีจะเพี้ยนไหมนะ แต่ว่าไฟล์จะมีขนาดใหญ่กว่าพอสมควรเลย แต่ก็สามารถมั่นใจได้ว่าจะได้คลิปที่มีคุณภาพสูงที่สุดแน่นอน</p>
<p>ถ้าไม่ได้ซีเรียสเรื่องสีเพี้ยนหรืออะไรพวกนี้สามารถปล่อยผ่านได้เลยครับ</p>
<hr />
<h1 id="heading-4lmb4lil4lmj4lin4liv4lmj4lit4lih4lmd4lik4lmj4lit4liw4lme4lij4lit4lix4liu4lil4liwid8">แล้วต้องใช้อะไรอัดละ ?</h1>
<p>ในโพสต์นี้จะใช้ OBS Studio ในการอัดฮะ สำหรับใครที่ใช้ Streamlab OBS ขอแสดงความเสียใจด้วยนะครับ ไม่สามารถทำได้ แต่ถ้าจะโหลด OBS Studio มาเพื่อใช้อัดคลิปโดยเฉพาะก็โอเคนะ !</p>
<hr />
<h1 id="heading-tldr">TLDR;</h1>
<p>ถ้าใครตั้งค่าเป็นอยู่แล้วตั้งตามนี้ได้เลยนะครับ แต่ถ้าทำไม่เป็นสามารถเลื่อนไปอ่านหัวข้อถัดไปได้เลย</p>
<ul>
<li><p>Color Format: BGRA (8-bit)</p>
</li>
<li><p>Recording Type: Custom Output (FFmpeg)</p>
</li>
<li><p>Container Format: mov</p>
</li>
<li><p>Video Encoder: png</p>
</li>
</ul>
<hr />
<h1 id="heading-4lih4liy4lma4lij4li04lmi4lih4lib4lix4lizice">มาเริ่มกัน !</h1>
<h2 id="heading-vtube-studio-obs">เอาโมเดลจาก VTube Studio มาเข้า OBS</h2>
<p>ถ้ามีโมเดลที่เคยตั้งค่าไว้แล้วก็สามารถนำมาใช้ได้เลยนะ แต่ไม่แนะนำให้ใช้การ Windows Capture แล้วใส่ Chroma Key น้า โดยในส่วนนี้จะแนะนำทั้งหมด 2 วิธีคือการใช้ ใช้ Spout 2 และ Game Capture เข้ามาเป็นพื้นหลังใสครับ</p>
<h3 id="heading-spout-2-plugin">Spout 2 (แนะนำมากที่สุด แต่ต้องลง Plugin)</h3>
<p>วิธีนี้เป็นวิธีที่แนะนำมากที่สุด ได้คุณภาพดีมากที่สุด ไม่มีหน้าโปรแกรมโผล่ขึ้นมาแน่นอน แล้วก็ใช้ทรัพยาการเครื่องน้อยมากฮะ</p>
<p>โดยขั้นแรกให้เข้าไปที่ตั้งค่าของ VTube Studio ก่อน แล้วมาหมวดที่เป็นรูปกล้อง</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804294081/00fefd6d-ca4d-4e9c-a1fa-057c4f51526e.png" alt class="image--center mx-auto" /></p>
<p>เสร็จแล้วเลื่อนลงไปเรื่อยๆ จนถึงหมวดที่ชื่อ Spout 2 Config เสรจแล้วกด Install Spout 2 ได้เลย</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804377135/72e658ab-3ddf-494b-8f9d-2aafe2805c9e.png" alt class="image--center mx-auto" /></p>
<p>กดแล้วจะเจอหน้าต่างนี้เด้งขึ้นมา ให้กด More Info ได้เลย</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804448239/f45e4806-7bde-4977-9201-9b8cc86779f8.png" alt class="image--center mx-auto" /></p>
<p>เสร็จแล้วจะมาโผล่ที่หน้านี้ ให้กดตรง "Releases Page"</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804557612/681e1d6e-06ff-486c-b29e-319580d16896.png" alt class="image--center mx-auto" /></p>
<p>เสร็จแล้วให้กด Download ไฟล์ที่เป็น .exe มาติดตั้งได้เลยฮะ ถ้าเปิด OBS อยู่ปิดก่อนด้วยนะ !</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804624739/2cd4557d-99eb-4887-8129-eb80bc65ffa1.png" alt class="image--center mx-auto" /></p>
<p>หลังจากติดตั้งเรียบร้อยแล้วให้กลับมาที่ VTube Studio แล้วติ๊กเปิด "Activate Spout 2" ได้เลย</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804729314/93d2324c-13ad-45f5-a792-649ecdcfe4ce.png" alt class="image--center mx-auto" /></p>
<p>ต่อมาให้เปิด OBS ขึ้นมาได้เลยฮะ สำหรับตรง Sources ให้เพิ่ม Spout 2 Capture เข้ามา</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804823098/dcc75c45-3993-4620-b798-d953fdcab972.png" alt class="image--center mx-auto" /></p>
<p>เสร็จแล้วตรง SpoutSenders ให้เลือกเป็น VTubeStudioSpout และตรง Composite mode ให้เลือกเป็น Default เท่านี้เป็นอันเรียบร้อยครับ</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695806206370/b7e8d1d5-8ac3-43b1-8e53-9821de2b4478.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-game-capture">Game Capture</h3>
<p>ถ้าไม่อยากลงอะไรในเครื่องเพิ่มสามารถใช้ Game Capture เปลี่ยน Mode เป็น Capture specific window เพิ่ม VTube Studio เข้ามา แล้วติ๊กถูกตรง Allow Transparency ครับ</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695806258987/cd66056e-9490-4343-9a36-0a8f21c16123.png" alt class="image--center mx-auto" /></p>
<p>แค่นี้ก็จะได้โมเดลพื้นหลังใสเข้ามาแบบไม่ต้อง Key แล้ว แต่ระวังมีหน้าโปรแกรมโผล่เข้ามาด้วยนะ</p>
<h2 id="heading-profile-obs">สร้าง Profile OBS (ไม่จำเป็น แต่ทำก็สะดวกดีจ้า)</h2>
<p>ส่วนตัวแนะนำให้สร้าง Profile แยกเอาไว้สำหรับการอัด และ Live นะครับ จะได้ไม่ต้องเปลี่ยน Settings เองทุกครั้ง สลับ Profile แล้วใช้ได้เลย</p>
<p>โดยขั้นแรกให้ไปที่เมนู Profile ที่ด้านบน แล้วกด New</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695803724865/b68a6f95-c366-48a8-a4b0-90cdde840486.png" alt class="image--center mx-auto" /></p>
<p>เสร็จแล้วตั้งชื่อที่ต้องการ แล้วกด OK</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695803860582/56761487-01fa-4740-a0db-9df431d594f0.png" alt class="image--center mx-auto" /></p>
<p>จากนั้นให้เลือก Optimize just for recording เสร็จแล้วกด Next ไปเรื่อยๆ จนจบได้เลย</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695803902685/285352f7-2531-493a-a758-833c3724913c.png" alt class="image--center mx-auto" /></p>
<p>เพียงเท่านี้เราก็จะได้ Profile ใหม่มาไว้สลับแล้ว เย่ !</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695803959100/1e98bba2-02e0-4a22-8880-acc878bb0530.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-obs">ตั้งค่า OBS เพื่อให้อัดวีดีโอออกมาเป็นพื้นหลังใส</h2>
<p>ขั้นแรกให้เข้าไปที่ Settings ของโปรแกรม แล้วก็ไปตรงหมวด Advance นะครับ</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695803393903/4b8a4f6e-76ec-4d68-8132-11e6ba4ff53b.png" alt class="image--center mx-auto" /></p>
<p>ตรงหมวด Video ให้เปลี่ยน Color Format เป็น BGRA (8-bit) ตามภาพได้เลยฮะ และถ้าอยากได้สีที่ดูใกล้เคียงกับที่เห็นในโปรแกรมมากที่สุดให้เปลี่ยน Color Space เป็น sRGB และ Color Range เป็น Full ตามภาพได้เลยฮะ</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695803422430/6a166db5-751a-4e0c-b98b-0747c5b7e5b5.png" alt class="image--center mx-auto" /></p>
<p>อัดเสร็จแล้วก่อน Live อย่าลืมปรับกลับไปเป็น NV12 นะ ! (ถ้าสร้าง Profile ให้ก็อย่าลืมสลับกลับละ)</p>
<p>ต่อมาให้มาที่หมวด Output</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804160441/3377f1a9-58d6-4f80-9dba-375101f8faf9.png" alt class="image--center mx-auto" /></p>
<p>เปลี่ยน Output Mode เป็น Advance ครับ เสร็จแล้วมาที่แท็บ Recording แล้วเปลี่ยน Type เป็น Custom Output (FFmpeg)</p>
<p><strong>ถ้าเคยตั้งที่บันทึกไฟล์ไว้แล้วอย่าลืมตั้งใหม่ด้วยนะ !</strong></p>
<p>ต่อไปให้เปลี่ยน Container Format เป็น mov ต่อมาให้ตั้ง Video Encoder เป็น png เสร็จแล้วกด OK เป็นที่เรียบร้อย !</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695804116621/16faf762-86af-43bc-8a5d-0859b44f071c.png" alt class="image--center mx-auto" /></p>
<hr />
<h1 id="heading-4lii4lia4lmb4lil4lmj4lin4lii4lmj4liy">จบแล้วจ้า</h1>
<p>ถ้ามีข้อสงสัย ติดปัญหาตรงไหนสามารถ Comment ทิ้งไว้ หรือ ทักเข้ามาสอบถามที่ <a target="_blank" href="https://twitter.com/_nkpd">https://twitter.com/_nkpd</a> ได้เลยนะครับ พร้อมช่วยเหลือทุกอย่างเท่าที่จะทำได้ครับ</p>
<hr />
<p>Model ที่ใช้ <a target="_blank" href="https://twitter.com/sakurai_mon/status/1621323352072945666">https://twitter.com/sakurai_mon/status/1621323352072945666</a></p>
]]></content:encoded></item><item><title><![CDATA[Workaround for using nuke_i license with Nuke Bridge in Katana on Windows]]></title><description><![CDATA[First of all, thanks to Foundry staff from Katana Forums for helping and providing a workaround!
As we can see from Katana User Guide about Nuke Bridge, we need to tell Katana to use nuke_i (Nuke, NukeX or Nuke Studio) license instead of nuke_r (Head...]]></description><link>https://blog.nkpd.moe/ktn-nukei-nukebridge-win-workaround</link><guid isPermaLink="true">https://blog.nkpd.moe/ktn-nukei-nukebridge-win-workaround</guid><category><![CDATA[katana]]></category><category><![CDATA[nuke-bridge]]></category><category><![CDATA[nuke]]></category><dc:creator><![CDATA[Minami Kanako]]></dc:creator><pubDate>Fri, 23 Dec 2022 19:54:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671813139877/029690b0-8cde-402d-878a-3523984b4171.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>First of all, thanks to Foundry staff from <a target="_blank" href="https://community.foundry.com/discuss/topic/160631/having-trouble-configuring-nuke-bridge-with-a-nuke-i-license">Katana Forums</a> for helping and providing a workaround!</p>
<p>As we can see from <a target="_blank" href="https://learn.foundry.com/katana/Content/ug/rendering_scene/katana-nuke-interop.html">Katana User Guide about Nuke Bridge</a>, we need to tell Katana to use nuke_i (Nuke, NukeX or Nuke Studio) license instead of nuke_r (Headless version of Nuke), if we don't have one or want to perform interactive comps.</p>
<hr />
<h1 id="heading-the-problem">The Problem</h1>
<p>According to the User Guide, you need to create an additional custom launcher script for nuke_i license, then set it in KATANA_NUKE_EXECUTABLE.</p>
<p>On Windows, only <strong>binary executables <em>(.exe)</em></strong> can be used as launchers at the moment. Otherwise, you'll get a message informed that it couldn't determine Nuke version from the launch script.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671814598720/007df40e-2b08-45e8-92de-d1af0dea5dfb.png" alt class="image--center mx-auto" /></p>
<hr />
<h1 id="heading-workaround">Workaround</h1>
<p>For a workaround, we need to create a <strong><em>binary executable (.exe)</em></strong> that acts as a launcher script. This will get a bit technical, but don't worry you can follow along!</p>
<hr />
<h2 id="heading-tldr">TLDR;</h2>
<ol>
<li><p>Download a <strong>C++ compiler</strong> (MSVC, MinGW, Clang, ...).</p>
</li>
<li><p>Create a new .cpp file and modify this code to your Nuke executable location.</p>
<pre><code class="lang-cpp"> <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;cstdlib&gt;</span></span>
 <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string&gt;</span></span>
 <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;vector&gt;</span></span>

 <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span>** argv)</span>
 </span>{
     <span class="hljs-built_in">std</span>::<span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>&gt; arguments;
     <span class="hljs-comment">//Specify the location of Nuke executable.</span>
     arguments.push_back(<span class="hljs-string">"C:\\Path\\to\\Nuke.exe"</span>);
     <span class="hljs-comment">//Specify the edition of Nuke to use.</span>
     arguments.push_back(<span class="hljs-string">"--nukex"</span>);
     <span class="hljs-comment">//Specify the type of license to use.</span>
     arguments.push_back(<span class="hljs-string">"-i"</span>);
     <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>; i &lt; argc; ++i)
         arguments.push_back(argv[i]);

     <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> command;
     <span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>&amp; argument : arguments)
     {
         <span class="hljs-keyword">if</span> (command.size())
             command += <span class="hljs-string">" "</span>;
         command += <span class="hljs-string">"\""</span> + argument + <span class="hljs-string">"\""</span>;
     }
     command = <span class="hljs-string">"\""</span> + command + <span class="hljs-string">"\""</span>;

     <span class="hljs-keyword">return</span> <span class="hljs-built_in">std</span>::system(command.c_str());
 }
</code></pre>
</li>
<li><p>Compile the code to .exe with your compiler of choice.</p>
</li>
<li><p>Point KATANA_NUKE_EXECUTABLE in Katana launcher script to newly created .exe.</p>
</li>
<li><p>Launch Katana with the launcher script.</p>
</li>
</ol>
<hr />
<h2 id="heading-step-by-step-guide">Step-by-Step Guide</h2>
<h3 id="heading-1-getting-a-compiler">1. Getting a compiler</h3>
<p>To compile or create an executable file from the code you'll need <strong>a compiler</strong> for C++, in this guide I'll use <strong>MinGW</strong>. You can install MinGW via MSYS2, which you can download from <a target="_blank" href="https://www.msys2.org/">here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671816012134/4fe17394-49f1-46b8-bb03-b53cc7791213.gif" alt class="image--center mx-auto" /></p>
<p>After the download is finished, <strong>open the file</strong> and simply go through the installation process.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671816205887/c12c8bc4-cec1-4ad9-adcb-9147dba61703.gif" alt class="image--center mx-auto" /></p>
<p>Next, click on <strong>Finish</strong> to run MSYS2.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671816349755/9ca4956c-f545-4571-ba34-fb10f03a58f0.png" alt class="image--center mx-auto" /></p>
<p>Now, you'll be greeted by the black window. To install MinGW copy the command from the box below and paste it into that window by pressing <strong>Shift+Ins</strong> or right-clicking and selecting <strong>Paste</strong>, then press <strong>Enter</strong> to execute the command.</p>
<pre><code class="lang-bash">pacman -S --needed mingw-w64-x86_64-gcc
</code></pre>
<p>Then, type <strong>Y</strong> and press <strong>Enter</strong> to start installing all the necessary tools. This will take about 400MB of your disk space.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671824385586/72ecc9d9-440a-475a-aa4d-66690e53b41a.png" alt class="image--center mx-auto" /></p>
<p>After it finished, you'll see a screen that looks like this. Feel free to close it as we don't need it anymore.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671824435996/8a79ab68-f4f1-4762-a7d5-f7d2e87401c5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-adding-mingw-to-path-environment-variables">2. Adding MinGW to Path Environment Variables</h3>
<p>After installing MinGW, we'll need to add it to <strong>Path</strong> to be able to use it properly.</p>
<p>First, open the start menu and simply type <strong>'env'</strong> to search for <strong>Edit the system environment variables</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671817782364/bed62aa3-c0f9-4a73-a751-51d48c61fc56.gif" alt class="image--center mx-auto" /></p>
<p>Next, click on <strong>"Environment Variables..."</strong> button at the bottom of the window.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671826731010/8ccabe13-72ea-4092-8f40-3e204e117cf8.png" alt class="image--center mx-auto" /></p>
<p>Double-click on <strong>Path</strong> to edit, then click on <strong>"New"</strong> button on the right and, type <code>C:\msys64\mingw64\bin</code> to add MinGW to Path. Then, click OK on every window to save.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671819146555/1544f5e9-2eed-445a-8d29-0fa64ba80014.gif" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-create-a-new-c-file">3. Create a new C++ file</h3>
<p>First, open Notepad or any other IDE of your choice, copy the code below and paste it in.</p>
<pre><code class="lang-cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;cstdlib&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;vector&gt;</span></span>

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span>** argv)</span>
</span>{
    <span class="hljs-built_in">std</span>::<span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>&gt; arguments;
    <span class="hljs-comment">//Specify the location of Nuke executable.</span>
    arguments.push_back(<span class="hljs-string">"C:\\Path\\to\\Nuke.exe"</span>);
    <span class="hljs-comment">//Specify the type of license to use.</span>
    arguments.push_back(<span class="hljs-string">"-i"</span>);
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>; i &lt; argc; ++i)
        arguments.push_back(argv[i]);

    <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> command;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>&amp; argument : arguments)
    {
        <span class="hljs-keyword">if</span> (command.size())
            command += <span class="hljs-string">" "</span>;
        command += <span class="hljs-string">"\""</span> + argument + <span class="hljs-string">"\""</span>;
    }
    command = <span class="hljs-string">"\""</span> + command + <span class="hljs-string">"\""</span>;

    <span class="hljs-keyword">return</span> <span class="hljs-built_in">std</span>::system(command.c_str());
}
</code></pre>
<p>Then, <strong>modify the code</strong> where it said <code>("C:\\Path\\to\\Nuke.exe");</code> to the location of your Nuke executable. Don't forget to change <code>\</code> to <code>\\</code> !</p>
<p>If you want to use <strong>NukeX</strong>, you can add a new line and type <code>arguments.push_back("--nukex");</code>, for <strong>Nuke Indie</strong> can type <code>arguments.push_back("--indie");</code> instead.</p>
<p>For example, my <strong>Nuke 13.1v5</strong> executable is <code>S:\Program Files\Nuke13.1v5\Nuke13.1.exe</code> and I want to use <strong>NukeX</strong> my code would look like this.</p>
<pre><code class="lang-cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;cstdlib&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;vector&gt;</span></span>

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span>** argv)</span>
</span>{
    <span class="hljs-built_in">std</span>::<span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>&gt; arguments;
    arguments.push_back(<span class="hljs-string">"S:\\Program Files\\Nuke13.1v5\\Nuke13.1.exe"</span>);
    arguments.push_back(<span class="hljs-string">"--nukex"</span>);
    arguments.push_back(<span class="hljs-string">"-i"</span>);
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>; i &lt; argc; ++i)
        arguments.push_back(argv[i]);

    <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> command;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>&amp; argument : arguments)
    {
        <span class="hljs-keyword">if</span> (command.size())
            command += <span class="hljs-string">" "</span>;
        command += <span class="hljs-string">"\""</span> + argument + <span class="hljs-string">"\""</span>;
    }
    command = <span class="hljs-string">"\""</span> + command + <span class="hljs-string">"\""</span>;

    <span class="hljs-keyword">return</span> <span class="hljs-built_in">std</span>::system(command.c_str());
}
</code></pre>
<p>Next, save the modified code as .cpp file. In Notepad, you can Press Ctrl+S to save then change "Save as type:" to <strong>All Files</strong> and add <strong>.cpp</strong> to your file name.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671820811450/9efd9ba1-289d-4492-8d43-93c243e16d90.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-compile-the-code">3. Compile the code!</h3>
<p>We are now close to the finish! To get the usable executable file we need to compile the code.</p>
<p>First, go to the location of the file saved in the previous step, right-click and select <strong>Open in Terminal</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671821476089/06127bb9-e62c-4b77-a7ec-1f54e830cfa1.png" alt class="image--center mx-auto" /></p>
<p>If Open in Terminal isn't available you can press <strong>Shift and right-click</strong> then select <strong>Open PowerShell window here</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671821557903/f409ce5a-5d35-4793-a1cf-468a1379107e.png" alt class="image--center mx-auto" /></p>
<p>Next, copy and modify the command below or type <code>g++</code> then space and type your .cpp <strong>filename</strong> with the <strong>.cpp</strong> extension, then space and type <code>-o</code> , then space again and type the <strong>filename</strong> you want with <strong>.exe</strong> extension.</p>
<pre><code class="lang-bash">g++ your_cpp_file.cpp -o your_exe_file.exe
</code></pre>
<p><em>Use right-click to paste anything to Windows Terminal or PowerShell.</em></p>
<p>For example, my file is named <code>launcher_for_katana_nuke_bridge.cpp</code> and I want my .exe file to name <code>launcher_for_knb.exe</code> the command will look like this.</p>
<pre><code class="lang-bash">g++ launcher_for_katana_nuke_bridge.cpp -o launcher_for_nkb.exe
</code></pre>
<p>Finally, press <strong>Enter</strong> and the executable file will be <strong>created</strong>!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671822342191/fb58afa2-98da-47ce-98a1-8bf79c9ddacf.gif" alt class="image--center mx-auto" /></p>
<h3 id="heading-4-tell-katana-to-use-the-new-executable-we-created">4. Tell Katana to use the new executable we created</h3>
<p>We are now at the last step! Change <strong>KATANA_NUKE_EXECUTABLE</strong> to the executable we created.</p>
<p><em>Before</em></p>
<pre><code class="lang-bash"><span class="hljs-built_in">set</span> KATANA_NUKE_EXECUTABLE=S:\Program Files\Nuke13.1v5\Nuke13.1.exe
</code></pre>
<p><em>After</em></p>
<pre><code class="lang-bash"><span class="hljs-built_in">set</span> KATANA_NUKE_EXECUTABLE=C:\Users\VM\Documents\launcher_for_nkb.exe
</code></pre>
<p><strong><em>Finally,</em></strong> save and launch Katana with your launcher script. You should be able to use Nuke Bridge with nuke_i license now!</p>
<hr />
<h1 id="heading-resources">Resources</h1>
<ul>
<li><p><a target="_blank" href="https://learn.foundry.com/katana/Content/ug/rendering_scene/katana-nuke-interop.html">Katana User Guide about Nuke Bridge</a></p>
</li>
<li><p><a target="_blank" href="https://community.foundry.com/discuss/topic/160631/having-trouble-configuring-nuke-bridge-with-a-nuke-i-license">A topic where I ask about the problem</a></p>
</li>
<li><p><a target="_blank" href="https://learn.foundry.com/nuke/content/comp_environment/configuring_nuke/command_line_operations.html">Nuke User Guide about Command Line Operations</a></p>
</li>
<li><p><a target="_blank" href="https://code.visualstudio.com/docs/cpp/config-mingw">VSCode Documentation about Using GCC with MinGW</a></p>
</li>
</ul>
<hr />
<p>Please let me know if anything needs to be changed or if something is unclear.</p>
]]></content:encoded></item><item><title><![CDATA[After Effects implementation of JS Spirograph]]></title><description><![CDATA[Midterm Project นี้อ้างอิงวิธีการคำนวณจาก JavaScript Spirograph
และอ้างอิง Expressions จาก

https://ae-expressions.docsforadobe.dev/

World of Expressions - After Effects Training - YouTube


โดยผมได้ทำการสร้าง Pesudo Effects ขึ้นมาสำหรับ Controller ...]]></description><link>https://blog.nkpd.moe/after-effects-implementation-of-js-spirograph</link><guid isPermaLink="true">https://blog.nkpd.moe/after-effects-implementation-of-js-spirograph</guid><dc:creator><![CDATA[Minami Kanako]]></dc:creator><pubDate>Sat, 05 Mar 2022 14:32:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1646490681531/nfkWzKSpD.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Midterm Project นี้อ้างอิงวิธีการคำนวณจาก <a target="_blank" href="https://www.maissan.net/articles/javascript-spirograph">JavaScript Spirograph</a></p>
<p>และอ้างอิง Expressions จาก</p>
<ul>
<li><p>https://ae-expressions.docsforadobe.dev/</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/playlist?list=PLvr5U5ZSt6IzHyvSL9fo0M9NRPsTvra31">World of Expressions - After Effects Training - YouTube</a></p>
</li>
</ul>
<p>โดยผมได้ทำการสร้าง Pesudo Effects ขึ้นมาสำหรับ Controller ต่างๆ ในการปรับค่าตัวแปรที่ใช้ในการคำนวณตำแหน่งของจุดต่างๆ ที่ใช้สำหรับวาดเส้น path ขึ้นมา</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671811353999/2e7b5bff-e93a-4ad9-9e5a-c1a0714c896d.png" alt class="image--center mx-auto" /></p>
<p>โดยการคำนวณดังกล่าวใช้สูตร</p>
<p>x=cx+radius1×cos(θ)+radius2×cos(θ×ratio)y=cy+radius1×sin(θ)+radius2×cos(θ×ratio)</p>
<p>ซึ่งเป็นสูตรที่ใช้สำหรับการสร้าง Spirograph ซึ่งสามารถอ้างอิงคำอธิบายสูตรการคำนวณเพิ่มเติมได้จาก <a target="_blank" href="https://www.maissan.net/articles/javascript-spirograph">JavaScript Spirograph</a></p>
<p>ต่อมาผมได้นำ Code JS ที่ใช้คำนวณจากบนเว็บไซต์มาประยุกต์ให้สามารถใช้งานได้กับ Expression ของ After Effects ซึ่งทำงานด้วยระบบ JavaScript เช่นกัน</p>
<p>ซึ่งขั้นตอนแรกผมได้ทำการประกาศตัวแปร path เอาไว้สำหรับเรียกใช้ property ของ path ภายใน shape layer อย่างง่ายโดยการใช้</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> path = content(thisProperty.propertyGroup(<span class="hljs-number">1</span>).name).path;
</code></pre>
<p>และต่อมาก็ได้ประกาศตัวแปรต่าง ๆ เพิ่มขึ้นมาสำหรับใช้งานกับ Controller</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> cx = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Position"</span>)[<span class="hljs-number">0</span>];
<span class="hljs-keyword">var</span> cy = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Position"</span>)[<span class="hljs-number">1</span>];
<span class="hljs-keyword">var</span> outr = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Outer Radius"</span>);
<span class="hljs-keyword">var</span> inr = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Inner Radius"</span>);
<span class="hljs-keyword">var</span> ratio = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Ratio"</span>);
<span class="hljs-keyword">var</span> res = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Resolution"</span>);
<span class="hljs-keyword">var</span> angle = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Angle"</span>);
<span class="hljs-keyword">var</span> closedPath = effect(<span class="hljs-string">"JS Spirograph"</span>)(<span class="hljs-string">"Closed Path"</span>);
</code></pre>
<p>และต่อมาก็ได้สร้างตัวแปรประเภท Array ขึ้นมาเพื่อเก็บข้อมูลของตำแหน่งของจุดที่คำนวณออกมาได้</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> allPoints = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>();
</code></pre>
<p>ต่อมาจึงเริ่มให้เริ่มต้นการคำนวณ โดยมีข้อแม้ว่า จะคำนวณไปเรื่อยๆ ถ้าค่า θ น้อยกว่าหรือเท่ากับค่า PI*2 และจพหยุดคำนวณต่อเมื่อค่า θ เท่ากับ 1 หารกับค่า Resolution ที่ตั้งเอาไว้ และให้บันทึกค่าจุดที่ได้จากการคำนวณเก็บเอาไว้ในตัวแปร allPoints</p>
<pre><code class="lang-js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> theta = <span class="hljs-number">0</span> + degreesToRadians(angle); theta &lt;= <span class="hljs-built_in">Math</span>.PI * <span class="hljs-number">2</span>; theta += <span class="hljs-number">1</span>/res)
{
    x = cx + outr * <span class="hljs-built_in">Math</span>.cos(theta) + outr * <span class="hljs-built_in">Math</span>.cos(theta * ratio);
    y = cy + outr * <span class="hljs-built_in">Math</span>.sin(theta) + inr * <span class="hljs-built_in">Math</span>.sin(theta * ratio);
    allPoints.push([x,y]);
}
</code></pre>
<p>หลังจากนั้นจึงสั่งให้ After Effects สร้าง path ขึ้นมาจากจุดทั้งหมดที่คำนวณได้เป็นที่เรียบร้อย</p>
<pre><code class="lang-js">path.createPath(allPoints, [], [], closedPath);
</code></pre>
]]></content:encoded></item></channel></rss>