message: switched to GGX for the flake normals
diff: #pragma once
  #include "Noise.ih"
  +#include "../bsdfs/GGXDistribution.ih"
  struct Flakes
  {
  @@ -27,24 +28,6 @@ struct Flakes
  //int layers;
  };
  -inline vec3f Beckmann_sample(float alpha, const vec2f& s)
  -{
  - float alpha2 = sqr(alpha);
  - float tanTheta2 = -alpha2 * log(1.f-s.x);
  - float cosTheta = rsqrt(1.f + tanTheta2);
  - float sinTheta = cos2sin(cosTheta);
  -
  - float phi = 2.f*pi * s.y;
  -
  - float sinPhi, cosPhi;
  - sincos(phi, &sinPhi, &cosPhi);
  -
  - float x = cosPhi * sinTheta;
  - float y = sinPhi * sinTheta;
  - float z = cosTheta;
  - return make_vec3f(x,y,z);
  -}
  -
  inline vec3f Flakes_eval(const varying Flakes* uniform self, vec3f p)
  {
  vec3f N = make_vec3f(0.f, 0.f, 1.f);
  @@ -52,8 +35,9 @@ inline vec3f Flakes_eval(const varying Flakes* uniform self, vec3f p)
  if (self->density <= 0.f || self->spread <= 0.f)
  return N;
  - p = p * self->scale;
  + GGXDistribution flakeDistribution = make_GGXDistribution(roughnessToAlpha(self->spread));
  float mask = 0.f;
  + p = p * self->scale;
  // Simple Worley cellular noise with jittered feature points
  // [Apodaca and Gritz, 1999, "Advanced RenderMan: Creating CGI for Motion Pictures", pp. 255-261]
  @@ -93,7 +77,8 @@ inline vec3f Flakes_eval(const varying Flakes* uniform self, vec3f p)
  if (LCG_getFloat(cellRnd) <= self->density)
  {
  // generate a random normal for the flake
  - N = Beckmann_sample(sqr(self->spread), LCG_getFloat2(cellRnd));
  + float pdf;
  + N = sample(flakeDistribution, pdf, LCG_getFloat2(cellRnd));
  mask = 1.f;
  }
  