Simple custom node to get started with functions into Substance Designer

Tutorial / 09 August 2021

Hi !

Very simple tutorial to get started with functions in Substance designer ( Substance  3D designer )

The idea is to create a custom node  which can always select one element of Flood Fill same if we change the input before.

Without the custom node we will have difficulty to select with precision one elements what  we need

exemple:



The custom node use the number of elements to select precisely the one you want.


How to do this custom node ?

Final graph : 

You see very simple :)


Start:

Create an empty graph a give a name :)


  1. Now we need to create tile generator, it will be our map for test the node.  (When the custom node works we will replace by Input node )
  2. Add a flood fill after the tile generator and use the option "display advanced parameters and output"

  3.  Add the node Flood Fill to Index, and link. You see now we have the information about number of elements

  4. Add Distance node with maximum distance at 256

  5. Add the node Histogram select and add one input value on it.
  6. Link shape count of flood fill to index to your input, we can rename the input for "Number_shapes"
     

  7. We need to create an other  input to drive the selection .  The selection  will be a real number like, 1, 2 ,3 4 ,5 ...  so the type is "integer" on Substance Designer the color for the integer type is Yellow. The decimal number are the type "float" the color are Green.
  8. Double click on the background and add an input of type "integer"


      

  9. Now we have all ingredient for enter in the function part  :)
    Begin with the position of Histogram  Select, chose Empty function to open function graph


      

  10.  So, the idea is to divide number of shape with the number we want to select.
     use "Get Integer" to recuperate the integer value that we created / exposed

    and " Get float" to recuperate the float value of the input value


    /!\ We can't do operation between two differente type : float and integrer

  11. if we look at the bottom left of your graph window, we see that this graph ask Float1. Float 1 means it's only one of  number decimal value. (Float 2 need two number decimal, Float 3 need three number decimal and Float 4 four number decimal ). So we need to transform the Integrer to Float for can do the division.
  12. Use the node "to Float"

  13. We can do the division and set it as output node


      

  14.  We need to reduce the range of the histogram select.  if we play with our "Selection" exposed, we see the position change.


  15. If we change the tiling we see that the range are not good, so we need an other function to fixe that :)

     
    Excepte if you have more than 100 shapes, in this case you can do this like it, and you will be so SMART ;D

  16.  Enter in the Function graph of Range. 


     

  17.  The idea is simply to divide one by the number of elements. Use "Float " for add a Float value


      

  18. Our functions work correctly. 


      

  19. add a Blend node at multiply 


  20. we need to replace the tile generator with the "Grayscale input", so that the user uses his own.

     

  21. Add an "Output" node at the end, so that the user retrieves the selection and another "Output" so that he knows how many elements there are.



     

  22. We can save the graph and publish the .sbsar and use our node ! :)