Learn more about Russian war crimes in Ukraine.

WebGL fragment shader

Above, you should see some concentric circles on the left, and some code on the right. The code is a “fragment shader”, and it generated the image on the left. You can edit it yourself to change the image.

For each pixel in the image, the fragment shader is run to get an output color. The shader has access to the current coordinate as gl_FragCoord. It puts its desired color in gl_FragColor.

This is implemented using WebGL, which gives this page access to your graphics card. Whenever you change the text in that textarea, the text is sent to your graphics driver, which compiles it to a program sitting on your graphics card. The webpage then tells the driver to draw a big square using this program.

What can computers do? What are the limits of mathematics? And just how busy can a busy beaver be? This year, I’m writing Busy Beavers, a unique interactive book on computability theory. You and I will take a practical and modern approach to answering these questions — or at least learning why some questions are unanswerable!

It’s only $19, and you can get 50% off if you find the discount code ... Not quite. Hackers use the console!

After months of secret toil, I and Andrew Carr released Everyday Data Science, a unique interactive online course! You’ll make the perfect glass of lemonade using Thompson sampling. You’ll lose weight with differential equations. And you might just qualify for the Olympics with a bit of statistics!

It’s $29, but you can get 50% off if you find the discount code ... Not quite. Hackers use the console!

More by Jim

Tagged . All content copyright James Fisher 2017. This post is not associated with my employer. Found an error? Edit this page.