Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Opacity linking to camera location

Contributor ,
Jan 11, 2009 Jan 11, 2009
I may have asked this before, but I cannot find the question.

I'd like to link the opacity of a 3D layer to the location of the camera - so that items become more opaque when they become (for example) 500px from camera. I'd want to adjust the number to suit the animation.

Is this easy? Any resources that anyone knows of to do this?

Thanks

----------S
TOPICS
Scripting
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2009 Jan 11, 2009
This will ramp the opacity from 0 to 100 as the layer moves from 0 to 500 pixels away from the camera. Should be easy to modify if it's not exactly what you're after:

maxDist = 500;
minDist = 0;
maxOpacity = 100;
minOpacity = 0;

C = thisComp.activeCamera;
d = length(C.toWorld([0,0,0]),toWorld(anchorPoint));
linear(d,minDist,maxDist,minOpacity,maxOpacity)

Dan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 11, 2009 Jan 11, 2009
That is almost perfect - thank you very much for your help.

One more question. . .

How would I link the "maxDist" to the X value of a null - so that I can move that null and easily adjust the value?

I have MANY layers that I need to use this on, and it's easier to test this way to get the correct settings rather then copy/past the script OVER&OVER&OVER.

Thanks again, I appreciate the help!

-------S
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 11, 2009 Jan 11, 2009
LATEST
I figured it out!

There's hope for me yet!

I have to make sure that x y and z values for my null are computed separately by right-clicking on the null's position attribute and selecting "separate dimensions".

maxDist = thisComp.layer("nullName").transform.xposition;
minDist = 0;
maxOpacity = 100;
minOpacity = 0;

C = thisComp.activeCamera;
d = length(C.toWorld([0,0,0]),toWorld(anchorPoint));
linear(d,minDist,maxDist,minOpacity,maxOpacity)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines