Sorry - your browser does not support the canvas element. Try using Chrome, Firefox, Safari or the latest version of IE.

Help

This page presents an interface for the creation and execution of small texture synthesis programs. Fundamentally, the program you type in needs to return some primitive function taking as input a point in R2 and returning an RGB floating point triple. There are several functions provided to aid in this process: generator functions which simply take some set of inputs and themselves return an appropriate primitive function, and mutator functions which will take some set of parameters as input as well as one or more primitive functions and return a new primitive function as a result. So, for example, the program typed in could simply be:
return TexGen.SoftSpot([0.3,0.6]);
SoftSpot is an example of a generator function - in this case it will return a primitive function that takes a point as input and returns white if its distance is less than 0.3 from the origin, black if its distance is more than 0.6 from the origin and a linear interpolation between. All of the available generators/mutators are contained within the global TexGen object.

The resulting function will be called for each pixel in the 512x512 canvas on the right side of the page. Each pixel is assigned a point in R2 based on its position in the canvas from [-1,1] in the upper left to [1,-1] in the lower right. There are a few different geometric mutator functions which can be used to modify this coordinate space.

The complete list of generator functions is as follows:

  • Color(color: [r,g,b])
    Generates the same color for every point.
  • Random()
    Takes no inputs. Generates random color for every point.
  • Perlin()
    The classical Perlin noise function. Takes no inputs.
  • Simplex()
    A simplex noise function. Takes no inputs.
  • SoftSpot(dist: [r0,r1])
    r0 represents the distance from the origin before which the function should return white. r1 represents the distance after which the function should return black. Between the function returns a linear interpolation.
  • Bar(dir: [x,y], dist: [r0,r1])
    This function behaves similarly to SoftSpot, but instead of calculating the distance from the origin for the current point it calculates the distance from the ray passing through the origin with the given direction.
  • Sinc()
    This takes the distance of the current point from the origin and feeds it as input to the normalized sinc function. It returns the result as an [r,g,b] triple.
  • RadialGrad(freq: scalar)
    This will determine the angle from the origin for the current point and then feeds it, multiplied by the freq parameter, to the sin function, returning the result as an [r,g,b] triple.
The complete list of mutator functions is as follows:
  • Add(color0: fn, color1: fn)
    Returns the value of color0 at each point added with the value of color1 at each point.
  • Sub(color0: fn, color1: fn)
    Returns the value of color1 at each point subtracted from the value of color0 at each point.
  • Mul(color0: fn, color1: fn)
    Returns the value of color0 at each point multiplied by the value of color1 at each point.
  • Div(color0: fn, color1: fn)
    Returns the value of color0 at each point divided by the value of color1 at each point.
  • Translate(offset: [x,y], node: fn)
    Translates each requested point by the offset parameter before passing the point to the node function and returning its result.
  • Scale(scale: [x,y], node: fn)
    Scales each requested point by the scale parameter before passing the point to the node function and returning its result.
  • Rotate(radians: scalar, node: fn)
    Rotates each requested point by the requested amount around the origin before passing the point to the node function and returning its result.
  • Tile(dim: [width,height], ul: [x,y], lr: [x,y], node: fn)
    Divides the plane R2 in to width by height sized tiles and with each tile having internal coordinates with range determined by the ul and lr parameters. Transforms a requested point in to this tiling scheme before passing the point to the node function and returning its result.
  • Blend(color0: fn, color1: fn, frac: fn)
    Takes the value of color0 at each point and blends it with the value of color1 at each point using the value of frac at each point to determine the blending weights.
  • Blur(size: scalar, node: fn)
    Applies a 3x3 Gaussian blur to the value of node at each point, using the size parameter to determine the area around a requested point from which to grab the samples.
  • Twist(center: [x,y], strength: scalar, node: fn)
    Twists the image by rotating each requested point around the center position by an amount dependent on the distance from the requested point to the center point. The strength parameter controls the strength of the effect, with a value of 0 nullifying the effect.
  • Warp(center: [x,y], strength: scalar, node: fn)
    Applies a localized warp to the image by scaling the requested point by an amount that is dependent upon the distance from the requested point to the center point. The strength parameter controls the strength of the effect, with a value of 0 nullifying the effect.