anything that might need them. */
const ProgramBuilder::VariableDefinition ProgramBuilder::standard_variables[] =
{
- { FRAGMENT, "gl_FragColor", 0, "frag_color", "g" },
- { FRAGMENT, "frag_color", 0, "color_base", "!t" },
- { FRAGMENT, "frag_color", 0, "tex_sample", "!l!s!mt" },
- { FRAGMENT, "frag_color", 0, "tex_sample*color_base", "l|s|mt" },
+ { FRAGMENT, "gl_FragColor", "vec4", "frag_color", "g" },
+ { FRAGMENT, "frag_color", "vec4", "color_base", "!t" },
+ { FRAGMENT, "frag_color", "vec4", "tex_sample", "!l!s!mt" },
+ { FRAGMENT, "frag_color", "vec4", "tex_sample*color_base", "l|s|mt" },
{ FRAGMENT, "color_base", "vec4", "vec4(1.0)", "!l!s!m" },
{ FRAGMENT, "color_base", "vec4", "color", "!l!sm" },
{ FRAGMENT, "color_base", "vec4", "vec4(vec3(l_shadow), 1.0)", "!ls!m" },
{ FRAGMENT, "normal_sample", "vec3", "texture2D(normalmap, texture_coord).xyz", 0 },
{ FRAGMENT, "tex_sample", "vec4", "texture2D(texture, texture_coord)", 0 },
- { VERTEX, "gl_Position", 0, "projection_matrix*eye_vertex", 0 },
+ { VERTEX, "gl_Position", "vec4", "projection_matrix*eye_vertex", 0 },
{ VERTEX, "shd_vertex", "vec3", "vec3(dot(eye_vertex, gl_EyePlaneS[shadow_unit]), dot(eye_vertex, gl_EyePlaneT[shadow_unit]), dot(eye_vertex, gl_EyePlaneR[shadow_unit]))", "g" },
{ VERTEX, "shd_vertex", "vec3", "(shd_eye_matrix*eye_vertex).xyz", "!g" },
{ VERTEX, "tbn_light_dir", "vec3", "eye_light_dir*eye_tbn_matrix", 0 },
source += format("%s %s v_%s;\n", qualifier, (*i)->variable->type, (*i)->resolved_name);
}
- if(scope==FRAGMENT && !features.legacy)
- source += "out vec4 frag_color;\n";
+ for(list<ShaderVariable *>::const_iterator i=variables.begin(); i!=variables.end(); ++i)
+ if((*i)->referenced_by.empty() && (*i)->resolved_name.compare(0, 3, "gl_"))
+ source += format("out %s %s;\n", (*i)->variable->type, (*i)->resolved_name);
source += "void main()\n{\n";
if((*i)->variable->scope==scope && !(*i)->inlined)
{
source += '\t';
- if((*i)->variable->type)
+ if(!(*i)->referenced_by.empty())
{
source += (*i)->variable->type;
source += ' ';
const char *space = 0;
if(name_match(var.name, resolved_name.c_str(), &space)==FUZZY)
resolve_space(string(space, 3));
+
}
void ProgramBuilder::ShaderVariable::resolve(ShaderVariable &var)