Testing shaders locally

20 July 2025 . 7min read

Why?

As usual I was crawling youtube, watching random videos. I came across this video showing how to create shader art. And there I found my next thing that I was gonna nerd about, Shaders. I went to the website which the guy showed in the video, shadertoy.

I was watching all the amazing shader art people had made, trying to understand them. After 2 hours of dedicated and focused work, I was finally able to understand that I couldn't make sense of anything. I went on youtube again to learn and to understand shaders. I figured out a little bit about shaders, but I was still not able to understand what they were.

Whatever I learned from youtube and other google searches, I want to try out making my own shaders. I wrote some basic shaders I saw on youtube and tried to understand them. I was able to understand the basics of shaders, but I was not able to make anything.

Cut to July 18, 2025, I was at home and wanted to try writing my own shaders again in my free time. But........ my internet was so bad that I couldn't even open shadertoy.

The solution

The real solution would be to fix my f****ing internet connection. But that wasn't upto me, I was using mobile internet and I didn't have wifi at home.

So I thought "what if shadertoy was offline?". I tried to run the website locally, but I couldn't. I searched for a local version of shadertoy, i.e. something that could display shaders on my local machine. Most of the solutions were either too much for what I wanted or didn't work. So I decided to take matters into my own hands.

fine I will do it myself

The plan was to make a simple application that would display the shaders on my local machine. A simple glfw, glad and imgui application would do just fine.

Issues I faced

The first issue was obviously linking the libraries with cmake. I tried to link glfw, glad and imgui but the linker errors just fried my brain. Somehow the linking problem was solved.

I downloaded glad with OpenGL 4.6 and all the extensions. Yes, all of them. Through exhausting searches on Stack Overflow and Google, finally the shaders were showing up on screen. Next step was to make an interface with imgui so that the user can use shader files from his local machine. That was not really a problem, I just had to figure out how to do it, and I did. I also added a dropdown for the available OpenGl extensions. And a little note for people copy pasting shaders from shadertoy.

Adding on the base

The shaders were loading correctly but at this point the path to the directory that had the shader files was hardcoded into the executable. A native file picker would be appropriate. For this I found a library called tinyfiledialogs. Also added some things like a default shader, the option to only load fragment shaders and use a default vertex shader.

Results

The result was satisfactory for me. The goal never was to make a huge application for making shaders, just a place to view shaders locally that was simple and easy. Not sure if there is a better plan for this project in the future.

The last thing would be to add hot reloading for the shaders. I was thinking of using watchdog for this. But I didn't have time to do it. I will edit this story if I do it in the future.