{"id":50,"date":"2022-06-24T08:22:55","date_gmt":"2022-06-24T08:22:55","guid":{"rendered":"https:\/\/trew.tk\/blog\/?p=50"},"modified":"2023-12-05T09:34:46","modified_gmt":"2023-12-05T09:34:46","slug":"graphical-programming-weirdness","status":"publish","type":"post","link":"https:\/\/trewest.dev\/blog\/index.php\/2022\/06\/24\/graphical-programming-weirdness\/","title":{"rendered":"Graphical Programming Weirdness"},"content":{"rendered":"<div class=\"wp-post-series-box series-susminer wp-post-series-box--expandable\">\n\t\t\t<input id=\"collapsible-series-susminer69dec780495b4\" class=\"wp-post-series-box__toggle_checkbox\" type=\"checkbox\">\n\t\n\t<label\n\t\tclass=\"wp-post-series-box__label\"\n\t\t\t\t\tfor=\"collapsible-series-susminer69dec780495b4\"\n\t\t\ttabindex=\"0\"\n\t\t\t\t>\n\t\t<p class=\"wp-post-series-box__name wp-post-series-name\">\n\t\t\tThis is post 3 of 4 in the series <em>&ldquo;Susminer&rdquo;<\/em>\t\t<\/p>\n\t\t\t\t\t<div class=\"wp-post-series-box__description wp-post-series-description\">\n\t\t\t\t<p>A game that never was.  Posts related to Procedural Generation and coding.<\/p>\n\t\t\t<\/div>\n\t\t\t<\/label>\n\n\t\t\t<div class=\"wp-post-series-box__posts\">\n\t\t\t<ol>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/trewest.dev\/blog\/index.php\/2022\/06\/23\/procedural-generation-heatmaps\/\">Procedural Generation Heatmaps<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/trewest.dev\/blog\/index.php\/2022\/06\/23\/creating-a-world-generator\/\">Creating A World Generator<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><span class=\"wp-post-series-box__current\">Graphical Programming Weirdness<\/span><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/trewest.dev\/blog\/index.php\/2023\/01\/12\/project-susminer\/\">Project: Susminer<\/a><\/li>\n\t\t\t\t\t\t\t<\/ol>\n\t\t<\/div>\n\t<\/div>\n\n<p>Whilst creating a fully code drawn sky system as a challenge to myself, I decided the best way to create clouds would be to apply some graphing math directly to code.  This did not yield the expected results.  Instead of a nice line of semicircles I got this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"937\" height=\"242\" src=\"https:\/\/trew.tk\/blog\/wp-content\/uploads\/2022\/06\/image-15.png\" alt=\"\" class=\"wp-image-51\" srcset=\"https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-15.png 937w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-15-300x77.png 300w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-15-768x198.png 768w\" sizes=\"auto, (max-width: 937px) 100vw, 937px\" \/><figcaption class=\"wp-element-caption\">Neat, but not what I desired.<\/figcaption><\/figure>\n\n\n\n<p>And so, as programmers do, I stared at my code looking or some sort of error.  When I had no idea what to do I decided to throw some random numbers out and see what happened, and got something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"96\" src=\"https:\/\/trew.tk\/blog\/wp-content\/uploads\/2022\/06\/image-16-1024x96.png\" alt=\"\" class=\"wp-image-52\" srcset=\"https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-16-1024x96.png 1024w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-16-300x28.png 300w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-16-768x72.png 768w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-16.png 1049w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>A <em>slightly<\/em> different pattern!  Progress?!  Eventually I thought to myself that this might be weirdness related to both floating point numbers, and rounding down to integers to draw on the image.  So I figured if I just used Unity&#8217;s tools I could change the numbers until I got what I had wanted in the first place.  And I also changed it to draw a sine wave instead of what I actually wanted for this purpose.  And that caused me to get this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"951\" height=\"257\" src=\"https:\/\/trew.tk\/blog\/wp-content\/uploads\/2022\/06\/image-18.png\" alt=\"\" class=\"wp-image-54\" srcset=\"https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-18.png 951w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-18-300x81.png 300w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-18-768x208.png 768w\" sizes=\"auto, (max-width: 951px) 100vw, 951px\" \/><\/figure>\n\n\n\n<p>It almost resembled a sine wave!  How Nice!  Also the variable names I chose were just random letters, I&#8217;m not a mathematician and my Greek isn&#8217;t all that good so I figured whatever I threw at it was good enough.  I also made it so it&#8217;d change one of the variables over time for convenience sake, which is why I also had a boolean to change it.  Anyways, with a bit more trial and error I&#8217;d get these:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"280\" src=\"https:\/\/trew.tk\/blog\/wp-content\/uploads\/2022\/06\/image-19-1024x280.png\" alt=\"\" class=\"wp-image-55\" srcset=\"https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-19-1024x280.png 1024w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-19-300x82.png 300w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-19-768x210.png 768w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-19.png 1486w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Images that resembled something!  Sinewaves!  Yes!  They&#8217;re not perfectly smooth but that&#8217;s no big issue since we&#8217;re super zoomed in.  If I had wanted to go crazy I&#8217;d do some subpixel stuff, make it look clean with nearest neighbor or some other smoothing algorithm, but that wasn&#8217;t in the cards for me.  I wanted to make my faux clouds, and I was going to do it <em>now!<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"278\" src=\"https:\/\/trew.tk\/blog\/wp-content\/uploads\/2022\/06\/image-17-1024x278.png\" alt=\"\" class=\"wp-image-53\" srcset=\"https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-17-1024x278.png 1024w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-17-300x81.png 300w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-17-768x209.png 768w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-17.png 1432w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"185\" src=\"https:\/\/trew.tk\/blog\/wp-content\/uploads\/2022\/06\/image-20-1024x185.png\" alt=\"\" class=\"wp-image-56\" srcset=\"https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-20-1024x185.png 1024w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-20-300x54.png 300w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-20-768x139.png 768w, https:\/\/trewest.dev\/blog\/wp-content\/uploads\/2022\/06\/image-20.png 1225w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>And now I had my little semicircles somewhat smoothly making a little cloud pattern in the sky.  With some more effort I&#8217;d have multiple layers of them moving at different rates indefinitely to imitate a moving sky.  Or so it would be if it wasn&#8217;t for the fact that the animation of these wasn&#8217;t all that smooth, whether that be my code being bad and having no way to account for decimals or what not, or Unity&#8217;s limitations when it comes to drawing a new texture every frame, I cannot truthfully answer.  But nonetheless, this was a days worth of work, and somewhat of a bust.  I ended up just making a cloud sprite and a script that&#8217;d just move them around the &#8220;proper&#8221; way, or what I call the <em>boring<\/em> way.  Us programmers and designers are so spoiled with fancy tools like <em>&#8220;Sprites&#8221;<\/em> and <em>&#8220;Animations&#8221;<\/em> how dare you not wish to recreate the wheel every time you make a graphical program!  But at least I can say, I tried to learn a different way.  Maybe next time I&#8217;ll make a complex post about an all new library I made for improving Unity&#8217;s manual texture manipulation (in code) tools.  But then I&#8217;d have to make a library like that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is post 3 of 4 in the series &ldquo;Susminer&rdquo; A game that never was. Posts related to Procedural Generation and coding. Procedural Generation Heatmaps Creating A World Generator Graphical &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[16,17,7],"post_series":[56],"class_list":["post-50","post","type-post","status-publish","format-standard","hentry","category-coding","category-gamedev","tag-c","tag-graphics","tag-unity","post_series-susminer"],"_links":{"self":[{"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":2,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/posts\/50\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=50"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/trewest.dev\/blog\/index.php\/wp-json\/wp\/v2\/post_series?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}