Cg (programming language)

Cg/HLSL
A scene containing several different 2D HLSL shaders. Distortion of the statue is achieved purely physically, while the texture of the rectangular frame beside it is based on color intensity. The square in the background has been transformed and rotated. The partial transparency and reflection of the water in the foreground are added by a shader applied finally to the entire scene.
Familyshading language
DevelopernVIDIA, Microsoft
Websitedeveloper.nvidia.com/cg-toolkit
Dialects
Cg, HLSL, Playstation Shading Language
Influenced by
C, RenderMan Shading Language
Influenced
GLSL

Cg (short for C for Graphics) and High-Level Shader Language (HLSL) are two names given to a high-level shading language developed by Nvidia and Microsoft for programming shaders. Cg/HLSL is based on the C programming language and although they share the same core syntax, some features of C were modified and new data types were added to make Cg/HLSL more suitable for programming graphics processing units.[1][2]

Two main branches of the Cg/HLSL language exist: the Nvidia Cg compiler (cgc) which outputs DirectX or OpenGL and the Microsoft HLSL which outputs DirectX shaders in bytecode format.[3][4] Nvidia's cgc was deprecated in 2012, with no additional development or support available.[5]

HLSL shaders can enable many special effects in both 2D and 3D computer graphics. The Cg/HLSL language originally only included support for vertex shaders and pixel shaders, but other types of shaders were introduced gradually as well:

  1. ^ "Fusion Industries :: Cg and HLSL FAQ ::". 24 August 2012. Archived from the original on 24 August 2012.
  2. ^ "The Cg Tutorial - Chapter 1. Introduction". developer.download.nvidia.cn.
  3. ^ "Writing HLSL Shaders in Direct3D 9 (Windows)". msdn.microsoft.com. 24 May 2021.
  4. ^ "Cg FAQ". NVIDIA DesignWorks. 8 March 2011. Retrieved 25 May 2017.
  5. ^ "Cg Toolkit | NVIDIA Developer". 8 March 2011.
  6. ^ "Cg 2.0 Release Notes" (PDF). nvidia.com. January 2008.