Skip to content

Commit

Permalink
Fix rendering bugs caused by intersecting rects with different mipMap…
Browse files Browse the repository at this point in the history
…Levels.

This change fixes 2 bugs where RectI objects containing information for
different mipMapLevels were being intersected with eachother. This was
causing visible compositing errors in the viewer when viewing the image
zoomed out and partially clipped by the edge of the viewer. This fix
just makes sure the RectIs are converted to the proper mipMapLevel before
being intersected.
  • Loading branch information
acolwell committed Sep 8, 2023
1 parent 8bdf642 commit 31f65c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Engine/EffectInstanceRenderRoI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,14 @@ EffectInstance::renderRoI(const RenderRoIArgs & args,
* Keep in memory what the user has requested, and change the roi to the full bounds if the effect doesn't support tiles
*/
const RectI originalRoI = roi;
// Store the mipMapLevel for originalRoI here because renderFullScaleThenDownscale may change later and we'll lose
// the ability to recover this information when we potentially need it for a downscale operation later.
const unsigned int originalRoIMipMapLevel = renderFullScaleThenDownscale ? 0 : args.mipMapLevel;

if (frameArgs->tilesSupported) {
#ifndef NATRON_ALWAYS_ALLOCATE_FULL_IMAGE_BOUNDS
///just allocate the roi
const RectI upscaledRoI = renderFullScaleThenDownscale ? roi : roi.toNewMipMapLevel(args.mipMapLevel, 0, par, rod);
upscaledImageBoundsNc.clipIfOverlaps(roi);
downscaledImageBoundsNc.clipIfOverlaps(args.roi);
#endif
Expand Down Expand Up @@ -1749,7 +1753,8 @@ EffectInstance::renderRoI(const RenderRoIArgs & args,
assert(comp);
///The image might need to be converted to fit the original requested format
if (comp) {
it->second.downscaleImage = convertPlanesFormatsIfNeeded(getApp(), it->second.downscaleImage, originalRoI, *comp, args.bitdepth, useAlpha0ForRGBToRGBAConversion, planesToRender->outputPremult, -1);
const RectI downscaledOriginalRoI = originalRoI.toNewMipMapLevel(originalRoIMipMapLevel, args.mipMapLevel, par, rod);
it->second.downscaleImage = convertPlanesFormatsIfNeeded(getApp(), it->second.downscaleImage, downscaledOriginalRoI, *comp, args.bitdepth, useAlpha0ForRGBToRGBAConversion, planesToRender->outputPremult, -1);
assert(it->second.downscaleImage->getComponents() == *comp && it->second.downscaleImage->getBitDepth() == args.bitdepth);

StorageModeEnum imageStorage = it->second.downscaleImage->getStorageMode();
Expand Down

0 comments on commit 31f65c3

Please sign in to comment.