diff options
| author | yum <yum.food.vr@gmail.com> | 2026-02-24 18:11:03 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-02-24 18:11:03 -0800 |
| commit | aacad28954ceb792ecc7ebd90338466b9f70d456 (patch) | |
| tree | 8a9a7b793caa594728d322646d4f3417f9b532bb /math.cginc | |
| parent | 142805d05c999ab1c36cdecffcc305c66dd15feb (diff) | |
Implement wrapped lighting (direct & IBL diffuse)
Diffstat (limited to 'math.cginc')
| -rwxr-xr-x | math.cginc | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -32,15 +32,16 @@ float sin_noise_3d_fbm(float3 uvw, uint octaves, float k, float strength) { return result; } -// Wrap a dot product. Assume it's already clamped. +// Wrap NoL. Assume it's already clamped. // At k=0, you get standard lambertian shading. // At k=0.5, you get half-lambertian shading. // At k=1.0, you get flat shading. // k must be on [0, 1]. // Energy preserving, within some small bound. -float wrapDotProduct(float XoY, float k) { - float lambertian = XoY; - float half_lambertian = pow(max(1e-4, (XoY + 0.5f) / (1.0f + 0.5f)), 2); +float wrapNoL(float NoL, float k) { + float lambertian = NoL; + float tmp = (NoL + 0.5f) / (1.0f + 0.5f); + float half_lambertian = tmp * tmp; float flat = RCP_PI; if (k < 0.5) { |
