Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2021-02-13 20:50:09 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-02-13 20:52:19 +0300
commit83ac8628c490eda4fa5237b7a4256bc670dc0682 (patch)
tree89563a6d46dcea4ea51b70d23b3a73e7637161a6 /source/blender/draw/engines/eevee/eevee_materials.c
parent06492fd61984c1a92fb1f93d30028de97ead451f (diff)
EEVEE: Update LUT GGX generation shader
This modifies the principled BSDF and the Glass BSDF which now have better fit to multiscatter GGX. Code to generate the LUT have been updated and can run at runtime. The refraction LUT has been changed to have the critical angle always centered around one pixel so that interpolation can be mitigated. Offline LUT data will be updated in another commit This simplify the BTDF retreival removing the manual clean cut at low roughness. This maximize the precision of the LUT by scalling the sides by the critical angle. I also touched the ior > 1.0 approximation to be smoother. Also incluse some cleanup of bsdf_sampling.glsl
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_materials.c')
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 5f2821730f1..841da7fd076 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -142,11 +142,20 @@ static void eevee_init_noise_texture(void)
e_data.noise_tex = DRW_texture_create_2d(64, 64, GPU_RGBA16F, 0, (float *)blue_noise);
}
+#define RUNTIME_LUT_CREATION 1
+
static void eevee_init_util_texture(void)
{
const int layers = 4 + 16;
float(*texels)[4] = MEM_mallocN(sizeof(float[4]) * 64 * 64 * layers, "utils texels");
float(*texels_layer)[4] = texels;
+#if RUNTIME_LUT_CREATION
+ float *bsdf_ggx_lut = EEVEE_lut_update_ggx_brdf(64);
+ float(*btdf_ggx_lut)[64 * 64 * 2] = (float(*)[64 * 64 * 2]) EEVEE_lut_update_ggx_btdf(64, 16);
+#else
+ const float *bsdf_ggx_lut = bsdf_split_sum_ggx;
+ const float(*btdf_ggx_lut)[64 * 64 * 2] = btdf_split_sum_ggx;
+#endif
/* Copy ltc_mat_ggx into 1st layer */
memcpy(texels_layer, ltc_mat_ggx, sizeof(float[4]) * 64 * 64);
@@ -155,8 +164,8 @@ static void eevee_init_util_texture(void)
/* Copy bsdf_split_sum_ggx into 2nd layer red and green channels.
* Copy ltc_mag_ggx into 2nd layer blue and alpha channel. */
for (int i = 0; i < 64 * 64; i++) {
- texels_layer[i][0] = bsdf_split_sum_ggx[i * 2 + 0];
- texels_layer[i][1] = bsdf_split_sum_ggx[i * 2 + 1];
+ texels_layer[i][0] = bsdf_ggx_lut[i * 2 + 0];
+ texels_layer[i][1] = bsdf_ggx_lut[i * 2 + 1];
texels_layer[i][2] = ltc_mag_ggx[i * 2 + 0];
texels_layer[i][3] = ltc_mag_ggx[i * 2 + 1];
}
@@ -183,8 +192,8 @@ static void eevee_init_util_texture(void)
/* Copy Refraction GGX LUT in layer 5 - 21 */
for (int j = 0; j < 16; j++) {
for (int i = 0; i < 64 * 64; i++) {
- texels_layer[i][0] = btdf_split_sum_ggx[j * 2][i];
- texels_layer[i][1] = 0.0; /* UNUSED */
+ texels_layer[i][0] = btdf_ggx_lut[j][i * 2 + 0];
+ texels_layer[i][1] = btdf_ggx_lut[j][i * 2 + 1];
texels_layer[i][2] = 0.0; /* UNUSED */
texels_layer[i][3] = 0.0; /* UNUSED */
}
@@ -195,6 +204,10 @@ static void eevee_init_util_texture(void)
64, 64, layers, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_WRAP, (float *)texels);
MEM_freeN(texels);
+#if RUNTIME_LUT_CREATION
+ MEM_freeN(bsdf_ggx_lut);
+ MEM_freeN(btdf_ggx_lut);
+#endif
}
void EEVEE_update_noise(EEVEE_PassList *psl, EEVEE_FramebufferList *fbl, const double offsets[3])