Cleanup: use utility function for LUTs parametrized by `cos_theta` and `roughness`
Pull Request: https://projects.blender.org/blender/blender/pulls/111651
This commit is contained in:
parent
3876133ef5
commit
dc9589d3e4
|
@ -1266,9 +1266,18 @@ float4 utility_tx_sample(sampler2DArray util_tx, float2 uv, float layer)
|
|||
float4 utility_tx_sample_lut(sampler2DArray util_tx, float2 uv, float layer)
|
||||
{
|
||||
/* Scale and bias coordinates, for correct filtered lookup. */
|
||||
uv = uv * ((UTIL_TEX_SIZE - 1.0) / UTIL_TEX_SIZE) + (0.5 / UTIL_TEX_SIZE);
|
||||
uv = uv * UTIL_TEX_UV_SCALE + UTIL_TEX_UV_BIAS;
|
||||
return textureLod(util_tx, float3(uv, layer), 0.0);
|
||||
}
|
||||
|
||||
/* Sample LTC or BSDF LUTs with `cos_theta` and `roughness` as inputs. */
|
||||
float4 utility_tx_sample_lut(sampler2DArray util_tx, float cos_theta, float roughness, float layer)
|
||||
{
|
||||
/* LUTs are parametrized by `sqrt(1.0 - cos_theta)` for more precision near grazing incidence. */
|
||||
vec2 coords = vec2(roughness, sqrt(saturate(1.0 - cos_theta)));
|
||||
return utility_tx_sample_lut(util_tx, coords, layer);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -90,9 +90,8 @@ void light_eval(ClosureDiffuse diffuse,
|
|||
inout vec3 out_specular,
|
||||
inout float out_shadow)
|
||||
{
|
||||
vec2 uv = vec2(reflection.roughness, safe_sqrt(1.0 - dot(reflection.N, V)));
|
||||
uv = uv * UTIL_TEX_UV_SCALE + UTIL_TEX_UV_BIAS;
|
||||
vec4 ltc_mat = utility_tx_sample(utility_tx, uv, UTIL_LTC_MAT_LAYER);
|
||||
vec4 ltc_mat = utility_tx_sample_lut(
|
||||
utility_tx, dot(reflection.N, V), reflection.roughness, UTIL_LTC_MAT_LAYER);
|
||||
|
||||
LIGHT_FOREACH_BEGIN_DIRECTIONAL (light_cull_buf, l_idx) {
|
||||
light_eval_ex(diffuse,
|
||||
|
|
|
@ -310,9 +310,7 @@ vec3 F_brdf_multi_scatter(vec3 f0, vec3 f90, vec2 lut)
|
|||
vec2 brdf_lut(float cos_theta, float roughness)
|
||||
{
|
||||
#ifdef EEVEE_UTILITY_TX
|
||||
/* Parametrizing with `sqrt(1.0 - cos(theta))` for more precision near grazing incidence. */
|
||||
vec2 coords = vec2(roughness, sqrt(1.0 - cos_theta));
|
||||
return utility_tx_sample_lut(utility_tx, coords, UTIL_BSDF_LAYER).rg;
|
||||
return utility_tx_sample_lut(utility_tx, cos_theta, roughness, UTIL_BSDF_LAYER).rg;
|
||||
#else
|
||||
return vec2(1.0, 0.0);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue