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.62 by root, Fri Feb 11 15:28:51 2005 UTC vs.
Revision 1.64 by root, Mon Jul 18 04:28:40 2005 UTC

89 { 89 {
90 using namespace shader::compile; 90 using namespace shader::compile;
91 91
92 temp_1f lz; 92 temp_1f lz;
93 93
94 // TODO: negative z is not calculated in an acceptable way, clipping does horrible things(?) 94 // TODO: negative z is not calculated in an a very acceptable way
95 lz = z (vout.position); 95 lz = z (vout.position);
96#if 0 96 lz = sign (lz) * (log (abs (lz) + exp (1e0)) - 1e0) / log (1e30);
97 lz = (log (max (lz, 0) + 1) / log (1e30)) - 1;
98#else
99 lz = ifelse (lz <= 0,
100 0,
101 log (lz + 1) / log (1e30)
102 ) - 1;
103#endif
104 z (vout.position) = lz * w (vout.position); 97 z (vout.position) = lz * w (vout.position);
105 } 98 }
106 99
107 vsh_src = shader::shader_builder::stop (); 100 vsh_src = shader::shader_builder::stop ();
108 101
140: tex ("textures/rockwall.jpg"), texvar (tex.name) 133: tex ("textures/rockwall.jpg"), texvar (tex.name)
141, norm ("textures/rockwall_normal.jpg"), normvar (norm.name) 134, norm ("textures/rockwall_normal.jpg"), normvar (norm.name)
142{ 135{
143} 136}
144 137
145
146void mat_timed::enable (view &ctx) 138void mat_timed::enable (view &ctx)
147{ 139{
148 material::enable (ctx); 140 material::enable (ctx);
149 141
150 time->set (timer::now); 142 time->set (timer::now);
212 temp_1f fac; 204 temp_1f fac;
213 205
214 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec)); 206 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec));
215 207
216 xyz (fout.frag_color) = ctx.pass->l->sh_colour * sh_colour * fac; 208 xyz (fout.frag_color) = ctx.pass->l->sh_colour * sh_colour * fac;
209 }
210}
211
212static shader::varying_3f f_normal;
213
214void mat_debug::enable (view &ctx)
215{
216 material::enable (ctx);
217
218 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
219 glEnable (GL_BLEND);
220 glDepthMask (1);
221}
222
223void mat_debug::disable (view &ctx)
224{
225 material::disable (ctx);
226
227 glDisable (GL_BLEND);
228 glDepthMask (0);
229}
230
231void mat_debug::vsh (view &ctx)
232{
233 using namespace shader::compile;
234 std_vsh ();
235
236 if (ctx.pass->l)
237 f_normal = normal_matrix * vin.normal;
238}
239
240void mat_debug::fsh (view &ctx)
241{
242 using namespace shader::compile;
243
244 if (ctx.pass->l)
245 {
246 temp_1f fac;
247
248 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec));
249
250 xyz (fout.frag_color) = float3 (1.,0.,0.);
251 w (fout.frag_color) = 0.1;
217 } 252 }
218} 253}
219 254
220static shader::varying_2f texcoord; 255static shader::varying_2f texcoord;
221static shader::varying_3f normal; 256static shader::varying_3f normal;
276} 311}
277 312
278test_material *testmat; 313test_material *testmat;
279mat_gouraud_shaded *testmat2; 314mat_gouraud_shaded *testmat2;
280mat_timed *testmat3; 315mat_timed *testmat3;
316mat_debug *debugmat;
281 317

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines