ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

layer transparency distance from camera

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
mindset
layer transparency distance from camera
on Oct 13, 2007 at 8:18:08 pm

I need an expression that does the following:

the further a layer gets from a camera, the darker it gets until it is fully transparent...here is the catch I need to layer to remain at ful opacity for "x" amount of time. Anybody know of any way to accomplish this?


Return to posts index

Dan Ebberts
Re: layer transparency distance from camera
on Oct 13, 2007 at 9:49:47 pm

Do you really mean "x amount of time", or do you mean its opacity needs to be 100% until it reaches a certain distance from the camera and then it fades until it reaches some other distance where it would be 0%? That would be like this:

C = thisComp.activeCamera;
startFade = 500;
endFade = 1500;
d = length(toWorld(anchorPoint),C.toWorld([0,0,0]));
linear(d,startFade,endFade,100,0)


I'm not sure what it would be if you mean something else.

Dan


Return to posts index

mindset
Re: layer transparency distance from camera
on Oct 13, 2007 at 10:22:14 pm

how about if the camera is in another comp and I am collapsing transformations?


Return to posts index


Dan Ebberts
Re: layer transparency distance from camera
on Oct 13, 2007 at 10:32:15 pm

I think you'd just change the first line to this:

C =comp("your outer comp name goes here").activeCamera;


Dan


Return to posts index

mindset
Re: layer transparency distance from camera
on Oct 13, 2007 at 10:44:49 pm

this doesn't seem to be operating correctly...can you explain the parameters?


Return to posts index

mindset
Re: layer transparency distance from camera
on Oct 13, 2007 at 10:55:50 pm

hey dan,
it is fading in and out...I apoloigze for not explain clearly. The camera is flying by an image tunnel...and I need them to slowly fade away as they get further from the camera. But currently, they are fading based on distance...so when they are infront of the camera they are also fading...I need to eliminate this effect. understand? I apologize if I am not clear.


Return to posts index


Passo3d
Re: layer transparency distance from camera
on Oct 14, 2007 at 5:53:40 am

not that i can shed a new light on this situation...
but it wouldn't kill ya to add a "Please" or a "Thank you" somewhere in the post.
all this "i need" stuff doesn't come off too polite...


Return to posts index

mindset
Re: layer transparency distance from camera
on Oct 14, 2007 at 7:06:50 pm

point taken...thanks for the advice...although, adding tone to emails and forum post is a dangerous practice...what you interpeted as unpolietness was really deep confusion.


Return to posts index

Dan Ebberts
Re: layer transparency distance from camera
on Oct 14, 2007 at 6:41:26 pm

Sorry, you lost me. I'm sure there's a soulution - I'm just not sure what the problem is. :-)

Dan


Return to posts index


mindset
Re: layer transparency distance from camera
on Oct 14, 2007 at 8:09:20 pm

First I want to take a minue and say thanks for all the help...

so the issue is that the opacity of the layers is not stayig at 100% behind the camera. what it is doing is starting at 0 rising to 100, only for a frame and then dropping back down to 0.

Example:

layer 1 is at postion -300 z, behind the camera (at this position it is 0% opacity)), when it reaches pos 0, it becomes 100% opacity. then when it reaches pos 300 it is at 0 opacity again. Basically what I am trying to do is have it at 100% opacity until position 0 then dissolve away. The positions I put in this example are abritrary, and not exactly relavant to the actually composition, because there are so many layers and they all have different positions that the camera flys by.

I have built 7 comps, each with about 100 layers, all the layers are in different places in z space. I brought these 7 comps into another comp, collapsed thir transformation (to maintain their z space), offset them and flew a camera through them. Creating a tunnel of images.

I hope this better explains my situation and delimea. What do you think?


Return to posts index

Dan Ebberts
Re: layer transparency distance from camera
on Oct 14, 2007 at 8:47:27 pm

What you descibed (I think) covers layers on the camera's z axis. What about layers that are off axis? What determines their opacity - distance from the camera, distance from the camera's z-plane, or ?

Dan


Return to posts index

mindset
Re: layer transparency distance from camera
on Oct 15, 2007 at 4:17:02 pm

currently I believe their opacity is determained by distance from camera in z space


Return to posts index


Dan Ebberts
Re: layer transparency distance from camera
on Oct 15, 2007 at 7:32:14 pm

Well, I'm lost. What I'm picturing doesn't make any sense. Maybe somebody else (with more imagination) can jump in and help out.

Dan


Return to posts index

sam.mltn
Re: layer transparency distance from camera
on Nov 22, 2007 at 6:52:54 am

From what I understand you want to pull back through a tunnel of images and as they get a certain distance from the camera you want them to fade out.

The part I don't understand is why visibility matters if the layers are behind the camera, because you can't see them when they are behind the camera. Dan's expression should work just fine if you establish the proper distances for the images to start and end their fade out.


Return to posts index

Chad Smith
Re: layer transparency distance from camera
on Jan 16, 2009 at 4:48:54 am

Would a similar setup work for applying a Fast Blur to a layer based on distance(fake DOF) and if so what would that expression look like? Thanks in advance for any help you can offer.



Return to posts index


Jim Darski
Re: layer transparency distance from camera
on Oct 4, 2012 at 8:31:53 pm

Thanks so much. This works very well.
My question is: is there a way to adjust this expression to fade in when close to the camera in addition to fading out when away from the camera? For example: the object is transparent when closer than 50 from camera. From 100 to 200 its transparency goes from 0 to 100. And then 500 to 1500 it fades out as you have it now.
I was trying to put additional startFade and endFade commands, but it didn't work.

jim


Return to posts index

Dan Ebberts
Re: layer transparency distance from camera
on Oct 4, 2012 at 8:53:32 pm

I don't understand the closer than 50 part (it seems like that's covered by the 100 to 200 range) but here's one way to do two ranges:

C = thisComp.activeCamera;
startFade1 = 100;
endFade1 = 200;
startFade2 = 500;
endFade2 = 1500;
d = length(toWorld(anchorPoint),C.toWorld([0,0,0]));
if (d < (endFade1+startFade2)/2)
linear(d,startFade1,endFade1,0,100)
else
linear(d,startFade2,endFade2,100,0)



Return to posts index

Jim Darski
Re: layer transparency distance from camera
on Oct 4, 2012 at 9:02:04 pm

This is exactly what I need! I made a mistake and should have said closer than 100... But you got it. Basically I tried to say that I need to set up 2 ranges.
Thanks so much!
j.


Return to posts index


Nelson Rayner
Re: layer transparency distance from camera
on Jan 27, 2016 at 12:10:14 pm

Hey Everyone!

I have several layers (in the Z axis) of pre-composed image grids (with some images missing), that a camera is moving through and around.

What I'm trying to do is move around and focus on some of these images whilst the layers in the background are more transparent as to make the composition less busy and to focus on the images in the foreground. Also, as the camera moves through the images, the grids become transparent just before they hit the camera.

I'm having trouble with Dan's script as when the camera is moving through and around the grids, obviously the anchor point of each becomes further away from the camera and the grids become less opaque.

What I'm wondering is....if there a way to let the script reference the z position of the layer rather than the anchor point position so as to negate this issue?

Thanks in advance for helping!


Return to posts index

Stuart Simpson
Re: layer transparency distance from camera
on Nov 28, 2017 at 12:05:53 pm

Hi all,

If I'm reading this correctly I have the same issue. I've been using this Dan's expression (below) for the opacity of a series of layers. With the camera in a master comp and the 3D layers in a pre-comp within the Master comp (the pre-comp is a 3D layer in the master comp with transformations collapsed).

The problem is the x-position seems to be affecting the opacity and I need just the z position. Any ideas greatly appreciated! :)

startFade = thisComp.layer("opacity controller").effect("start")("Slider");
endFade = thisComp.layer("opacity controller").effect("end")("Slider");
C = comp("MASTER").activeCamera;
CL = comp("MASTER").layer(thisComp.name);
CL.toWorld(toWorld(anchorPoint));
d = length(CL.toWorld(toWorld(anchorPoint)),C.toWorld([0,0,0]));
linear(d,startFade,endFade,100,0)


Return to posts index

Stuart Simpson
Re: layer transparency distance from camera
on Nov 28, 2017 at 12:59:39 pm

Okay this seems to work, although I'm sure it can be made more elegant!

Basically, only the z depth seems to affecting the opacity now, not any of the other position coordinates.

I've added my own novice understanding of what's happening so please feel free to correct and improve for the benefit of others :)

// SETTING THE CONTROLS //
startFade = thisComp.layer("opacity controller").effect("start")("Slider");
endFade = thisComp.layer("opacity controller").effect("end")("Slider");

// CONVERTING THE COORDIANTES //
C = comp("MASTER").activeCamera; // SELECTS THE CAMERA LAYER IN THE MASTER COMP //
CL = comp("MASTER").layer(thisComp.name); // SELECTS THE PRE-COMP IN THE MASTER COMP //
CLTRANS = CL.toWorld(toWorld(anchorPoint)); // CONVERTS THE PRE COMP LAYER ANCHOR TO WORLD COORDINATES //
CTRANS = C.toWorld([0,0,0]); // CONVERTS THE CAMERA LAYER POSITION TO WORLD COORDINATES //

// CALCULATING THE FADE //
ZONE = CLTRANS[2];
ZTWO = CTRANS[2];
d = length(ZONE, ZTWO);
linear(d,startFade,endFade,0,100)


Return to posts index

Adam Nelson
Re: layer transparency distance from camera
on Sep 28, 2016 at 7:10:47 pm

Awesome expression, Dan! This really got me out of a jam today on a quick turnaround and it makes me want to learn a lot more about the toWorld command.

Thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]