X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=7598bf1572adc036f7777fa8e9741c6086102689;hb=b07e3b2103c53e3cd6a4674eef481178ec64f2c7;hp=ea1f30d2aea724cc9e9b10e2bcdf531accc48bb7;hpb=70b3d2475f229809b59d559ffaf4f95e8ea58f28;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index ea1f30d2..7598bf15 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "arb_shader_objects.h" #include "arb_vertex_shader.h" #include "error.h" @@ -71,20 +73,27 @@ const char *standard_fragment_src[] = /* XXX This is incorrect with normal mapping, since the vectors are in TBN space but environment map is expected to be in eye space */ "e", "\tvec4 reflection = textureCube(environment, n_normal*(dot(n_normal, v_eye_dir)*2.0)-v_eye_dir);\n", - 0, "\tgl_FragColor = ", - "!t!l!m", "vec4(1.0, 1.0, 1.0, 1.0)", - "t", "texture2D(texture, v_texcoord)", + "t", "\tvec4 tex_sample = texture2D(texture, v_texcoord);\n", + 0, "\tgl_FragColor.rgb = ", + "!t!l!m", "vec3(1.0)", + "t", "tex_sample.rgb", "l|mt", "*", - "!lm", "v_color", + "!lm", "v_color.rgb", "l", "((l_diffuse", - "lm", "*gl_FrontLightProduct[0].diffuse", + "lm", "*gl_FrontLightProduct[0].diffuse.rgb", "p", "+l_specular", - "pm", "*gl_FrontLightProduct[0].specular", + "pm", "*gl_FrontLightProduct[0].specular.rgb", "l", ")", "s", "*l_shadow", - "lm", "+gl_FrontLightModelProduct.sceneColor", + "lm", "+gl_FrontLightModelProduct.sceneColor.rgb", "l", ")", - "e", "+reflection*reflectivity", + "e", "+reflection.rgb*reflectivity", + 0, ";\n", + 0, "\tgl_FragColor.a = ", + "!m", "1.0", + "!lm", "v_color.a", + "lm", "gl_FrontMaterial.diffuse.a", + "t", "*tex_sample.a", 0, ";\n", 0, "}\n", 0, 0 @@ -239,6 +248,16 @@ void Program::link() uniforms[name] = info; } } + + string layout_descriptor; + for(map::const_iterator i = uniforms.begin(); i!=uniforms.end(); ++i) + if(i->second.location>=0) + { + if(!layout_descriptor.empty()) + layout_descriptor += '\n'; + layout_descriptor += format("%d:%s:%x", i->second.location, i->second.name, i->second.type); + } + uniform_layout_hash = hash32(layout_descriptor); } string Program::get_info_log() const