Skip to main content
Participating Frequently
February 27, 2010
Question

Turn Down Opacity or Hide Layer

  • February 27, 2010
  • 3 replies
  • 3663 views

Hi @ everybody,

1) I would like to turn on/off the layer (toggle hide) or turn down the opacity to 100%. Can you explain me how i can do that?

I did a littl research and found just one forum post about opacity:

PF_compositeMode

    compositeMode.opacity   = PF_MAX_CHAN8; // 0 - 255

would be nice if someone could give me a hint

2) I've played around with the "resize"-example by adding currentframenumber (in-data->current_time / in-data->time_step) to the border-size to give it a dynamic changement. I've recognized that it only works when i add keyframes to that effect. I think i did not totally understand how to handle with specific variables.

the change i've made:

out_data->width  = 2 * static_cast<A_long>(border_x) + params[0]->u.ld.width +  6* (in_data->current_time / in_data->time_step);

out_data->height = 2 * static_cast<A_long>(border_y) + params[0]->u.ld.height + 6* (in_data->current_time / in_data->time_step) ;

i thought, that as soon as i click play, the timeline is increasing, that the changes will be made.

by the way what is

u.ld.width

This topic has been closed for replies.

3 replies

yafes7Author
Participating Frequently
February 28, 2010

euheuheuhe are you living in the same flat?

first of all i want to thank you both, really informative. Now i have the commands, but i don't know how they are handled in action. I've opened up about 10 examples but i could't find anywhere where AEGP_SetLayerFlag is used.

Thats what i got from the SDK-Guide:

AEGP_SetLayerFlag( AEGP_LayerH layerH, AEGP_LayerFlagssingle_flag, A_BooleanvalueB);

otherwise i couldn't also not find any usage of AEGP_GetLayerFlags...

if you know a example file, it would be more easy for me. I don't want to scrump your time. I've started doing my idea in expressions, but i would like to learn how to build plugins. So what was my expression doing?


var moduloConst = 32;
if(timeToFrames(time)%moduloConst<moduloConst/2)
transform.opacity = 100;
moduloConst =/2;
}
else {
transform.opacity = 0;
}

that was "turning on/off" the layer. I would like to use that for fast cut scenes in horror-movies. Thats why i was asking for the time and the opacity or if possible the "eye" turn on/off

thank you very much

Inspiring
March 1, 2010

You can use the AEGP_SetLayerFlag like every other suite function. Have a look at the following code snippet.

AEGP_SuiteHandler suites(in_data->pica_basicP); //the suite handler

AEGP_LayerH your_layer = whatever your layer is

A_Boolean valueB = FALSE; //True if you want to turn it on

suites.LayerSuite6()->AEGP_SetLayerFlag(your_layer,AEGP_LayerFlag_VIDEO_ACTIVE,valueB);

Looking at your expression, there is no way you can achieve that using layer flags, because they are not keyframed. So you have to use the opacity of the layer and streams. To understand streams, there are many example projects in the SDK like Streamie etc etc.,

But, I highly suggest you to do this using AE Scripting instead of going in the plugin route. Trust me, it saves you a lot of time and debugging.

If you are that particular of creating a plugin, another way is to calculate your time interval based on the time given by the In_data and then fill the image buffer with NULL (Basically, transparent pixels) so that it gives you a zero opacity effect. That'll save you from using streams.

BTW, I didnt see your expression in great detail, but isn't that similar to the "Strobe Light" effect that comes with AE by default. I am not sure, but you might wanna have a look at it.

yafes7Author
Participating Frequently
March 1, 2010

Hi gutsblow,

a friend of me, who is using AE a lot in Postpro told me already, that such an effect is also possible with strobelights. I've already watched out but recognized, that strobelight supports only linear deformation but i want to create an exponential one.

    8sec     4s  2s

[           ] [     ] [ ]  => it will give an effect of "getting closer"

so as i said it will be really easy with this littl script, but for learning purposes i want to do that by c++ plugin.

I want to start with a short complexity, so your hint with filling the image buffer with 0 seems for me very reasonable.

Sorry for that question, but is the "out_data" ? maybe you can tell me a example file, where the outbuffer is filled with a blank color.

thank you very much for your concern.

Inspiring
February 27, 2010

1.To Hide a Layer, you need to get the layer's flag AEGP_LayerFlag_VIDEO_ACTIVE (or audio if you want) of that layer using AEGP_GetLayerFlags and then set the layer flag using AEGP_SetLayerFlag with a A_boolean  FALSE (or TRUE if you want to make it active.)

2. To change the opacity to 100% you have to use streams.

3. Coming to your other problem, I guess you are applying it to a still image. By default time varying effects dont work on still images unless you apply PF_OutFlag_NON_PARAM_VARY to the outflags. Once you add it, then you can see the changes even though you don't animate any parameter.

4.u.ld.width is the width parameter of the current layer AE is passing to your effect. Be default the current layer is also passed as a parameter union to your effect and you can obtain the dimensions from it. It is similar to PF_EffectWorld.

Hope this helps.

Community Expert
February 27, 2010

1) what do you mean by "turn off the layer"?

do you want to toggle the layer's visibility, mimicking a user click on the layer's "eye" icon?

if so the use AEGP_SetLayerFlag along with AEGP_LayerFlag_VIDEO_ACTIVE (at some constellation).

what do you mean by turning down the opacity?

if you want to turn the actual layer's opacity, then use AEGP_SetStreamValue along with AEGP_LayerStream_OPACITY.

on the other hand if you want to lower the opacity of your plug-in's input, the copy it to the output using composite_rect, or transfer_rect.

both of which have a transparency param.

2) the reason your plug-in renders only when it has keyframes is that AE caches your plug-in's result, and won't call upon it to render unless something has changed.

AE is not aware of internal changes in your plug-in and will only regard changes in the input image or on the effect params as reason to render.

to overcome that, you must set the PF_OutFlag_NON_PARAM_VARY flag during global setup (and the resource file), to tell AE to call on your plug-in every frame, regardless of not having detected any changes.

note that this will help you with the arbitrary test you're making.

be sure to turn that flag off if you don't really need it. it will cripple performance is you kept that around for no reason.

Inspiring
February 27, 2010

Honest to God, I didnt see Shachar replying. I was typing it for a long time just to find a reply from Shachar. Trust me, you better follow his instructions.

Community Expert
February 27, 2010

HAHHAHAHAHAHHAHAHAHAHAH!!!!!!!!

Ahhhhh.....

nice.