Hi, I'm trying to display an equirectangular image on the inside of a usdz sphere but it only renders it on the outside, I guess is because of the culling configuration. Any idea how can I acheive this?
Render material on the inside of a sphere.
I create a sphere that I use for sky and display an image on the inside of it by changing the scale
property on the Entity
.
Here is how I create a very large sphere and have the material rendered on the inside of it.
let entity = Entity()
entity.components.set(ModelComponent(
mesh: .generateSphere(radius: 100000),
materials: [material]
))
// Ensure the texture image points inward at the viewer.
entity.scale *= .init(x: -1, y: 1, z: 1)
Almost like you need to reverse the direction of the mesh triangles. I wonder if there’s a convenient way to do that…
Hello,
You may find this helpful:
struct ImmersiveView: View {
var body: some View {
RealityView { content in
let mesh = MeshResource.generateSphere(radius: 10)
var material = PhysicallyBasedMaterial()
material.faceCulling = .front
material.baseColor = .init(tint: .red, texture: nil)
let entity = ModelEntity(mesh: mesh, materials: [material])
content.add(entity)
}
}
}