View Full Version : GLSL Shader File Extensions
01-28-2010, 05:48 PM
What, if any, are the recommended file extensions for the shader, geometric, and fragment shaders? I've seen *.glslv and *.vert, to name a few, for the former.
OpenGL shaders have no native file format, so there is no file extension, at all.
Some people put each shader into a single file and then call them ".vert" or ".frag", others put all shaders into a single file, seperated by some markers and call them ".glsl" or just ".shader". It's entirely up to you. There simply is no standard, at all.
01-28-2010, 06:46 PM
Thanks Jan. I realized there was no standard extension, assuming they wish to store it on disk as a standalone text file. I was just curious what common conventions people use when they do.
Do people typically have general purpose matrix transformation routines in another shader file, and then attach that to every shader program they use whenever their shaders need to perform things like translation, rotations, reset to identity matrix, etc? Or do they copy and paste general routines like these into every shader file manually? Or do people perhaps implement something like #include?
Puh, i don't know what people "typically" do. Personally i implemented my own #include, but i think most people start with the most simple solution, which is to manually copy such functions into each shader, that needs it.
In a more complex engine, one can assume that something like #include is supported, but since every program needs to handle that on its own, most people won't go to such great lengths and have simpler, less powerful solutions.
01-29-2010, 11:19 AM
Interesting. Yes, I figured #include must come in at some point. One of my concerns was in trying to find compile time errors in shaders since the line numbers would be displaced from the text insertions. I imagine one can use the #line directive to work around that?
Don't know about #line, but what i do, is to simply write out the entire shader, when an error is detected. So i append the text-files, compile the shader, and when an error appears, i log the whole shader, with line-numbers automatically inserted. That way people can easily see where the problem is. Also one should log the file-name of the main-source-file.
01-29-2010, 05:22 PM
I believe #line should work, or if its possible to implement #include by passing multiple strings to glShaderSource, you can leave the original shader string untouched. This is what I do when I make a set of constants available to all shaders.
01-30-2010, 01:12 AM
Thanks you two. When the time comes, I will give the #line trick a shot.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.