diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-11 21:03:58 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-11 21:03:58 -0800 |
| commit | 883e50070aca6017c9d71945c2c6e685938d12c4 (patch) | |
| tree | 472cda3216e65d443f894ce79b11b5fd1622a956 | |
| parent | 73686635d2e82659853a227338f0a826e32c3ab2 (diff) | |
switch to lambertian diffuse
| -rw-r--r-- | brdf.cginc | 8 | ||||
| -rw-r--r-- | lysenko.cginc | 2 |
2 files changed, 9 insertions, 1 deletions
@@ -12,6 +12,10 @@ float pow5(float x) { return x2 * x2 * x; } +float Fd_Lambertian(float NoL) { + return NoL; +} + // Schlick "An Inexpensive BRDF Model for Physically-based Rendering". // Equation 24. // f0: Reflectance at normal incidence. Typically around 0.04. @@ -209,7 +213,11 @@ float4 brdf(Pbr pbr, LightData data) { direct_specular = max(0, direct_specular); specular += direct_specular; +#if defined(F_OREN_NAYAR) float Fd = Fd_OrenNayar(pbr.roughness, data.common.NoV, data.direct.NoL, data.direct.LoV); +#else + float Fd = Fd_Lambertian(data.direct.NoL); +#endif float3 direct_diffuse = Fd * (1.0f - pbr.metallic) * pbr.albedo.xyz * data.direct.color; direct_diffuse *= layer_attenuation; direct_diffuse = max(0, direct_diffuse); diff --git a/lysenko.cginc b/lysenko.cginc index 3026caf..d3c51f0 100644 --- a/lysenko.cginc +++ b/lysenko.cginc @@ -28,7 +28,7 @@ float Fd_OrenNayar(float roughness, float NoV, float NoL, float LoV) { float s = LoV - NoL * NoV; float t = lerp(1.0f, max(NoL, NoV), step(0.0f, s)); float sigma2 = roughness * roughness; - float A = 1.0f + sigma2 * rcp(sigma2 + 0.13f) + 0.5f / (sigma2 + 0.33f); + float A = 1.0f - 0.5f * sigma2 / (sigma2 + 0.33f); float B = 0.45f * sigma2 / (sigma2 + 0.09f); return max(0.0f, NoL * (A + B * s / t)); |
