Skip to content

Instantly share code, notes, and snippets.

@tiffany352
Created July 28, 2013 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiffany352/6097238 to your computer and use it in GitHub Desktop.
Save tiffany352/6097238 to your computer and use it in GitHub Desktop.
An example of how IL's conditional shader compilation system could work.
#version 1
required-version: 140 // GLSL version
name: "Example Shader"
description: "A simple example shader, which shows how you could have conditional compilation based on whether or not texture coordinates are available."
#vertex-shader
#array-attrib position vec3 in_Position
#if drawable.texcoord
#array-attrib texcoord vec2 in_Texcoord
out vec2 texcoord;
#endif
#matrix MVP mvp
void main()
{
gl_Position = mvp * vec4(in_Position, 1.0);
#if drawable.texcoord
texcoord = in_Texcoord;
#endif
}
#fragment-shader
#fragdata accumulation vec3 out_Color
#if drawable.texcoord
in vec2 texcoord;
#texture color0 sampler2D tex
#elif lighting.ambient
#constant lighting.ambient vec3 color
#endif
void main()
{
#if drawable.texcoord
out_Color = texture(tex, texcoord);
#elif lighting.ambient
out_Color = color;
#else
out_Color = vec3(.5, .5, .5);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment