How to set the parameter of the promoted input in XCode

To set the parameter of the promoted input of a custom shader material in XCode, gather the ShaderGraphMaterial from the entity & use setParameter(name:value:).

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 08/27/2024 at 13:59
Last Updated on 08/27/2024 at 14:16
<p>Three flowers that represent SwiftUI, RealityKit and XCode side by side. Beneath them sits the text "Adjust Promoted Input Parameter".</p>

To set the parameter of the promoted input of a custom shader material in XCode, gather the ShaderGraphMaterial from the entity & use setParameter(name:value:).

Subscribe

For more information on promoted inputs and using them in XCode, please consult the WWDC sessions and articles linked below.

Apple: Work with Reality Composer Pro content in Xcode (WWDC23)Apple Developer: Designing RealityKit content with Reality Composer ProHow to promote shader parameters in Reality Composer Pro

The code for the example illustrated below can be found on the tutorials/reality-composer-pro/bread-shader branch of our open source VisionOS starter project.

View Repository
<p>A screenshot of Reality Composer Pro showing the scene that we are working with.</p>

The code illustrated below is in reference of the scene above.

As demonstrated, you must:

  • Use a RealityView
  • Add the scene programatically.
  • Gather the relevant model (i.e. brioche).
  • Gather its model component.
  • Gather its ShaderGraphMaterial
  • Adjust the parameter.
<p>A screenshot of the code that we used to adjust the promoted input.</p>

Looking to learn more about Augmented Reality, Design and Technology?

Search our blog to learn more about A/R, design and technology.

Search our Blog

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe