Artisanデータ型
以下は、Artisan API で最も一般的に使用されるデータ型です。
Artisan API で使用されるデータ型
Section titled “Artisan API で使用されるデータ型”| 型 | 説明 |
|---|---|
AEGP_RenderLayerContextH | レンダー要求時点のレイヤー状態情報です。After Effects から Artisan へ渡されます。 |
PR_RenderContextH | 何をどの条件でレンダリングするかを定義する設定集合です。 |
AEGP_SoundDataH | 対象レイヤーのオーディオ設定です。 |
AEGP_RenderReceiptHAEGP_FrameReceiptH | Artisan レンダリング時の受領情報(キャッシュ判定など)です。 |
AEGP_WorldH | 1 フレーム分のピクセルバッファです。 |
AEGP_RenderOptionsH | レンダーキュー項目に紐づくレンダー設定です。 |
行列の向き(Horz / Vert)
Section titled “行列の向き(Horz / Vert)”After Effects の行列は行優先(row-based)、OpenGL は列優先(column-based)です。
座標変換を扱う際は、この差分を吸収する実装が必要です。
実装設計の前提
Section titled “実装設計の前提”Artisan は「AEGP の 1 機能」というより、小さなレンダラー実装そのものに近い存在です。
交差判定やシェーディングなど、3D レンダリング問題には複数の設計アプローチがあります。
この API は、Adobe 本体とサードパーティの双方が任意の 3D レンダリング方式を実装できるよう設計されています。
3D 合成であり、3D モデリングではない
Section titled “3D 合成であり、3D モデリングではない”After Effects は 3D モデラー ではありません。
ユーザーは通常、操作中は軽い品質で作業し、確認時や最終出力時のみ高品質に切り替えます。
Artisan 実装では少なくとも 2 つの品質モード(レイアウト用 / 最終出力用)を用意し、低品質時の応答性を重視してください。
Artisan の登録
Section titled “Artisan の登録”Artisan は AEGP の一種で、単一のエントリポイントを持ちます。
加えて、Artisan 固有の各関数エントリポイントを登録する必要があります。
詳細は AEGP_RegisterSuite5 の AEGP_RegisterArtisan() を参照してください。
次の表は PR_ArtisanEntryPoints で定義される Artisan の実装関数です。必須なのは render_func のみです。
Artisan エントリポイント
Section titled “Artisan エントリポイント”| PR_ArtisanEntryPoints | |
|---|---|
global_setup_func0 | Called only once, right after GP_Main. The global data is common across all instances of the plug-in.If you allocate memory during Global Setup, you must free it during your global_setdown_func.PR_GlobalSetupFunc( |
global_setdown_func0 | Dispose of any global data you allocated.PR_GlobalSetdownFunc( |
global_do_about_func0 | Tell the world about yourself! Use in_dataP>msg_func to display your dialog.PR_GlobalDoAboutFunc( |
setup_instance_func0 | Allocate and instantiate any data specific to this instance of your Artisan.PR_InstanceSetupFunc( |
setdown_instance_func0 | Deallocate and free any data specific to this instance of your Artisan.PR_InstanceSetdownFunc( |
flatten_instance_func0 | Flatten your data in preparation to being written to disk. (making sure it’s OS independent, if your Artisan is).PR_FlattenInstanceFunc( |
do_instance_dialog_func0 | If your Artisan has a additional parameters (accessed through its Options dialog), this function will be called to get and set them.PR_DoInstanceDialogFunc(PR_DialogResultis is either PR_DialogResult_NO_CHANGE or PR_DialogResult_CHANGE_MADE. |
frame_setup_func0 | Perform any setup necessary to render a frame (called immediately before rendering).PR_FrameSetupFunc( |
frame_setdown_func0 | Dispose of any setup data allocated during frame_setup (sent immediately after rendering).PR_FrameSetdownFunc( |
render_func | Render the scene.PR_FrameRenderFunc( |
query_func0 | Artisans can draw their own projection axes, should the need arise. After Effects will call this function to obtain the transform between the composition world and those axes, as well as for a number of other functions related to on- and off-screen preview drawing (the former is relevant only to interactive artisans). PR_QueryFunc(PR_QueryType can be one of the following:- PR_QueryType_NONE = 0- PR_QueryType_TRANSFORM- PR_QueryType_INTERACTIVE_WINDOW_DISPOSE- PR_QueryType_INTERACTIVE_WINDOW_CLEAR- PR_QueryType_INTERACTIVE_WINDOW_FROZEN_PROXY- PR_QueryType_INTERACTIVE_SWAP_BUFFER- PR_QueryType_INTERACTIVE_DRAW_PROCS- PR_QueryType_PREPARE_FOR_LINE_DRAWING- PR_QueryType_UNPREPARE_FOR_LINE_DRAWING- PR_QueryType_GET_CURRENT_CONTEXT_SAFE_FOR_LINE_DRAWING- PR_QueryType_GET_ARTISAN_QUALITY (New in CS6.) |
レンダー対象レイヤーの取得と描画
Section titled “レンダー対象レイヤーの取得と描画”AEGP_RenderTexture() supplies the raw pixels of a layer, untransformed, into an arbitrarily-sized buffer.
AEGP_RenderLayer() invokes the entire After Effects render pipeline, including transforms, masking, et cetera, providing the layer as it appears in its composition, in a composition-sized buffer.
If the layer being rendered is 3D, the default (Standard 3D) Artisan is invoked to perform any 3D geometrics.
Your Artisan can use this to render track matte layers, and apply them only in a strictly 2D sense, to the transformed 3D layer.
Before rendering, the Artisans that ship with After Effects apply an inverse transform to get square pixels, then re-apply the transform before display.
For example, if the pixel aspect ratio is 10/11 (DV NTSC), we multiply by 11/10 to get square pixels. We process and composite 3D layers, then re-divide to get back to the original pixel aspect ratio.
The following suite supplies the layers, compositions, texture and destination buffers. This is a vital suite for all artisans.
AEGP_CanvasSuite8
Section titled “AEGP_CanvasSuite8”| Function | Purpose |
|---|---|
AEGP_GetCompToRender | Given the render context provided to the Artisan at render time, returns a handle to the composition.AEGP_GetCompToRender( |
AEGP_GetNumLayersToRender | Given the render context, returns the number of layers the Artisan needs to render.AEGP_GetNumLayersToRender( |
AEGP_GetNthLayerContextToRender | Used to build a list of layers to render after determining the total number of layers that need rendering by the Artisan.AEGP_GetNthLayerContextToRender( |
AEGP_GetLayerFromLayerContext | Given a AEGP_RenderLayerContextH,retrieves the associated AEGP_LayerH (required by many suite functions).AEGP_GetLayerFromLayerContext( |
AEGP_GetLayerAndSubLayerFromLayerContext | Allows for rendering of sub-layers (as within a Photoshop file).AEGP_GetLayerAndSubLayerFromLayerContext( |
AEGP_GetTopLayerFromLayerContext | With collapsed geometrics “on” this gives the layer in the root composition containing the layer context. With collapsed geometrics off this is the same as AEGP_GetLayerFromLayerContext.AEGP_GetTopLayerFromLayerContext( |
AEGP_GetCompRenderTime | Given the render context, returns the current point in (composition) time to render.AEGP_GetNthLayerIndexToRender( |
AEGP_GetCompDestinationBuffer | Given the render context, returns a buffer in which to place the final rendered output.AEGP_GetCompToRender( |
AEGP_GetROI | Given the render context provided to the Artisan at render time, returns a handle to the composition.AEGP_GetROI( |
AEGP_RenderTexture | Given the render context and layer, returns the layer texture. All parameters with a trailing ‘0’ are optional; the returned PF_EffectWorld can be NULL.AEGP_RenderTexture(AEGP_RenderHints contains one or more of the following:- AEGP_RenderHints_NONE- AEGP_RenderHints_IGNORE_EXTENTS- AEGP_RenderHints_NO_TRANSFER_MODE (prevents application of opacity & transfer mode; for use with RenderLayer calls.) |
AEGP_DisposeTexture | Disposes of an acquired layer texture.AEGP_DisposeTexture( |
AEGP_GetFieldRender | Returns the field settings of the given PR_RenderContextH.AEGP_GetFieldRender( |
AEGP_ReportArtisanProgress | Given the render context provided to the Artisan at render time, returns a handle to the composition. !!! note This is NOT thread-safe on macOS; only use this function when the current thread ID is 0. AEGP_ReportArtisanProgress( |
AEGP_GetRenderDownsampleFactor | Returns the downsample factor of the PR_RenderContextH.AEGP_GetRenderDownsampleFactor( |
AEGP_IsBlankCanvas | Determines whether the PR_RenderContextH is blank (empty).AEGP_IsBlankCanvas( |
AEGP_GetRenderLayerToWorldXform | Given a render context and a layer (at a given time), retrieves the 4 by 4 transform to move between their coordinate spaces.AEGP_GetRenderLayerToWorldXform( |
AEGP_GetRenderLayerBounds | Retrieves the bounding rectangle of the layer_contextH (at a given time) within the render_contextH.AEGP_GetRenderLayerBounds( |
AEGP_GetRenderOpacity | Returns the opacity of the given layer context at the given time, within the render context.AEGP_GetRenderOpacity( |
AEGP_IsRenderLayerActive | Returns whether or not a given layer context is active within the render context, at the given time.AEGP_IsRenderLayerActive( |
AEGP_SetArtisanLayerProgress | Sets the progress information for a rendering Artisan. - countL is the number of layers completed,- num_layersL is the total number of layers the Artisan is rendering.AEGP_SetArtisanLayerProgress( |
AEGP_RenderLayerPlus | Similar to AEGP_RenderLayer, but takes into account the AEGP_RenderLayerContextH.AEGP_RenderLayerPlus( |
AEGP_GetTrackMatteContext | Retrieves the AEGP_RenderLayerContextH for the specified render and fill contexts.AEGP_GetTrackMatteContext( |
AEGP_RenderTextureWithReceipt | Renders a texture into an AEGP_WorldH, and provides an AEGP_RenderReceiptH for the operation.The returned receiptPH must be disposed of with AEGP_DisposeRenderReceipt.AEGP_RenderTextureWithReceipt( |
AEGP_GetNumberOfSoftwareEffects | Returns the number of software effects applied in the given AEGP_RenderLayerContextH.AEGP_GetNumberOfSoftwareEffects( |
AEGP_RenderLayerPlusWithReceipt | An improvement over AEGP_RenderLayerPlus, this function also provides an AEGP_RenderReceiptH for caching purposes.AEGP_RenderLayerPlusWithReceipt( |
AEGP_DisposeRenderReceipt | Frees an AEGP_RenderReceiptH.AEGP_DisposeRenderReceipt( |
AEGP_CheckRenderReceipt | Checks with After Effects’ internal caching to determine whether a given AEGP_RenderReceiptH is still valid.AEGP_CheckRenderReceipt( |
AEGP_GenerateRenderReceipt | Generates a AEGP_RenderReceiptH for a layer as if the first num_effectsS have been rendered.AEGP_GenerateRenderReceipt( |
AEGP_GetNumBinsToRender | Returns the number of bins After Effects wants the artisan to render.AEGP_GetNumBinsToRender( |
AEGP_SetNthBin | Sets the given render context to be the n-th bin to be rendered by After Effects.AEGP_SetNthBin( |
AEGP_GetBinType | Retrieves the type of the given bin.AEGP_GetBinType(AEGP_BinType will be one of the following:- AEGP_BinType_NONE- AEGP_BinType_2D- AEGP_BinType_3D |
AEGP_GetRenderLayerToWorldXform2D3D | Retrieves the transform to correctly orient the layer being rendered with the output world. Pass TRUE for only_2dB to constrain the transform to two dimensions.AEGP_GetRenderLayerToWorldXform2D3D( |
| Function | Purpose |
|---|---|
AEGP_GetPlatformWindowRef | Retrieves the platform-specific window context into which to draw the given PR_RenderContextH.AEGP_GetPlatformWindowRef( |
AEGP_GetViewportScale | Retrieves the source-to-frame downsample factor for the given PR_RenderContextH.AEGP_GetViewportScale( |
AEGP_GetViewportOrigin | Retrieves to origin of the source, within the frame (necessary to translate between the two), for the given PR_RenderContextH.AEGP_GetViewportOrigin( |
AEGP_GetViewportRect | Retrieves the bounding rectangle for the area to be drawn, for the given PR_RenderContextH.AEGP_GetViewportRect( |
AEGP_GetFallowColor | Retrieves the color used for the fallow regions in the given PR_RenderContextH.AEGP_GetFallowColor( |
AEGP_GetInteractiveCheckerboard | Retrieves whether or not the checkerboard is currently active for the given PR_RenderContextH.AEGP_GetInteractiveCheckerboard( |
AEGP_GetInteractiveCheckerboardColors | Retrieves the colors used in the checkerboard.AEGP_GetInteractiveCheckerboardColors( |
AEGP_GetInteractiveCheckerboardSize | Retrieves the width and height of one checkerboard square.AEGP_GetInteractiveCheckerboardSize( |
AEGP_GetInteractiveCachedBuffer | Retrieves the cached AEGP_WorldH last used for the PR_RenderContextH.AEGP_GetInteractiveCachedBuffer( |
AEGP_ArtisanMustRenderAsLayer | Determines whether or not the artisan must render the current AEGP_RenderLayerContextH as a layer.AEGP_ArtisanMustRenderAsLayer( |
AEGP_GetInteractiveDisplayChannel | Returns which channels should be displayed by the interactive artisan.AEGP_GetInteractiveDisplayChannel(AEGP_DisplayChannelType will be one of the following:- AEGP_DisplayChannel_NONE- AEGP_DisplayChannel_RED- AEGP_DisplayChannel_GREEN- AEGP_DisplayChannel_BLUE- AEGP_DisplayChannel_ALPHA- AEGP_DisplayChannel_RED_ALT- AEGP_DisplayChannel_GREEN_ALT- AEGP_DisplayChannel_BLUE_ALT- AEGP_DisplayChannel_ALPHA_ALT |
AEGP_GetInteractiveExposure | Returns the exposure for the given PR_RenderContextH, expressed as a floating point number.AEGP_GetInteractiveExposure( |
AEGP_GetColorTransform | Returns the color transform for the given PR_RenderContextH.AEGP_GetColorTransform( |
AEGP_GetCompShutterTime | Returns the shutter angle for the given PR_RenderContextH.AEGP_GetCompShutterTime( |
AEGP_MapCompToLayerTime | New in CC. Unlike AEGP_ConvertCompToLayerTime, this handles time remapping with collapsed or nested comps.AEGP_MapCompToLayerTime( |
コンテキスト間の変換
Section titled “コンテキスト間の変換”Convert between render and instance contexts, and manage global data specific to the artisan.
AEGP_ArtisanUtilSuite1
Section titled “AEGP_ArtisanUtilSuite1”| Function | Purpose |
|---|---|
AEGP_GetGlobalContextFromInstanceContext | Given an instance context, returns a handle to the global context.AEGP_GetGlobalContextFromInstanceContext( |
AEGP_GetInstanceContextFromRenderContext | Given the render context, returns a handle to the instance context.AEGP_GetInstanceContextFromRenderContext( |
AEGP_GetInstanceContextFromQueryContext | Given a query context, returns a handle to the instance context.AEGP_GetInstanceContextFromQueryContext( |
AEGP_GetGlobalData | Given the global context, returns a handle to global data.AEGP_GetGlobalData( |
AEGP_GetInstanceData | Given an instance context, return the associated instance data.AEGP_GetInstanceData( |
AEGP_GetRenderData | Given a render context, returns the associated render data.AEGP_GetRenderData( |
Obtains the camera geometry, including camera properties (type, lens, depth of field, focal distance, aperture, et cetera).
AEGP_CameraSuite2
Section titled “AEGP_CameraSuite2”| Function | Purpose |
|---|---|
AEGP_GetCamera | Given a layer handle and time, returns the current camera layer handle.AEGP_GetCamera( |
AEGP_GetCameraType | Given a layer, returns the camera type of the layer.AEGP_GetCameraType(The camera type can be the following: - AEGP_CameraType_NONE = -1- AEGP_CameraType_PERSPECTIVE- AEGP_CameraType_ORTHOGRAPHIC |
AEGP_GetDefaultCameraDistanceToImagePlane | Given a composition handle, returns the camera distance to the image plane.AEGP_GetDefaultCamera DistanceToImagePlane( |
AEGP_GetCameraFilmSize | Retrieves the size (and units used to measure that size) of the film used by the designated camera.AEGP_GetCameraFilmSize( |
AEGP_SetCameraFilmSize | Sets the size (and unites used to measure that size) of the film used by the designated camera.AEGP_SetCameraFilmSize)( |
カメラの動作に関する注意事項
Section titled “カメラの動作に関する注意事項”カメラの向きは合成座標で表され、回転はレイヤー (カメラのレイヤー) 座標で表されます。
カメラ レイヤに親がある場合、位置は親を基準とした座標空間内にあります。
正投影カメラ マトリックス
Section titled “正投影カメラ マトリックス”内部的には、コンポジションの幅と高さを使用して、OpenGL 仕様で記述されているマトリックスを次のように設定します。
glOrtho(-width/2, width/2, -height/2, height/2, -1, 100);正投影行列は投影を表します。カメラの位置は、別のスケーリングされた行列によって記述されます。カメラ位置行列の逆行列により、「目」の座標が得られます。
フォーカルに焦点を当てる
Section titled “フォーカルに焦点を当てる”焦点距離は視野に影響することに注意してください。焦点距離は被写界深度にのみ影響します。
フィルムサイズ
Section titled “フィルムサイズ”現実の世界では、フィルムのサイズはミリメートル単位で測定されます。 After Effects では、ピクセル単位で測定されます。ミリメートルからピクセルに移動するには、72 を掛けて 25.4 で割ります。
視野はより複雑です。
ϴ = 1/2 視野
Tan(ϴ) = 1/2 構図の高さ / 焦点距離
焦点距離 = 2tan(ϴ) / 構図の高さ
ライトを当てよう!
Section titled “ライトを当てよう!”コンポジション内のライトのタイプを取得および設定します。
AEGP_LightSuite2
Section titled “AEGP_LightSuite2”| Function | Purpose |
|---|---|
AEGP_GetLightType | Retrieves the AEGP_LightType of the specified camera layer.AEGP_GetLightType(AEGP_LightType will be one of the following:- AEGP_LightType_PARALLEL- AEGP_LightType_SPOT- AEGP_LightType_POINT- AEGP_LightType_AMBIENT |
AEGP_SetLightType | Sets the AEGP_LightType for the specified camera layer.AEGP_SetLightType( |
ライト挙動の注意点
Section titled “ライト挙動の注意点”The formula for parallel lights is found in Foley and Van Dam’s “Introduction to Computer Graphics” (ISBN 0-201-60921-5) as is the formula for point lights.
We use the half angle variant proposed by Jim Blinn instead.
Suppose we have a point on a layer and want to shade it with the light.
Let V be the unit vector from the layer point to the eye point. Let L be the unit vector to the light (in the parallel light case this is constant). Let H be (V+L)/2 (normalized). Let N be the unit normal vector to the layer.
The amount of specular reflected light is S * power(H Dot N, shine), where S is the specular coefficient.
3D ハンドル描画
Section titled “3D ハンドル描画”After Effects relies upon Artisans to draw 3D layer handles. If your Artisan chooses not to respond to this call, the default Artisan will draw 3D layer handles for you. Querying transforms is important for optimization of After Effects’ caching.
The coordinate system is positive x to right, positive y down, positive z into the screen. The origin is the upper left corner. Rotations are x then y then z. For matrices the translate is the bottom row, orientations are quaternions (which are applied first), then any x-y-z rotation after that. As a general rule, use orientation or rotation but not both. Also use rotations if you need control over angular velocity.
変換クエリ関数
Section titled “変換クエリ関数”These functions give artisans information about the transforms they’ll need in order to correctly place layers within a composition and respond appropriately to the various queries After Effects will send to their PR_QueryFunc entry point function.
As that entry point is optional, so is your artisan’s response to the queries; however, if you don’t, your users may be disappointed that (while doing interactive preview drawing) all the camera and light indicators vanish, until they stop moving! Artisans are complex beasts; contact us if you have any questions.
AEGP_QueryXFormSuite2
Section titled “AEGP_QueryXFormSuite2”| Function | Purpose |
|---|---|
AEGP_QueryXformGetSrcType | Given a query context, returns trasnsform source currently being modified.AEGP_QueryXformGetSrcType(The query context will be one of the following: - AEGP_Query_Xform_LAYER- AEGP_Query_Xform_WORLD- AEGP_Query_Xform_VIEW- AEGP_Query_Xform_SCREEN |
AEGP_QueryXformGetDstType | Given a query context, returns the currently requested transform destination.AEGP_QueryXformGetDstType( |
AEGP_QueryXformGetLayer | Used if the source or destination type is a layer. Given a query context, returns the layer handle.AEGP_QueryXformGetLayer( |
AEGP_QueryXformGetComp | Given a query context, returns the current composition handle.AEGP_QueryXformGetComp( |
AEGP_QueryXformGetTransformTime | Given a query context, returns the time of the transformation.AEGP_QueryXformGetTransformTime( |
AEGP_QueryXformGetViewTime | Given a query context, returns the time of the associated view.AEGP_QueryXformGetViewTime( |
AEGP_QueryXformGetCamera | Given a query context, returns the current camera layer handle.AEGP_QueryXformGetCamera( |
AEGP_QueryXformGetXform | Given a query context, returns the current matrix transform.AEGP_QueryXformGetXform( |
AEGP_QueryXformSetXform | Given a query context, return the matrix transform you compute in xform.AEGP_QueryXformSetXform( |
AEGP_QueryWindowRef | Sets the window reference to be used (by After Effects) for the given PR_QueryContextH.AEGP_QueryWindowRef( |
AEGP_QueryWindowClear | Returns which AEGP_PlatformWindowRef (and A_Rect) to clear, for the given PR_QueryContextH.AEGP_QueryWindowClear( |
AEGP_QueryFrozenProxy | Returns whether or not the textures used in the given PR_QueryContextH should be frozen.AEGP_QueryFrozenProxy( |
AEGP_QuerySwapBuffer | Sent after rendering and camera/light handle drawing is complete; After Effects returns the buffer into which the artisan should draw its output.AEGP_QuerySwapBuffer( |
AEGP_QueryDrawProcs | Sets the interactive drawing functions After Effects will call while drawing camera and lighting handles into the artisan’s provided context.AEGP_QueryDrawProcs( |
AEGP_QueryPrepareForLineDrawing | Informs After Effects about the context into which it will be drawing.AEGP_QueryPrepareForLineDrawing( |
AEGP_QueryUnprepareForLineDrawing | As far as After Effects is concerned, the artisan is done drawing lines.AEGP_QueryUnprepareForLineDrawing( |
インタラクティブ描画関数
Section titled “インタラクティブ描画関数”We’ve added the ability for artisans to provide functions After Effects can use to do basic drawing functions for updating the comp window display during preview, including camera, light, and wireframe preview modeling.
PR_InteractiveDrawProcs
Section titled “PR_InteractiveDrawProcs”| Function | Purpose |
|---|---|
PR_Draw_MoveToFunc | PR_Draw_MoveToFunc( |
PR_Draw_LineToFunc | PR_Draw_LineToFunc( |
PR_Draw_ForeColorFunc | PR_Draw_ForeColorFunc( |
PR_Draw_FrameRectFunc | PR_Draw_FrameRectFunc( |
PR_Draw_PaintRectFunc | PR_Draw_PaintRectFunc( |
クエリ時関数に関する注意事項
Section titled “クエリ時関数に関する注意事項”AEGP_QueryXformGetTransformTime() と AEGP_QueryXformGetViewTime() は両方とも、職人がレンダリングするシーンの表現を構築するために必要です。
AEGP_QueryXformGetTransformTime() は変換の時間を取得し、AEGP_CompSuite11 から AEGP_GetCompShutterFrameRange() に渡します。
AEGP_QueryXformGetViewTime() はビューの時間を取得します。これは AEGP_LayerSuite9 から AEGP_GetLayerToWorldXformFromView() を呼び出す際に使用されます。