Introduction to HLSL shader programs
Learn about writing shader programs in HLSL in Unity, and vertex and fragment shaders.
읽는 시간 1분최근 업데이트: 한 달 전
In Unity, you usually write shader programs in High-Level Shader Language (HLSL). To add HLSL code to your shader asset, add the code in a shader code block.
There are two main types of shader programs you write in HLSL:
- Vertex shader programs, also known as vertex shaders. These programs usually transform the position of the mesh from object space to clip space, and pass data such as UV coordinates to the fragment shader program.
- Fragment shader programs, also known as fragment shaders or pixel shaders. These programs usually calculate and output the color of each pixel on-screen.
To make it easier to write shaders across different HLSL versions, graphics APIs, and platforms, Unity provides shader libraries with preprocessor macros. For more information, refer to Shader methods in the Universal Render Pipeline (URP) or Shader methods in the Built-In Render Pipeline.
For general information on writing HLSL, refer to the HLSL documentation on the Microsoft website.