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

Comparing libgender/material.C (file contents):
Revision 1.57 by root, Mon Feb 7 08:16:31 2005 UTC vs.
Revision 1.58 by root, Mon Feb 7 08:51:18 2005 UTC

140: tex ("textures/rockwall.jpg"), texvar (tex.name) 140: tex ("textures/rockwall.jpg"), texvar (tex.name)
141, norm ("textures/rockwall_normal.jpg"), normvar (norm.name) 141, norm ("textures/rockwall_normal.jpg"), normvar (norm.name)
142{ 142{
143} 143}
144 144
145void mat_gouraud_shaded::enable (view &ctx)
146{
147 material::enable (ctx);
148
149 sh_colour->set (vec3 (c.r, c.g, c.b) * (1.F / 255.F));
150}
151
152void mat_gouraud_shaded::disable (view &ctx)
153{
154 material::disable (ctx);
155}
156
157void mat_gouraud_shaded::vsh (view &ctx)
158{
159 using namespace shader::compile;
160 std_vsh ();
161
162 if (ctx.pass->l)
163 f_normal = normal_matrix * vin.normal;
164}
165
166void mat_gouraud_shaded::fsh (view &ctx)
167{
168 using namespace shader::compile;
169
170 if (ctx.pass->l)
171 {
172 temp_1f fac;
173
174 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec));
175
176 xyz (fout.frag_color) = ctx.pass->l->sh_colour * sh_colour * fac;
177 }
178}
179
180static shader::varying_2f texcoord;
145static shader::varying_3f normal; 181static shader::varying_3f normal;
146static shader::varying_2f texcoord;
147
148void test_material2::vsh (view &ctx)
149{
150 using namespace shader::compile;
151 std_vsh ();
152
153 if (ctx.pass->l)
154 {
155 normal = normal_matrix * vin.normal;
156 }
157}
158
159void test_material2::fsh (view &ctx)
160{
161 using namespace shader::compile;
162
163 if (ctx.pass->l)
164 {
165 temp_1f fac;
166 fac = dot (normalize (normal), normalize (ctx.pass->l->sh_lightvec));
167 xyz (fout.frag_color) = ctx.pass->l->sh_colour * fac;//normalize (ctx.pass->l->sh_lightvec);
168 }
169}
170 182
171void test_material::vsh (view &ctx) 183void test_material::vsh (view &ctx)
172{ 184{
173 using namespace shader::compile; 185 using namespace shader::compile;
174 186
222 texvar->disable (); 234 texvar->disable ();
223 material::disable (ctx); 235 material::disable (ctx);
224} 236}
225 237
226test_material *testmat; 238test_material *testmat;
227test_material2 *testmat2; 239mat_gouraud_shaded *testmat2;
228 240

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines