message: fixed MicrofacetDielectricLayer for perfectly specular substrates
diff: @@ -134,7 +134,7 @@ inline BSDF_SampleRes MicrofacetDielectricLayer_sample(const varying BSDF* unifo
  if (reduce_max(res.weight) <= 0.f)
  return res;
  substrate.pdf = res.pdf;
  - substrate.value = res.weight * res.pdf;
  + substrate.value = res.weight * ((res.type & BSDF_SPECULAR) ? 1.f : res.pdf); // correctly handle delta distributions
  // Compute the microfacet normal
  wh = normalize(res.wi + wo);
  @@ -148,6 +148,22 @@ inline BSDF_SampleRes MicrofacetDielectricLayer_sample(const varying BSDF* unifo
  // Fresnel term
  float F = fresnelDielectric(cosThetaOH, self->eta);
  + // Apply the coating transmittance
  + float cosThetaO1 = refract(cosThetaO, self->eta); // positive
  + float cosThetaI1 = refract(cosThetaI, self->eta); // positive
  + substrate.value = substrate.value * pow(self->transmittance, self->thickness * (rcp(cosThetaO1) + rcp(cosThetaI1)));
  +
  + // Compute the final substrate reflection
  + substrate.value = substrate.value * (1.f-F);
  +
  + if (res.type & BSDF_SPECULAR)
  + {
  + // If we sampled a delta distribution, we don't have to evaluate the coating reflection (see MultiBSDF_sample)
  + res.weight = substrate.value * rcp(substratePickProb);
  + return res;
  + }
  + else
  + {
  // Evaluate the coating reflection
  float cosThetaH = dot(wh, getN(super));
  float cosThetaIH = dot(res.wi, wh);
  @@ -161,19 +177,12 @@ inline BSDF_SampleRes MicrofacetDielectricLayer_sample(const varying BSDF* unifo
  coating.pdf = whPdf * rcp(4.f*cosThetaOH);
  coating.value = make_vec3f(F * D * G * rcp(4.f*cosThetaO));
  - // Apply the coating transmittance
  - float cosThetaO1 = refract(cosThetaO, self->eta); // positive
  - float cosThetaI1 = refract(cosThetaI, self->eta); // positive
  - substrate.value = substrate.value * pow(self->transmittance, self->thickness * (rcp(cosThetaO1) + rcp(cosThetaI1)));
  -
  - // Compute the final substrate reflection
  - substrate.value = substrate.value * (1.f-F);
  -
  // Compute the total reflection
  res.pdf = coatingPickProb * coating.pdf + substratePickProb * substrate.pdf;
  res.weight = (coating.value + substrate.value) * rcp(res.pdf);
  return res;
  }
  +}
  inline void MicrofacetDielectricLayer_Constructor(varying MicrofacetDielectricLayer* uniform self, const varying linear3f* uniform frame,
  varying BSDF* varying substrate, float eta, vec3f transmittance, float thickness, float roughness)
  