5

Is there a "best" naming convention for shaders? If not, what are the popular options?

For example

*.vert *.vertex *.vsh

*.frag *.pixel *.fsh *.psh

I dont have examples for geometry and tesselation

aCuria
  • 6,935
  • 14
  • 53
  • 89

2 Answers2

5

The reference GLSL compiler recognizes these extensions :

Usage: glslangValidator [option]... [file]...

'file' can end in .<stage> for auto-stage classification, where <stage> is:
    .conf   to provide a config file that replaces the default configuration
            (see -c option below for generating a template)
    .vert   for a vertex shader
    .tesc   for a tessellation control shader
    .tese   for a tessellation evaluation shader
    .geom   for a geometry shader
    .frag   for a fragment shader
    .comp   for a compute shader
    .mesh   for a mesh shader
    .task   for a task shader
    .rgen    for a ray generation shader
    .rint    for a ray intersection shader
    .rahit   for a ray any hit shader
    .rchit   for a ray closest hit shader
    .rmiss   for a ray miss shader
    .rcall   for a ray callable shader
    .glsl   for .vert.glsl, .tesc.glsl, ..., .comp.glsl compound suffixes
    .hlsl   for .vert.hlsl, .tesc.hlsl, ..., .comp.hlsl compound suffixes
diapir
  • 2,872
  • 1
  • 19
  • 26
4

I think the reason why there's such a variety of names to choose from is because, according to the GLSL spec, shaders aren't files, they're character strings. Strings which nearly every application loads from a file, but strings nonetheless.

That said, the authors of the Orange Book in their sample applications have settled upon .vert and .frag. I think that's a pretty meaningful vote. I also think it strikes the right note between succinct (moreso than .fragment) and legible (moreso than .fsh).

  • what do they use for the other shader types? – aCuria Mar 27 '12 at 18:46
  • You know, in that book, they don't provide any geometry or tesselation shaders, but I would bet $5 that it would be .geom and .tess. The only problem I could see with that is that your actual mesh data might be called .geom for some reason. –  Mar 27 '12 at 18:55