Rev 6013 | Rev 6101 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6013 | Rev 6093 | ||
---|---|---|---|
Line 353... | Line 353... | ||
353 | endp |
353 | endp |
Line 354... | Line 354... | ||
354 | 354 | ||
355 | align 4 |
355 | align 4 |
Line 356... | Line -... | ||
356 | fl_1e_3 dd 1.0e-3 |
- | |
357 | - | ||
358 | if DEBUG |
- | |
359 | txt_mate db 'Material',0 |
- | |
360 | txt_colo db 'Color',0 |
- | |
361 | txt_rgba db 'R, G, B',0 |
- | |
362 | end if |
356 | fl_1e_3 dd 1.0e-3 |
363 | 357 | ||
364 | ; non optimized lightening model |
358 | ; non optimized lightening model |
365 | align 4 |
359 | align 4 |
366 | proc gl_shade_vertex, context:dword, v:dword |
360 | proc gl_shade_vertex, context:dword, v:dword |
Line 384... | Line 378... | ||
384 | endl |
378 | endl |
385 | pushad |
379 | pushad |
386 | ; ebx -> GLLight *l |
380 | ; ebx -> GLLight *l |
387 | ; ecx -> GLMaterial *m |
381 | ; ecx -> GLMaterial *m |
388 | ; esi -> GLVertex *v |
382 | ; esi -> GLVertex *v |
- | 383 | ||
- | 384 | ;n = v.normal |
|
- | 385 | ;d = l.position |
|
- | 386 | ; diffuse light |
|
- | 387 | ;dot = d*n |
|
- | 388 | ;dot_spot = d*l.norm_spot_direction |
|
- | 389 | ; specular light |
|
- | 390 | ;s = d-v.ec |
|
- | 391 | ;dot_spec = n*s |
|
- | 392 | ||
389 | mov esi,[v] |
393 | mov esi,[v] |
390 | mov edx,[context] |
394 | mov edx,[context] |
391 | mov ecx,edx |
395 | mov ecx,edx |
392 | add ecx,offs_cont_materials ;ecx(m) = &context.materials[0] |
396 | add ecx,offs_cont_materials ;ecx(m) = &context.materials[0] |
393 | mov eax,[edx+offs_cont_light_model_two_side] |
397 | mov eax,[edx+offs_cont_light_model_two_side] |
Line 399... | Line 403... | ||
399 | movsd ;n.X=v.normal.X |
403 | movsd ;n.X=v.normal.X |
400 | movsd ;n.Y=v.normal.Y |
404 | movsd ;n.Y=v.normal.Y |
401 | movsd ;n.Z=v.normal.Z |
405 | movsd ;n.Z=v.normal.Z |
402 | mov esi,[v] |
406 | mov esi,[v] |
Line 403... | Line -... | ||
403 | - | ||
404 | if DEBUG ;offs_mate_emission, offs_mate_ambient, offs_mate_specular, offs_mate_diffuse |
- | |
405 | push ecx |
- | |
406 | stdcall dbg_print,txt_mate,txt_nl |
- | |
407 | add ecx,offs_mate_emission |
- | |
408 | stdcall gl_print_matrix,ecx,1 |
- | |
409 | add ecx,offs_mate_ambient-offs_mate_emission |
- | |
410 | stdcall gl_print_matrix,ecx,1 |
- | |
411 | add ecx,offs_mate_specular-offs_mate_ambient |
- | |
412 | stdcall gl_print_matrix,ecx,1 |
- | |
413 | add ecx,offs_mate_diffuse-offs_mate_specular |
- | |
414 | stdcall gl_print_matrix,ecx,1 |
- | |
415 | pop ecx |
- | |
416 | end if |
- | |
417 | 407 | ||
418 | fld dword[edx+offs_cont_ambient_light_model] |
408 | fld dword[edx+offs_cont_ambient_light_model] |
419 | fmul dword[ecx+offs_mate_ambient] |
409 | fmul dword[ecx+offs_mate_ambient] |
420 | fadd dword[ecx] ;offs_mate_emission=0 |
410 | fadd dword[ecx] ;offs_mate_emission=0 |
421 | fstp dword[R] ;R=m.emission.v[0]+m.ambient.v[0]*context.ambient_light_model.v[0] |
411 | fstp dword[R] ;R=m.emission.v[0]+m.ambient.v[0]*context.ambient_light_model.v[0] |
Line 452... | Line 442... | ||
452 | sahf |
442 | sahf |
453 | jne .els_0 |
443 | jne .els_0 |
454 | ; light at infinity |
444 | ; light at infinity |
455 | ffree st0 ;l.position.v[3] |
445 | ffree st0 ;l.position.v[3] |
456 | fincstp |
446 | fincstp |
457 | mov eax,[ebx+offs_ligh_position] |
447 | mov eax,[ebx+offs_ligh_norm_position] |
458 | mov [d],eax ;d.X=l.position.v[0] |
448 | mov [d],eax ;d.X=l.norm_position.v[0] |
459 | mov eax,[ebx+offs_ligh_position+offs_Y] |
449 | mov eax,[ebx+offs_ligh_norm_position+offs_Y] |
460 | mov [d+offs_Y],eax ;d.Y=l.position.v[1] |
450 | mov [d+offs_Y],eax ;d.Y=l.norm_position.v[1] |
461 | mov eax,[ebx+offs_ligh_position+offs_Z] |
451 | mov eax,[ebx+offs_ligh_norm_position+offs_Z] |
462 | mov [d+offs_Z],eax ;d.Z=l.position.v[2] |
452 | mov [d+offs_Z],eax ;d.Z=l.norm_position.v[2] |
463 | mov dword[att],1.0 |
453 | mov dword[att],1.0 |
464 | jmp .els_0_end |
454 | jmp .els_0_end |
465 | .els_0: |
455 | .els_0: |
466 | ; distance attenuation |
456 | ; distance attenuation |
467 | ffree st0 ;l.position.v[3] |
457 | ffree st0 ;l.position.v[3] |
Line 560... | Line 550... | ||
560 | fstsw ax |
550 | fstsw ax |
561 | sahf |
551 | sahf |
562 | je .if1_end |
552 | je .if1_end |
563 | fld dword[ebx+offs_ligh_norm_spot_direction] |
553 | fld dword[ebx+offs_ligh_norm_spot_direction] |
564 | fmul dword[d] |
554 | fmul dword[d] |
565 | fld dword[ebx+offs_ligh_norm_spot_direction+4] |
555 | fld dword[ebx+offs_ligh_norm_spot_direction+offs_Y] |
566 | fmul dword[d+offs_Y] |
556 | fmul dword[d+offs_Y] |
567 | faddp |
557 | faddp |
568 | fld dword[ebx+offs_ligh_norm_spot_direction+8] |
558 | fld dword[ebx+offs_ligh_norm_spot_direction+offs_Z] |
569 | fmul dword[d+offs_Z] |
559 | fmul dword[d+offs_Z] |
570 | faddp |
560 | faddp |
571 | fchs |
561 | fchs |
572 | fst dword[dot_spot] |
562 | fst dword[dot_spot] |
573 | cmp dword[twoside],0 ;if (twoside && dot_spot < 0) |
563 | cmp dword[twoside],0 ;if (twoside && dot_spot < 0) |
Line 754... | Line 744... | ||
754 | mov [esi+offs_vert_color+4],eax ;v.color.v[1]=clampf(G,0,1) |
744 | mov [esi+offs_vert_color+4],eax ;v.color.v[1]=clampf(G,0,1) |
755 | clampf [B],0,1 |
745 | clampf [B],0,1 |
756 | mov [esi+offs_vert_color+8],eax ;v.color.v[2]=clampf(B,0,1) |
746 | mov [esi+offs_vert_color+8],eax ;v.color.v[2]=clampf(B,0,1) |
757 | mov eax,[A] |
747 | mov eax,[A] |
758 | mov [esi+offs_vert_color+12],eax ;v.color.v[3]=A |
748 | mov [esi+offs_vert_color+12],eax ;v.color.v[3]=A |
759 | if DEBUG ;offs_vert_color |
- | |
760 | push esi |
- | |
761 | stdcall dbg_print,txt_colo,txt_nl |
- | |
762 | add esi,offs_vert_color |
- | |
763 | stdcall gl_print_matrix,esi,1 |
- | |
764 | pop esi |
- | |
765 | end if |
- | |
766 | popad |
749 | popad |
767 | ret |
750 | ret |
768 | endp>>>-->>0) |
751 | endp>>>-->>0) |