直接从 usdz 文件而不是 Reality Composer 文件加载模型时,如何在 RealityKit 中渲染阴影? [英] How can I get shadows to render in RealityKit when loading models directly from usdz files rather than a Reality Composer file?

查看:74
本文介绍了直接从 usdz 文件而不是 Reality Composer 文件加载模型时,如何在 RealityKit 中渲染阴影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将模型直接从 usdz 文件添加到场景锚点时,模型下方不会出现接地阴影.如果您将模型导入 RealityComposer 并添加 RealityComposer 场景,则会出现这些.但是你能在不使用 RC 的情况下启用接地阴影吗?

When adding a model directly to a scene anchor from a usdz file, there are no grounding shadows appearing under the model. These appear if you import the model into RealityComposer and add the RealityComposer scene. But can you enable grounding shadows without using RC?

我曾尝试向场景中添加一个 DirectionalLight,但这并没有投射任何阴影.我也尝试过更改 ARView 上的 RenderingOptions.

I have tried adding a DirectionalLight to the scene, but this is not casting any shadows. I have also tried changing the RenderingOptions on the ARView.

//no shadows
  penguin = try? Entity.loadModel(named: "penguin", in: nil)
  penguinAnchor.addChild(penguin!)

//shadows
  penguinScene = try! PenguinRC.loadPenguinScene()
  arView.scene.addAnchor(penguinScene)

推荐答案

我在这个问题上取得了一些进展.

I made some progress with this issue.

从加载的 USDZ 投射阴影似乎依赖于实体(或更好的)ModelEntity 通过平面初始值设定项添加到 AnchorEntity,而不是像这样的简单 AnchorEntity():

Casting shadows from loaded USDZs seems to rely on the Entity (or better) ModelEntity to be added to an AnchorEntity with via a plane initializer rather than a simple AnchorEntity() like so:

 let penguinAnchor = AnchorEntity(plane: .horizontal, classification: .any, minimumBounds: [0.1, 0.1])

不能 100% 确定这是否真的解决了我的问题.

Not 100% sure if this is really the part which resolved my issue though.

这篇关于直接从 usdz 文件而不是 Reality Composer 文件加载模型时,如何在 RealityKit 中渲染阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆