Nepedia
Back to Discover
Fluent Reader
💻

Shading language

technology Maturity 5-7 Next article →

Computers use special code to create the images we see on screens. This code is called a shading language. Most computer code tells the main processor what to do. Shading languages are different because they talk to the graphics processing unit, or GPU. The GPU is a part of the computer built for graphics. These languages are often "low level." This means they use special data types like vectors, matrices, colors, and normals.

There are two main ways these languages work. One way is called offline rendering. This method aims to make the highest quality images possible. It takes a lot of time and computer power to finish. Another way is real-time rendering. This is used when images must appear instantly, like in video games. Real-time languages are very flexible. They give creators more control with less extra work.

One of the first major tools was the RenderMan Shading Language. It uses different types of shaders to build a scene. Light shaders calculate how light moves from a source to a surface. Surface shaders decide how an object looks based on light. Displacement shaders can change the shape of an object. Volume shaders can make things look like fog. Imager shaders act like filters for the final image.

Many different companies have made their own languages over the years. Nvidia made a language called Cg, but they stopped making it in 2012. The OpenGL group created ARB assembly in 2002. There is also GLSL, which is used with OpenGL. Microsoft uses HLSL for DirectX and Xbox consoles. Sony has a language called PSSL for the PlayStation 4 and 5. Apple uses Metal Shading Language for Macs and iPhones.

Sometimes, a programmer needs to move code from one language to another. This is called porting. One way to do this is to use a common interface. For example, GLSL and MSL both use special macros to help. Another way is to use a tool to translate the code directly. Some people use an intermediate language like SPIR-V. This acts like a middle ground to help move data between different systems.

352 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.