Graphical Programming Weirdness

  1. Procedural Generation Heatmaps
  2. Creating A World Generator
  3. Graphical Programming Weirdness
  4. Project: Susminer

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:

Neat, but not what I desired.

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:

A slightly 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’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:

It almost resembled a sine wave! How Nice! Also the variable names I chose were just random letters, I’m not a mathematician and my Greek isn’t all that good so I figured whatever I threw at it was good enough. I also made it so it’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’d get these:

Images that resembled something! Sinewaves! Yes! They’re not perfectly smooth but that’s no big issue since we’re super zoomed in. If I had wanted to go crazy I’d do some subpixel stuff, make it look clean with nearest neighbor or some other smoothing algorithm, but that wasn’t in the cards for me. I wanted to make my faux clouds, and I was going to do it now!

And now I had my little semicircles somewhat smoothly making a little cloud pattern in the sky. With some more effort I’d have multiple layers of them moving at different rates indefinitely to imitate a moving sky. Or so it would be if it wasn’t for the fact that the animation of these wasn’t all that smooth, whether that be my code being bad and having no way to account for decimals or what not, or Unity’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’d just move them around the “proper” way, or what I call the boring way. Us programmers and designers are so spoiled with fancy tools like “Sprites” and “Animations” 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’ll make a complex post about an all new library I made for improving Unity’s manual texture manipulation (in code) tools. But then I’d have to make a library like that.