--- libgender/material.C 2004/12/11 00:17:28 1.54 +++ libgender/material.C 2005/02/07 08:16:31 1.57 @@ -57,8 +57,7 @@ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - glTexImage2D (GL_TEXTURE_2D, - 0, + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); SDL_FreeSurface (image); /* No longer needed */ @@ -95,11 +94,11 @@ // TODO: negative z is not calculated in an acceptable way, clipping does horrible things(?) lz = z (vout.position); #if 0 - lz = (log (max (lz, 0) + 1) / log (1e18)) - 1; + lz = (log (max (lz, 0) + 1) / log (1e30)) - 1; #else lz = ifelse (lz <= 0, 0, - log (lz + 1) / log (1e18) + log (lz + 1) / log (1e30) ) - 1; #endif z (vout.position) = lz * w (vout.position); @@ -129,7 +128,7 @@ i->second->enable (); if (ctx.pass->l) - ctx.pass->l->enable (); + ctx.pass->l->enable (ctx); } void material::disable (view &ctx) @@ -146,6 +145,29 @@ static shader::varying_3f normal; static shader::varying_2f texcoord; +void test_material2::vsh (view &ctx) +{ + using namespace shader::compile; + std_vsh (); + + if (ctx.pass->l) + { + normal = normal_matrix * vin.normal; + } +} + +void test_material2::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); + } +} + void test_material::vsh (view &ctx) { using namespace shader::compile; @@ -202,4 +224,5 @@ } test_material *testmat; +test_material2 *testmat2;