0x2A / NoWork

NoWork is a simple graphics framework using OpenGL to allow easy prototyping of graphical functions and algorythms
GNU General Public License v3.0
6 stars 0 forks source link

add glsl preprocessor #5

Open 0x2A opened 8 years ago

0x2A commented 8 years ago

It might be useful to create a preprocessor for GLSL shader files. It causes a loss of compatibility for standard glsl code but it might be useful to have some #include or #pragma functionality. So this should it make possible to create some reusable shader code like default lighting or headers (for example the in vec3 vertPosition ... uniforms), so its easier to create custom shaders.

0x2A commented 2 years ago

_default_vertex_inputs_ and _reduced_vertex_inputs_ macros are now implemented.

_default_vertex_inputs_ adds:

 in layout(location=MODEL_NORMAL_LOCATION) vec3 vertexNormal;
 in layout(location=MODEL_TEXCOORD_LOCATION) vec2 vertexUV;
 in layout(location=MODEL_VERTEX_COLOR_LOCATION) vec4 vertexColor;
 in layout(location=MODEL_TANGENT_LOCATION) vec3 vertexTangent;

and _reduced_vertex_inputs_ adds:

in layout(location=MODEL_VERTEX_LOCATION) vec3 vertexPosition;
in layout(location=MODEL_TEXCOORD_LOCATION) vec2 vertexUV;
in layout(location=MODEL_VERTEX_COLOR_LOCATION) vec4 vertexColor;

to shader code