Pages

vineri, 14 iulie 2023

Graphics programming - Unity 3D shaders - 004.

In the previous tutorial number 002, I presented how a shader can be implemented using an HLSL type file that provides two output variables: _in1 and _in2. Theoretically, they should be renamed with _out because they are output. Today I will show you how to use the color variable as an input in the custom node. Here is the source code with a compound math function on a vector with size 4 for Color added in Shader Graph.
Let's see the source code :
#pragma shader_feature_local OutCode001

float DataInput_float( in float4  _in11, in float x , out float4 _out11)
{
    //_in11 = _input11Float;
    _in11 = _in11;
    _out11 = sin(_in11) * ( x * 1000 );
    return  _out11;
}
This is how to link the _in11, x and _out11 to Inputs and Outputs lists. You can see the function is used like DataInput and not DataInput_float in the GUI.