An example of how IL's conditional shader compilation system could work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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