Fix #123045: Accumulate Samples When Navigating

When navigating the samples were always reset. This was introduced
by 7ec59b05ffb0143b7d7a68b7989a1b48fd6bd1b8 where samples needed
to be reset when painting.

This PR solves it by separating the navigation and the painting more
clearly in the API. Also cleans up some calls that are also encapsulated
via the EEVEE Instance class.

Validated that painting and navigating still worked with these changes
applied.

Pull Request: https://projects.blender.org/blender/blender/pulls/123064
This commit is contained in:
Jeroen Bakker 2024-06-11 14:07:26 +02:00
parent bb9e3df6d2
commit e1ee3ed7df
5 changed files with 21 additions and 6 deletions

@ -86,7 +86,7 @@ void Instance::init(const int2 &output_res,
if (assign_if_different(overlays_enabled_, v3d && !(v3d->flag2 & V3D_HIDE_OVERLAYS))) {
sampling.reset();
}
if (DRW_state_is_navigating()) {
if (is_painting()) {
sampling.reset();
}

@ -268,6 +268,11 @@ class Instance {
return DRW_state_is_navigating();
}
bool is_painting() const
{
return DRW_state_is_painting();
}
bool use_scene_lights() const
{
return (!v3d) ||

@ -202,7 +202,7 @@ void MotionBlurModule::render(View &view, GPUTexture **input_tx, GPUTexture **ou
if (inst_.is_viewport()) {
float frame_delta = fabsf(inst_.velocity.step_time_delta_get(STEP_PREVIOUS, STEP_CURRENT));
/* Avoid highly disturbing blurs, during navigation with high shutter time. */
if (frame_delta > 0.0f && !DRW_state_is_navigating()) {
if (frame_delta > 0.0f && !inst_.is_navigating()) {
/* Rescale motion blur intensity to be shutter time relative and avoid long streak when we
* have frame skipping. Always try to stick to what the render frame would look like. */
data_.motion_scale = float2(shutter_time_ / frame_delta);
@ -212,15 +212,15 @@ void MotionBlurModule::render(View &view, GPUTexture **input_tx, GPUTexture **ou
* Apply motion blur as smoothing and only blur towards last frame. */
data_.motion_scale = float2(1.0f, 0.0f);
if (was_navigating_ != DRW_state_is_navigating()) {
if (was_navigating_ != inst_.is_navigating()) {
/* Special case for navigation events that only last for one frame (for instance mouse
* scroll for zooming). For this case we have to wait for the next frame before enabling
* the navigation motion blur. */
was_navigating_ = DRW_state_is_navigating();
was_navigating_ = inst_.is_navigating();
return;
}
}
was_navigating_ = DRW_state_is_navigating();
was_navigating_ = inst_.is_navigating();
}
else {
data_.motion_scale = float2(1.0f);

@ -951,9 +951,13 @@ bool DRW_state_is_scene_render();
bool DRW_state_is_viewport_image_render();
bool DRW_state_is_playback();
/**
* Is the user navigating the region.
* Is the user navigating or painting the region.
*/
bool DRW_state_is_navigating();
/**
* Is the user painting?
*/
bool DRW_state_is_painting();
/**
* Should text draw in this mode?
*/

@ -3000,6 +3000,12 @@ bool DRW_state_is_navigating()
return (rv3d) && (rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING));
}
bool DRW_state_is_painting()
{
const RegionView3D *rv3d = DST.draw_ctx.rv3d;
return (rv3d) && (rv3d->rflag & (RV3D_PAINTING));
}
bool DRW_state_show_text()
{
return (DST.options.is_select) == 0 && (DST.options.is_depth) == 0 &&