[Bf-blender-cvs] [d1ebfc7ac8c] principled-v2: Remap x coordinate in dielectric Fresnel albedo LUTs

Lukas Stockner noreply at git.blender.org
Mon Jul 4 23:56:15 CEST 2022


Commit: d1ebfc7ac8cdd963a8d57e91c74f444d8f2e9b06
Author: Lukas Stockner
Date:   Mon Jul 4 23:31:48 2022 +0200
Branches: principled-v2
https://developer.blender.org/rBd1ebfc7ac8cdd963a8d57e91c74f444d8f2e9b06

Remap x coordinate in dielectric Fresnel albedo LUTs

===================================================================

M	intern/cycles/app/cycles_precompute.cpp
M	intern/cycles/kernel/closure/bsdf_microfacet.h
M	intern/cycles/kernel/closure/bsdf_microfacet_util.h
M	intern/cycles/kernel/tables.h

===================================================================

diff --git a/intern/cycles/app/cycles_precompute.cpp b/intern/cycles/app/cycles_precompute.cpp
index 1b399df3d01..acc8d0d9fbf 100644
--- a/intern/cycles/app/cycles_precompute.cpp
+++ b/intern/cycles/app/cycles_precompute.cpp
@@ -167,8 +167,31 @@ static float precompute_ggx_glass_E(
 
 static float precompute_ggx_dielectric_E(float rough, float mu, float eta, float u1, float u2)
 {
-  // TODO: Reparametrize based on fresnel_dielectric_cos(mu, eta) instead of mu to get more resolution?
-  // Probably need lerp(mu, fresnel_dielectric_cos(mu, eta), 0.9) or so because of flat IOR region.
+  {
+    /* Reparametrize based on macrosurface fresnel to get more resolution into areas where
+     * the Fresnel curve is rapidly changing. Particularly important for eta<1 due to the TIR edge.
+     * However, in the eta<1 case, the entire TIR area would be compressed down to a point, which
+     * is an issue since there are changes in that range at higher roughnesses.
+     * Therefore, the remapping is blended with the identity function for a compromise.
+     */
+    float F0 = fresnel_dielectric_cos(1.0f, eta);
+    auto get_remap = [eta, F0](float x) {
+      return lerp(x, inverse_lerp(1.0f, F0, fresnel_dielectric_cos(x, eta)), 0.5f);
+    };
+
+    float remap_target = mu;
+    float start = 0.0f, end = 1.0f;
+    while (end - start > 1e-7f) {
+      mu = (end + start) * 0.5f;
+      if (get_remap(mu) > remap_target) {
+        end = mu;
+      }
+      else {
+        start = mu;
+      }
+    }
+  }
+
   MicrofacetExtrav2 extra;
   MicrofacetBsdf bsdf;
   bsdf.weight = one_float3();
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index ebe13ec6a33..6b9309c0fa6 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -9,7 +9,6 @@
 #pragma once
 
 #include "kernel/closure/bsdf_microfacet_util.h"
-#include "kernel/closure/bsdf_util.h"
 
 CCL_NAMESPACE_BEGIN
 
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_util.h b/intern/cycles/kernel/closure/bsdf_microfacet_util.h
index 509cd6708ec..4915807d275 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_util.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_util.h
@@ -3,6 +3,8 @@
 
 #pragma once
 
+#include "kernel/closure/bsdf_util.h"
+
 CCL_NAMESPACE_BEGIN
 
 /* GGX microfacet with Smith shadow-masking from:
@@ -112,6 +114,8 @@ ccl_device_forceinline float microfacet_ggx_glass_E(float mu, float rough, float
 
 ccl_device_forceinline float microfacet_ggx_dielectric_E(float mu, float rough, float ior)
 {
+  mu = lerp(mu, inverse_lerp(1.0f, fresnel_dielectric_cos(1.0f, ior), fresnel_dielectric_cos(mu, ior)), 0.5f);
+
   bool inv_table = (ior < 1.0f);
   if (inv_table) {
     ior = 1.0f / ior;
diff --git a/intern/cycles/kernel/tables.h b/intern/cycles/kernel/tables.h
index 169ef40142a..733affec6c7 100644
--- a/intern/cycles/kernel/tables.h
+++ b/intern/cycles/kernel/tables.h
@@ -722,583 +722,583 @@ static const float table_sheen_E[32][32] = {
 
 static const float table_ggx_dielectric_E[16][16][16] = {
   {
-    {0.000415471f, 0.000132454f, 6.02304e-05f, 3.2349e-05f, 1.89411e-05f, 1.21628e-05f, 8.25374e-06f, 5.85431e-06f, 4.37281e-06f, 3.34566e-06f, 2.63778e-06f, 2.15633e-06f, 1.80054e-06f, 1.53889e-06f, 1.35031e-06f, 1.20534e-06f},
-    {0.000500569f, 0.000167997f, 7.57408e-05f, 4.05907e-05f, 2.42137e-05f, 1.5401e-05f, 1.04112e-05f, 7.33722e-06f, 5.39029e-06f, 4.09224e-06f, 3.22436e-06f, 2.60533e-06f, 2.16446e-06f, 1.84878e-06f, 1.62258e-06f, 1.45125e-06f},
-    {0.000631643f, 0.000217958f, 0.000100288f, 5.3289e-05f, 3.109e-05f, 1.96765e-05f, 1.32621e-05f, 9.20107e-06f, 6.70118e-06f, 5.04004e-06f, 3.89982e-06f, 3.12116e-06f, 2.58227e-06f, 2.18829e-06f, 1.91778e-06f, 1.72415e-06f},
-    {0.000807995f, 0.000285155f, 0.000131307f, 6.98269e-05f, 4.08318e-05f, 2.54499e-05f, 1.68666e-05f, 1.16319e-05f, 8.38762e-06f, 6.13532e-06f, 4.71284e-06f, 3.71552e-06f, 3.0378e-06f, 2.55783e-06f, 2.22496e-06f, 2.0118e-06f},
-    {0.00106589f, 0.00038733f, 0.000176011f, 9.36545e-05f, 5.3984e-05f, 3.35446e-05f, 2.19039e-05f, 1.48318e-05f, 1.03839e-05f, 7.52919e-06f, 5.65876e-06f, 4.39196e-06f, 3.50482e-06f, 2.94163e-06f, 2.53876e-06f, 2.29142e-06f},
-    {0.001453f, 0.00053215f, 0.000243545f, 0.000126661f, 7.22715e-05f, 4.4385e-05f, 2.8361e-05f, 1.87374e-05f, 1.29863e-05f, 9.20271e-06f, 6.69805e-06f, 5.08628e-06f, 3.99503e-06f, 3.29186e-06f, 2.82329e-06f, 2.54467e-06f},
-    {0.0020343f, 0.000748349f, 0.000339965f, 0.000174612f, 9.84092e-05f, 5.88162e-05f, 3.66575e-05f, 2.38413e-05f, 1.5922e-05f, 1.09605e-05f, 7.79514e-06f, 5.76436e-06f, 4.44091e-06f, 3.59403e-06f, 3.06771e-06f, 2.75371e-06f},
-    {0.00300857f, 0.0010926f, 0.000491688f, 0.000246388f, 0.000134689f, 7.80441e-05f, 4.756e-05f, 2.97255e-05f, 1.92082e-05f, 1.28153e-05f, 8.84601e-06f, 6.32998e-06f, 4.78029e-06f, 3.81701e-06f, 3.24172e-06f, 2.92231e-06f},
-    {0.00456566f, 0.00165612f, 0.000718974f, 0.000348896f, 0.000183809f, 0.000102446f, 5.97574e-05f, 3.61011e-05f, 2.23647e-05f, 1.44132e-05f, 9.60647e-06f, 6.68339e-06f, 4.95371e-06f, 3.90912e-06f, 3.32515e-06f, 3.0115e-06f},
-    {0.00738665f, 0.00259509f, 0.00107763f, 0.000497453f, 0.000248034f, 0.000130573f, 7.24356e-05f, 4.14835e-05f, 2.48774e-05f, 1.54146e-05f, 9.95278e-06f, 6.78691e-06f, 4.96036e-06f, 3.92023e-06f, 3.34373e-06f, 3.06328e-06f},
-    {0.0125017f, 0.00419002f, 0.00162011f, 0.000690663f, 0.000319282f, 0.0001576f, 8.20314e-05f, 4.51641e-05f, 2.59064e-05f, 1.55605e-05f, 9.81415e-06f, 6.6463e-06f, 4.8242e-06f, 3.83793e-06f, 3.3166e-06f, 3.07314e-06f},
-    {0.0224401f, 0.00691917f, 0.00236534f, 0.000899984f, 0.000378675f, 0.00017348f, 8.60665e-05f, 4.56151e-05f, 2.54936e-05f, 1.5027e-05f, 9.41134e-06f, 6.33024e-06f, 4.63698e-06f, 3.73457e-06f, 3.26869e-06f, 3.06797e-06f},
-    {0.0423292f, 0.0111929f, 0.00317213f, 0.00104444f, 0.000403465f, 0.00017612f, 8.45793e-05f, 4.39214e-05f, 2.43073e-05f, 1.42152e-05f, 8.89344e-06f, 6.02307e-06f, 4.45433e-06f, 3.63296e-06f, 3.22046e-06f, 3.06874e-06f},
-    {0.0823524f, 0.0162723f, 0.0036457f, 0.001077f, 0.000396278f, 0.000169879f, 8.09576e-05f, 4.1808e-05f, 2.30926e-05f, 1.35603e-05f, 8.52663e-06f, 5.79983e-06f, 4.34057e-06f, 3.578e-06f, 3.19346e-06f, 3.0524e-06f},
-    {0.152152f, 0.0189342f, 0.0036744f, 0.00105228f, 0.000383198f, 0.000164288f, 7.84115e-05f, 4.06264e-05f, 2.24144e-05f, 1.3232e-05f, 8.35e-06f, 5.71449e-06f, 4.28616e-06f, 3.54443e-06f, 3.18719e-06f, 3.05304e-06f},
-    {0.224767f, 0.0193104f, 0.00363404f, 0.00103463f, 0.000378405f, 0.000162257f, 7.75583e-05f, 4.0111e-05f, 2.22893e-05f, 1.30944e-05f, 8.28835e-06f, 5.68236e-06f, 4.27269e-06f, 3.54102e-06f, 3.18324e-06f, 3.05311e-06f}
+    {0.000833139f, 0.000739042f, 0.000661531f, 0.00058659f, 0.000504253f, 0.000429894f, 0.00034459f, 0.000248786f, 0.000130008f, 4.30204e-05f, 1.54746e-05f, 7.03338e-06f, 3.85273e-06f, 2.39524e-06f, 1.67518e-06f, 1.27851e-06f},
+    {0.000971227f, 0.000870615f, 0.000791253f, 0.000703758f, 0.000616392f, 0.000533401f, 0.000428542f, 0.000310971f, 0.000162786f, 5.49843e-05f, 1.97338e-05f, 8.86372e-06f, 4.74838e-06f, 2.90918e-06f, 2.0109e-06f, 1.53578e-06f},
+    {0.00117122f, 0.00106393f, 0.000977222f, 0.00087564f, 0.000762933f, 0.000667494f, 0.000542036f, 0.000394954f, 0.000209898f, 7.17009e-05f, 2.53486e-05f, 1.11729e-05f, 5.8894e-06f, 3.51212e-06f, 2.38932e-06f, 1.82166e-06f},
+    {0.00145307f, 0.00132647f, 0.00123762f, 0.00111287f, 0.00098268f, 0.000850916f, 0.000704074f, 0.000520591f, 0.000278186f, 9.42205e-05f, 3.27689e-05f, 1.42655e-05f, 7.27467e-06f, 4.21994e-06f, 2.79021e-06f, 2.1252e-06f},
+    {0.00187665f, 0.00174242f, 0.0015913f, 0.00147f, 0.0012994f, 0.00112776f, 0.000939697f, 0.000694948f, 0.000375119f, 0.000126431f, 4.36664e-05f, 1.83223e-05f, 8.92567e-06f, 5.04081e-06f, 3.22432e-06f, 2.41999e-06f},
+    {0.00250117f, 0.00231726f, 0.00215006f, 0.00194379f, 0.00174525f, 0.00153672f, 0.00127908f, 0.000963896f, 0.000518268f, 0.000174377f, 5.81443e-05f, 2.35887e-05f, 1.10161e-05f, 5.88478e-06f, 3.6355e-06f, 2.68866e-06f},
+    {0.00344393f, 0.00321262f, 0.00297996f, 0.00275639f, 0.00248222f, 0.00219712f, 0.00181121f, 0.00136085f, 0.000733074f, 0.000241602f, 7.79961e-05f, 3.03e-05f, 1.34434e-05f, 6.78013e-06f, 4.01359e-06f, 2.90952e-06f},
+    {0.00502222f, 0.00468816f, 0.00437739f, 0.00400831f, 0.00363854f, 0.00321053f, 0.00268791f, 0.00200402f, 0.00107331f, 0.000344745f, 0.000105866f, 3.84394e-05f, 1.60633e-05f, 7.58774e-06f, 4.30163e-06f, 3.08396e-06f},
+    {0.00760919f, 0.00717899f, 0.00670281f, 0.0061924f, 0.00560971f, 0.00490708f, 0.00410922f, 0.00307884f, 0.00162484f, 0.000500342f, 0.000142486f, 4.77747e-05f, 1.83874e-05f, 8.12365e-06f, 4.43344e-06f, 3.16708e-06f},
+    {0.0123334f, 0.0115619f, 0.0108044f, 0.00999222f, 0.00902f, 0.00794271f, 0.00664624f, 0.00491208f, 0.0025462f, 0.00073129f, 0.000187547f, 5.68591e-05f, 2.01069e-05f, 8.37956e-06f, 4.43916e-06f, 3.20476e-06f},
+    {0.0210496f, 0.0198311f, 0.0185466f, 0.0170842f, 0.0154773f, 0.0135819f, 0.0112714f, 0.0082633f, 0.00412282f, 0.001059f, 0.000235039f, 6.366e-05f, 2.06888e-05f, 8.23859e-06f, 4.33161e-06f, 3.1942e-06f},
+    {0.0385231f, 0.036234f, 0.0338544f, 0.031228f, 0.0282111f, 0.0246418f, 0.0203127f, 0.0146674f, 0.00682645f, 0.00148063f, 0.00027352f, 6.59662e-05f, 2.02234e-05f, 7.8928e-06f, 4.18144e-06f, 3.16758e-06f},
+    {0.0750848f, 0.0708705f, 0.0661296f, 0.0607573f, 0.0547065f, 0.0476295f, 0.0388318f, 0.0269979f, 0.0111858f, 0.00187513f, 0.000285965f, 6.43457e-05f, 1.91992e-05f, 7.45021e-06f, 4.03854e-06f, 3.15126e-06f},
+    {0.156612f, 0.147597f, 0.13748f, 0.12619f, 0.113024f, 0.0970109f, 0.0768087f, 0.0495397f, 0.0165158f, 0.00206221f, 0.000279698f, 6.11915e-05f, 1.82972e-05f, 7.16881e-06f, 3.94998e-06f, 3.12396e-06f},
+    {0.339907f, 0.318571f, 0.297574f, 0.271907f, 0.238398f, 0.195571f, 0.142549f, 0.0791503f, 0.0199063f, 0.00204778f, 0.000270804f, 5.93819e-05f, 1.77928e-05f, 7.02194e-06f, 3.91683e-06f, 3.12036e-06f},
+    {0.716349f, 0.663103f, 0.590735f, 0.503601f, 0.407083f, 0.305267f, 0.200609f, 0.097081f, 0.0203857f, 0.00201006f, 0.000266758f, 5.87193e-05f, 1.76699e-05f, 6.99297e-06f, 3.90627e-06f, 3.11936e-06f}
   },
   {
-    {0.00370

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list