<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sneha Belkhale on Medium]]></title>
        <description><![CDATA[Stories by Sneha Belkhale on Medium]]></description>
        <link>https://medium.com/@snayss?source=rss-d5b5fc1296ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5R2Mq9zrX8U2QXoP-aGyuA.jpeg</url>
            <title>Stories by Sneha Belkhale on Medium</title>
            <link>https://medium.com/@snayss?source=rss-d5b5fc1296ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:46:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@snayss/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ON SET WITH A METAHUMAN]]></title>
            <link>https://snayss.medium.com/on-set-with-a-metahuman-95ed59e55a63?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/95ed59e55a63</guid>
            <category><![CDATA[motion-capture]]></category>
            <category><![CDATA[vfx]]></category>
            <category><![CDATA[virtual-production]]></category>
            <category><![CDATA[meta-human]]></category>
            <category><![CDATA[unreal-engine]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Fri, 10 Jun 2022 14:05:17 GMT</pubDate>
            <atom:updated>2022-06-10T14:05:17.628Z</atom:updated>
            <content:encoded><![CDATA[<h3>Behind the Scenes into the making of “Kì-Kí Ÿågø — Сирои Ха”</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlD_SNhWDLyI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DlD_SNhWDLyI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlD_SNhWDLyI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/aaffe42f50449c586a75bb3eef418a12/href">https://medium.com/media/aaffe42f50449c586a75bb3eef418a12/href</a></iframe><p><a href="https://instagram.com/kif11">Kirill</a> and I (<a href="https://www.instagram.com/snayss/">Snayss</a>) recently made a music video in Unreal Engine 5, exploring the new advances in Metahumans, Lumen Lighting, and Face Capture technology. This was a very cool exploration in digital production, and left us feeling like we had just been “on set” for one month:) I want to go through some of the details of the project in this article, as I think it will be interesting to those with eyes on the metaverse!</p><h3>THE METAHUMAN</h3><p>Our drive to start this project actually emerged from an introduction to the Metahuman software for Unreal Engine 5. I had seen the amazing advances in Unreal Engine over the last few years, but could not convince myself to learn this beast of a program until I saw THE METAHUMANS. <a href="https://metahuman.unrealengine.com/">Metahuman Creator</a> is a web app that allows you to create and customize an avatar. During this process, the app streams to you a video feed in order to avoid any client side render costs. When you are ready, you can export and load all the textures / models / shaders / blueprints for a functional metahuman in Unreal Engine.</p><p>It’s very mesmerizing to use this tool, blending between different faces and sculpting the face and textures to your taste. It’s really hard to look away from her, watching her animate shyly, looking at me, looking away…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3Ra90UyRZsgnqS3TLsPdg.png" /><figcaption>Our attempt at recreating Kiki Yago</figcaption></figure><p>We did the first pass at recreating <a href="https://www.instagram.com/xenofontova_dasha/">Kiki Yago</a> — we found this task quite challenging, as the tool always seemed to clamp the features we wanted to sculpt, for example we could not find a way to get the avatars eyes to be wider apart. Anyway, we sent this draft to Kiki and she said that it was cool but definitely did not look like her, and that she would give it a try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-C9oz8M16g71rMoGpdwnQ.png" /><figcaption>Kiki’s self exploration</figcaption></figure><p>I was skeptical that it would be possible to create an avatar that looks like yourself, since we all have some sort of self perception deficiencies and biases… but I was proven wrong! Kiki’s versions capture the essence of her facial features way better than ours, even with our restrictions that she must be bald:)</p><p>I am very curious now to create my own avatar, and think it could be a cool exercise in self perception for all of us, since it’s the first avatar creator that can actually photo-realistically look like you, but do you even think you look like you?:0</p><h3>FACIAL CAPTURE</h3><p>The goal was to get Kiki to sing and record her facial capture for the entire song, keeping in mind that Kiki was in Saint Petersburg / Russia , and we were in San Francisco / USA. We decided on using the <a href="https://apps.apple.com/us/app/face-cap-motion-capture/id1373155478">FaceCap</a> application, since our friend used it for her <a href="https://www.littlemartians.world/">Little Martian</a> project and had promising results, and all it needed was an iPhone 10 or above! Kiki downloaded it on her iPhone, and could send us the FBX over telegram!</p><p>It’s amazing with the technologies that we have today and the power of virtual production, we were able to come up with a face capture solution that did not require any studio equipment or even being in the same country!</p><p>Kiki sent us some short initial test recordings, and we spent a few days struggling through the technical details of getting the animation to map to the Metahuman facial rig — this was mostly due to the fact that it was our first time using Unreal Engine for.. anything, and also that Unreal Engine completely changed their animation retargeting system in UE5.</p><p>However, thanks to watching this video, its beautiful elevator soundtrack, and the <a href="https://www.youtube.com/redirect?event=video_description&amp;redir_token=QUFFLUhqbExnbUJBOV9KcEFLRGFadlZKN2lJSWt0QnR2UXxBQ3Jtc0trODRlRHZZdHNQdzVTM2hRS0xwS0p5VnhyNkRYX0NjTk5QYWxHeTUzRU4xT3M1MGd5d2pkazluZHlMUkhhX25FU0dzcGd3OVo2UGR0ekphS2JPZVpRdkxRYzc5WHhSWHNZZmNuaFpPQ1dGSmVJQ0lFaw&amp;q=https%3A%2F%2Fdrive.google.com%2Fdrive%2Ffolders%2F1YHd5_ASl-KAS2e_k9h-CIwXIkAUMtSM0%3Fusp%3Dsharing&amp;v=xixo8ljv9_8">FaceCap morph target re-mapping data</a> that the author generously shared, we were able to get an initial working demo!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fxixo8ljv9_8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dxixo8ljv9_8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fxixo8ljv9_8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f399b7daf130fc3131acf3214c848fb/href">https://medium.com/media/4f399b7daf130fc3131acf3214c848fb/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FdeAAQt5yPug%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdeAAQt5yPug&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9644b1cd57002488a6d40ac985d4ded/href">https://medium.com/media/f9644b1cd57002488a6d40ac985d4ded/href</a></iframe><p>This was super promising! Meta Kiki was alive! But obviously there was a lot of work to be done on adjusting the remapping of FaceCap to Metahuman Rig, specifically in the mouth and jaw area.</p><p>We asked Kiki to send us the FaceCap FBX along with a recording of herself from a separate camera and a WAV file, on Telegram, our Remote Face Capture Studio. This was a complete picture of the data, so that we had reference videos while adjusting the Metahuman facial rig remapping, and reference audio for aligning the face capture to the main audio track.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*mFK9iIGsUlqpRJIWzkd8bA.png" /><figcaption>Telegram, the Remote Face Capture Studio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xig1jISlakbKXtN6utAdmw.jpeg" /><figcaption>Quick sassy capture of Kiki</figcaption></figure><p>After we got a good pipeline going, we could focus on ways to improve the overall effect of the face capture. We found that eye acting and head rotations came across really well and was a good place to focus the performance efforts. It was also critical to over articulate words and press lips together, which was actually a difficult task for this song where Kiki is pushing her lyrical alliterations at 100 words/second:)</p><p>Kiki pushed forward on this, coming up with some crazy fast eye blinking action and creepy doll expressions. She split the song into 12 sections of around 20 seconds each, because we found that smaller recordings were much easier to process in Unreal Engine.</p><h3>TO BE CONTINUED</h3><p>Once we were confident in our Face Capture remote pipeline, we moved on to the environment design and visual effects! This is a big and slightly unrelated topic since most of this work was done in HoudiniFX — so i’m going to split that into another article:)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0g6LTBc_RPIHvgQ16tRZA.jpeg" /><figcaption>MSPaint Concept Art</figcaption></figure><p>We are really excited about this technology, and to take this whole experience to the next level. Since the metahumans are so realistic, we definitely need to put some work into the 3D environment, shader, and geometry styles that are harmonious. This will be an exploration that i’m very looking forward to, with some shorter concept video renders.</p><p>❤ <a href="https://codercat.tk/">CODERCAT</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95ed59e55a63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Local Network Chat With OpenWRT]]></title>
            <link>https://medium.com/swlh/local-network-chat-with-openwrt-736dfb48a400?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/736dfb48a400</guid>
            <category><![CDATA[openwrt]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[captive-portal]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[wifi]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Fri, 20 Nov 2020 16:23:29 GMT</pubDate>
            <atom:updated>2021-12-02T07:18:52.972Z</atom:updated>
            <content:encoded><![CDATA[<h3>Captive Portal Chat With OpenWrt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47l3NTbMySfII5GYEff47w.png" /></figure><p>Heya! So, lately I’ve been thinking about how the current state of media directs us to spending a lot of time focusing on global events and people. We are so connected with the entire world, that sometimes we lose sight of what is happening right outside our windows. Instead of trying to reach the largest audience possible by sharing events and ideas on social media, what if we steered our efforts towards our local communities? This could look like pinning up event posters outside, gathering for mutual aid community dinners, oor hosting a web page on an open local network…??</p><p>I had seen this idea in Berlin — Google was attempting to open a new headquarters in Neukölln and the people were <strong>not</strong> going to allow it. Alongside the protests, someone had setup a local network where Google was planning to build its office. When you connected to the network, it would pop up a page of anti-google propaganda that <em>everyone</em> should be aware of. It was a cool supplementary way to share information, localized to a specific area and idea.</p><p>I wanted to implement something like this here in NYC, and maybe take it a step further by including a local network chat to spark the sense of community along with some (<em>abolitionist?)</em> propaganda. I came up with a list of the most important features…</p><ul><li>The page should pop up automatically after you connect (Captive Portal).</li><li>The local network should not need internet connection.</li><li>The router should be able to run a small server for the chat API.</li><li>All processes should survive a reboot.</li></ul><p>Lets do iittt::::</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Xc3t0OMeQb8QRW80_gqoew.png" /><figcaption>OpenWRT — Wireless Freedom — OS that runs on the router</figcaption></figure><h3><strong>The Hardware</strong></h3><p>We need a portable router for this project. This could come in many different forms, I even contemplated using my Raspberry Pi, but eventually settled on the <a href="https://www.gl-inet.com/products/gl-ar750s">GL.iNet Slate Router</a> for it’s simplicity and specialized functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*WYFL0O8kaRvf2xfBYpU9zw.png" /><figcaption><a href="https://www.gl-inet.com/products/gl-ar750s">GL.iNet Slate Router</a></figcaption></figure><p>This cute portable router comes with an installation of OpenWRT, as well as a Admin Panel web interface. I knooww we all want to be terminal purists sometimes, but this admin panel is actually really nice and helpful to get a visual representation of the router state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*poqCjPaZ3MJKsQUsiBfIOg.png" /><figcaption>Router Admin Panel, for basic network configuration</figcaption></figure><p>To prep for this experiment, I used the Admin Panel to set up an open guest network named Starbucks WiFi…(ask me about it :p) I also enabled a captive portal for the guest network using the interface. Depending on which router you use, you may have to figure out some of those things with commands, but I have been blessed with this interface and will enjoy its benefits:)</p><h3>Setting up the Captive Portal</h3><p>Now that the captive portal has been enabled, when connecting to the router, I receive a popup html page! Now to swap it out with our own.</p><p>OpenWRT comes with the <a href="https://nodogsplashdocs.readthedocs.io/en/stable/">NoDogSplash</a> captive portal manager. Looking through the docs, I found that the html page that it sends to newly connected users is located in /etc/nodogsplash/htdocs/splash.html.</p><p>So all we need to do is copy over our html page with (<em>anti-capitalist?)</em> propaganda using scp from our computer.</p><pre>scp index.html root@192.168.8.1:/etc/nodogsplash/htdocs/splash.html</pre><p>Wonderful! Now every time you connect to the open guest network, it should bring you to your (<em>anti-google?) </em>propaganda<em> </em>page.</p><h3><strong>Allowing Captive Portal to Work Offline</strong></h3><p>By default, NoDogSplash captive portals will not work without internet. If the router fails to resolve the DNS request for the operating systems “connectivity check” URL (mac uses captive.apple.com), then NoDogSplash will return an error and deem the network/captive portal unusable.</p><p>I found this to be quite a blocking problem, since one of my goals was to take my local network chat to places where a WiFi connection was not guaranteed (NYC Metro, street protests, etc). Furthermore, since all data for the chat is local to the router, there really was no reason it needed WiFi..</p><p>After scrolling through some G<a href="https://github.com/nodogsplash/nodogsplash/issues/328">ithub issues</a>, I found a hack to basically configure NoDogSplash to resolve all DNS queries locally with the same random public address, making them seem to pass the “connectivity check” and allow NoDogSplash to continue.</p><pre>(on router)</pre><pre>uci add_list dhcp.@dnsmasq[0].address=’/#/121.122.123.124&#39;</pre><pre># saves the config edit for persistency after reboot<br>uci commit dhcp </pre><pre>service dnsmasq restart</pre><h3>Setting up the Chat Server</h3><p>At this point, we basically have enough to recreate the Berlin anti google setup:) However I still wanted to see if it was possible to setup a simple chat server. The simplest chat ever needs a running server with one route for posting a message, one route for getting all messages, a<strong> super sophisticated </strong>.json file database, and an html page to display the chat.</p><p>The router model I have only has 128 mb of RAM.. so I thought about downloading Python-Light, but it was too light and did not have SimpleHttpServer. I decided to just pray and hope the device could withstand the vanilla Python installation.</p><p>First I installed Python on the router using the OpenWRT package manager.</p><pre>opkg update<br>opkg install python</pre><p>Then copied over my server code and new chat html page from my computer ( I wont go into describing how the chat code works here, but its pretty simple and you can check it out <a href="https://gist.github.com/sneha-belkhale/e7a1fe52e33b5c98f1ea2081a3b4ed8a">here</a> if you want :)</p><pre>scp server.py root@192.168.8.1:/root/</pre><pre>scp chat.html root@192.168.8.1:/etc/nodogsplash/htdocs/splash.html</pre><p>Create an empty “database” on the router to store our messages:</p><pre>echo &quot;[]&quot; &gt;&gt; /root/data.json</pre><p>And run the server!</p><pre>python /root/server.py</pre><p>All is well…. but if we open our chat now we can see that requests to the Python server are failing with a connection time out, meaning that the port our server is listening on is not accessible from our chat page. If we remember, NoDogSplash is in charge of the captive portal which blocks most of the ports by default, so we can adjust its settings to allow traffic directed to our server port.</p><pre>uci add_list nodogsplash.@nodogsplash[0].users_to_router=&#39;allow tcp port 8989&#39;</pre><pre>uci commit nodogsplash</pre><pre>service nodogsplash restart</pre><p>Now, if we run the server again and try connecting to our open network, our chat should pop up as a captive portal, happily GETting/POSTing requests to our local server :)</p><h3><strong>Survive the Reboot, the Final Boss</strong></h3><p>If you’ve gotten this far.. you should have a captive portal that automatically pops up with a chat window served by the simple Python server running on the router.</p><p>In order to reach our ideal of robustness, we need to make sure our processes can survive a reboot!</p><p>OpenWRT uses Init Scripts to configure daemons that run on startup, if we make our python server run as a daemon, it should hopefully be able to survive a reboot.</p><p>The <a href="https://openwrt.org/docs/techref/initscripts">OpenWRT docs</a> give a pretty simple example Init Script, which we can modify for our purposes :</p><pre><em>#!/bin/sh /etc/rc.common</em></pre><pre>START=98<br>STOP=98</pre><pre>start() {<br>    echo &quot;starting chat server&quot;<br>    (sleep 20; python /root/server.py)&amp;<br>}</pre><pre>stop() {<br>    echo &quot;stopping chat server&quot;<br>    killall python <br>}</pre><p>Init scripts use the template /etc/rc.common<strong>, </strong>a wrapper that provides its main and default functionality, such as start, stop, restart, enable, and disable. We need to override the default start and stop functions. If you want to learn more about the details of init scripts, check out the <a href="https://openwrt.org/docs/techref/initscripts">OpenWRT docs</a> on the subject, they are awesome.</p><p>If you noticed in the script, our start function has a lot going on in the line :</p><pre>(sleep 20; python /root/server.py)&amp;</pre><p>First off, the process is running in the background — indicated by the &amp;. I noticed that if I tried running the process in the foreground, the Admin Panel wouldn’t show up! I have a hunch that init.d start functions are blocking, so whatever you need to start needs to account for that by running itself as a background process.</p><p>Another mystery is that if I just ran (python /root/server.py)&amp; without the sleep bit, the server would not start up properly. After killing the process and starting it again manually using /etc/init.d/chat start, everything would work fine! My hunch here is that something needed for python servers to initialize is not available at boot time… would love if someone has more information on that. For now, the sleep timer works :)</p><p>We can copy this file from our computer into the designated directory of init scripts:</p><pre>scp chat.sh root@192.168.8.1:/etc/init.d/</pre><p>And enable it! Enabling the process allows it to startup on boot.</p><pre>sudo chmod +x /etc/init.d/chat.sh<br>/etc/init.d/chat enable<br>/etc/init.d/chat start</pre><p>Nowwww cross your fingers and lets reboot!!! To make sure your python server is running in the background after the reboot, you can run</p><pre>ps | grep python</pre><p>and check if the server process survived :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47l3NTbMySfII5GYEff47w.png" /><figcaption>Captive Portal Chat</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AG13yc7RuvJnQ4uzYesSGA.png" /><figcaption>Captive Portal Zapatista Wisdom</figcaption></figure><p>We made it! This article may not accurately portray the amount of mental breakdowns that occurred during this exploration, but hey thats linux so it’s implied :) I hope after an adequate amount of flipped tables you are able to get this to work too and we can spread the joy of LAN chats &amp; local environment awareness :P</p><p>❤ Snayss</p><p>check out my other things @</p><p>website: <a href="https://codercat.tk/">codercat.tk</a></p><p>github: <a href="https://github.com/sneha-belkhale">https://github.com/sneha-belkhale</a></p><p>insta: <a href="https://www.instagram.com/snayss/">@snayss</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=736dfb48a400" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/local-network-chat-with-openwrt-736dfb48a400">Local Network Chat With OpenWRT</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three.js Fog Hacks]]></title>
            <link>https://snayss.medium.com/three-js-fog-hacks-fc0b42f63386?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc0b42f63386</guid>
            <category><![CDATA[webgl]]></category>
            <category><![CDATA[shaders]]></category>
            <category><![CDATA[graphics]]></category>
            <category><![CDATA[fog]]></category>
            <category><![CDATA[threejs]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Wed, 17 Jun 2020 02:32:11 GMT</pubDate>
            <atom:updated>2021-12-02T07:20:40.767Z</atom:updated>
            <content:encoded><![CDATA[<p>Fog is everything. Its a simple effect that effortlessly adds depth and cinematic qualities to a scene. It’s also has negligible performance costs, meaning it’s suitable for web graphics. Imagine a cube on a plane with a sky sphere.. seems pretty bland but then add FOG and BOOM! Masterpiece.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpvhDxBzfXWsI7oXJisRPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6socDT8rkTHNkXivqRO5KQ.png" /><figcaption>this is the.. same scene… whaat?</figcaption></figure><p>I think most 3D designers/nerds/whatever are pretty aware of the glories of fog, but from what i’ve seen, the effect is normally just taken at face value. The three.js default fog is definitely beautiful on its own, but I want to share some shader simple tricks on how to take the implementation to the ~ next level ~.</p><p>I’m going to be doing this exploration in three.js, but the basic ideas can be easily implemented in shaders everywhere. Also, if you are the kind of person that hates reading and is screaming “JUST SHOW ME THE CODE”, the demo and code is available @ <a href="https://stackblitz.com/edit/threejs-fog-hacks">https://stackblitz.com/edit/threejs-fog-hacks</a></p><p>So, let’s begin with the <a href="https://threejs.org/examples/?q=fog#webgl_geometry_terrain_fog">three.js fog demo</a> as the starting point. This is the only mention of fog on the three.js examples page, yet it seems to be more about the terrain :(</p><p>The article requires a basic understanding of how the shader library works in three.js. If you are not familiar, I would really recommend reading this article on <a href="https://medium.com/@pailhead011/extending-three-js-materials-with-glsl-78ea7bbb9270">Extending Three.js Materials</a> , its good stuff.</p><p>Also, i’m going to mostly just go over concepts, with code snippets here and there, so I advise that you have the full <a href="https://stackblitz.com/edit/threejs-fog-hacks?">stackblitz demo code</a> open for reference :)</p><h3>THE SETUP</h3><p>So, our first goal is to get to a hold of the fog implementation and have it under our control. One way to do that would be writing a custom shader from scratch, but this would mean having to reimplement a lot of the material features ( present in THREE.MeshBasicMaterial, THREE.MeshPhysicalMaterial, etc. ) that you are already love and are using for your scene.</p><p>You could also just copy and paste the <a href="https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderLib">bones of the material shaders</a> you are using, and overwrite the fog shader chunks with your own.. This is better, but since it is still a custom shader and of type THREE.ShaderMaterial, it will miss out on the integration with the rest of the scene properties ( including lights and fog).</p><p>For example, the standard way to control fog is scene.fog = new THREE.FogExp2(color, density) . For all built in materials, the fog parameters are automatically passed in by the library as uniforms with the correct shader #defines. However, they are ignored if the material is of type Three.ShaderMaterial .</p><p>So… what we need is a material that is a default type but also has our custom logic?? Don’t worry, there’s a third option! We can instantiate our material as whatever base material we want (so that it is registered and gets all scene properties), and just sneak in the chunks that we want to replace in the materialOnBeforeCompile callback.</p><pre>mesh.material = <strong>new</strong> THREE.MeshBasicMaterial({ color: <strong>new</strong> THREE.Color(0xefd1b5) })</pre><pre>mesh.material.onBeforeCompile = shader =&gt; {</pre><pre>  shader.vertexShader = shader.vertexShader.replace(</pre><pre>    `#include &lt;fog_pars_vertex&gt;`,</pre><pre>     fogParsVert</pre><pre>  );</pre><pre>  shader.vertexShader = shader.vertexShader.replace(</pre><pre>    `#include &lt;fog_vertex&gt;`,</pre><pre>     fogVert</pre><pre>  );</pre><pre>  shader.fragmentShader = shader.fragmentShader.replace(</pre><pre>    `#include &lt;fog_pars_fragment&gt;`,</pre><pre>     fogParsFrag</pre><pre>  );</pre><pre>  shader.fragmentShader = shader.fragmentShader.replace(</pre><pre>    `#include &lt;fog_fragment&gt;`,</pre><pre>     fogFrag</pre><pre>  );</pre><pre>};</pre><p>Yay! Okay, but let’s take a step back… how do we know which chunks we need to replace?</p><p>By studying the <a href="https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderLib">shader chunks on Github</a>. No but really, the only way we can successfully use this approach is by getting familiar with what the included shader chunks do, what #defines exist, what varyings are provided, etc.</p><p>I recommend two things.</p><p><strong>#1</strong> Go to Github and look at the <a href="https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js">shaders chunks that compose each material</a>, and dive into the shader chunks you are interested in.</p><p><strong>#2 </strong>If you “break” the shader by, lets say, writing an invalid line like hellofdksaf #include &lt;fog_fragment&gt; : you will get an error message in the console with the full print out of the shader and all its chunks in one place! it’s nice reading material.</p><p><strong>I feel like the setup is actually one of the coolest parts of this lil article, since it sets you up with the freedom to pretty much hack any part of the three.js shader system with little resistance.</strong></p><p>Once you’ve done those things, you will see that the fog uniforms are presented in &lt;fog_pars_vertex&gt; &amp; &lt;fog_pars_fragment&gt;, and the implemention is in &lt;fog_vertex&gt;, &lt;fog_fragment&gt;. You will want to start out with the <a href="https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderChunk">default implementation</a> in a <a href="https://stackblitz.com/edit/threejs-fog-hacks?file=FogReplace.js">javascript file</a>, that we can slowly modify.</p><h3>NEAR + APEX COLORS</h3><p>Finally ready for our first hack! Who said fog had to be restricted to one color?? It may not be physically accurate, but it surely does give an artistic edge to be able to control fog colors that are near and at a distance.</p><p>At the end of the fog fragment chunk, there is a float named fogFactor , a 0-1 value that represents where the fragments depth value lies on the scale of no fog, to full fog. It is used to calculate the final fragment color like so:</p><p>gl_FragColor.rgb = <strong>mix</strong>( gl_FragColor.rgb, fogColor, fogFactor );</p><p>When fogFactor is 0, the color remains equal to gl_FragColor . When fogFactor is 1, the fragment is at our max depth value and is fully in fog.</p><p>We can achieve a dual fog color system by having fogColor depend on the fogFactor as well. If a new uniformfogNearColor is the color of fragments closer to you, and fogColor is for those far away, we can mix the two depending on the fogFactor :</p><p>gl_FragColor.rgb = <strong>mix</strong>( gl_FragColor.rgb, <strong>mix</strong>(fogNearColor, fogColor, fogFactor), fogFactor );</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKF1YXEbCA2XdBD5me_wrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0uBN8c6x7SL60NxvhQkBJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bixvFDCd_PMoUfV7oWfS0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzrFoZv10AKFQNhFxdJurw.png" /><figcaption>Few looks with different near and apex colors</figcaption></figure><p>Of course this can also be extended to having horizon + sky fog colors, but thats something for you to try. Moving on.</p><h3><strong>NOISE</strong></h3><p>The three.js fog is fixed at every depth value, meaning the fog will look the same in every direction. From the example above it’s not too noticeable since the terrain we are working with is complex on its own, but if you have simpler geo, it becomes pretty obvious quickly.</p><p>Real fog has patches, areas that are denser than others. We can try to mimick that complexity by applying a noise function to the depth value.</p><blockquote>Perlin noise will solve all your problems. -me</blockquote><p>There is a cool resource of <a href="https://gist.github.com/patriciogonzalezvivo/670c22f3966e662d2f83">GLSL Noise algorithms</a> that I tend to include in all of my three.js project, before even starting to work on the shaders, and they always come in handy.</p><p>For the purpose of fog, we are going to need a noise function that takes a 3D input, since we want it to be fixed and driven by the world space position. I’m going to go with Classic Perlin 3D Noise by Stefan Gustavson , but its fun to experiment with others if you want :)</p><p>The first thing we are going to need is to set up the world position value as a varying , to access it in our fragment shader. That includes changes in all of our replacement chunks : Declaring vFogWorldPosition in the headers, setting it in the vertex shader chunk vFogWorldPosition = (modelMatrix * vec4( transformed, 1.0 )).xyz; , and using it in the fragment shader. Another note to look at the <a href="https://stackblitz.com/edit/threejs-fog-hacks?file=index.js">stackblitz</a> if you need more details.</p><p>In the fragment shader, let’s just start and see what the noise looks like by multiplying it with thefogDepth value. Since cnoise outputs a value between 0–1, this should be a kosher experiment.</p><pre><strong>float</strong> noise = <strong>cnoise</strong>(fogNoiseFreq * vFogWorldPosition.xyz);<br><strong>float</strong> vFogDepth = noise * fogDepth; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B5paJWj8A4yx8gZO0Hq7eg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_jtgZvQequyImVbbasB5Q.png" /><figcaption>fogNoiseFreq of 0.0036 &amp; 0.0012</figcaption></figure><p>Playing around with different values of fogNoiseFreq gives us some pretty interesting looks already! But since we are multiplying all fogDepth values equally by noise, we are losing the constant gradual shift to complete fog.</p><p>Scaling the noise by the fogDepth value, as well as adding a multiplier for artistic taste should help us maintain that gradual shift.</p><p><strong>float</strong> vFogDepth = fogDepth - fogNoiseImpact * noise * fogDepth;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7I9-qTtlYTi-87IDUOY9XQ.png" /></figure><h3>MOVEMENT</h3><p>Ok maybe i’ve been staring at the fog too much ( can’t help it in Daly City.. ) , but fog is rarely static here. There’s always a gust or slow wind pushing it (<a href="https://twitter.com/karlthefog?lang=en">karl</a>) along its way.</p><p>In order to start making the fog move, our shader needs a time uniform ( reference <a href="https://stackblitz.com/edit/threejs-fog-hacks?file=FogReplace.js">code</a> if you are unsure of how to add that ). Then, all we need to do is add a direction to vFogWorldPosition, and the noise will smoothly transition with time.</p><pre><strong>vec3</strong> windDir = <strong>vec3</strong>(0.0, 0.0, time);</pre><pre><strong>vec3</strong> scrollingPos = vFogWorldPosition.xyz + fogNoiseSpeed * windDir;</pre><pre><strong>float</strong> noise = <strong>cnoise</strong>(fogNoiseFreq * scrollingPos.xyz);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*iwKa6ZU-fMWm1ajlos-xQg.gif" /><figcaption>banding is shitty :( but pls check out the <a href="https://threejs-fog-hacks.stackblitz.io/">demo</a> for a better idea</figcaption></figure><h3>PERFORMANCE</h3><p>Having the noise function in the fragment shader looks awesome, but isn’t the most performative option. If you are tied on performance, there is always the option of losing some smoothness and calculating the noise in the vertex shader.</p><p>If you are looking for a more subtle effect, you can create a pretty similar effect by approximating with parametric surfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4n0ydrfVfWh9OeQF7WAMhA.png" /></figure><p>I think I was browsing parametric surfaces for something else.. but when I saw this plot I was like ooooh looks like a blanket of fog!! Again, thats what living in Daly City does to you…</p><p>We can use the x &amp; z values of our world position to calculate the surface, and then do a fade base on how close the y position is to the surface value — that way basically any point under the surface would have fog, and any point over would smoothly transition to no fog.</p><pre><strong>float</strong> scale = 0.04;<br><strong>float</strong> yCutoff = 3.0;</pre><pre><strong>vec3</strong> scaledPos = scale * vWorldPosition.xyz;</pre><pre><strong>float</strong> val = scaledPos.z * sin(scaledPos.x) - scaledPos.x * cos(scaledPos.z);</pre><pre><strong>float</strong> normDist = clamp(vWorldPos.y - yCutoff*val, 0.0, 100.0)/100.0;</pre><p>There is some hackery you need to do if you want to add movement to this fog, since this particular function does not look good when x &amp; y move away from the origin.. I solved this by just moving the world position in a circular pattern, but i’m sure there are other ways :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ub0BQQ1boBhg6DAZCIiGcw.png" /><figcaption>Parametric surface fog approximation for one of my projects. Subtle, but trust me, its there :)</figcaption></figure><h3>FIN</h3><p>Anyways, I hope there were bits and pieces of that that would be useful to some of y’all threejs friends out theree! Feel free to reach out if anything was unclear, or if you come up with some other cool hacks :)</p><p>❤ snayz</p><p>Final demo @ <a href="https://threejs-fog-hacks.stackblitz.io/">https://threejs-fog-hacks.stackblitz.io/</a></p><p>Check out other related repos @<a href="https://github.com/sneha-belkhale"> https://github.com/sneha-belkhale</a></p><p>Other VR/Graphics projects @ <a href="https://codercat.tk/">https://codercat.tk</a></p><p>And renders / screenshots @ <a href="https://www.instagram.com/snayss/">https://www.instagram.com/snayss/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc0b42f63386" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bake a pretty — or computationally challenging — shader into a texture (Unity)]]></title>
            <link>https://snayss.medium.com/bake-a-pretty-or-computationally-challenging-shader-into-a-texture-unity-b524569d7384?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b524569d7384</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[shaders]]></category>
            <category><![CDATA[graphics]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[realtime]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Wed, 07 Aug 2019 05:00:06 GMT</pubDate>
            <atom:updated>2021-12-02T07:20:56.448Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bake a pretty — or computationally challenging — shader into a texture (Unity)</h3><p><a href="https://en.wikipedia.org/wiki/Texture_mapping#Baking">Texture baking</a> is very common technique in computer graphics to transfer the details of your shader into a texture. This is useful if your shader is computationally heavy, but produces a static result eg. complex noises.</p><p>Many modeling applications have this functionality down. If you have a pipeline of transferring assets from Blender/Houdini/Maya, then you may want to do the texture baking there. However, if you primarily work out of Unity, this tutorial is for you. With this technique, you can effectively save a custom shader’s results that were manipulated in real-time, and use the generated texture in any another application with a default shader ( Sketchfab? etc. ) .</p><p>So first, let’s start off with laying out the problems:</p><ul><li>Unwrap a mesh with shader applied, into uv coordinate space.</li><li>Render the unwrapped mesh to a texture.</li><li>Save texture to disk.</li></ul><p>FYI, if you just wanna see some code (as I always do), it’s <a href="https://github.com/sneha-belkhale/shader-bake-unity">here</a>.</p><p><strong>Unwrapping a mesh</strong></p><p><a href="https://en.wikipedia.org/wiki/UV_mapping#UV_unwrapping">Unwrapping a mesh </a>is the process of mapping 3D vertex coordinates to their 2D uv coordinate space. To do this in a vertex shader, we can set the x &amp; y components of the vertex to be its uv coordinates. Setting the z component to 0 will leave us with an unwrapped mesh in the XY plane, at z=0.</p><p>To try this out, duplicate the shader you want to bake, and adjust the vertex positions with the following line.</p><pre>v.vertex = float4(v.uv.xy, 0.0, 1.0);</pre><p>This new shader applied to your original mesh will show you the unwrapped mesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*EzrSp7MtxG-_pXj7HSSRaA.png" /><figcaption>unwrapped unity sphere, with a <a href="https://gist.github.com/sneha-belkhale/d944211b9af1e3575392d4e460676f30">fbm noise shader</a> applied</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWynanqbaPxdzT-u4cYopA.png" /><figcaption>unwrapped cool tree from sketchfab, with a<a href="https://gist.github.com/sneha-belkhale/d944211b9af1e3575392d4e460676f30"> fbm noise shader </a>applied</figcaption></figure><p><strong>How to render this unwrapped mesh to a texture?</strong></p><p>Orthographic cameras! With orthographic projection, there is no depth cues. An object’s size in the rendered image stays constant regardless of its distance from the camera. This will allow us to draw a perfect 2D UV grid without distortion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*lG2ZR2CeUClhl2AeuTWRag.gif" /><figcaption>Perspective vs. Orthographic projection</figcaption></figure><p>To start the baking process (we add two cups of flour?), we need to attach a script to the camera that is going to handle the baking logic. We attach it to a camera because we want to draw our mesh, using Graphics.DrawMeshNow, after we are done rendering the scene. For this, we need access to theOnPostRender function.</p><p>In the example project, I have the following code happen in ShaderBaker.cs on n the “M” key down event ( because binding things to random keys is just so easy lol).</p><pre>Mesh M = objectToBake.GetComponent&lt;MeshFilter&gt;().mesh;<br>// create a new render texture <br>RenderTexture rt = RenderTexture.GetTemporary(width, height);<br><br>// set the active render target <br>Graphics.SetRenderTarget(rt);</pre><pre>// save the last camera state<br>GL.PushMatrix(); </pre><pre>// load an orthographic camera <br>GL.LoadOrtho(); </pre><pre>// set the active material to be the unwrapping material we made earlier<br>uvMaterial.SetPass(0);</pre><pre>// draw the mesh, the matrix does not matter because we are not using it for any projection in the shader<br>Graphics.DrawMeshNow(M, Matrix4x4.identity);</pre><pre>// ** save to disk  here **</pre><pre>// reset state<br>Graphics.SetRenderTarget(null);<br>RenderTexture.ReleaseTemporary(rt);<br>GL.PopMatrix();</pre><p>There is a lot to say about what’s going on above, but how to say it depends on your level of familiarity with the Graphics pipeline in general… I guess the two most interesting things here are loading the Orthographic camera and activating the proper UV Unwrapping material for rendering using SetPass .</p><p>The UV Unwrapping shader will be identical to the shader you want to bake, except for the two line changes in the vertex shader. The first change mentioned earlier is the remapping of vertex coordinates to UV space.</p><pre>v.vertex = float4(v.uv.xy, 0.0, 1.0);</pre><p>Secondly, we will need to replace the standard line :</p><p>o.vertex = UnityObjectToClipPos(v.vertex)</p><p>with :</p><p>o.vertex = mul(UNITY_MATRIX_P, v.vertex);</p><p>UnityObjectToClipPos essentially multiples the vertex point by its world matrix and projection matrix. We do not care about the world matrix of this object, since we are rendering UV coordinates now that should always be centered around 0. However we do still need to project the UV coordinates to screen space, which we can do with just the projection matrix UNITY_MATRIX_P .</p><p>Another thing to note is that <a href="https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshNow.html">Unity docs </a>specify that DrawMeshNow does not include lighting information, so that means this implementation will only work with unlit shaders. If want to bake a shader with full integration of lighting and shadows, you would have to look into using theDrawMesh function.</p><p><strong>Save texture to disk</strong></p><p>At this point, we should have the baked shader texture map in the render texture. A few googles were all I needed to figure this out, as this part of the process is quite common. The steps involve converting the RenderTexture to a Texture2D , and then encoding the result to a PNG. This code can be found in ShaderBaker.cs .</p><p>Woo! Now we have a .png texture representing the unlit shader of choice. However — as usual — there are always <em>fundamental</em> problems that arise. If you try using your new texture as _MainTex on any default Unity material, you may see black artifacts around the edges of the UV islands—</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a39Z3p2APSnNCDMkeU5hkQ.png" /><figcaption>Artifacts caused by blackness around exact uv seams</figcaption></figure><p>This is because the texture was baked using exact UV coordinates, and does not account for the sampling variances that occur when sampling a texture at the edges. To combat this problem, I found that other modeling softwares implement “island border expansion” on new baked textures, which is simply a blending operation to expand the border.</p><p>I decided to go about this “island border expansion” by implementing a second dilation pass on output texture.</p><p><a href="https://en.wikipedia.org/wiki/Dilation_(morphology)">Dilation</a> is a method of expanding shapes that is originally defined for binary ( black or white ) images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*Zw6XeU_kijtNi-7vCW7DHQ.gif" /></figure><p>The algorithm takes a structuring element, in this case a 3x3 tile, and iterates over every pixel of the image by centering the tile at the pixel. If there is a white element within the tile, we convert the tile to white.</p><p>To expand this to colored images, we need a different factor to convert the tile. I decided to have the structuring element operate on the difference of the pixel color to a predefined background color. If there is a pixel within the structuring element who’s color value is <em>far enough away</em> from the background color, we can convert the given pixel.</p><p>This implementation can be found in Dilate.shader . To incorporate this into our existing setup, we add the following lines to the baking code:</p><pre>...</pre><pre>Graphics.DrawMeshNow(M, Matrix4x4.identity);<br>Graphics.SetRenderTarget(null);</pre><pre>...</pre><pre>// create a second render target <br>RenderTexture rt2 = RenderTexture.GetTemporary(width, height);</pre><pre>// use the dilate shader on our first render target, output to rt2<br>Graphics.Blit(rt, rt2, dilateMat);</pre><pre>// save rt2 to png<br>SaveTexture(rt2, objectToBake.name);</pre><pre>// reset <br>RenderTexture.ReleaseTemporary(rt);<br>RenderTexture.ReleaseTemporary(rt2);<br>GL.PopMatrix();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*EP7-yLUg1uvfc1b0MuxLGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*_Fen6gCEUMjm-uZteOZJKQ.png" /><figcaption>Before &amp; after dilation</figcaption></figure><p>This expands the textures nicely! One caveat is that this implementation of dilation only works if the background color of the texture is distinct from the colors of the shader. I added a property in ShaderBaker.cs to set the background color :)</p><p>Also, there still are veryyy small artifacts at the seams, and I have yet to find out what’s going on there -__-</p><p>Since the code is pretty choppy in this article, I would really recommend looking through the code in the <a href="https://github.com/sneha-belkhale/shader-bake-unity/blob/master/README.md">github project</a>. Here is a summary to navigate the code:</p><p>UVUnwrap.shader — this shader is a duplicate of the one you want to bake, except with the vertex shader modified to render the vertices in UV space.</p><p>Dilate.shader — this shader is responsible for the dilation post processing of the output texture.</p><p>ShaderBaker.cs — attach this script to the camera, it is responsible for rendering the mesh to a texture. It has public fields where you should place the object you want to bake, a material with the unwrapped version of the shader you want to bake (UVUnwrap.shader), and a material with the dilate shader (Dilate.shader). You should also set the backgroundColor property to be a color that is distinct from the colors in your shader.</p><p>That should be all~~ was a fun exploration for me and hope it helps a dev out there :)</p><p>❤ <a href="http://h/">snayz</a></p><p>Check out other related repos @<a href="https://github.com/sneha-belkhale"> https://github.com/sneha-belkhale</a></p><p>Other VR/Graphics projects @ <a href="https://codercat.tk/">https://codercat.tk</a></p><p>And renders / screenshots @ <a href="https://www.instagram.com/snayss/">https://www.instagram.com/snayss/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b524569d7384" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploration into Image Based Procedural Generation (Unity)]]></title>
            <link>https://snayss.medium.com/exploration-into-image-based-procedural-generation-unity-8f9fa7de10c1?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f9fa7de10c1</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[procedural-generation]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Tue, 16 Jul 2019 05:10:56 GMT</pubDate>
            <atom:updated>2021-12-02T07:21:23.051Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-OVB6u0-YGlxwca9m6sSQ.png" /></figure><p>I watched this cool talk by Anastasia Opara called <a href="https://vimeo.com/261901560"><em>Creativity of Rules and Patterns: Designing Procedural Systems</em></a><em> </em>and since I have a soft spot for anything procedural, I was immediately inspired to play around with the concept.</p><p>In the talk, Anastasia describes an approach to procedural composition that imagines every element as physically weighted, and the goal is to balance the system around the central point. She uses a modified version of Newtons Law of Universal Gravitation to mathematically calculate the next elements position and mass that maximizes the equilibrium of the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VwH9EeqnP2lMfmZS5OPpXA.png" /><figcaption>screenshot from <a href="https://vimeo.com/261901560">Anastasia’s talk </a>. Red is the original element, Green is the element we are trying to optimize. In the optimal state, the yellow vector will have a magnitude of 0.</figcaption></figure><p>I found it really interesting how she brought concepts from the physical world to solve an artistic composition problem — and decided to try it out for myself in Unity. In the GIF below, the red cubes position and scale(mass) changes as I change the position and scale of the two blue cubes, in order to maximize the equilibrium with respect to the central sphere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATR07GIk3TziGKc6aVclPw.gif" /></figure><p>This was fun to play with, but I came to a <strong><em>fundamental</em></strong> problem. The third cube puts the system in equilibrium, so there’s no need for a fourth cube! Of course there are ways around this ( moving the central point, etc. ), but I felt like taking the exploration in a new direction.</p><p>I started reading about basic principles of design and composition, just to get more familiar with the subject. <a href="http://www.scholarpedia.org/article/Gestalt_principles?__hstc=77520074.36a0ddae8e24bce7c0af0efdd41a6531.1445731200144.1445731200145.1445731200146.1&amp;__hssc=77520074.1.1445731200147&amp;__hsfp=1314462730">Gestalt’s principles of visual perception</a> make you question things you always knew but never paid attention to, such as why we perceive objects to be part of a group. I also stumbled upon some compositional techniques, such as having directional elements that promote <em>flow</em> by drawing your eyes from one element to the next…</p><p>Flow… it would be cool to have a generation pattern that flowed…</p><p>The <a href="https://en.wikipedia.org/wiki/Diamond-square_algorithm">Diamond Square algorithm</a> is a fractal technique used for terrain generation and has a really beautiful flow… what if I could use this algorithm to drive the generation? I thought about coding up the algorithm and storing the resulting values into a texture that I could use realtime. But since I just needed a texture at the end of the day, I decided to make life easier and use a pre-made image of the diamond square algorithm —</p><p>I was excited by this idea because if the technique worked out, you should be able to get new results by swapping out the base image :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TspYDeHZrwIqIT8XBxAzxw.png" /><figcaption>infinite diamond square fractal by<a href="https://www.jasondavies.com/plasma/"> Jason Davies</a></figcaption></figure><p>The overview of the algorithm I had in my head went something like this :</p><ul><li>Start at arbitrary point on the image.</li><li>Chose the next cube’s point to be on of the 8 neighboring points ( at a given step size ) that minimizes the following two values:</li><li>Difference in color value.</li><li>Dot product of the previous and current direction of motion. This is so that the cubes are inclined to move in a flowing pattern.</li></ul><p>I had parameters to control the step size, randomness applied to choosing the neighboring point positions, and weights of the minimization steps —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*kRSdiddJGtVyYg7yw1RHqw.gif" /><figcaption>cubes are generating by minimizing the color difference from reference image, and angle of movement</figcaption></figure><p>Clearly the overlapping cubes were a problem — so I made a world grid that had as many units as the texture (2048 x 1024 in this case), and made sure every new cube was not intersecting with the filled world grid positions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*0790YRTuvMBOjxbnb5JvRg.gif" /><figcaption>fsafa</figcaption></figure><p>So at this point, the cube sizes look kind of neat, and they were just cycling through 1–5 units.</p><p>For further exploration, I thought I would apply a modified version of Anastasia’s compositional approach, where we solve for the next cubes size by maximizing the equilibrium of the position and sizes of the previous N cubes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*eXAp9x0JNtqElBldd55tWg.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umlQHd8pYa9-oy-3vr3p3A.png" /></figure><p>IMHO I feel like just cycling through predefined scales was more reliable, but the balancing approach definitely has something interesting about it.</p><p>Soo that sums up the exploration — in the future I would like to take this exploration and tune it for a specific goal, such as alien cities, forests, or caves. It would also be cool to optimize the problem for a first person view, instead of only thinking of the 2D top down scattering problem.</p><p>Check out the Unity source code @ <a href="https://github.com/sneha-belkhale/procedural-image-based-scattering">https://github.com/sneha-belkhale/procedural-image-based-scattering</a></p><p>Other projects @ <a href="https://codercat.tk/">https://codercat.tk</a></p><p>Renders / screenshots @ <a href="https://www.instagram.com/snayss/">https://www.instagram.com/snayss/</a></p><p>And some results with other reference images below ❤</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zREVH6VRO_Gn1wRzrZbQkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1btynXwKY4aqT0RDdk3pGQ.png" /><figcaption>blurry galaxy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--QHvpceYXmSRIbDWzBLHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PT6uaeGYRVcXP0i0Uk-j3g.png" /><figcaption>its jupiter!!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6MnoeDFlkBD8Af1Q0gL6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qtKjn_2Aojp0y5-F5UhLg.png" /><figcaption>without a background image</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f9fa7de10c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[making of webvr experience, three body]]></title>
            <link>https://snayss.medium.com/making-of-webvr-experience-three-body-a45d4b75b1d2?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/a45d4b75b1d2</guid>
            <category><![CDATA[vr]]></category>
            <category><![CDATA[three-body-problem]]></category>
            <category><![CDATA[a-frame]]></category>
            <category><![CDATA[webvr]]></category>
            <category><![CDATA[oculus]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Tue, 11 Jun 2019 14:33:22 GMT</pubDate>
            <atom:updated>2021-12-02T07:22:37.477Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/u/f26ed4afb87c">Kirill</a> and I made our second WebVR experience, <a href="https://codercat.tk/three-body">Three Body</a>. It’s a story experience based on the sci-fi novel <a href="https://en.wikipedia.org/wiki/The_Three-Body_Problem_(novel)"><em>Three Body Problem</em></a> by Cixin Liu.</p><p><em>Three Body Problem</em> tells a really amazing story about humanity and interplanetary contact. In the book, the main character plays a WebVR simulation where he experiences life on Trisolaris — a planet in the Alpha Centauri galaxy that lives in the chaotic orbit of three suns. The visual imagery of this planet was captivating, and left me inspired and dreaming of all the shaders I could write to recreate this world…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2qZ_oz_EL3oHUCMCoUMKSw.png" /></figure><p>This project was quite different than most of our previous work, since our goal was to create an immersive experience with a story — instead of making another technical demo.</p><p>.. and we learned that this step from a technical demo to an experience with a story was a hard one that really adds to the scope and complexity of the project. All of a sudden we were asking questions such as “Will the user understand what to do here?” or “Is this speech too long for the user to stay focused?” instead of our usual aesthetically focused demo questions about shaders or performance.</p><p>So let me start from the beginning. The project took around 4 weeks, and in the first week of starting this project, we had written about 80% of the code. We had an apocalyptic environment with a procedural sky shade that reflected the position of the three procedurally animated suns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uypramzO8S9EGLa4frD2og.png" /></figure><p>Our main character was a nice floating #FF00FF color box ^^ — character design was very new for us :) We had to find a balance between what would fit the aesthetics of the story but also stay within our technical / time limitations. We decided that character animation would be out of the scope of this project… meaning no limbs. We wanted to have speech but did not want to show a talking animation… so no mouth either.</p><p>That left us with a mouthless, limbless creature… sounds rough but we were able to brainstorm some cool masked, hovering designs :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w5i8RQGnfU_zUHoOv_o9Hw.png" /><figcaption>Early character sketches, thinking about cape patterns with a three sun motif.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*ViauyNipVpiNWt470eTWDg.png" /><figcaption>Original graffiti in Seoul, South Korea, that inspired the mask</figcaption></figure><p>After some iterations between Houdini and my sketchbook, we ended up with a scholar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCgVHiDUzswu_rwfpIZPkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VxwiVI0FLDABQihaWdVaUg.png" /></figure><p>Now we had a mystical scholar hovering around our scene, and a Google Doc of his monologues. We thought about recording his voice ourselves, applying some strong filters in adobe audition, or maybe getting a friend to be a voice actor…</p><p>To be honest, I thought that this step was just way out of our expertise. I thought it would be an impossible hurdle and we would just end the project here with a purely visual <em>demo</em> where you just experience the beauty of the planet 0____o</p><p>But then, plot twist! Kirill checked on the state of the art text to speech algorithms — and it’s better than Siri! We found a website where you can paste in your text, select your lead voice (we picked Daniel, a nice British man with a deep coarse voice), and out comes a convincingly realistic MP3!</p><p>We bypassed some restrictions in order to make requests directly to the API from the terminal with unlimited word count (ask <a href="https://medium.com/u/f26ed4afb87c">Kirill</a> for details), and started converting our script to speech.</p><p>This website accepted <a href="https://developers.google.com/actions/reference/ssml">Speech Synthesis Markup Language</a> which allowed us to modify the generated speech. We used markups such as break time and prosody rate, but that’s pretty much it. We found the markup language pretty limited in general — it’s hard to markup an emotional statement such as “ quick hurry to the pyramid!!” We took this technical limitation into consideration and built it into the persona of our character, making him a more stoic, mumbling, and sarcastic scholar :)</p><p>After sharing with some friends, some were surprised to discover it was AI!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILUHXpFSV8jyiJ8A91KUJw.jpeg" /><figcaption>shot of our apocalyptic scene, hire me as a VR photographer?</figcaption></figure><p>At this point, the experience was more or less functional. The character comes to you from a distance and starts telling you about the wonders of his civilization... until three suns come out over the horizon and the world burns into flames. While the scene had some beautiful visual and dialogue moments, something felt wrong — it was missing interaction.</p><p>The scholar had long monologues, and you play a wallflower patiently listening… Even though the monologues were beautifully written, we needed a way to engage the user so that they feel like they are actually part of the scene.</p><p>After some brainstorming, we came up with a few ideas. We incorporated a “tour” element, where the scholar guides you to some key spots of the environment, saying lines like “I want to show you something, come, follow me”. This seems like a very simple touch but it was actually quite effective — it broke up the monologues with periods of walking and also made it feel like the scholar acknowledges your presence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9C-wPMRFlY_Em2WTfB76yw.png" /><figcaption>Giant pendulums to hypnotize the sun god into a deep slumber</figcaption></figure><p>We also added a win state, so you can save yourself from the heat of the three suns by completing certain actions. To complement the story, we added some giant pendulums that the scholar believes “have a hypnotic effect on the sun god”. The scholar asks you to swing the pendulums to help keep the planet in a stable harmony.</p><p>These small additions helped the overall engagement level of the experience, yet it still feels slightly lacking in this regard. It would be awesome to have the characters speech actually depend on your actions… but this would take the project much farther than originally planned.</p><p>To conclude, making an interactive story base experience was fun but challenging — we spent a lot of time thinking about the usability and design, instead of just technical details. It was hard to strike a balance between our technical abilities and requirements of the story we want to tell. However we are quite happy with the result and encourage you to check it out <a href="https://codercat.tk/three-body">here</a>, and <a href="https://github.com/Kif11/three-body">github</a> for the devs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwoC1MS4-XgWE6kM_boOvQ.png" /><figcaption>Trisolaris</figcaption></figure><p>Also can check out other projects @ <a href="https://codercat.tk/">https://codercat.tk</a></p><p>And renders / screenshots @ <a href="https://www.instagram.com/snayss/">https://www.instagram.com/snayss/</a></p><p>❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a45d4b75b1d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[making of webvr demo “monster or friend”]]></title>
            <link>https://snayss.medium.com/making-of-webvr-demo-monster-or-friend-103befe0e5b5?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/103befe0e5b5</guid>
            <category><![CDATA[webvr]]></category>
            <category><![CDATA[oculus-go]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[virtual-reality]]></category>
            <category><![CDATA[a-frame]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Sun, 21 Apr 2019 11:49:44 GMT</pubDate>
            <atom:updated>2021-12-02T07:22:59.798Z</atom:updated>
            <content:encoded><![CDATA[<p>For those who are curious, <a href="https://medium.com/u/f26ed4afb87c">Kirill Kovalevskiy</a> and I thought we would share some behind the scenes of our first WebVR demo, <a href="https://codercat.tk/">monster or friend</a>.</p><p>This project was created using <a href="https://aframe.io/">A-Frame</a> and <a href="https://threejs.org/">three</a>.js in about one week. To be honest, I am generally not a framework person and try to stay as low level as possible while still humane (no openGL lol) - but using A-Frame was probably the right choice for this project.</p><p>A-Frame gives you a working controller in just one line, including the controller model, positioning, and highlighting user interactions on the model itself. Also, I was able to open this demo on Chrome, Oculus Go, and my Pixel 2 phone and the views / controls just worked, and this was really cool and something that I wouldn’t want to program from scratch. I also appreciate that A-Frame is an Entity Component System, which may take some getting familiar to if you are used to coding three.js examples in one html file.. but I think it is worth it for organizational purposes.</p><p><strong>THE CREATURE</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zQsRuO4CCro-TsI0W79fKw.png" /></figure><p>The creature was the starting point of this demo. I have been interested in procedural animation in the last few months, and contributed a little to this <a href="https://jsantell.github.io/THREE.IK/examples/">repo</a> that implemented inverse kinematics for three.js. I wanted to play around more with this library, so I thought I’d make a 25-legged sea / space creature : )</p><p><a href="https://en.wikipedia.org/wiki/Inverse_kinematics">Inverse kinematics</a> is really awesome, it adds a complexity that would be very hard to manually animate. Every limb of this creature is one bone chain, with a target point ( the head ). Inverse kinematics reverses the forward kinematic equation to determine the bone positions and rotations such that the last bone reaches the target point at every step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-5NmMPZX9i4QhqzWYVPgHA.png" /><figcaption>inverse kinematics example from three.ik</figcaption></figure><p>After playing around with randomized target point movement, a tweening library called <a href="https://github.com/tweenjs/tween.js/">tween.js</a>, and the forever handy sin function, I found a pretty organic effect that brought the creature to life.</p><p>Making a shader for the creature was the next step, I blended some colors along the UVs, changed the colors over time, and used an opacity map to add complexity.</p><p>My creature was ready for the world.</p><p><strong>THE COLORS</strong></p><p>Colors are really hard, and also really important for the purely visual demo that we were building. At this point, we had a nice environment with a spacey sky sphere, little dust particles, and the creature. We decided to consolidate these elements with color themes of 7 colors: 2 colors for the sky, 1 color for the particles, and 4 colors for the creature (it transitions between two states).</p><p>We organized these colors into one color component that would be added to all elements of our scene, and then got carried away for a few hours playing around with the endless color possibilities. We used this <a href="https://colorhunt.co/">color palette generator </a>for initial inspiration, sampled some colors from images we like, and tried the colors from our website logo :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*gMRrg-7VUndbVw8wrohC3Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRZzgwuTZ3n1aJN3kg1pVQ.png" /><figcaption>❤ cyberpunk seoul ❤</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ru2q_v3qo-h-MTuxWW04NA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UeDfJKwPStGcSslFTyVmQ.png" /><figcaption>❤ codercat ❤</figcaption></figure><p><strong>THE CONTROLLER</strong></p><p>I mentioned before that the A-Frame controller was awesome because a lot of the functionality was built in… but not all of it. Since movement based on controller input is not easily defined in VR, the A-Frame devs decided not to include it as part of the library. However, it was not too difficult to define our own movement schema, where the user can move forwards and backwards with the trackpad, and change color theme on trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTpzHMm6zvIf-cQH-8gLSg.png" /><figcaption>controller helper in VR</figcaption></figure><p>Another thing we thought it was important to add was a tutorial for the controller, to show the users how to move around the scene. We made this 3D Text in HoudiniFX, and added a subtle fresnel shader to the controller. This tutorial hovers in front of the camera until the users first interaction.</p><p><strong>THE MUSIC</strong></p><p>We felt like the creature might need some entertainment in its new home, so we decided to add in some music to its world. I was dreaming of something ambient and deep, and decided to create it in <a href="http://foxdot.org/">FoxDot</a>, an awesome framework to make music using Python. I used simplex noise to drive the ambient sounds, and recorded it with SoundFlower and Quicktime ~~ <a href="https://twitter.com/snayyss/status/1119306325203095553">here</a> is a little clip from the process.</p><p>Check out the source code @ <a href="https://github.com/Kif11/monster-or-friend">https://github.com/Kif11/monster-or-friend</a></p><p>Other projects @ <a href="https://codercat.tk/">https://codercat.tk</a></p><p>And renders / screenshots @ <a href="https://www.instagram.com/snayss/">https://www.instagram.com/snayss/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103befe0e5b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[letter from me to an aspiring “digital nomad”]]></title>
            <link>https://snayss.medium.com/letter-from-me-to-an-aspiring-digital-nomad-4d65a4ad6b27?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d65a4ad6b27</guid>
            <category><![CDATA[remote-working]]></category>
            <category><![CDATA[traveling]]></category>
            <category><![CDATA[lifestyle]]></category>
            <category><![CDATA[digital-nomads]]></category>
            <category><![CDATA[career-change]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Fri, 17 Aug 2018 07:25:01 GMT</pubDate>
            <atom:updated>2018-08-17T07:29:09.573Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDqx3QPdJ6SeNquIl0Vhjg.png" /></figure><p>Hey &lt; Friend &gt;,</p><p>Sorry for the late response, its nice to hear that you are looking into the “digital nomad” lifestyle. I’ll try my best to answer your questions, but I want to start by saying that you should just do it :) I was overthinking a lot before starting this journey, thinking about all the possible things that could go wrong. But since these are all new experiences, the only way to answer these questions for yourself is to try it.</p><p>Anyways, I graduated UCLA with a Mathematics/Programming degree, and went into the field of computer vision engineering after school. I interned at NASA for 3 months and then worked at the autonomous driving division of HERE maps for about 1 year, working mostly in C++ and python. I was doing some side projects in 3D computer graphics using three.js, and started getting pretty interested in the field of computer graphics because it combined my artistic and math skills.</p><p>The first few months of traveling, I was taking it easy and working on some personal projects/ doing more adventurous trips. Around March this year, I started applying for remote jobs. I tried Upwork, but didn’t like it because the pay was minimal and the projects were very short term. I was looking for something long term, so I decided to just apply to startups as a normal applicant on AngelList. I was lucky to find an augmented reality company based in SF that was open to hiring remote workers, and have been working with them doing AR graphics related things for the last 6 months.</p><p>I started because I was friends with a great group of people in San Francisco who began following this digital nomad entrepreneur named Pieter Levels (you should google him if you haven’t heard of him already). We had a lot of conversations about the subject, and started questioning why we follow the system, commuting to our 9–5 day jobs just to work on the same computer we have at home. I felt like there has to be another way to live, and theres no better time than now to try it. I remember reassuring myself that “it’s just an experiment”, and if it doesn’t work out, I can always come home and get back into the SF lifestyle.</p><p>I don’t really wish I had known any of the negative things when I started, because then maybe I wouldn’t have started this experience. So I guess I wish I had known that I can adapt to new things better than I thought. Oh, also that Charles Schwab debit cards refund all foreign ATM fees ( amazing ).</p><p>One of the best experiences was probably meeting a very cool live coding (music) community in Bogota, Colombia, and doing a small performance myself after taking a course there. Another awesome experience was doing a bike trip from Mexico City to Guatemala City.</p><p>Worst experiences.. I guess the general sadness that happens sometimes when you feel alone in new cities. Integrating into new cities is difficult, but the challenge is interesting / makes you learn something about yourself.</p><p>So, hope that answered everything, let me know if you have any other questions!</p><p>Best,</p><p>Sneha</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d65a4ad6b27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buy geeky feminist prints from the terminal]]></title>
            <link>https://snayss.medium.com/buy-geeky-feminist-prints-from-the-terminal-c53468122152?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/c53468122152</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[product-hunt]]></category>
            <category><![CDATA[feminism]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Tue, 10 Oct 2017 19:23:07 GMT</pubDate>
            <atom:updated>2017-10-10T19:24:00.381Z</atom:updated>
            <content:encoded><![CDATA[<p>TLDR: If the terminal &amp;|| feminism are your jamz, check out <a href="http://codercat.club/terminalprints.html">http://codercat.club/terminalprints.html</a>.</p><p>&amp; <a href="https://www.producthunt.com/posts/terminal-prints">https://www.producthunt.com/posts/terminal-prints</a></p><p>One day my roommate came home wearing a tshirt that said:</p><p><strong>while ( in_crib ) {</strong></p><p><strong>for ( int i = 0; i &lt; 3; i++) { drop ( like_hot ); }</strong></p><p><strong>}</strong></p><p>I was obviously very entertained by this… and then got an idea. What if I could reword some common feminist slogans in various programming languages? It felt like an interesting way to compliment the women in tech movements, by creating awareness and maybe even bringing a community closer together. I brainstormed for a bit, thinking of how to play with my favorite bash commands, and came up with a list of slogans that were unreasonably amusing to me.</p><ul><li>rm -rf patriarchy</li><li>from feminism import *</li><li>assert ( woman == man );</li><li>apt-get install feminism</li><li>nastywoman.smash( patriarchy );</li><li>def wakeup ( self ): return “flawless”</li></ul><p>If I was so amused by these prints, there must be other like-minded people that would enjoy them as well, sooo it was time to put them on the web.</p><p>There are quite a few sites that facilitate printing custom designs onto products such as tshirts, mugs, posters, stickers, etc. Kirill and I browsed around and made accounts on various sites to test out the interfaces, and eventually settled on Redbubble as it seemed like the path of least resistance. Using Redbubble, we could easily upload a design onto a nice selection of items in one click, while also getting the benefit of the Redbubble marketplace bringing traffic to the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ScwBqzHdav4AMUNCOCXH_g.png" /><figcaption>Redbubble’s one click upload is awesome.</figcaption></figure><p>There was still one problem, I could not stand the Redbubble shop interface. I found it quite difficult to navigate, and not an effective interface to deliver the style, emotion, and message that I was imagining for the feminist — tech slogans.</p><p>I decided to make my own interface for the Redbubble shop on Strikingly, because I was already familiar using this service to display my other <a href="http://tkfs.strikingly.com/">tshirt extravaganza</a> in 2015. However, I slowly found that these designs were not graphic enough to hold their own on a web page, they were just text slogans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LRFCZkHAjQ3aOZ_69pfLuw.png" /></figure><p>Then, I remembered my homie <a href="https://github.com/kif11">Kirill</a> suggesting how cool it would be if I made a package that allows you to buy these t-shirts from the terminal. Since they are all command line phrases anyways, all you really need to decide which design you want is to decide on a slogan that can be presented to you in its native location. We pushed this idea aside at the time because it seemed difficult to integrate a method of payment. However, if the terminal was replicated on a browser, we could easily redirect the user to the item on Redbubble where they can complete their payment!</p><p>The terminal seems like a minimalistic interface, but attempting to recreate it with html and css made me realize how magical it truly is (newlines, search history, text fitting, oh my!). Everything you want to do with web has probably been done before… so I checked GitHub and wallaaa there it was, an open source terminal in your browser called <a href="https://github.com/sourcelair/xterm.js/">xterm.js</a>!</p><p>This is an awesome repo. Out of the box, you can basically access your own file system from a terminal in the browser. Super awesome, but I did not really want people to be accessing my files on the web… So I hacked into the xterm.js repo and found a section that allows you to run a fake terminal, basically an empty terminal with no file system but all the beautiful terminal functionality organized in div elements.</p><p>At this point, it was trivial to add my own commands, list the available slogans, redirect the user to the chosen Redbubble page, and some other terminal essentials (such as hitting the up arrow to see previous commands!). Surprisingly the xterm.js terminal was so functional that it supported <a href="http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html">bash colors</a> without me having to add any code! So I had to decorate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BiJVLILOrD-q4yrWYjd1zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KF9gcK-k41YDE-uDiIskUA.png" /><figcaption>FEELS LIKE MAGIC</figcaption></figure><p>I am very serious when I say that the toughest part about this project was probably closing a color scheme, and which ASCII font to use for the logo from this <a href="http://patorjk.com/software/taag/#p=testall&amp;f=Graffiti&amp;t=Dope%0A">ASCII Font Generator</a>.</p><p>Anyways, I thought it turned out pretty cool, and is an interesting concept for a feminist geeky tee store.</p><p>Hope y’all enjoy, there are secrets in the terminal if you know how to find them …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56UpxLyYKM5yQSFaD4KURA.png" /></figure><p>Check out the source code @ <a href="https://github.com/sneha-belkhale/codercat-prints">https://github.com/sneha-belkhale/codercat-prints</a></p><p>Product Hunt page @ <a href="https://www.producthunt.com/posts/terminal-prints">https://www.producthunt.com/posts/terminal-prints</a></p><p>And other projects @ <a href="http://codercat.club/">http://codercat.club</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*ZrFKtffDo84q5VIxvalyIQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c53468122152" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JPEG Compression]]></title>
            <link>https://snayss.medium.com/i-met-this-artist-during-sf-open-studios-that-had-a-very-unique-style-of-decomposing-images-into-56a025e9cf6f?source=rss-d5b5fc1296ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/56a025e9cf6f</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[compression]]></category>
            <category><![CDATA[opencv]]></category>
            <dc:creator><![CDATA[Sneha Belkhale]]></dc:creator>
            <pubDate>Mon, 09 Oct 2017 05:12:43 GMT</pubDate>
            <atom:updated>2017-10-09T05:19:16.616Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*60XXeJQpfZzI1TgAe8mNEw.png" /></figure><p>met this artist during SF Open Studios that had a very unique style of decomposing images into individual square blocks that are incomprehensible when standing close to the painting, but form figures as you step away. My friend mentioned that this effect reminded him of jpeg compression when using a very large compression block size.</p><p>I had heard of jpeg compression before (saving photoshop files to jpeg, etc), but was suddenly curious to find out how it works under the hood. After reading that the main process involves the discrete cosine transform, I had a flashback to my days at UCLA studying Fourier transforms and was instantly hooked.</p><p>I found some <a href="http://www.whydomath.org/node/wavlets/basicjpg.html">articles</a> and <a href="https://www.youtube.com/watch?v=_bltj_7Ne2c&amp;t=779s">video tutorials</a> describing the process of discrete cosine transforms and quantization matrices, but the subject matter is pretty dense to get on the first go. I also have this thing where if something is interesting to me, I have an urge to understand every piece of down to the core.</p><p>So, the only option was to implement my own jpeg compressor, and maybe find some artistic value in the process.</p><p>The basic steps are as follows:</p><ol><li>Divide your image into n x n squares.</li><li>Transform every n x n image block using the discrete cosine transform:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*wG7fp14tQkbIeTg-IPRTbQ.png" /></figure><p>Friendly formula for sure.. Essentially all this formula is doing is transforming the image block from pixel intensity to frequency domain. In the frequency domain, we can keep the low frequencies and get rid of the high frequency data without sacrificing too much image quality.</p><blockquote>&lt;&lt;&lt; IF THE DCT GIVES YOU NIGHTMARES, PROCEED TO STEP 3 &gt;&gt;&gt;</blockquote><p>The image below helped me understand how the DCT was being applied to the image, for an example where n = 8. Think of each square as a set of weights specified by grayscale value ( top left is uniform ). Multiplying the first square by the entire 8 x 8 image block will give you the [0,0] value of our 8 x 8 block in the frequency domain. Multiplying the second square (first row) by the entire 8 x 8 image will give you the [0,1] value of our 8 x 8 block in the frequency domain. Ponder over this for a while and it will make sense that the most information is stored in the top left corner of our frequency domain block… or just admire the matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*rLZMwoQWXvv4432i8cRdAQ.png" /><figcaption>Discrete Cosine Transform Matrix</figcaption></figure><p>3. The quantization step. This is the step where we are losing information by removing the high frequency components. I currently quantize the data by dividing each component by a uniform number, and discard the number if the result rounds to 0. There are more complex methods of quantization, such as dividing the top left data by smaller numbers because we know this is where the most information is stored. However, there is no absolute standard for choosing your quantization matrix. Some say it is sort of a black art, and this is definitely something I want to look into more in the future.</p><p>4. Dequantize by multiplying back the same coefficients from the quantization matrix, this is where you can see the loss of information as the values you rounded down to 0 in the last step are now gone :0</p><p>5. Apply the Inverse Discrete Cosine Transform to return to pixel intensity domain.</p><p>Applying these steps to every block in a large image requires quite a lot of operations -&gt; lengthy runtimes. However, I found some ways to decrease computation time, such as precomputing DCT and IDCT coefficient matrices.</p><p>Anyways, if interested in the mathematics behind jpeg compression, I would highly recommend checking out my source code below. It has some pretty detailed comments that should help illustrate the process, and also allows the user to play around with the image block/quantization parameters (which is pretty fun).</p><p>source code:</p><p><a href="https://github.com/sneha-belkhale/jpeg-compression-art">https://github.com/sneha-belkhale/jpeg-compression-art</a></p><p>Orrrr… just enjoy some cool pics that I generated using some pretty lossy quantization values~</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*GWn8Sy1V9tlgEdNOMWC4bA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*x63u73UTrriF-kRnvRlaCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*LRghUG8FX8UNZ4_y6c6UIw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56a025e9cf6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>