Hello World

Starting out with a very basic 'print a colour to the screen' example. In this case we are just changing all the pixels inside the canvas to the same colour.

#ifdef GL_ES
precision mediump float;
#endif

void main() {
	gl_FragColor = vec4(0.5,0.0,1.0,1.0);
}
					

Or using a separate function that returns the colour.

#ifdef GL_ES
precision mediump float;
#endif

// must define before first use
vec4 violet(){
	return vec4(127.0/255.0,0.0,1.0,1.0);
}

void main() {
	gl_FragColor = violet();
}
					

Based on 'Hello World' - https://thebookofshaders.com