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.58 by root, Mon Feb 7 08:51:18 2005 UTC vs.
Revision 1.63 by root, Mon Jul 18 01:40:01 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_timed::enable (view &ctx)
146{
147 material::enable (ctx);
148
149 time->set (timer::now);
150 sh_colour->set (vec3 (255, 0, 0) * (1.F / 255.F));
151}
152
153void mat_timed::disable (view &ctx)
154{
155 material::disable (ctx);
156}
157
158void mat_timed::vsh (view &ctx)
159{
160 using namespace shader::compile;
161 std_vsh ();
162
163 if (ctx.pass->l)
164 f_normal = normal_matrix * vin.normal;
165}
166
167void mat_timed::fsh (view &ctx)
168{
169 using namespace shader::compile;
170
171 if (ctx.pass->l)
172 {
173 temp_1f fac;
174 temp_3f normal;
175
176 normal = f_normal + 0.3 * pow (sin (f_normal * 3.14159 + time), 3);
177
178 fac = dot (normalize (normal), normalize (ctx.pass->l->sh_lightvec));
179
180 xyz (fout.frag_color) = fac * float3 (0.1,0.5,1);//ctx.pass->l->sh_colour * sh_colour * fac;
181 }
182}
183
145void mat_gouraud_shaded::enable (view &ctx) 184void mat_gouraud_shaded::enable (view &ctx)
146{ 185{
147 material::enable (ctx); 186 material::enable (ctx);
148 187
149 sh_colour->set (vec3 (c.r, c.g, c.b) * (1.F / 255.F)); 188 sh_colour->set (vec3 (c.r, c.g, c.b) * (1.F / 255.F));
172 temp_1f fac; 211 temp_1f fac;
173 212
174 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec)); 213 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec));
175 214
176 xyz (fout.frag_color) = ctx.pass->l->sh_colour * sh_colour * fac; 215 xyz (fout.frag_color) = ctx.pass->l->sh_colour * sh_colour * fac;
216 }
217}
218
219static shader::varying_3f f_normal;
220
221void mat_debug::enable (view &ctx)
222{
223 material::enable (ctx);
224
225 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
226 glEnable (GL_BLEND);
227 glDepthMask (1);
228}
229
230void mat_debug::disable (view &ctx)
231{
232 material::disable (ctx);
233
234 glDisable (GL_BLEND);
235 glDepthMask (0);
236}
237
238void mat_debug::vsh (view &ctx)
239{
240 using namespace shader::compile;
241 std_vsh ();
242
243 if (ctx.pass->l)
244 f_normal = normal_matrix * vin.normal;
245}
246
247void mat_debug::fsh (view &ctx)
248{
249 using namespace shader::compile;
250
251 if (ctx.pass->l)
252 {
253 temp_1f fac;
254
255 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec));
256
257 xyz (fout.frag_color) = float3 (1.,0.,0.);
258 w (fout.frag_color) = 0.1;
177 } 259 }
178} 260}
179 261
180static shader::varying_2f texcoord; 262static shader::varying_2f texcoord;
181static shader::varying_3f normal; 263static shader::varying_3f normal;
235 material::disable (ctx); 317 material::disable (ctx);
236} 318}
237 319
238test_material *testmat; 320test_material *testmat;
239mat_gouraud_shaded *testmat2; 321mat_gouraud_shaded *testmat2;
322mat_timed *testmat3;
323mat_debug *debugmat;
240 324

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines