Skip to main content
Inspiring
February 18, 2025
Answered

The render does not update when the timeline time changes

  • February 18, 2025
  • 1 reply
  • 317 views

Hi!
I can't figure out why when using SmartRender() my render doesn't update when I adjust the slider on the timeline. The value in this line

A_long shift = in_data->current_time / in_data->time_step;
does change but the render itself doesn't update. When I use the deprecated Render() everything works fine. How can I ensure that the render is updated when the timeline time changes?

This code is supposed to shift the image to the right as the timeline time changes. It works with video, but not with images. Perhaps I need to set the correct flag?

 

out_data->out_flags = PF_OutFlag_DEEP_COLOR_AWARE |
                      PF_OutFlag_SEND_UPDATE_PARAMS_UI |
                      PF_OutFlag_WIDE_TIME_INPUT;

out_data->out_flags2 = PF_OutFlag2_FLOAT_COLOR_AWARE |
                       PF_OutFlag2_SUPPORTS_SMART_RENDER |
                       PF_OutFlag2_DOESNT_NEED_EMPTY_PIXELS |
                       PF_OutFlag2_AUTOMATIC_WIDE_TIME_INPUT |
                       PF_OutFlag2_SUPPORTS_THREADED_RENDERING;

static PF_Err
SmartRender(
    PF_InData* in_data,
    PF_OutData* out_data,
    PF_ParamDef* params[],
    PF_SmartRenderExtra* extraP)
{
    PF_Err          err = PF_Err_NONE;
    PF_EffectWorld* inputP = nullptr;
    PF_EffectWorld* outputP = nullptr;
    AEGP_SuiteHandler suites(in_data->pica_basicP);

    if (!suites.HandleSuite1()->host_lock_handle(
        reinterpret_cast<PF_Handle>(extraP->input->pre_render_data)))
    {
        return PF_Err_INTERNAL_STRUCT_DAMAGED;
    }

    err = extraP->cb->checkout_layer_pixels(in_data->effect_ref, INPUT, &inputP);
    if (err) {return err;}

    err = extraP->cb->checkout_output(in_data->effect_ref, &outputP);
    if (err || !outputP) { return err;}

    // In this line the time is not updated if you use a picture. With video everything works
    A_long shift = in_data->current_time / in_data->time_step;

    PF_Rect src_rect = { -shift, 0, outputP->width - shift, outputP->height };
    PF_Rect dest_rect = { 0, 0, outputP->width, outputP->height };
    err = PF_COPY(inputP, outputP, &src_rect, &dest_rect);
    ERR(extraP->cb->checkin_layer_pixels(in_data->effect_ref, INPUT));

    suites.HandleSuite1()->host_unlock_handle(
        reinterpret_cast<PF_Handle>(extraP->input->pre_render_data));

    return err;
}

 

Correct answer James Whiffin

If you want the render to update based on the time, you can either set the flag:

PF_OutFlag_NON_PARAM_VARY

 

Which means the caching is invalidated even if no params changed (as in your case)

 

Or inside pre_render, mix the time into your GuidMixInPtr:

ERR(extra->cb->GuidMixInPtr(in_data->effect_ref, sizeof(cacheDependencies), reinterpret_cast<void *>(&myDependencies)));

 

Then when the time changes, you'll get another pre_render call.

1 reply

James Whiffin
James WhiffinCorrect answer
Legend
February 20, 2025

If you want the render to update based on the time, you can either set the flag:

PF_OutFlag_NON_PARAM_VARY

 

Which means the caching is invalidated even if no params changed (as in your case)

 

Or inside pre_render, mix the time into your GuidMixInPtr:

ERR(extra->cb->GuidMixInPtr(in_data->effect_ref, sizeof(cacheDependencies), reinterpret_cast<void *>(&myDependencies)));

 

Then when the time changes, you'll get another pre_render call.

Rewind_Author
Inspiring
February 21, 2025

Thanks! Yes, it worked for me!