What is the correct file extension for GLSL shaders?

Samssonart picture Samssonart · Jun 22, 2011 · Viewed 63.5k times · Source

I'm learning glsl shading and I've come across different file formats. I've seen people giving their vertex and fragment shaders .vert and .frag extensions. But I've also seen .vsh and .fsh extensions, and even both shaders together in a single .glsl file. So I'm wondering if there is a standard file format, or which way is the 'correct' one?

Answer

Colonel Thirty Two picture Colonel Thirty Two · Oct 23, 2014

There's no official extension in the spec. OpenGL doesn't handle loading shaders from files; you just pass in the shader code as a string, so there's no specific file format.

However, glslang, Khronos' reference GLSL compiler/validator, uses the following extensions to determine what type of shader that the file is for:

  • .vert - a vertex shader
  • .tesc - a tessellation control shader
  • .tese - a tessellation evaluation shader
  • .geom - a geometry shader
  • .frag - a fragment shader
  • .comp - a compute shader