[Bf-blender-cvs] [8885fb5929f] master: EEVEE: Fix seams in reflection cubemap on low roughness

Clément Foucault noreply at git.blender.org
Tue Feb 25 13:24:57 CET 2020


Commit: 8885fb5929f23d59141986cda6f71f9503018a40
Author: Clément Foucault
Date:   Tue Feb 25 13:12:29 2020 +0100
Branches: master
https://developer.blender.org/rB8885fb5929f23d59141986cda6f71f9503018a40

EEVEE: Fix seams in reflection cubemap on low roughness

This was caused by the texture size not being power of 2. Thus the
padding applied to the base LOD did not match the highest mipmaps.

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

M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/engines/eevee/eevee_lookdev.c
M	source/blender/draw/engines/eevee/eevee_private.h

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

diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 92e36597d99..3201ffb10f4 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -186,7 +186,7 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
 #elif defined(IRRADIANCE_HL2)
     int grid_res = 4;
 #endif
-    int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution);
+    int cube_res = octahedral_size_from_cubesize(scene_eval->eevee.gi_cubemap_resolution);
     int vis_res = scene_eval->eevee.gi_visibility_resolution;
     sldata->fallback_lightcache = EEVEE_lightcache_create(
         1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1});
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index 94d61a81fcc..55a35087684 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -117,7 +117,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
 #elif defined(IRRADIANCE_HL2)
         int grid_res = 4;
 #endif
-        int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution);
+        int cube_res = octahedral_size_from_cubesize(scene_eval->eevee.gi_cubemap_resolution);
         int vis_res = scene_eval->eevee.gi_visibility_resolution;
 
         stl->lookdev_lightcache = EEVEE_lightcache_create(
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 7e93892ab3b..dfe3dc5a538 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -136,9 +136,20 @@ extern struct DrawEngineType draw_engine_eevee_type;
              ((v3d->shading.type == OB_RENDER) && \
               ((v3d->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER) == 0))))
 
-#define OCTAHEDRAL_SIZE_FROM_CUBESIZE(cube_size) \
-  ((int)ceilf(sqrtf((cube_size * cube_size) * 6.0f)))
 #define MIN_CUBE_LOD_LEVEL 3
+
+BLI_INLINE int octahedral_size_from_cubesize(int cube_size)
+{
+  int cube_pixel_count = SQUARE(cube_size) * 6.0f;
+  int octa_size = (int)ceilf(sqrtf(cube_pixel_count));
+  int lod_count = log2_floor_u(octa_size) - MIN_CUBE_LOD_LEVEL;
+  /* Find lowest lod size and grow back to avoid having non matching mipsizes that would
+   * break trilinear interpolation. */
+  octa_size /= 1 << lod_count;
+  octa_size *= 1 << lod_count;
+  return octa_size;
+}
+
 #define MAX_PLANAR_LOD_LEVEL 9
 
 /* All the renderpasses that use the GPUMaterial for accumulation */



More information about the Bf-blender-cvs mailing list