CC Sphere是AE中非常常用的一个特效,常用它来做一些地球之类的效果。但我们知道它是一个假的三维,如果打开三维图层,摄像机从侧面去看,会发现它只是一个薄片,而它的旋转需要靠CC Sphere参数里的Rotation属性来做。
而这一组表达式非常有趣,可以直接利用摄像机来观察你的CC Sphere制作的球体,让它变得像一个真正的三维球体了,并且还可以链接一个灯光层,用灯光层的位置来影响CC Sphere的照明

放动图来看一波操作:

以下是CC Sphere的X、Y旋转的表达式:
CC Sphere Rotation X:
// change camera & effect names as needed...(根据需要更改相机和效果名称…)
campos=thisComp.activeCamera.toWorld([0,0,0]);
planetpos=thisLayer.toWorld(effect("CC Sphere")("Offset"));
x=length([planetpos[0],planetpos[1]], [campos[0],campos[2]]);
y=campos[1]-planetpos[1];
alpha=Math.atan2(y,x)
value+radiansToDegrees(alpha) ;
CC Sphere Rotation Y:
// change camera & effect names as needed...(根据需要更改相机和效果名称…)
campos=thisComp.activeCamera.toWorld([0,0,0]);
planetpos=thisLayer.toWorld(effect("CC Sphere")("Offset"));
x=campos[0]-planetpos[0];
y=planetpos[1]-campos[2];
beta=Math.atan2(y,x)
value+radiansToDegrees(beta) - 90;
这是光照的表达式。
CC Sphere Light Height
// change camera & light names as needed...(根据需要更换相机和灯光名称)
campos=thisComp.activeCamera.toWorld([0,0,0]);
planetpos=thisLayer.toWorld(effect("CC Sphere")("Offset"));
sunpos=thisComp.layer("Light 1").toWorld([0,0,0]);
camvector=normalize(campos-planetpos);
sunvector=normalize(sunpos-planetpos);
angle=Math.acos(dot(camvector, sunvector));
100 - (angle/Math.PI)*200
CC Sphere Light Direction
// change light name as needed...(根据需要更换灯光名称)
thesun=thisComp.layer("Light 1");
xy=thisLayer.fromWorld(thesun.position) - effect("CC Sphere")("Offset");
angle=Math.atan2(xy[1],xy[0]);
radiansToDegrees(angle) + 90;
在此基础上还可以再做一些改进,比如目前摄像机还无法影响CC Sphere的位移、远近,这时候可以打开CC Sphere图层的三维开关,并执行Auto-Orientation(Ctrl+Alt+O)命令,勾选orient towards camera,作用是让三维图层始终面朝摄像机,这时候就会发现摄像机能进一步影响球体的平移和远近了,更像一个三维的真实球体了

最后,要敲这么多表达式可能会比较麻烦,所以我把这个效果存成了一个预设,直接双击预设就能使用,需要的童鞋可自取: