Shader parameters and Material instances

A parameter to a shader is going to be a variable input to that shader. You can configure scalars or vectors to be used as input parameters to your shader. Some materials within UE4 come preprogrammed with material parameters exposed.

Getting ready

In order to set up a parameter to a shader, you first need a shader with something that you want to modify with a variable. A good thing to modify with a variable is the suit color of a character. We can expose the color of the suit as a shader parameter that we multiply suit color by.

How to do it...

  1. Construct a new Material.
  2. Within the Material, create a VectorParameter. Give the parameter a name, such as Color. Give it a default value, such as blue or black.
    How to do it...
  3. Close the Material.
  4. In Content Browser, right-click on the Material with the parameter in it, and select Create Material Instance.
  5. Double-click on your Material instance. Check the box beside your VectorParameter name, and voila! Your VectorParameter is customizable without further affecting the base functionality of the Material.
    How to do it...
  6. Further, if you change the base functionality of the Material, the Material instance will inherit those changes without needing any further configurations.

How it works…

Material Parameters allow you to edit the value of variables sent to a Material without editing the Material itself. In addition, you can also change a Material instance's values from C++ code quite easily. This is useful for things such as team colors, and the like.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.197.212