Sceneekit–来自相机节点的UV投影

发布于 2025-02-07 11:02:49 字数 189 浏览 3 评论 0原文

我正在尝试将360图像从相机投射到网格喜欢这个

如果有人知道如何做到这一点,将会有所帮助。

I am trying to project 360 image from camera to mesh like this.

If anyone has idea on how to do this will be helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞取 2025-02-14 11:02:49

与Unity,Autodesk Maya或Foundry Nuke不同,在Scenekit中,相机不能成为投影仪。即使可以将SCNCAMERA用作360个项目,它也需要每台摄像机的6个摄像机的钻机 square https://stackoverflow.com/questions/50769722/50769722/how-to-use-environment-map-in-arkit/50772728#50772728"> like this ),不是矩形的远剪辑平面,就像您一样使用。

解决方案1 ​​ - GOBO

创建一个360个项目,使用 6个点灯 (带有 North-south-West-west-west-up-ind-down 方向)带有Gobo效果。 Gobo据说是“在光学之间”的首字母缩写词。

这是一个单点的示例代码(将每个点作为孩子节点添加到相机中)。

let projector = SCNNode()
projector.light = SCNLight()
projector.light?.type = .spot
projector.position.y = 10

projector.light?.gobo?.contents = UIImage(named: "imageForProjection.jpg")

projector.light?.gobo?.contentsTransform.m11 = 0.5    // texture's scale X
projector.light?.gobo?.contentsTransform.m22 = 0.5    // texture's scale Y

projector.light?.intensity = 1000
projector.eulerAngles.x = -.pi/2
camera.addChildNode(projector)

另外,还有三个有用的属性可以控制光的衰减:

var attenuationStartDistance: CGFloat { get set }
var attenuationEndDistance: CGFloat { get set }
var attenuationFalloffExponent: CGFloat { get set }

解决方案2

有时,您需要程序氛围环境照明带有立方图像图。

解决方案3

要从头开始生成球形,立方或圆柱形投影,请使用苹果金属

Unlike Unity, Autodesk Maya or The Foundry NUKE, in SceneKit a camera cannot be a projector. Even if the SCNCamera could be used as a 360-projector, it would require a rig of 6 cameras with a square far clipping plane for each camera (like this), not a rectangular far clipping plane, like you're using.

Solution 1 – Gobo

To create a 360-projector, use 6 spot lights (with north-south-east-west-up-down directions) with gobo effect. Gobo is supposedly an acronym for "goes between optics".

Here's a sample code for a single spot (add each spot as a child node to your camera).

let projector = SCNNode()
projector.light = SCNLight()
projector.light?.type = .spot
projector.position.y = 10

projector.light?.gobo?.contents = UIImage(named: "imageForProjection.jpg")

projector.light?.gobo?.contentsTransform.m11 = 0.5    // texture's scale X
projector.light?.gobo?.contentsTransform.m22 = 0.5    // texture's scale Y

projector.light?.intensity = 1000
projector.eulerAngles.x = -.pi/2
camera.addChildNode(projector)

enter image description here

Also, there are three useful properties to control light's attenuation:

var attenuationStartDistance: CGFloat { get set }
var attenuationEndDistance: CGFloat { get set }
var attenuationFalloffExponent: CGFloat { get set }

Solution 2

Sometimes, you need a Procedural Ambience and an Environmental Lighting with a cubic image map.

Solution 3

To generate a spherical, cubic or cylindrical projection from scratch, use Apple Metal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文