Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct file extension for GLSL shaders? [closed]

People also ask

What is the GLSL extension?

A GLSL file contains shader properties in the GL Shading Language (GLSL), which is used to shade 3D graphics. It may store vertex, fragment, or both vertex and fragment properties that program how a 3D graphic appears in applications that utilize the Open Graphics Library (OpenGL). GLSL files are saved in plain text.

What is a .shader file?

A SHADER file contains shader properties used by Godot Engine, a free and open-source game engine used to create 2D and 3D games. It stores various data types and functions in the Godot shading language, which is based on the OpenGL ES (GLSL ES) 3.0 shading language.

How do I open a .vert file?

You can also open and edit VERT files with source code editors, such as Microsoft Visual Studio Code (cross-platform), and plain text editors, such as Microsoft Notepad (bundled with Windows), Apple TextEdit (bundled with macOS), or gedit (Linux).


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

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.


Identifying file type by extension is a thing specific to Windows. All other operating systems use different approaches: MacOS X stores the file type in a special metadata structure in the file system entries. Most *nixes identify files by testing their internal structure against a database of known "magic bytes"; however text editors use the extension.

Anyway, GLSL sources are just like any other program source file: plain text, and that's their file type.

The extension you may choose as you wish. I use the following naming:

  • ts.glsl
  • gs.glsl
  • vs.glsl
  • fs.glsl

but that's my choice and technically my programs don't even enforce any naming or extension scheme. The naming is for humans to read and know what's in it; having a common major extension requires me to have an syntax highlighing rule for only one file extension set.


As others have mentioned there isn't a correct answer in the strictest sense. It does bear mentioning that Sublime (confirmed for v2 and v3) also expects .vert and .frag for syntax highlighting and validation.