atom-glsl-preview
atom-glsl-preview copied to clipboard
Uniform support for other types than textures
I'm using glsl-viewer to develop shaders that are then loaded in a different programming environment. The idea of passing textures using comments is very useful and I think it would be nice to be able to also set float and vec uniforms in comments.
uniform float frequency; // 20.0
uniform vec2 size; // 800.0 600.0
uniform vec3 color; // 1.0 0.0 1.0
It shouldn't be be too hard to copy the texture function and make it work with other uniforms:
// Match floats
re = /^\s*uniform\s+float\s+(\S+)\s*;\s*\/\/\s*(\S+)\s\s*$/gm;
// Match vec2s
re = /^\s*uniform\s+vec2\s+(\S+)\s*;\s*\/\/\s*(\S+)\s(\S+)\s*$/gm;
// Match vec3s
re = /^\s*uniform\s+vec3\s+(\S+)\s*;\s*\/\/\s*(\S+)\s(\S+)\s(\S+)\s*$/gm;