Svelte Reactive Classes

I’ve been working on migrating my old PianoTypes project over from Vue to Svelte. So far the syntax has been much cleaner to use and has been an overall a great experience. My first and primary pain point thus far has been implementing a global reactive state for the piano. The Problem In Vue, it’s possible to add a reactive wrapper to any object. In my case, I had created a class containing all of the piano data and property methods so all I had to do was wrap this class in the wrapper and state is maintained across all instances of my piano class. ...

August 12, 2023

Some More GLSL

Vertex Shaders So far, I’ve been primarily writing 2D shaders to create patterns on a flat canvas. In practice, shaders can also be applied to 3D objects to manipulate not only their textures but also their shape. To start, let’s take a look at a simple 2D shader placed on a 3D cube. Notice that the texture remains flat but is effectively cropped onto the projection of the cube. Ideally, we’d like the texture to wrap over the cube instead. ...

July 19, 2023

JS Modules in Hugo

While writing this blog, I’ve been constantly finding a need to include various JavaScript libraries such as graphics libraries or text processors. I love the simplicity of Markdown but sometimes it can be really helpful to include more meaningful content and visuals to better illustrate a certain topic or idea. My most recent endeavor was adding an easy way to render shaders within each of posts which turned out to be a more painful task than I originally anticipated. Here, I hope to document some of my process of importing modules and hopefully make it easier for whoever is reading to import modules into their own Hugo blog. ...

July 14, 2023

Basics of Shader Fractals

Fractals are built off of a single pattern or formula, repeated constantly with smaller and smaller transformations. In glsl, this idea translates nicely into iterative coding with for loops. How to Make a Fractal I’ll be following kishimisu’s guide on shaders. Create a Shape First off, we can start by creating some base patterns that we want to design our fractal off of. In this case, we can start with a simple circle. ...

July 13, 2023

Some Casual Art

I’ve been thinking about drawing more casually, inspired by how others seem to sketch just for the joy of it, not tied to contests or big projects. I really admire how they just go with whatever they’re feeling, letting their ideas spill onto the page without worrying about a specific style. I’ve tried a few doodles myself, and it’s kind of neat to see them starting to share a certain look, even if I’m not sure what it means yet. ...

July 13, 2023

3D Matrix Rotations

Intuition of 3x3Matrix Transformations Rotations can be achieved by locking the desired axes of rotation and transforming the rest of the axes by \(sin\) and \(cos\). 3x3 matrices can be used to bend the coordinate space in 3 dimensions, effectively allowing any desired transformations to objects in that space. As the coordinate space is being transformed, it’s helpful breaking up the matrix into its unit vectors $$ \vec{a} = x\begin{bmatrix}1\\0\\0\end{bmatrix} + y\begin{bmatrix}0\\1\\0\end{bmatrix} + z\begin{bmatrix}0\\0\\1\end{bmatrix} $$ ...

June 15, 2023

Intro to Deep Learning

Neural Networks See Machine Learning How do you decide how many neurons to use per layer? One way is to start with all layers uing the same amount of neurons and continue adding them until they start overfitting the data Dropout: Regularlization technique to avoid overfitting. Leaves out data to better deal with general cases. 20%-50% dropout is a good starting range. Momentum: Helps finding the direction of next descent and prevent oscillations. Typical choice between 0.5 to 0.9 Epochs #times the whole training data is shown to netowrk during training. 1 epoch = one forward and one backward pass of all training data Back Propagation See Machine Learning ...

June 12, 2023

Overview of Probability

I’ve always had trouble understanding probability, especially when entering into the more theoretical aspects of it. Here, I want to cover some of the basic concepts and functions core to probability in an easily digestible format that I can refer to later on when I inevitably forget it all. Random Variable Whenever there’s a question of probability, you tend to have some range of possible outcomes sourced from a specific event. ...

June 4, 2023

Intro to Machine Learning

In preparation for a deep learning course I’m taking over the Summer, I’m taking a short intro course on machine learning to help prepare me for some of the fundamental concepts. I’ve been avoiding AI for a while but given its ongoing application in nearly everything now, I figure it’s more than worth getting my feet wet. ML Overview flowchart LR subgraph Shader Lifecycle direction LR d[("Dataset")] --> m(("Model")) --> o("Predicted Values") ---|compare with| a("Actual Values") -->|calculate| l["Loss"] l -->|training data| m end Loss Functions When we compare our predicted results to the actual results, how do we calculate the loss? ...

May 28, 2023

Handling Normals from Unity to Blender

While trying to import a plane from Blender to Unity, I ran into the issue of the normals facing the wrong direction once imported into Unity. This was particularly an issue when it came to vertex shaders as any vertex transform performed incorrectly. This crux of the issue is that Blender considers the z-axis to be the vertical axis while unity considers the y-axis to be. So, for a plane in Blender, the normals would face towards the positive z-axis but when imported to Unity, they remain so which to Unity is actually along the horizontal plane. Oddly, the actual model imports in the correct orientation, it’s just the normals that don’t adjust after import (which creates the mismatch problem of normals not facing the right direction. If the whole mesh and normals rotated equally, that’d be fine). ...

May 15, 2023