Hello!
I’m trying to make a material in RealityKit
that has a basic gradient. I am making an iPadOS app.
A few thoughts:
- I cannot use Reality Composer Pro to do this because the Shader Graph tool only works for visionOS.
- I cannot use a Metal file to create a shader because I am using a .swiftpm (app playgrounds) file targeted for Swift Playgrounds. Metal files don’t seem to work on Swift Playgrounds (it’s a Swift playground, after all).
- I would prefer to not use image textures for a simple thing like this. That would take up storage. I wish it was as easy as applying a
.basecolor
with a UIColor
, but UIColor
does not support gradients.
What are my options? I know my requirements are likely not typical, but I really need to try to not break those.
I looked into CustomMaterial
from RealityKit
but once again, those take Metal shaders. Amazing tool, but I sadly cannot use them because I’m using a Swift Playground that doesn’t seem to with Metal files, at least it seems.
I’ve briefly done research on MetalKit? Could that help me out?
Let’s say I have a simple box in RealityKit
. How would I apply a simple gradient to it given my constraints?
I really appreciate the help.
P.S. This is a SwiftUI project for reference.
EDIT:
Could I create a texture without images, perhaps by making a view into a texture and applying it? How would I do this? What are the pros and cons of this?