Cleanup: EEVEE: rename glass BTDF to BSDF at several places

because it contains reflectance and transmittance, so BSDF would be a
morep proper name.
Also rename BSDF to BRDF at places where only reflectance is returned.
This commit is contained in:
Weizhen Huang 2023-09-14 16:04:26 +02:00
parent 4e00410d9e
commit 5baf652374
13 changed files with 32 additions and 32 deletions

View File

@ -154,12 +154,12 @@ static void eevee_init_util_texture()
memcpy(texels_layer, blender::eevee::lut::ltc_mat_ggx, sizeof(float[4]) * 64 * 64);
texels_layer += 64 * 64;
/* Copy bsdf_split_sum_ggx into 2nd layer red and green channels.
/* Copy brdf_ggx into 2nd layer red and green channels.
* Copy ltc_mag_ggx into 2nd layer blue and alpha channel. */
for (int x = 0; x < 64; x++) {
for (int y = 0; y < 64; y++) {
texels_layer[y * 64 + x][0] = blender::eevee::lut::bsdf_split_sum_ggx[y][x][0];
texels_layer[y * 64 + x][1] = blender::eevee::lut::bsdf_split_sum_ggx[y][x][1];
texels_layer[y * 64 + x][0] = blender::eevee::lut::brdf_ggx[y][x][0];
texels_layer[y * 64 + x][1] = blender::eevee::lut::brdf_ggx[y][x][1];
texels_layer[y * 64 + x][2] = blender::eevee::lut::ltc_mag_ggx[y][x][0];
texels_layer[y * 64 + x][3] = blender::eevee::lut::ltc_mag_ggx[y][x][1];
}
@ -188,12 +188,12 @@ static void eevee_init_util_texture()
}
texels_layer += 64 * 64;
/* Copy Refraction GGX LUT in layer 5 - 21 */
/* Copy BSDF GGX LUT in layer 5 - 21 */
for (int j = 0; j < 16; j++) {
for (int x = 0; x < 64; x++) {
for (int y = 0; y < 64; y++) {
texels_layer[y * 64 + x][0] = blender::eevee::lut::btdf_split_sum_ggx[j][y][x][0];
texels_layer[y * 64 + x][1] = blender::eevee::lut::btdf_split_sum_ggx[j][y][x][1];
texels_layer[y * 64 + x][0] = blender::eevee::lut::bsdf_ggx[j][y][x][0];
texels_layer[y * 64 + x][1] = blender::eevee::lut::bsdf_ggx[j][y][x][1];
texels_layer[y * 64 + x][2] = 0.0; /* UNUSED */
texels_layer[y * 64 + x][3] = 0.0; /* UNUSED */
}

View File

@ -93,7 +93,7 @@ float ambient_occlusion_eval(vec3 normal,
vec3 safe_normalize(vec3 N);
float fast_sqrt(float a);
vec3 cameraVec(vec3 P);
vec2 btdf_lut(float a, float b, float c, float d);
vec2 bsdf_lut(float a, float b, float c, float d);
vec2 brdf_lut(float a, float b);
vec3 F_brdf_multi_scatter(vec3 a, vec3 b, vec2 c);
vec3 F_brdf_single_scatter(vec3 a, vec3 b, vec2 c);

View File

@ -73,8 +73,8 @@ vec3 lut_coords_btdf(float cos_theta, float roughness, float ior)
return coords;
}
/* Returns GGX BTDF in first component and fresnel in second. */
vec2 btdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter)
/* Returns GGX transmittance in first component and reflectance in second. */
vec2 bsdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter)
{
if (ior <= 1e-5) {
return vec2(0.0);

View File

@ -38,7 +38,7 @@ void main()
}
/* Stubs */
vec2 btdf_lut(float a, float b, float c, float d)
vec2 bsdf_lut(float a, float b, float c, float d)
{
return vec2(0.0);
}

View File

@ -4144,7 +4144,7 @@ const float ltc_disk_integral[64][64][1] = {
{0.888889f}, {0.904762f}, {0.920635f}, {0.936508f}, {0.952381f}, {0.968254f}, {0.984127f},
{1.000000f}}};
const float bsdf_split_sum_ggx[64][64][2] = {
const float brdf_ggx[64][64][2] = {
{{1.000000f, 0.000000f}, {1.000000f, 0.000000f}, {1.000000f, 0.000000f},
{0.999996f, 0.000000f}, {0.999985f, 0.000000f}, {0.999962f, 0.000000f},
{0.999919f, 0.000000f}, {0.999847f, 0.000000f}, {0.999736f, 0.000000f},
@ -5554,7 +5554,7 @@ const float bsdf_split_sum_ggx[64][64][2] = {
{0.626607f, 0.023551f}, {0.615875f, 0.022188f}, {0.604963f, 0.020914f},
{0.593906f, 0.019723f}}};
const float btdf_split_sum_ggx[16][64][64][2] = {
const float bsdf_ggx[16][64][64][2] = {
{{{0.000000f, 1.000000f}, {0.000000f, 1.000000f}, {0.000000f, 1.000000f},
{0.000000f, 1.000000f}, {0.000000f, 1.000000f}, {0.000000f, 1.000000f},
{0.000000f, 1.000000f}, {0.000000f, 1.000000f}, {0.000000f, 1.000000f},

View File

@ -19,9 +19,9 @@ extern const float ltc_mag_ggx[64][64][2];
/* Precomputed Disk integral for different elevation angles and solid angle. */
extern const float ltc_disk_integral[64][64][1];
/* Precomputed integrated split fresnel term of the GGX BRDF. */
extern const float bsdf_split_sum_ggx[64][64][2];
/* Precomputed reflectance and transmission of glass material. */
extern const float btdf_split_sum_ggx[16][64][64][2];
extern const float brdf_ggx[64][64][2];
/* Precomputed reflectance and transmittance of glass material with IOR < 1. */
extern const float bsdf_ggx[16][64][64][2];
/* 4 different blue noise, one per channel. */
extern const float blue_noise[64][64][4];

View File

@ -391,8 +391,8 @@ class UtilityTexture : public Texture {
Layer &layer = data[UTIL_LTC_MAG_LAYER];
for (auto x : IndexRange(lut_size)) {
for (auto y : IndexRange(lut_size)) {
layer.data[y][x][0] = lut::bsdf_split_sum_ggx[y][x][0];
layer.data[y][x][1] = lut::bsdf_split_sum_ggx[y][x][1];
layer.data[y][x][0] = lut::brdf_ggx[y][x][0];
layer.data[y][x][1] = lut::brdf_ggx[y][x][1];
layer.data[y][x][2] = lut::ltc_mag_ggx[y][x][0];
layer.data[y][x][3] = lut::ltc_mag_ggx[y][x][1];
}
@ -412,8 +412,8 @@ class UtilityTexture : public Texture {
Layer &layer = data[UTIL_BTDF_LAYER + layer_id];
for (auto x : IndexRange(lut_size)) {
for (auto y : IndexRange(lut_size)) {
layer.data[y][x][0] = lut::btdf_split_sum_ggx[layer_id][y][x][0];
layer.data[y][x][1] = lut::btdf_split_sum_ggx[layer_id][y][x][1];
layer.data[y][x][0] = lut::bsdf_ggx[layer_id][y][x][0];
layer.data[y][x][1] = lut::bsdf_ggx[layer_id][y][x][1];
}
}
}

View File

@ -88,7 +88,7 @@ enum eDebugMode : uint32_t {
enum PrecomputeType : uint32_t {
LUT_GGX_BRDF_SPLIT_SUM = 0u,
LUT_GGX_BTDF_SPLIT_SUM = 1u,
LUT_GGX_BSDF_SPLIT_SUM = 1u,
};
/** \} */

View File

@ -55,7 +55,7 @@ vec4 ggx_brdf_split_sum(vec3 lut_coord)
}
/* Generate BSDF LUT for `IOR < 1`. Returns the transmittance and the reflectance. */
vec4 ggx_btdf_split_sum(vec3 lut_coord)
vec4 ggx_bsdf_split_sum(vec3 lut_coord)
{
float ior = sqrt(lut_coord.x);
/* ior is sin of critical angle. */
@ -125,8 +125,8 @@ void main()
case LUT_GGX_BRDF_SPLIT_SUM:
result = ggx_brdf_split_sum(lut_normalized_coordinate);
break;
case LUT_GGX_BTDF_SPLIT_SUM:
result = ggx_btdf_split_sum(lut_normalized_coordinate);
case LUT_GGX_BSDF_SPLIT_SUM:
result = ggx_bsdf_split_sum(lut_normalized_coordinate);
break;
}
imageStore(table_img, ivec3(gl_GlobalInvocationID), result);

View File

@ -297,7 +297,7 @@ vec2 brdf_lut(float cos_theta, float roughness)
#endif
}
vec2 btdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter)
vec2 bsdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter)
{
if (ior <= 1e-5) {
return vec2(0.0);

View File

@ -1448,14 +1448,14 @@ static void test_eevee_lut_gen()
Manager manager;
/* Check if LUT generation matches the header version. */
auto bsdf_ggx_gen = Precompute(manager, LUT_GGX_BRDF_SPLIT_SUM, {64, 64, 1}).data<float2>();
auto btdf_ggx_gen = Precompute(manager, LUT_GGX_BTDF_SPLIT_SUM, {64, 64, 16}).data<float2>();
auto brdf_ggx_gen = Precompute(manager, LUT_GGX_BRDF_SPLIT_SUM, {64, 64, 1}).data<float2>();
auto bsdf_ggx_gen = Precompute(manager, LUT_GGX_BSDF_SPLIT_SUM, {64, 64, 16}).data<float2>();
Span<float2> bsdf_ggx_lut((const float2 *)&eevee::lut::bsdf_split_sum_ggx, 64 * 64);
Span<float2> btdf_ggx_lut((const float2 *)&eevee::lut::btdf_split_sum_ggx, 64 * 64 * 16);
Span<float2> brdf_ggx_lut((const float2 *)&eevee::lut::brdf_ggx, 64 * 64);
Span<float2> bsdf_ggx_lut((const float2 *)&eevee::lut::bsdf_ggx, 64 * 64 * 16);
EXPECT_NEAR_ARRAY_ND(brdf_ggx_lut.data(), brdf_ggx_gen.data(), brdf_ggx_gen.size(), 2, 1e-4f);
EXPECT_NEAR_ARRAY_ND(bsdf_ggx_lut.data(), bsdf_ggx_gen.data(), bsdf_ggx_gen.size(), 2, 1e-4f);
EXPECT_NEAR_ARRAY_ND(btdf_ggx_lut.data(), btdf_ggx_gen.data(), btdf_ggx_gen.size(), 2, 1e-4f);
GPU_render_end();
}

View File

@ -14,7 +14,7 @@ void node_bsdf_glass(vec4 color,
vec3 V = cameraVec(g_data.P);
float NV = dot(N, V);
vec2 bsdf = btdf_lut(NV, roughness, ior, do_multiscatter);
vec2 bsdf = bsdf_lut(NV, roughness, ior, do_multiscatter);
ClosureReflection reflection_data;
reflection_data.weight = bsdf.y * weight;

View File

@ -84,7 +84,7 @@ void node_bsdf_principled(vec4 base_color,
coat_data.N = CN;
coat_data.roughness = coat_roughness;
float coat_NV = dot(coat_data.N, V);
float reflectance = btdf_lut(coat_NV, coat_data.roughness, coat_ior, 0.0).y;
float reflectance = bsdf_lut(coat_NV, coat_data.roughness, coat_ior, 0.0).y;
coat_data.weight = weight * coat * reflectance;
coat_data.color = vec3(1.0);
/* Attenuate lower layers */
@ -125,7 +125,7 @@ void node_bsdf_principled(vec4 base_color,
/* TODO: change `specular_tint` to rgb. */
vec3 reflection_tint = mix(vec3(1.0), base_color.rgb, specular_tint);
if (true) {
vec2 bsdf = btdf_lut(NV, roughness, ior, do_multiscatter);
vec2 bsdf = bsdf_lut(NV, roughness, ior, do_multiscatter);
reflection_data.color += weight * transmission * bsdf.y * reflection_tint;