X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogrambuilder.cpp;h=636d87a92018bdd7542007f9b7437193c33780f1;hb=08d72eb25d3f99f347e6c801755871b7a5f29f5d;hp=a24b5d565c6687dc3a614c1834fb1026d262d681;hpb=c63ae0f5dfa50c31e811adf0ce7fbf108330937a;p=libs%2Fgl.git diff --git a/source/programbuilder.cpp b/source/programbuilder.cpp index a24b5d56..636d87a9 100644 --- a/source/programbuilder.cpp +++ b/source/programbuilder.cpp @@ -3,6 +3,7 @@ #include "program.h" #include "programbuilder.h" #include "shader.h" +#include "vertexformat.h" using namespace std; @@ -65,7 +66,7 @@ const ProgramBuilder::StandardVariable ProgramBuilder::standard_variables[] = { FRAGMENT, "tex_sample", "vec4", "texture2D(texture, texture_coord)", 0 }, { VERTEX, "gl_Position", 0, "gl_ProjectionMatrix*eye_vertex", 0 }, - { VERTEX, "shd_vertex", "vec3", "eye_vertex*eye_shd_rmatrix", 0 }, + { VERTEX, "shd_vertex", "vec3", "(eye_vertex*eye_shd_rmatrix).xyz", 0 }, { VERTEX, "eye_shd_rmatrix", "mat4", "mat4(gl_EyePlaneS[shadow_unit], gl_EyePlaneT[shadow_unit], gl_EyePlaneR[shadow_unit], vec4(0.0, 0.0, 0.0, 1.0))", 0 }, { VERTEX, "tbn_light_dir", "vec3", "eye_light_dir*eye_tbn_matrix", 0 }, { VERTEX, "eye_light_dir", "vec3", "normalize(gl_LightSource[0].position.xyz-eye_vertex.xyz*gl_LightSource[0].position.w)", 0 }, @@ -182,6 +183,12 @@ void ProgramBuilder::add_shaders(Program &prog) const prog.attach_shader_owned(new VertexShader(create_source(resolved_vars, VERTEX))); prog.attach_shader_owned(new FragmentShader(create_source(resolved_vars, FRAGMENT))); + + if(features.normalmap) + { + prog.bind_attribute(get_component_type(TANGENT3), "tangent"); + prog.bind_attribute(get_component_type(BINORMAL3), "binormal"); + } } string ProgramBuilder::create_source(const list &variables, VariableScope scope) const