Skip to main content
dkt0
Inspiring
June 10, 2025
Question

Buffer Expansion - SmartFX

  • June 10, 2025
  • 3 replies
  • 712 views

So I modified the Skeleton sample plugin by adding SmartFX and by making it move the layer based on 2 parameters, X and Y, because I want to understand how to make it go out of bounds.

 

If I set the rects like this:

extra->output->result_rect = in_result.result_rect;
extra->output->max_result_rect = expanded_rect;

Then the expansion is not happening or whatever, because the pixels are clearly still limited by the bounds.

If I set them like this:

extra->output->result_rect = expanded_rect;
extra->output->max_result_rect = expanded_rect;

 

Then the effect just gets completely bugged and moves the layer to top-left.

 

What am I missing? I tried so many things...such a sad thing that we don't have a sample plugin in the SDK that shows how to do this.

 

Here's my currect PreRender btw:

static PF_Err
PreRender(
	PF_InData* in_data,
	PF_OutData* out_data,
	PF_PreRenderExtra* extra)
{
	PF_Err err = PF_Err_NONE;
	PF_RenderRequest req = extra->input->output_request;
	PF_CheckoutResult in_result;

	ERR(extra->cb->checkout_layer(in_data->effect_ref,
		SKELETON_INPUT,
		SKELETON_INPUT,
		&req,
		in_data->current_time,
		in_data->time_step,
		in_data->time_scale,
		&in_result));


	PF_LRect expanded_rect = in_result.result_rect;
	expanded_rect.left -= 200;
	expanded_rect.top -= 200;
	expanded_rect.right += 200;
	expanded_rect.bottom += 200;

	extra->output->result_rect = in_result.result_rect;
	extra->output->max_result_rect = expanded_rect;

	extra->output->flags |= PF_RenderOutputFlag_RETURNS_EXTRA_PIXELS;

	return err;
}

3 replies

Community Expert
June 15, 2025

so...

i put together a working sample the shows buffer resizing in smartFX. (based on the "smarty pants" sample)

download it from here:
https://drive.google.com/file/d/1w4Fc9rtGXjU-YT4CC-6q01ft2MOvOLtt/view?usp=sharing

from what i gathered during the making of this was that you should put the expanded buffer rect in "extra->output->result_rect".

seems AE will take just that rect. i didn't see AE asking for the max_result_rect yet...

 

so depending on your implementation, you should decide *what* get's expanded.

is it relative to any buffer you get, be it cropped by a mask or the comp bounds?
is it relative to the original layer size?
is it relative to the max rect of the input?

all these very much depend on your implementation.

in the sample project, i expanded the input buffer whatever it may be, and put it in the "extra->output->result_rect". then i expanded the "in_result.max_result_rect" and put the expanded result in "

extra->output->max_result_rect".

from all i've seen, AE always used the rect from "extra->output->result_rect" for the render call, even when the layer was scaled down and exposed the area around the original layer that it *could* grow into.

James Whiffin
Legend
June 11, 2025

To ensure it's working correctly, you need to account for the difference in origins in smart_render. When you expand the output, it's now larger than the input:

PF_Rect dstRect = { input_world->origin_x - output_world->origin_x, 
                    input_world->origin_y - output_world->origin_y, 
                    0, 0 };

dstRect.right = dstRect.left + input_world->width;
dstRect.bottom = dstRect.top + input_world->height;

PF_COPY(input_world, output_world, NULL, &dstRect);

 An even easier way to verify if your output buffer is expanding correctly is simply to fill it with a solid colour.

dkt0
dkt0Author
Inspiring
June 11, 2025

That would work if the only thing you wanna do is fill the buffer with a color. What do you do if your plugin moves the layer, or samples? I modified the skeleton to move the layer via sampling. Custom SampleBilinear function and custom offset function. Nothing I do is working, the layer is just completely bugged when I try to expand the buffer.

 

What you provided there just copies the pixels in the center of the buffer, that's not really helpful in my situation.

James Whiffin
Legend
June 11, 2025

If you want to transform the layer, you start with an identity matrix, add your other transforms, and feed it into transform_world. You still need to account for the origin difference, otherwise it will be at the top left of your output buffer. I think your pre_render code is correct, and you can verify it is using the methods i mentioned in my previous reply. 

Kevin J. Monahan Jr.
Community Manager
Community Manager
June 11, 2025

HI DKT,

Thanks for the question. I appreciate you labeling the post as SDK. It's a bit out of my purview to field this qustion, but I did want to acknowledge and thank you for posting. Hopefully, the product team or the community will respond shortly. Sorry for the frustration.

 

Take Care,

Kevin

Kevin Monahan - Sr. Community and Engagement Strategist – Adobe Pro Video and Audio