Skip to main content
brunop95489334
Inspiring
April 17, 2021
Question

Extend layer bounds to comp size

  • April 17, 2021
  • 1 reply
  • 1585 views

Hi there! Thanks for your time!

I am very new to c++ code, this is my first attempt, I am a bit used to shader code, like glsl, hlsl, etc... So I am using glator to make a plugin, that way I am a bit more confortable.

I`ve managed to do almost everything that I wanted. But I am stuck at resizing text, shape layers, etc...
Masked ones, etc I was able to render outside the masks by using preserve_rgb_of_zero_alpha.

I cant for the life of me extend the bounds from layers that are not composition size... Ive tried modifying the result_rect and max_result_rect, and setting extra->output->flags to PF_RenderOutputFlag_RETURNS_EXTRA_PIXELS, but no luck, the layer just get shifted around. 😞

 

Ive really searched a lot for this, and some of the examples on the SDK that would`ve helped does not use the smart render.

Can anyone help, please? haha
Again, thanks a lot and please bare with the noob.

This topic has been closed for replies.

1 reply

James Whiffin
Legend
April 17, 2021

Hi Bruno

For collapsed layers this code will expand it to the buffer size. 

 

Pre render:

UnionLRect(&req.rect, &extra->output->result_rect);
UnionLRect(&req.rect, &extra->output->max_result_rect);

When copying input to output you will need to make allowances for input and output origins. 

Copy operation:

PF_Rect dstRect = { input->origin_x,
                    input->origin_y,
                    input->origin_x + input->width,
                    input->origin_y + input->height };
        
dstRect.left    -= output->origin_x;
dstRect.right   -= output->origin_x;
dstRect.top     -= output->origin_y;
dstRect.bottom  -= output->origin_y;
        
PF_COPY(input, output, NULL, &dstRect);

Perhaps if there's a less convoluted way to achieve the same functionality someone can chime in. With my method, the input/output origins must be handled as effects up + downstream can effect those origins, such as the drop shadow effect.

brunop95489334
Inspiring
April 18, 2021

Hi James! Thanks a lot!

The pre render part is already done.

 

Ive tried a lot of things to expand it, like so:

//extra->output->result_rect.bottom += 200;
	//extra->output->result_rect.right += 200;
	//extra->output->result_rect.top -= 200;
	//extra->output->result_rect.left -= 200;

	//extra->output->max_result_rect.bottom += 200;
	//extra->output->max_result_rect.right += 200;
	//extra->output->max_result_rect.top -= 200;
	//extra->output->max_result_rect.left -= 200;



	extra->output->flags = PF_RenderOutputFlag_RETURNS_EXTRA_PIXELS;

	
	if (!err){
		
	UnionLRect(&in_result.result_rect, &extra->output->result_rect);

	UnionLRect(&in_result.max_result_rect, &extra->output->max_result_rect);

	
		
	}

The second part I am not sure, as I GLator uploads a texture to an openGL buffer, where I do stuff, and then download it back, and PF_COPY is not used anywhere (real noob here, sorry haha)

 

James Whiffin
Legend
April 21, 2021

No worries. GLator uses an iterate function to upload/download the buffers. I believe the upload function is based on the size of the input and the download is based on the size of the output. So there may be an issue if the input and output are different sizes. In that case, you may want to copy the smaller input to a larger CPU buffer before uploading (easier but slower) or once it's on the GPU, blit it to an output sized GPU buffer. That way there won't be any issues with uploading and downloading to and from the GPU.