Pages

marți, 11 iulie 2023

Graphics programming - Unity 3D shaders - 002.

In this article - tutorial I will show you how to use the most simple HLSL source code with Unity 3D.
You need to install the Shader Graph package in Unity 3D.
Create a basic shader with Create - Shader Graph - BuildIn - Unlit Shader.
Open this shader in the Shader Graph package and add a Custom Function.
This allows you to create variables and use an HLSL file.
You can see how I create this in this image:
Create a file and name this file with this name: MyNewCode.hlsl then add this in the Shader Graph package like in that image.
For each variable is need to use the Outputs to add these two variables: _in1 and _in2.
In the HLSL file, you can add this simple source code.
// file for custom node shader function
static float _input1Float = 1;
static float _input2Float = 1;
void Data_float(out float _in1, out float _in2)
{
    _in1 = _input1Float;
    _in2 = _input2Float;
  
}
Now, you have a custom node shader in your Shader Graph package project with an HLSL source code.

News : Adjusting Pivot Points on Objects in Daz Studio.