Shader Battle

Make the image on the left match the image on the right by editing the fragment shader code below.

Here, we're converting to polar coordinates and drawing a pattern ☢️

Make These Images Match

By Editing This Code

What do I do With This Thing?

The pixels in the image can be manipulated with the fragment shader code written above.

Fragment shaders run once for each pixel in an image. Each run is given the coordinate of a pixel in the image, and outputs the color we want that pixel to have.

Fragment shaders are written in GLSL. Think of it as a strange dialect of C.

GLSL has various built-in functions, see the official documentation.

Note that in GLSL, floats can't be used together with ints as you may be used to. I recommend using only floats, e.g. 2.0, and not ints, e.g. 2, when solving these tasks.

If you've got the time, The Book of Shaders has a nice introduction, and a lot more.

Submit Your Solution

When you think you've found the right answer, submit it below, and find out if it's correct!

Not logged in. You must sign up or log in before you can submit your solution!