##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".
If only one of the two is defined, the name of the program is "vs_name
/ fs_name
", e.g.: "Quad / Shadertoy"
If there's no #define
on any of the sources, the program name is the program number, e.g.: "Program 3"
At first I thought using a #pragma, but I was getting warnings:
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?
@mattdesl there are many ways, of course. I discarded #pragma because of the compiling warnings; and discarded using comments because it feels less hacky to use #define; I think getShaderSource can't be entirely relied on (from an instrumenting tool perspective) since a lot of WebGL programs delete the shaders once they're attached to the program.
I think the way the coder gets the relevant string (analyse the source independently, augment the WebGLProgram methods, inject set/getShaderSource) is not that important, as long as we agree on the basic things: it's in the source code, it's a #define, and it's called SHADER_NAME
I've tested OSX and Windows/ANGLE and the #define works correctly. Most of three.js #defines are not correct GLSL and there are no problems that I'm aware of.