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 .
👋 I'm Jim, a full-stack product engineer. Want to build an amazing product and a profitable business? Read more about me or Get in touch!

Similar posts

More by Jim

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