How do I call a custom value on a Shader Graph?

Asked on 2024-07-26

1 search

To call a custom value on a Shader Graph, you can use the concept of exposed parameters. This allows you to change the values dynamically without modifying the shader code directly. Here are the steps to achieve this:

  1. Expose Parameters in Shader Graph:

    • In the Shader Graph, you can promote certain values to inputs, making them accessible for modification. For example, in the session "Optimize your 3D assets for spatial computing," it is mentioned that you can right-click on file references and promote them to input, making those inputs accessible in the panel on the right.
  2. Using Material Instances:

    • Material instances allow you to reuse the logic of one material while being able to change exposed parameters. This is useful for performance and efficiency. You can create material instances and modify the exposed parameters as needed.
  3. Example of Using Exposed Parameters:

    • In the session "Discover RealityKit APIs for iOS, macOS and visionOS," a custom hover effect is created using a Shader Graph material. The hover state node provides several inputs, including an intensity value, which is animated from zero to one when the player looks at the spaceship. This intensity value is an example of an exposed parameter that can be dynamically modified.

For more detailed information, you can refer to the following sessions and chapters:

These sessions provide insights into how to work with Shader Graph and expose parameters for custom values.