I found out the cause of the issue I posted in the comment above:
You cannot update a model's mesh like this:
self.model?.mesh = MeshResource.generatePlane(
width: planeAnchor.extent.x,
depth: planeAnchor.extent.z
)
You must re-create the entire model anytime you want to update the size of it!
var material = SimpleMaterial(color: .blue, isMetallic: true)
material.tintColor = .init(white: 1, alpha: 0.5)
self.model = ModelComponent(
mesh: .generatePlane(
width: planeAnchor.extent.x,
depth: planeAnchor.extent.z
),
materials: [material]
)
'
Will be opening a new ticket to show an easy reproduction later today. For anyone else with the issue, updating the mesh size breaks transparency
Post
Replies
Boosts
Views
Activity
None of the suggestions work in iOS 14.4... kind of annoyed at the developer support here... I had followed countless Stack overflow posts, and green check marked solutions from the actual framework developers on this forum, but none of it works.
All I want is a transparent material with a base color. After trying for hours and hours, I decided to make a transparent PNG to try that so I could exactly match these pieces of code:
let resource = try? TextureResource.load(named: "WallOverlay")
var material = SimpleMaterial(color: .white, roughness: 1, isMetallic: true)
material.baseColor = MaterialColorParameter.texture(resource!)
material.tintColor = UIColor.white.withAlphaComponent(0.99)
Does not work at all. If I use an unlit material, doesn't work.
If I use a color instead of a texture resource, it doesn't work.
In iOS 14.4 there appears to be no way to make a material transparent at this time.
It would be great if the framework engineers could acknowledge this instead of having posts with solved statuses that DO NOT work in the latest version of iOS.
Please let us know when this will be fixed, or provide a full example of making a material that actually makes it transparent. Thank you :)
P.S this is all I want to do and expect this code to work:
var material = SimpleMaterial()
material.baseColor = MaterialColorParameter.color(
UIColor(red: 0.97, green: 0.75, blue: 0.09, alpha: 0.10)
)
self.model = ModelComponent(
mesh: .generatePlane(width: 0, depth: 0),
materials: [material]
)
Use this color and make it barely visible, and have the real world visible behind it.
Bump, I have found multiple people saying "set the alpha" or "set the tintColor to .99" none of this works when using a solid color simple material. It would be great if someone at apple could post the exact code that supposedly works, because the code sample above does not.
I need to make a material that can be see-through like SceneKit is able to do.
Thank you for the reply!
Is there an example on how I would get all the face indexes associated with a vertex?
Is there a bug in iOS 14 beta 3? I am unable to change opacity using the alpha channel of a material:
var material = SimpleMaterial()
material.baseColor = MaterialColorParameter.color(
UIColor(red: 0.97, green: 0.75, blue: 0.09, alpha: 0.10)
)
No matter what the alpha is, it is always solid and I cannot see the world behind.