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

Comparing cvsroot/libgender/material.C (file contents):
Revision 1.33 by root, Wed Nov 3 03:36:16 2004 UTC vs.
Revision 1.37 by root, Thu Nov 4 15:43:53 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 yxz (rot1) = (texture_2d (normvar, texcoord) * 2.F - 1.F);
150
151 //rot1 = normal_matrix * rot1;
152
153 rot2 = float3 (x(rot1), z(rot1), -y(rot1));
154 rot3 = float3 (y(rot1), -x(rot1), z(rot1));
155
156 normal = mat3 (rot1, rot2, rot3) * normal;
157
147 fac = dot (normalize (normal), normalize (lightvec)); 158 fac = dot (normalize (normal), normalize (lightvec));
148 fac = pow (max (fac, 0.0), 2); 159 fac = max (pow (max (fac, 0.0), 6), 0.3);
149 xyz (fout.frag_color) = texture_2d (texvar, texcoord) * lc * fac; 160 xyz (fout.frag_color) = (texture_2d (texvar, texcoord) + 0.2F) * lc * fac;
161 //xyz (fout.frag_color) = lc * fac;
150 } 162 }
151} 163}
152 164
153void test_material::enable (view &ctx) 165void test_material::enable (view &ctx)
154{ 166{
162 normvar->disable (); 174 normvar->disable ();
163 texvar->disable (); 175 texvar->disable ();
164 material::disable (ctx); 176 material::disable (ctx);
165} 177}
166 178
167test_material testmat; 179test_material *testmat;
180

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines