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

Determining the apparent scale of a 3D layer

Enthusiast ,
Jul 26, 2011 Jul 26, 2011

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.

TOPICS
Expressions
1.5K
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 ,
Jul 26, 2011 Jul 26, 2011

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

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
Enthusiast ,
Jul 27, 2011 Jul 27, 2011

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:

Screen shot 2011-07-27 at 9.03.30 AM.png

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 ,
Jul 27, 2011 Jul 27, 2011

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

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
Enthusiast ,
Aug 01, 2011 Aug 01, 2011

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.

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 ,
Aug 01, 2011 Aug 01, 2011

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

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
Enthusiast ,
Aug 02, 2011 Aug 02, 2011

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]);

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 ,
Aug 02, 2011 Aug 02, 2011
LATEST

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

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