FxPlug 4 . retrieving accurate pixelTransform

I am trying to retrieve the layer transform of a layer put into a generator’s image well parameter.


I setup like this:


[ l_FxParameterCreationAPI_v5 addImageReferenceWithName : [l_Bundle localizedStringForKey: @"Source" value:NULL table:NULL] parameterID : k_Parameter_ID_Source_Texture parameterFlags : kFxParameterFlag_DEFAULT ];



- ( BOOL ) properties : ( NSDictionary * _Nonnull * ) properties

error : ( NSError * _Nullable * ) error

{

*properties = @{

kFxPropertyKey_MayRemapTime : @NO,

kFxPropertyKey_IsThreadSafe : @NO,

kFxPropertyKey_UsesRationalTime : @YES,

kFxPropertyKey_PixelTransformSupport : [ NSNumber numberWithInt : kFxPixelTransform_ScaleTranslate ], // kFxPixelTransform_Full ],

kFxPropertyKey_VariesWhenParamsAreStatic : @YES,

kFxPropertyKey_NeedsFullBuffer : @YES,

kFxPropertyKey_ChangesOutputSize : @YES

};

return YES;

}


- ( BOOL ) destinationImageRect : ( FxRect * ) m_Destination_Image_Rectangle

sourceImages : ( NSArray < FxImageTile * > * ) m_Source_Images

destinationImage : ( FxImageTile * ) m_Destination_Image

pluginState : ( NSData * ) m_Plugin_State

atTime : ( CMTime ) m_Render_Time

error : ( NSError * _Nullable * ) m_Out_Error

{

Matrix44Data* pt = [ m_Source_Images [ 0 ].pixelTransform matrix ];

NSLog( @"NECTAR . PT . 0x:%f 0y:%f 0z:%f 0w:%f", (*pt)[0][0], (*pt)[0][1], (*pt)[0][2], (*pt)[0][3] ); // •••

NSLog( @"NECTAR . PT . 1x:%f 1y:%f 1z:%f 1w:%f", (*pt)[1][0], (*pt)[1][1], (*pt)[1][2], (*pt)[1][3] ); // •••

NSLog( @"NECTAR . PT . 2x:%f 2y:%f 2z:%f 2w:%f", (*pt)[2][0], (*pt)[2][1], (*pt)[2][2], (*pt)[2][3] ); // •••

NSLog( @"NECTAR . PT . 3x:%f 3y:%f 3z:%f 3w:%f", (*pt)[3][0], (*pt)[3][1], (*pt)[3][2], (*pt)[3][3] ); // •••


return YES;


}


Result:

PT . 0x:1.000000 0y:0.000000 0z:0.000000 0w:0.000000

PT . 1x:0.000000 1y:1.000000 1z:0.000000 1w:0.000000

PT . 2x:0.000000 2y:0.000000 2z:1.000000 2w:0.000000

PT . 3x:0.000000 3y:0.000000 3z:0.000000 3w:1.000000


The source layer is rotated 90° so the following identity matrix does make sense? How do I retrieve the transform matrix of the source layer correctly?


I tried in the render method as well with the same results.



Thank you,

David

Replies

That's just a vague idea about the quastion and potential solutions. So take it for what it's worth.

That's only if pure rotation (not comibned with translation)


Could you:

- take the original image, transform by rotation (with incremental values in a loop) and check when it best matches the transformed image.

- do the same, but applied only to a few points to save computation time

Not sure I understand. I am caching the results of the evaluation of the image.


I need to get the transformed vertices for the source image layer. Seems like it should be simple just transform by pixelTransform but that always seems to be the identity matrix ( except for scaling for thumbnails or dynamic resolution ).



thank you,

David

The pixel transform is not the layer's transform. It is the transformation that takes the 2D array of pixels of the image to an idealized 100% scale, square pixel image. So if you have HD footage that's 1440x1080 and the canvas is set to 1/2 resolution, you'll get an array of pixels that's 720x540. The pixel transform tells you how to go from that to an image that's 1920x1080. This allows you to forget about fields, proxy resolution, non-square pixels, etc., and do your rendering as if you were working on the full-frame square pixel image.

There's no way to get the transformation of a layer other than the one you are applied to. You can get the transform for the layer you're applied to by using the Fx3DAPI. (Or in the case of a generator, of the transform of the generator itself.)