2.0.6 • Published 8 years ago

glsl-domain-coloring v2.0.6

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

glsl-domain-coloring

Domain coloring as a shader, via glslify.

glsl-domain-coloring

Introduction

Domain coloring is an improvement over simple coloring by the complex argument and lightness by the magnitude. It makes the function easier to understand by applying the following logic:

  • the complex argument determines the hue. (Red is positive real and cyan is negative real, while green-yellow is positive imaginary and blue-magenta is negative imaginary.)
  • contours of the complex magnitude are lightened. The contours occur near integer values of log2(|z|).
  • real and imaginary grid lines are darkened. With grid spacing (1, 1), this means that the dark lines are simply the unit grid.

The result of these choices is that the behavior of the function is easier to discern than by a simple colormap. For example, the function f(z) = z plotted from -2 to 2 on the real and imaginary axes results in the colormap:

The function f(z) = 1 / z in the same range results in the map:

In the second example, the pole of the function is indicated by the bunching up of the grid lines as the white magnitude contours get closer and closer to the pole. In the first example though, the bunching up of the white magnitude contours without bunching up of the black grid lines indicates that it's a zero rather than a pole.

Examples

Live demos:

To use with glslify:

#pragma glslify: domainColoring = require(glsl-domain-coloring)

attribute vec3 position;

varying vec2 z;

void main () {
  gl_FragColor = domainColoring(z, vec2(1.0), 0.9, 0.5, 0.7);
}

API

vec3 domainColoring(vec2 f, vec2 gridSpacing, float saturation, float gridStrength, float magStrength)

Returns the rgb value given the real and imaginary components of f.

Arguments:

  • f: A vec2 containing the real and imaginary components of the function
  • gridSpacing: a vec2 containing the spacing of the grid in the x and y directions
  • saturation: the saturation of the coloring, from zero to one
  • gridStrength: the strength of the rectangular grid, from zero to one
  • magStrength: the strength of the magnitude contours, from zero to one
  • linePower: the strength of the lines, as a positive floating point number. Larger numbers result in sharper contours.

License

© 2016 Ricky Reusser. MIT License.

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago