Skip to content

Instantly share code, notes, and snippets.

@spite
Last active August 29, 2015 14:23
Show Gist options
  • Save spite/7ae92212b4f28076ba29 to your computer and use it in GitHub Desktop.
Save spite/7ae92212b4f28076ba29 to your computer and use it in GitHub Desktop.
A Modest Proposal: Standard for naming shaders and programs

##A Modest Proposal##

As per version 1.0.13 of the Shader Editor Extension, it will look for #define SHADERNAME name in both the vertex shader code and the fragment shader code.

If name is defined for both shaders, and it's the same string, the name of the program is that string, e.g.: "Shadertoy". common-name

If only one of the two is defined, the name of the program is "vs_name / fs_name", e.g.: "Quad / Shadertoy" mixed-name

If there's no #define on any of the sources, the program name is the program number, e.g.: "Program 3" no-name

At first I thought using a #pragma, but I was getting warnings: screen shot 2015-06-03 at 12 42 58

The SHADERNAME string is pretty random, just thinking of something that wouldn't collide with other #defines. It can be changed, but I think the important part is that we all agree.

Does it make sense? Would this be something it'd be interesting for developers to identify shaders, programs, materials, etc. regardless of frameworks or libraries?

@mrdoob
Copy link

mrdoob commented Jun 23, 2015

@spite
Copy link
Author

spite commented Jun 25, 2015

Cool! Updated on v1.0.14 (spite/ShaderEditorExtension#10)

@brianchirls
Copy link

@spite
Copy link
Author

spite commented Jun 25, 2015

@brianchirls Awesome! 😄

@craftfortress
Copy link

awesome thanks dude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment