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.61 by root, Fri Feb 11 15:17:47 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
145
146void mat_timed::enable (view &ctx) 145void mat_timed::enable (view &ctx)
147{ 146{
148 material::enable (ctx); 147 material::enable (ctx);
149 148
150 time->set (timer::now); 149 time->set (timer::now);
154void mat_timed::disable (view &ctx) 153void mat_timed::disable (view &ctx)
155{ 154{
156 material::disable (ctx); 155 material::disable (ctx);
157} 156}
158 157
159shader::varying_3f fish;
160
161void mat_timed::vsh (view &ctx) 158void mat_timed::vsh (view &ctx)
162{ 159{
163 using namespace shader::compile; 160 using namespace shader::compile;
164 std_vsh (); 161 std_vsh ();
165 162
166 if (ctx.pass->l) 163 if (ctx.pass->l)
167 {
168 f_normal = normal_matrix * vin.normal; 164 f_normal = normal_matrix * vin.normal;
169 fish = xyz(vin.vertex) + zxy (vin.vertex) * 0.2;
170 }
171} 165}
172 166
173void mat_timed::fsh (view &ctx) 167void mat_timed::fsh (view &ctx)
174{ 168{
175 using namespace shader::compile; 169 using namespace shader::compile;
177 if (ctx.pass->l) 171 if (ctx.pass->l)
178 { 172 {
179 temp_1f fac; 173 temp_1f fac;
180 temp_3f normal; 174 temp_3f normal;
181 175
182 normal = f_normal + 0.3 * pow (sin (fish * 0.1 + float3 (time * 2, time * 3.14, time * 1.55)), 3); 176 normal = f_normal + 0.3 * pow (sin (f_normal * 3.14159 + time), 3);
183 177
184 fac = dot (normalize (normal), normalize (ctx.pass->l->sh_lightvec)); 178 fac = dot (normalize (normal), normalize (ctx.pass->l->sh_lightvec));
185 179
186 xyz (fout.frag_color) = fac * float3 (0.1,0.5,1);//ctx.pass->l->sh_colour * sh_colour * fac; 180 xyz (fout.frag_color) = fac * float3 (0.1,0.5,1);//ctx.pass->l->sh_colour * sh_colour * fac;
187 } 181 }
217 temp_1f fac; 211 temp_1f fac;
218 212
219 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec)); 213 fac = dot (normalize (f_normal), normalize (ctx.pass->l->sh_lightvec));
220 214
221 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;
222 } 259 }
223} 260}
224 261
225static shader::varying_2f texcoord; 262static shader::varying_2f texcoord;
226static shader::varying_3f normal; 263static shader::varying_3f normal;
281} 318}
282 319
283test_material *testmat; 320test_material *testmat;
284mat_gouraud_shaded *testmat2; 321mat_gouraud_shaded *testmat2;
285mat_timed *testmat3; 322mat_timed *testmat3;
323mat_debug *debugmat;
286 324

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines