Create a custom preset for Stingray Physically Based Shaders

To avoid repeatedly creating identical shader graphs and slowing down your game, you can create and save a preset shader graph, then re-use this preset next time you create a new StingrayPBS.

  1. Create a Stingray PBS node.
  2. In the Attribute Editor, select Custom from the Preset Material drop-down list.

    The Parent Material field is now empty.

  3. Click Open ShaderFX in the Attribute Editor to open the ShaderFX editor window and build your ShaderFX graph.

    See also Build a Stingray Physically Based Shader using the ShaderFX editor.

  4. (Optional) Select the Standard Base node in the ShaderFX editor. In the StingrayPBS Attribute Editor, provide a path and resource name, for example: /content/materials/my_stingray_material in the Parent Material attribute. Now, upon export to Stingray, the shader graph points to the parent graph at /content/materials/my_stingray_material. When the StingrayPBS is imported in Stingray, Stingray will not re-create a parent graph. However, you must ensure that the graph in your ShaderFX editor in Maya be the same as the parent graph in the Stingray game engine; that is, the one set in your path. For more information, see Interoperability of shader graphs between Maya and Stingray.

  5. Select File > Export Graph from the ShaderFX editor menu.
  6. Save your .sfx file to one of the following:
    • To make the preset available for only the current project, save to the project directory, renderData\shaders folder.
    • To make the preset globally available to all projects, save to \Documents\maya\ShaderFX\Scenes\StingrayPBS.
  7. (Optional) Rename your shader node for easy identification when you import your .fbx file into a game engine.

    If you are exporting to Stingray using File > Send to Stingray, you can also enter a name for your material in the Engine Resource attribute in the StingrayPBS Attribute Editor, and this name will be used as the material name in Stingray.

  8. Now when you restart Maya and create a new Stingray PBS node, you can find your preset in the Preset Material drop-down list.

    Select your preset to reuse the same shader graph. You can continue to use the preset as long as you only change the attributes (those visible in the Stingray PBS Attribute Editor) and not the shader graph.

Create a custom preset with an existing shader graph

  1. From the Preset Material drop-down list, select the preset with the shader graph that you want to start building from.

  2. Click Make Unique in the Stingray PBS Attribute Editor. The Stingray PBS node no longer points to the previously selected preset; however, the shader graph of that preset is maintained when you click Open ShaderFX.

Application of custom presets

Parent and child materials

A material that contains a shader graph is called a parent material.

You can create child materials based on a parent material. A child material inherits the shader graph, and thus the material attributes, from the parent material.

Child materials can modify the attributes of the parent material; for example, its color values and texture maps. Generally speaking, these are attributes that are visible in the Stingray PBS Attribute Editor. However, a child material cannot change the parent material's shader graph.

If you have a team of soccer players in your scene, you can create one shader graph to shade all of their t-shirts.

Create one parent material with a preset shader graph, then create 10 child materials based on the parent. Each child material Attribute Editor can connect to a different texture that represents the player name and number. Because the 10 child materials do not have a shader graph connected, they are much faster to calculate, reducing the performance hit.

Editing an existing custom preset

  1. In the StingrayPBS shader Attribute Editor, select the preset you want to edit from the Preset Material drop-down list.
  2. Click Open ShaderFX to open the ShaderFX editor window.

    A message in the ShaderFX editor informs you that this graph is inherited from the preset graph; in this case, your custom preset.

  3. Edit the graph, then select File > Export Graph and save the preset under its existing filename to replace the previous version.

Related topics