Interactive Audio Crystal Shader
When I started working on this project, all I knew was that I wanted to figure out a way to connect two of my favorite parts of game development - graphics and audio programming. I knew I wanted to create a shader that changed based on audio input, but I didn’t know what I wanted that to look like.
To get started, I searched around for different types of audio reactive shaders, and decided I wanted to start by making something with some sort of glow effect, a type of shader that was also relatively new to me. I jumped into a tutorial, and using Unity’s Shader Graph (plus a little bit of modeling in Blender) I started creating some crystals.
Hooray! Glowy crystals! Now, I had to figure out what I wanted to do with them. After some deliberation, I decided I wanted to mess with the emissive value of my shader. To start, I added to my shader to make the crystal glow level get brighter and dimmer over time with a sine function.
Now that I knew how I wanted my shader to react to audio, it was time to dive into the sound portion of this project. The music I used is a song I had made a little over a year ago that actually worked very well for this. I started working in Wwise, and ended up splitting the song I had into three different parts, a low, medium, and high part. Each of these was connected to its own audio bus, which was then being watched by a parameter in Unity.
Then, all I had to do was hook up a C# script to update parameters I had added to my shader with the information coming from Wwise.
Once I had this, I hooked up each of the three music parts to the three colors of my shader (base color, top color and bottom color). It took a bit of messing around to get these hooked up where I wanted them to be, and have a value that worked and caused the end result I wanted, but then I had a shader that reacted to audio in 3 different ways based on the volume of the audio bus.
And with that, my audio reactive crystal shader was complete. This is one of my favorite personal projects I've worked on, as I got to combine two aspects of programming that I really enjoy and am passionate in, and I got to expand my knowledge in both using Wwise and Unity/Shader Graph, both of which are extremely helpful tools that I use frequently. This project was a very fun process, and I learned quite a bit. Additionally, I have a neat little final product to show off, with my crystals reacting to a song that I designed.