Cg



Website: developer.nvidia.com/cg-toolkit


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.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.

Nvidia’s cgc was deprecated in 2012, with no additional development or support available.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: DirectX 10 (Shader Model 4) and Cg 2.0 introduced geometry shaders.

DirectX 11 (Shader Model 5) introduced compute shaders (GPGPU) and tessellation shaders (hull and domain).

The latter is present in Cg 3.1. DirectX 12 (Shader Model 6.3) introduced ray tracing shaders (ray generation, intersection, bit /closest hit / miss).