Simplex Noise

Ported from: https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl

The noise function is imported, but we then need to set up a proxy function. This is because the macro system relies on inlining, and we want to create a function definition, not just inline the noise code at the point of use.

  inline def fragment =
    Shader[FragmentEnv] { env =>
      import ultraviolet.noise.*

      def proxy: vec2 => Float =
        pt => simplex(pt)

      def fragment(color: vec4): vec4 =
        val n = (proxy(env.UV) * 0.25f) +
          (proxy(env.UV * 2.0f) * 0.25f) +
          (proxy(env.UV * 8.0f) * 0.25f) +
          (proxy(env.UV * 32.0f) * 0.25f)

        vec4(vec3(n), 1.0f)
    }