Copy link to clipboard
Copied
I was reading an entry on Wikipedia ( http://en.wikipedia.org/wiki/Image_resolution ) the section on "distinguishable squares" caught my eye.
Is there some fancy expression math trick in determining if a 3D layer is being viewed at >100% scale? Somehow take into account the AE camera distance, FOV, the target layer's pixel dimension and scale? I think collapse transforms would have to be off.
I'm doing a strict Z-move with a camera and my source 4K footage gets a little soft. I'd like a way to ensure its apparent visual scale doesn't go beyond 100% until its off screen.
Copy link to clipboard
Copied
It could get pretty complicated, especially if you have to consider that the layer might be angled to the camera such that one corner could be much closer than the others. If you only have to consider where the anchor point is in relation to the camera's focal plane, something like this should give you the apparent scale:
C = thisComp.layer("Camera 1");
v1 = toWorld(anchorPoint) - C.toWorld([0,0,0]);
v2 = C.toWorldVec([0,0,1]);
d = dot(v1,v2);
s = 100 * C./d
Calculating whether any part of the layer is actually visible would add another layer of complexity.
Dan
Copy link to clipboard
Copied
Thanks Dan! Yeah, this measurement would only hold true for layers perfectly flat relative to the camera viewing plane.
Perhaps I'm using this wrong, but I'm applying your expression to a text layer source and I'm getting a syntax error:
Copy link to clipboard
Copied
That's strange--I don't know how that happened. I'll try it again:
C = thisComp.layer("Camera 1");
v1 = toWorld(anchorPoint) - C.toWorld([0,0,0]);
v2 = C.toWorldVec([0,0,1]);
d = dot(v1,v2);
s = 100 * C.cameraOption.zoom/d
Dan
Copy link to clipboard
Copied
Maybe I'm getting mixed up. What property should I apply this to? If this is applied to the source text property of a text layer, I don't see it referring to the image layer in question.
Copy link to clipboard
Copied
That depends on what you're trying to do.If you wanted to limit a layer's apparent scale to 100%, you'd change the last line to something like this and apply it to the scale property:
s = Math.min(100 * C.cameraOption.zoom/d,100);
[s,s,s]
Dan
Copy link to clipboard
Copied
That's really helpful! Thanks!
But if I wanted to apply it to a text source to get a read-out on another layer's apparent scale, could I change the second line to this?
v1 = toWorld(thisComp.layer("whatever layer").transform.anchorPoint) - C.toWorld([0,0,0]);
Copy link to clipboard
Copied
Like this:
C = thisComp.layer("Camera 1");
L = thisComp.layer("other layer");
v1 = L.toWorld(L.anchorPoint) - C.toWorld([0,0,0]);
v2 = C.toWorldVec([0,0,1]);
d = dot(v1,v2);
s = 100 * C.cameraOption.zoom/d
Dan
Find more inspiration, events, and resources on the new Adobe Community
Explore Now