Sure, here's the complete code
Sure
var triMat = SimpleMaterial(color: .orange, isMetallic: false)
triMat.color = SimpleMaterial.BaseColor( tint: .white.withAlphaComponent(0.9), texture: MaterialParameters.Texture(try! .load(named: "whity_4x4")))
self.components[ModelComponent.self] = try! ModelComponent(mesh: .generate(from: [meshDesc]), materials: [triMat])
guard let device = MTLCreateSystemDefaultDevice() else {
fatalError("Error creating default metal device.")
}
let library = device.makeDefaultLibrary()!
let geomShader = CustomMaterial.GeometryModifier(named: "billboard", in: library)
let surfaceShader = CustomMaterial.SurfaceShader(named: "scroll", in: library)
var customMaterials:[RealityKit.Material] = []
let materials = self.model?.materials
for material in materials! {
var material = try? CustomMaterial(from: material,
surfaceShader: surfaceShader,
geometryModifier: geomShader)
//these custom values are to define the speed and direction of the scrolling
material?.custom.value[0] = 100
material?.custom.value[1] = 4
material?.custom.value[2] = 4
customMaterials.append(material!)
}
self.model?.materials = customMaterials
Hmm, are you saying that for opacity there should be another texture like normal texture? and we can't get the alpha value from the RGBA texture?
Topic:
Graphics & Games
SubTopic:
General
Tags: