--- cvsroot/libgender/material.C 2005/02/07 08:16:31 1.57 +++ cvsroot/libgender/material.C 2005/02/07 08:51:18 1.58 @@ -142,32 +142,44 @@ { } -static shader::varying_3f normal; -static shader::varying_2f texcoord; +void mat_gouraud_shaded::enable (view &ctx) +{ + material::enable (ctx); + + sh_colour->set (vec3 (c.r, c.g, c.b) * (1.F / 255.F)); +} + +void mat_gouraud_shaded::disable (view &ctx) +{ + material::disable (ctx); +} -void test_material2::vsh (view &ctx) +void mat_gouraud_shaded::vsh (view &ctx) { using namespace shader::compile; std_vsh (); if (ctx.pass->l) - { - normal = normal_matrix * vin.normal; - } + f_normal = normal_matrix * vin.normal; } -void test_material2::fsh (view &ctx) +void mat_gouraud_shaded::fsh (view &ctx) { using namespace shader::compile; if (ctx.pass->l) { temp_1f fac; - fac = dot (normalize (normal), normalize (ctx.pass->l->sh_lightvec)); - xyz (fout.frag_color) = ctx.pass->l->sh_colour * fac;//normalize (ctx.pass->l->sh_lightvec); + + fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec)); + + xyz (fout.frag_color) = ctx.pass->l->sh_colour * sh_colour * fac; } } +static shader::varying_2f texcoord; +static shader::varying_3f normal; + void test_material::vsh (view &ctx) { using namespace shader::compile; @@ -224,5 +236,5 @@ } test_material *testmat; -test_material2 *testmat2; +mat_gouraud_shaded *testmat2;