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>2020-02-25 15:12:29 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-02-25 15:18:22 +0300
commit8885fb5929f23d59141986cda6f71f9503018a40 (patch)
tree4019474608afc5ed9f875f2578c854ae2c14cf24 /source/blender/draw/engines/eevee/eevee_private.h
parent7463da6c72a0fb2bc72bda53ece27670d5af2c72 (diff)
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.
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_private.h')
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h15
1 files changed, 13 insertions, 2 deletions
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 */