Learn more about Israeli war crimes in Gaza, funded by the USA, Germany, the UK and others.

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.

Tagged .

Similar posts

More by Jim

Want to build a fantastic product using LLMs? I work at Granola where we're building the future IDE for knowledge work. Come and work with us! Read more or get in touch!

This page copyright James Fisher 2017. Content is not associated with my employer. Found an error? Edit this page.