-2

I am looking to color a fractal within my fragment shader in an WebGL project.

Within my fragment shader, I have a vec3 called Color that contains the RGB values from 0.0-1.0.

To make a fractal design similar to

enter image description here

but in black and white,

what would I need to set the Color vector to? This color is then multiplied by the Weighted Lighting for the gl_FragColor.

gman
  • 100,619
  • 31
  • 269
  • 393
  • Does this answer your question? [Can't find a way to color the Mandelbrot-set the way i'm aiming for](https://stackoverflow.com/questions/56195735/cant-find-a-way-to-color-the-mandelbrot-set-the-way-im-aiming-for) – Spektre Nov 07 '19 at 09:51
  • heh I fully missed the B&W (I think you mean grayscale instead) that is easy if your color is from 0 to 1 let call it `c` then the grayscale output color would be `vec4(c,c,c,1.0);` ... so `r=g=b=c` – Spektre Nov 19 '19 at 22:24

1 Answers1

-1

Mandelbrot shaders typically have loop that evaluates an escape condition. To make a monochrome image, simply set Color to vec3(0) if the number of iterations to escape is less than some threshold T, and set it to vec3(1) otherwise. For an example, see this shader toy.

prideout
  • 2,895
  • 1
  • 23
  • 25