Hi,
I'm starting out with the SDK in an attempt to convert my Pixel Bender plugins to native so they'll run faster and work in CS6. It's important that they work in 32-bit (as I guess all new plugins should anyway for max compatability) so I'm dispensing with the old-style and going straight for SmartFX.
At the moment all I want to do is get the input and fill it with a colour depending on the bit depth, just so I can learn how things happen and I'll work the rest out later. I can compile and build the plugin OK but when I apply it to a layer, the layer just turns black, with no RGB or A info. I'm guessing that I'm doing something wrong during the Pre-Render call, in that I'm not setting the result rectangles correctly, but as I've based it on the supplied SmartyPants example plugin, it should work ok.
Here's the PreRender and SmartRender code:
// PreRender
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;
// Check out input
ERR(extra->cb->checkout_layer( in_data->effect_ref,
MY_INPUT, // Defined as 0
MY_INPUT,
&req,
in_data->current_time,
in_data->time_step,
in_data->time_scale,
&in_result));
// Set the result rectangles
UnionLRect(&in_result.result_rect, &extra->output->result_rect);
UnionLRect(&in_result.max_result_rect, &extra->output->max_result_rect);
return err;
}
// ActuallyRender...
static PF_Err ActuallyRender(
PF_InData *in_data,
PF_EffectWorld *input,
PF_OutData *out_data,
PF_EffectWorld *output)
{
PF_Err err = PF_Err_NONE,
err2 = PF_Err_NONE;
PF_Point origin;
PF_Rect src_rect, areaR;
PF_PixelFormat format = PF_PixelFormat_INVALID;
PF_WorldSuite2 *wsP = NULL;
PF_PixelFloat red_float = {0.0, 0.0, 1.0, 1.0};
PF_Pixel16 green_deep = {0, 32767, 0, 32767};
PF_Pixel8 blue_norm = {255, 0, 0, 255};
AEGP_SuiteHandler suites(in_data->pica_basicP);
src_rect.left = -in_data->output_origin_x;
src_rect.top = -in_data->output_origin_y;
src_rect.bottom = src_rect.top + output->height;
src_rect.right = src_rect.left + output->width;
ERR(AEFX_AcquireSuite( in_data,
out_data,
kPFWorldSuite,
kPFWorldSuiteVersion2,
"Couldn't load suite.",
(void**)&wsP));
if (!in_data->sequence_data) {
PF_COPY(input, output, &src_rect, NULL);
err = PF_Err_INTERNAL_STRUCT_DAMAGED;
}
if (!err){
ERR(wsP->PF_GetPixelFormat(input, &format));
switch (format) {
case PF_PixelFormat_ARGB128:
ERR(suites.FillMatteSuite2()->fill_float(in_data->effect_ref,
&red_float,
NULL,
input));
break;
case PF_PixelFormat_ARGB64:
ERR(suites.FillMatteSuite2()->fill16(in_data->effect_ref,
&green_deep,
NULL,
input));
break;
case PF_PixelFormat_ARGB32:
ERR(suites.FillMatteSuite2()->fill(in_data->effect_ref,
&blue_norm,
NULL,
input));
break;
default:
err = PF_Err_BAD_CALLBACK_PARAM;
break;
}
err = PF_COPY(input, output, &src_rect, NULL);
}
ERR2(AEFX_ReleaseSuite( in_data,
out_data,
kPFWorldSuite,
kPFWorldSuiteVersion2,
"Couldn't release suite."));
return err;
}
// SmartRender
static PF_Err SmartRender(
PF_InData *in_data,
PF_OutData *out_data,
PF_SmartRenderExtra *extra)
{
PF_Err err = PF_Err_NONE,
err2 = PF_Err_NONE;
PF_EffectWorld *input_worldP = NULL,
*output_worldP = NULL;
// checkout input & output buffers.
ERR((extra->cb->checkout_layer_pixels( in_data->effect_ref, QPMM_INPUT, &input_worldP)));
ERR(extra->cb->checkout_output( in_data->effect_ref, &output_worldP));
ERR(ActuallyRender( in_data,
input_worldP,
out_data,
output_worldP));
return err;
}
Please forgive my coding - it's been 15 years since I did any C++, and I was never much good at it!
Any help pointing me in the right direction will be much appreciated.
Thanks,
Christian