pex-gl / pex-renderer

Physically based renderer (PBR) and scene graph for PEX.
https://pex-gl.github.io/pex-renderer/examples/index.html
MIT License
237 stars 16 forks source link

Evaluate burley diffuse #199

Open dmnsgn opened 5 years ago

vorg commented 5 years ago

Possible implementations

Urho3d

vec3 BurleyDiffuse(vec3 diffuseColor, float roughness, float NdotV, float NdotL, float VdotH) {
  float energyBias = mix(roughness, 0.0, 0.5);
  float energyFactor = mix(roughness, 1.0, 1.0 / 1.51);
  float fd90 = energyBias + 2.0 * VdotH * VdotH * roughness;
  float f0 = 1.0;
  float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NdotL, 5.0);
  float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NdotV, 5.0);

  return diffuseColor * lightScatter * viewScatter * energyFactor;
}

Filament

float Fd_Burley(float NoV, float NoL, float LoH, float roughness) {
    float f90 = 0.5 + 2.0 * roughness * LoH * LoH;
    float lightScatter = F_Schlick(NoL, 1.0, f90);
    float viewScatter = F_Schlick(NoV, 1.0, f90);
    return lightScatter * viewScatter * (1.0 / PI);
}