I've been wanting to study shader since I saw a computer science course named 'computer graphics' when I was at college. I was learning Unity around that time, so 'graphics' sounded so cool. Yet, my course schedule was already loaded and it seemed quite hard for me, who was neither majoring nor minoring CS at the time (I wish I knew this is a stupid reason though).
Later, I learned more about Unity, openframeworks, and other creative coding tools or libraries. The more I worked with images and heavy renderings, I realized how important an effective computing is. And at NYU ITP summer CAMP, I first heard about 'Book of Shaders' from Michael Simpson's class.
It was always on my to do list. Finally, a week ago, I encountered some serious GPU / speed limitation while working on p5js WEBGL and 3D modes. Now I actually have an urge & full interest to start digging into SHADERS.
a small program that runs entirely on your graphics card
complex but performative graphics
no need to add .vert and .frag filenames on index.html. <script>
tag can load javascript file only, so it doesn't understand shader files anyway
preload .vert, .frag files in sketch.js
file like below
This is the code I got from p5js shaders glitch example
let theShader;
function preload(){
// load the shader
theShader = loadShader('onecolor.vert', 'onecolor.frag');
}
function setup() {
// shaders require WEBGL mode to work
createCanvas(windowWidth, windowHeight, WEBGL);
}
function draw() {
// shader() sets the active shader with our shader
shader(theShader);
// rect gives us some geometry on the screen
rect(0,0,width,height);
}
setUniform
method which allows User's input interactivity