3 Replies Latest reply: Jan 11, 2009 12:35 PM by spdorsey6969 RSS

    Opacity linking to camera location

    spdorsey6969 Community Member
      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
        • 1. Re: Opacity linking to camera location
          Dan Ebberts Community Member
          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
          • 2. Re: Opacity linking to camera location
            spdorsey6969 Community Member
            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
            • 3. Re: Opacity linking to camera location
              spdorsey6969 Community Member
              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)