… | |
… | |
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 | |
|
|
146 | void mat_timed::enable (view &ctx) |
|
|
147 | { |
|
|
148 | material::enable (ctx); |
|
|
149 | |
|
|
150 | time->set (timer::now); |
|
|
151 | sh_colour->set (vec3 (255, 0, 0) * (1.F / 255.F)); |
|
|
152 | } |
|
|
153 | |
|
|
154 | void mat_timed::disable (view &ctx) |
|
|
155 | { |
|
|
156 | material::disable (ctx); |
|
|
157 | } |
|
|
158 | |
|
|
159 | void mat_timed::vsh (view &ctx) |
|
|
160 | { |
|
|
161 | using namespace shader::compile; |
|
|
162 | std_vsh (); |
|
|
163 | |
|
|
164 | if (ctx.pass->l) |
|
|
165 | f_normal = normal_matrix * vin.normal; |
|
|
166 | } |
|
|
167 | |
|
|
168 | void mat_timed::fsh (view &ctx) |
|
|
169 | { |
|
|
170 | using namespace shader::compile; |
|
|
171 | |
|
|
172 | if (ctx.pass->l) |
|
|
173 | { |
|
|
174 | temp_1f fac; |
|
|
175 | temp_3f normal; |
|
|
176 | |
|
|
177 | normal = f_normal + 0.3 * pow (sin (f_normal * 3.14159 + time), 3); |
|
|
178 | |
|
|
179 | fac = dot (normalize (normal), normalize (ctx.pass->l->sh_lightvec)); |
|
|
180 | |
|
|
181 | xyz (fout.frag_color) = fac * float3 (0.1,0.5,1);//ctx.pass->l->sh_colour * sh_colour * fac; |
|
|
182 | } |
|
|
183 | } |
|
|
184 | |
145 | void mat_gouraud_shaded::enable (view &ctx) |
185 | void mat_gouraud_shaded::enable (view &ctx) |
146 | { |
186 | { |
147 | material::enable (ctx); |
187 | material::enable (ctx); |
148 | |
188 | |
149 | sh_colour->set (vec3 (c.r, c.g, c.b) * (1.F / 255.F)); |
189 | sh_colour->set (vec3 (c.r, c.g, c.b) * (1.F / 255.F)); |
… | |
… | |
235 | material::disable (ctx); |
275 | material::disable (ctx); |
236 | } |
276 | } |
237 | |
277 | |
238 | test_material *testmat; |
278 | test_material *testmat; |
239 | mat_gouraud_shaded *testmat2; |
279 | mat_gouraud_shaded *testmat2; |
|
|
280 | mat_timed *testmat3; |
240 | |
281 | |