Search code examples
openglglslshader

What is the correct file extension for GLSL shaders?


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?


Solution

  • The glslang compiler created by Khronos makes assumptions about the shader stage based on the extension, but there is no standard extension outside of this (and quite a few projects make up their own). The glslang compiler keys off of .vert, .tesc (TESsellation Control shaders), .tese (TESsellation Evaluation shaders), .geom, .frag, and .comp.

    But that's about it for any form of standard extension.