Eevee-Next: World Reflective Light #108149

Merged
Jeroen Bakker merged 33 commits from Jeroen-Bakker/blender:eevee-next-world-shader into main 2023-06-29 15:25:04 +02:00
1 changed files with 15 additions and 14 deletions
Showing only changes of commit 8236179f57 - Show all commits

View File

@ -4,11 +4,12 @@ void light_world_eval(ClosureReflection reflection, vec3 P, vec3 V, inout vec3 o
{
ivec3 texture_size = textureSize(reflectionProbes, 0);
/* TODO: This should be based by actual resolution. Currently the resolution is fixed but
* eventually this should based on a user setting. */
* eventually this should based on a user setting and part of the reflection probe data that will
* be introduced by the reflection probe patch. */
float lod_cube_max = 12.0;
Jeroen-Bakker marked this conversation as resolved Outdated

Check lightprobe_filter_glossy_frag

Check `lightprobe_filter_glossy_frag`
/* Pow2f to distributed across lod more evenly */
float roughness = clamp(pow2f(reflection.roughness), 1e-4f, 0.9999f); /* Avoid artifacts */
float roughness = clamp(pow2f(reflection.roughness), 1e-4f, 0.9999f);
#if defined(GPU_COMPUTE_SHADER)
vec2 frag_coord = vec2(gl_GlobalInvocationID.xy) + 0.5;
@ -30,26 +31,26 @@ void light_world_eval(ClosureReflection reflection, vec3 P, vec3 V, inout vec3 o
float NL = dot(reflection.N, L);
if (NL > 0.0) {
float NH = max(1e-8, dot(reflection.N, H)); /*cosTheta */
/* Coarse Approximation of the mapping distortion
* Unit Sphere -> Cubemap Face */
const float dist = 4.0 * M_PI / 6.0;
/* http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html : Equation 13 */
/* const float bias = 2.0;
const float lod_factor = bias + 0.5 * log(float(square_i(texture_size.x))) / log(2);
float lod = clamp(lod_factor - 0.5 * log2(pdf * dist), 0.0, lod_cube_max);
*/
vec3 l_col = textureLod_cubemapArray(reflectionProbes, vec4(L, 0.0), 0.0).rgb;
/* TODO: lod_factor should be precalculated and stored inside the reflection probe data. */
const float bias = 0;
const float lod_factor = bias + 0.5 * log(float(square_i(texture_size.x))) / log(2);
float lod = clamp(lod_factor - 0.5 * log2(pdf * dist), 0.0, lod_cube_max);
vec3 l_col = textureLod_cubemapArray(reflectionProbes, vec4(L, 0.0), lod).rgb;
/* Clamped brightness. */
// float luma = max(1e-8, max_v3(l_col));
/* For artistic freedom this should be read from the scene/reflection probe.
* Note: Eevee-legacy read the firefly_factor from gi_glossy_clamp. */
// const float firefly_factor = 1e16;
// l_col *= 1.0 - max(0.0, luma - firefly_factor) / luma;
* Note: Eevee-legacy read the firefly_factor from gi_glossy_clamp.
* Note: Firefly removal should be moved to a different shader and also take SSR into
* account.*/
float luma = max(1e-8, max_v3(l_col));
const float firefly_factor = 1e16;
l_col *= 1.0 - max(0.0, luma - firefly_factor) / luma;
/* TODO: for artistic freedom want to read this from the reflection probe. That can be added as
* part of the reflection probe patch. */