根据@rickster的建议,我查看了ARKit 2.0unity插件的实现,并成功地使用了
AREnvironmentProbeAnchor.environmentTexture
MTLTexture
有一个名为
textureType
.typeCubeArray
对于返回的纹理
AREnvironmentProbeAnchor.environment纹理
. 这在
混合料
documentation page
一个
混合料
有一个
texturetype
.cubearray型
意思是当你把指针传给
在统一方面,您可以使用它来创建
Cubemap
,然后可以将其用作反射探测器环境纹理。以下是在统一方面的大致情况:
// You can pass the pointer to your MTLTexture as an IntPtr to the Unity side
[DllImport("__Internal")]
public static extern IntPtr GetEnvironmentTexture();
void AddNewProbe()
{
var texturePtr = GetEnvironmentTexture();
if (texturePtr == IntPtr.Zero)
{
continue;
}
var cubemap = Cubemap.CreateExternalTexture(0, TextureFormat.R8, false, texturePtr);
var probeComponent = AddComponent<ReflectionProbe>();
probeComponent.customBakedTexture = cubemap;
}
混合料
. 它的返回类型可以是
void*
或
id<MTLTexture>
,两个都很好。这个方法应该放在你的统一桥上,以便它对统一侧可见。
extern "C" void* GetEnvironmentTexture() {
AREnvironmentProbeAnchor* anchor = [self updatedEnvironmentProbeAnchor];
return (__bridge_retained void*) [anchor environmentTexture];
}