ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/material.C
(Generate patch)

Comparing libgender/material.C (file contents):
Revision 1.34 by root, Thu Nov 4 03:58:32 2004 UTC vs.
Revision 1.35 by root, Thu Nov 4 04:46:58 2004 UTC

110} 110}
111 111
112test_material::test_material () 112test_material::test_material ()
113//: tex ("textures/osama.jpg"), texvar (tex.name) 113//: tex ("textures/osama.jpg"), texvar (tex.name)
114: tex ("textures/rockwall.jpg"), texvar (tex.name) 114: tex ("textures/rockwall.jpg"), texvar (tex.name)
115, norm ("textures/rockwall_height.jpg"), normvar (norm.name) 115, norm ("textures/rockwall_normal.jpg"), normvar (norm.name)
116{ 116{
117} 117}
118 118
119static shader::varying_3f normal, lightvec; 119static shader::varying_3f normal, lightvec;
120static shader::varying_2f texcoord; 120static shader::varying_2f texcoord;
142 temp_3f lc; 142 temp_3f lc;
143 temp_1f fac; 143 temp_1f fac;
144 144
145 lc = (*ctx.pass_data->l)(); 145 lc = (*ctx.pass_data->l)();
146 146
147 temp_3f rot1, rot2, rot3;
148
149 rot1 = yxz (texture_2d (normvar, texcoord) * 2.F - 1.F);
150 rot2 = float3 (x(rot1), -z(rot1), y(rot1));
151 rot3 = float3 (-y(rot1), x(rot1), z(rot1));
152
153 normal = mat3 (rot1, rot2, rot3) * normal;
154
147 fac = dot (normalize (normal), normalize (lightvec)); 155 fac = dot (normalize (normal), normalize (lightvec));
148 fac = pow (max (fac, 0.0), 2); 156 fac = pow (max (fac, 0.0), 6);
149 xyz (fout.frag_color) = texture_2d (texvar, texcoord) * lc * fac; 157 xyz (fout.frag_color) = (texture_2d (texvar, texcoord) + 0.2F) * lc * fac;
150 } 158 }
151} 159}
152 160
153void test_material::enable (view &ctx) 161void test_material::enable (view &ctx)
154{ 162{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines