HLSL (High-Level Shader Language) is an industry-standard high-level programming language with a syntax very similar to the C language, developed by Microsoft to write shader programs (vertex shader, pixel shader, etc.) that run on GPUs (graphics processing units).
Real-world analogy: ``dedicated remote control instruction description'' for an autopilot machine (GPU)
The role of HLSL can be likened to ``a ``dedicated remote control command description'' for directly writing driving instructions to a group of autopilot machines (GPU) running at ultra-high speed in parallel.
- Conventional (visual editing using Shader Graph): Maneuver commands are assembled by manually connecting a large number of predetermined buttons (various GUI nodes) placed in the cockpit of the machine. It's intuitive, but when you want to make complex movements, the number of buttons becomes enormous, and the cords that connect the buttons become tangled and difficult to operate.
- Code writing using HLSL: Directly input a precise and lean text command (HLSL code) to the machine's control CPU: ``Take 3 steps to the right, then loop around to the left 5 times, and when you collide, reverse the color.'' There is no need for any unnecessary buttons or wires, and the machine runs (draws) at ultra-high speed, utilizing 100% of the GPU's original brutal parallel computing power, without a 1-microsecond delay.
Figure: Image diagram of how the compiler automatically generates high-speed HLSL code behind the scenes from Shader Graph nodes
Mechanism and operating principle
Unity's Shader Graph automatically replaces and generates the connection network of nodes created by the user into a huge "HLSL code" text file behind the scenes during compilation. HLSL is written in two parts: ``Vertex Shader'' which performs world space transformation of 3D vertex coordinates passed from the CPU, and ``Fragment (Pixel) Shader'' which determines the final color of each pixel on the screen, and is computed in massively parallel by thousands of threads on the GPU.