本文介绍了直接从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中投射阴影似乎依赖于Entity(或更好)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中渲染阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 07:40