--- cvsroot/libgender/material.C 2004/11/01 20:20:22 1.27 +++ cvsroot/libgender/material.C 2004/11/01 22:23:38 1.28 @@ -93,18 +93,20 @@ p.vsh->start (); temp_4f wpos; - varying_1f camdist; - varying_3f lightvec; + varying_1f camdist, zpos; + varying_2f texcoord; + varying_3f lightvec, normal; - wpos = model_view_projection_matrix * vin.vertex; + wpos = model_view_matrix * vin.vertex; - //wpos = wpos / abs (w (wpos)); + temp_1f wz; + //wz = log2 (abs (wz)) * sign (wz); - vout.position = wpos; - vout.tex_coord[0] = vin.tex_coord[0]; - xyz (vout.tex_coord[1]) = normal_matrix * vin.normal; + vout.position = projection_matrix * wpos; + texcoord = xy (vin.tex_coord[0]); + normal = normal_matrix * vin.normal; lightvec = xyz (lightpos - model_view_matrix * vin.vertex); - camdist = 1 - max (length (xyz (vout.tex_coord[2])) / 10000., 0); + camdist = 1 - max (length (lightvec) / 10000., 0); p.vsh->end (); p.vsh->compile (); @@ -117,11 +119,11 @@ temp_1f bumpnormal; temp_1f dist; - fac = dot (normalize (xyz (fin.tex_coord[1])), normalize (lightvec)); + fac = dot (normalize (normal), normalize (lightvec)); //fac = dot (shader::compile::vec3 (normalize (fin.tex_coord[1]) + normalize (fin.tex_coord[2])) * 0.5, bumpnormal); //fac = dot (bumpnormal, normalize (fin.tex_coord[2])); - //fac = pow (max (fac, 0.0), 8); - xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp)) * max (fac * (0.4 + 1.F * camdist), 0); + fac = pow (max (fac, 0.0), 2); + xyz (fout.frag_color) = texture_2d (texvar, texcoord) * (fac + 0.4) * camdist; p.fsh->end (); p.fsh->compile ();