Rev 5269 | Rev 5387 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5269 | Rev 5278 | ||
---|---|---|---|
Line 201... | Line 201... | ||
201 | ; assert(a == 180 || (a>=0 && a<=90)); |
201 | ; assert(a == 180 || (a>=0 && a<=90)); |
202 | fst dword[edi+offs_ligh_spot_cutoff] ;l.spot_cutoff=a |
202 | fst dword[edi+offs_ligh_spot_cutoff] ;l.spot_cutoff=a |
203 | fcom dword[an180f] ;if (a != 180) |
203 | fcom dword[an180f] ;if (a != 180) |
204 | fstsw ax |
204 | fstsw ax |
205 | sahf |
205 | sahf |
206 | jne @f |
206 | je @f |
207 | fldpi |
207 | fldpi |
208 | fmulp |
208 | fmulp |
209 | fdiv dword[an180f] |
209 | fdiv dword[an180f] |
210 | fcos |
210 | fcos |
211 | fstp dword[edi+offs_ligh_spot_cutoff] ;l.cos_spot_cutoff=cos(a * M_PI / 180.0) |
211 | fstp dword[edi+offs_ligh_spot_cutoff] ;l.cos_spot_cutoff=cos(a * M_PI / 180.0) |
Line 287... | Line 287... | ||
287 | .o_1: |
287 | .o_1: |
288 | fld1 ;else if (a>=1.0) |
288 | fld1 ;else if (a>=1.0) |
289 | fcompp |
289 | fcompp |
290 | fstsw ax |
290 | fstsw ax |
291 | sahf |
291 | sahf |
292 | jb .o_2 |
292 | ja .o_2 |
293 | mov eax,1.0 |
293 | mov eax,1.0 |
294 | jmp .end_m ;return 1.0 |
294 | jmp .end_m ;return 1.0 |
295 | .o_2: |
295 | .o_2: |
296 | mov eax,dword a ;else return a |
296 | mov eax,dword a ;else return a |
297 | .end_m: |
297 | .end_m: |
Line 353... | Line 353... | ||
353 | fl_1e_3 dd 1.0e-3 |
353 | fl_1e_3 dd 1.0e-3 |
Line 354... | Line 354... | ||
354 | 354 | ||
355 | if DEBUG |
355 | if DEBUG |
356 | txt_mate db 'Material',0 |
356 | txt_mate db 'Material',0 |
- | 357 | txt_colo db 'Color',0 |
|
357 | txt_colo db 'Color',0 |
358 | txt_rgba db 'R, G, B',0 |
Line 358... | Line 359... | ||
358 | end if |
359 | end if |
359 | 360 | ||
360 | ; non optimized lightening model |
361 | ; non optimized lightening model |
361 | align 4 |
362 | align 4 |
362 | proc gl_shade_vertex, context:dword, v:dword |
363 | proc gl_shade_vertex, context:dword, v:dword |
363 | locals |
364 | locals |
364 | R dd ? ;float ebp-100 |
365 | R dd ? ;float ebp-96 |
365 | G dd ? ;float ebp-96 |
366 | G dd ? ;float ebp-92 |
366 | B dd ? ;float ebp-92 |
367 | B dd ? ;float ebp-88 |
367 | A dd ? ;float ebp-88 |
368 | A dd ? ;float ebp-84 |
368 | s V3 ;ebp-84 |
- | |
369 | d V3 ;ebp-72 |
369 | s V3 ;ebp-80 |
370 | dist dd ? ;float ebp-60 |
370 | d V3 ;ebp-68 |
371 | tmp dd ? ;float ebp-56 |
371 | tmp dd ? ;float ebp-56 |
372 | att dd ? ;float ebp-52 |
372 | att dd ? ;float ebp-52 |
373 | dot_spot dd ? ;float ebp-48 |
373 | dot_spot dd ? ;float ebp-48 |
Line 478... | Line 478... | ||
478 | fmul st0,st0 |
478 | fmul st0,st0 |
479 | faddp |
479 | faddp |
480 | fld dword[d+offs_Z] |
480 | fld dword[d+offs_Z] |
481 | fmul st0,st0 |
481 | fmul st0,st0 |
482 | faddp |
482 | faddp |
483 | fsqrt |
- | |
484 | fst dword[dist] ;dist=sqrt(d.X^2+d.Y^2+d.Z^2) |
483 | fsqrt ;dist=sqrt(d.X^2+d.Y^2+d.Z^2) |
485 | fcom dword[fl_1e_3] |
484 | fcom dword[fl_1e_3] |
486 | fstsw ax |
485 | fstsw ax |
487 | sahf |
486 | sahf |
488 | jbe @f ;if (dist>1.0e-3) |
487 | jbe @f ;if (dist>1.0e-3) |
489 | fld1 |
488 | fld1 |
Line 555... | Line 554... | ||
555 | ; spot light |
554 | ; spot light |
556 | fld dword[ebx+offs_ligh_spot_cutoff] |
555 | fld dword[ebx+offs_ligh_spot_cutoff] |
557 | fcomp dword[an180f] ;if (l.spot_cutoff != 180) |
556 | fcomp dword[an180f] ;if (l.spot_cutoff != 180) |
558 | fstsw ax |
557 | fstsw ax |
559 | sahf |
558 | sahf |
560 | jne .if1_end |
559 | je .if1_end |
561 | fld dword[ebx+offs_ligh_norm_spot_direction] |
560 | fld dword[ebx+offs_ligh_norm_spot_direction] |
562 | fmul dword[d] |
561 | fmul dword[d] |
563 | fld dword[ebx+offs_ligh_norm_spot_direction+4] |
562 | fld dword[ebx+offs_ligh_norm_spot_direction+4] |
564 | fmul dword[d+offs_Y] |
563 | fmul dword[d+offs_Y] |
565 | faddp |
564 | faddp |
Line 673... | Line 672... | ||
673 | fld dword[s+offs_Y] |
672 | fld dword[s+offs_Y] |
674 | fmul st0,st0 |
673 | fmul st0,st0 |
675 | faddp |
674 | faddp |
676 | fld dword[s+offs_Z] |
675 | fld dword[s+offs_Z] |
677 | fmul st0,st0 |
676 | fmul st0,st0 |
678 | faddp |
677 | faddp ;st0 = s.X^2 +s.Y^2 +s.Z^2 |
679 | fsqrt |
678 | fsqrt |
680 | fcom dword[fl_1e_3] |
679 | fcom dword[fl_1e_3] |
681 | fstsw ax |
680 | fstsw ax |
682 | sahf |
681 | sahf |
683 | jbe @f ;if (tmp > 1.0e-3) |
682 | jbe @f ;if (tmp > 1.0e-3) |
Line 695... | Line 694... | ||
695 | fld1 |
694 | fld1 |
696 | fcomp |
695 | fcomp |
697 | fstsw ax |
696 | fstsw ax |
698 | fild dword[idx] |
697 | fild dword[idx] |
699 | sahf |
698 | sahf |
700 | jae @f ;if(dot_spec < 1.0) |
699 | jbe @f ;if(dot_spec < 1.0) st0=1 st1=dot_spec |
701 | fmul st0,st1 ;idx *= dot_spec |
700 | fmul st0,st1 ;idx *= dot_spec |
702 | @@: |
701 | @@: |
703 | fistp dword[idx] |
702 | fistp dword[idx] |
704 | ffree st0 ;dot_spec |
703 | ffree st0 ;dot_spec |
705 | fincstp |
704 | fincstp |
Line 709... | Line 708... | ||
709 | fld dword[ebx+offs_ligh_specular] |
708 | fld dword[ebx+offs_ligh_specular] |
710 | fmul st0,st1 |
709 | fmul st0,st1 |
711 | fmul dword[ecx+offs_mate_specular] |
710 | fmul dword[ecx+offs_mate_specular] |
712 | fadd dword[lR] |
711 | fadd dword[lR] |
713 | fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0] |
712 | fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0] |
- | 713 | ;ffree st0 |
|
- | 714 | ;fincstp |
|
714 | fld dword[ebx+offs_ligh_specular+4] |
715 | fld dword[ebx+offs_ligh_specular+4] |
715 | fmul st0,st1 |
716 | fmul st0,st1 |
716 | fmul dword[ecx+offs_mate_specular+4] |
717 | fmul dword[ecx+offs_mate_specular+4] |
717 | fadd dword[lG] |
718 | fadd dword[lG] |
718 | fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1] |
719 | fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1] |
- | 720 | ;ffree st0 |
|
- | 721 | ;fincstp |
|
719 | fld dword[ebx+offs_ligh_specular+8] |
722 | fld dword[ebx+offs_ligh_specular+8] |
720 | fmul st0,st1 |
723 | fmul st0,st1 |
721 | fmul dword[ecx+offs_mate_specular+8] |
724 | fmul dword[ecx+offs_mate_specular+8] |
722 | fadd dword[lB] |
725 | fadd dword[lB] |
723 | fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2] |
726 | fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2] |
- | 727 | ;ffree st0 |
|
- | 728 | ;fincstp |
|
724 | ffree st0 ;dot_spec |
729 | ffree st0 ;dot_spec |
725 | fincstp |
730 | fincstp |
726 | jmp .if2_end |
731 | jmp .if2_end |
727 | .if0_end: |
732 | .if0_end: |
728 | ffree st0 ;dot [or] dot_spec |
733 | ffree st0 ;dot [or] dot_spec |