Rev 5262 | Rev 5278 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5262 | Rev 5269 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | align 4 |
|
- | 2 | sp128f dd 128.0 |
|
Line 1... | Line 3... | ||
1 | align 4 |
3 | |
2 | proc glopMaterial uses eax ebx ecx edi esi, context:dword, p:dword |
4 | align 4 |
3 | ; edi -> GLMaterial *m |
5 | proc glopMaterial uses eax ebx ecx edi esi, context:dword, p:dword |
4 | mov eax,[context] |
6 | ; edi -> GLMaterial *m |
Line 12... | Line 14... | ||
12 | add edi,12 |
14 | mov edi,ebp |
13 | stdcall glopMaterial,eax,edi |
15 | add edi,12 |
14 | mov ecx,GL_BACK |
16 | stdcall glopMaterial,eax,edi |
15 | @@: |
17 | mov ecx,GL_BACK |
16 | mov edi,[eax+offs_cont_materials] |
18 | @@: |
- | 19 | mov edi,eax |
|
17 | cmp ecx,GL_FRONT ;if (mode == GL_FRONT) m=&context.materials[0] |
20 | add edi,offs_cont_materials |
18 | je @f |
21 | cmp ecx,GL_FRONT ;if (mode == GL_FRONT) m=&context.materials[0] |
19 | add edi,sizeof.GLMaterial ;else m=&context.materials[1] |
22 | je @f |
20 | @@: |
23 | add edi,sizeof.GLMaterial ;else m=&context.materials[1] |
21 | 24 | @@: |
|
Line 52... | Line 55... | ||
52 | fld dword[esi] |
55 | jne @f |
53 | add edi,offs_mate_shininess |
56 | fld dword[esi] |
54 | movsd |
57 | add edi,offs_mate_shininess |
55 | mov dword[edi],SPECULAR_BUFFER_RESOLUTION |
58 | movsd |
56 | fdiv dword[an180f] |
59 | mov dword[edi],SPECULAR_BUFFER_RESOLUTION |
57 | fimul dword[edi] |
60 | fdiv dword[sp128f] |
58 | fistp dword[edi] ;m.shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION |
61 | fimul dword[edi] |
59 | jmp .end_f |
62 | fistp dword[edi] ;m.shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION |
60 | @@: |
63 | jmp .end_f |
61 | cmp ebx,GL_AMBIENT_AND_DIFFUSE |
64 | @@: |
62 | jne @f |
65 | cmp ebx,GL_AMBIENT_AND_DIFFUSE |
Line 172... | Line 175... | ||
172 | mov edi,edx |
175 | add esi,12 |
173 | add edi,offs_ligh_spot_direction |
176 | mov edi,edx |
174 | mov ecx,3 |
177 | add edi,offs_ligh_spot_direction |
175 | rep movsd ;l.spot_direction=v[0,1,2] |
178 | mov ecx,3 |
176 | mov esi,ebx |
179 | rep movsd ;l.spot_direction=v[0,1,2] |
177 | add esi,12 |
180 | ;mov esi,ebx |
178 | mov edi,edx |
181 | ;add esi,12 |
- | 182 | sub esi,12 |
|
179 | add edi,offs_ligh_norm_spot_direction |
183 | ;mov edi,edx |
180 | mov ecx,3 |
184 | ;add edi,offs_ligh_norm_spot_direction |
- | 185 | add edi,offs_ligh_norm_spot_direction-(offs_ligh_spot_direction+12) |
|
181 | rep movsd ;l.norm_spot_direction=v[0,1,2] |
186 | mov ecx,3 |
182 | add edx,offs_ligh_norm_spot_direction |
187 | rep movsd ;l.norm_spot_direction=v[0,1,2] |
183 | stdcall gl_V3_Norm,edx |
188 | add edx,offs_ligh_norm_spot_direction |
184 | jmp .end_f |
189 | stdcall gl_V3_Norm,edx |
185 | @@: |
190 | jmp .end_f |
Line 378... | Line 383... | ||
378 | ; ecx -> GLMaterial *m |
383 | ; ebx -> GLLight *l |
379 | ; esi -> GLVertex *v |
384 | ; ecx -> GLMaterial *m |
380 | mov esi,[v] |
385 | ; esi -> GLVertex *v |
381 | mov edx,[context] |
386 | mov esi,[v] |
382 | mov ecx,[edx+offs_cont_materials] ;ecx(m) = &context.materials[0] |
387 | mov edx,[context] |
- | 388 | mov ecx,edx |
|
383 | mov eax,[edx+offs_cont_light_model_two_side] |
389 | add ecx,offs_cont_materials ;ecx(m) = &context.materials[0] |
384 | mov [twoside],eax |
390 | mov eax,[edx+offs_cont_light_model_two_side] |
385 | 391 | mov [twoside],eax |
|
Line 386... | Line 392... | ||
386 | add esi,offs_vert_normal |
392 | |
387 | mov edi,ebp |
393 | add esi,offs_vert_normal |
Line 435... | Line 441... | ||
435 | fld dword[ecx+offs_mate_ambient+8] |
441 | fstp dword[lG] ;lG=l.ambient.v[1] * m.ambient.v[1] |
436 | fmul dword[ebx+offs_ligh_ambient+8] |
442 | fld dword[ecx+offs_mate_ambient+8] |
437 | fstp dword[lB] ;lB=l.ambient.v[2] * m.ambient.v[2] |
443 | fmul dword[ebx+offs_ligh_ambient+8] |
438 | 444 | fstp dword[lB] ;lB=l.ambient.v[2] * m.ambient.v[2] |
|
Line 439... | Line 445... | ||
439 | cmp dword[ebx+offs_ligh_position+12],0 ;if (l.position.v[3] == 0) |
445 | |
- | 446 | fld dword[ebx+offs_ligh_position+offs_W] |
|
- | 447 | ftst ;if (l.position.v[3] == 0) |
|
- | 448 | fstsw ax |
|
440 | jne .els_0 |
449 | sahf |
441 | ; light at infinity |
450 | jne .els_0 |
- | 451 | ; light at infinity |
|
- | 452 | ffree st0 ;l.position.v[3] |
|
442 | mov eax,[ebx+offs_ligh_position] |
453 | fincstp |
443 | mov [d],eax ;d.X=l.position.v[0] |
454 | mov eax,[ebx+offs_ligh_position] |
444 | mov eax,[ebx+offs_ligh_position+4] |
455 | mov [d],eax ;d.X=l.position.v[0] |
445 | mov [d+4],eax ;d.Y=l.position.v[1] |
456 | mov eax,[ebx+offs_ligh_position+offs_Y] |
446 | mov eax,[ebx+offs_ligh_position+8] |
457 | mov [d+offs_Y],eax ;d.Y=l.position.v[1] |
447 | mov [d+8],eax ;d.Z=l.position.v[2] |
458 | mov eax,[ebx+offs_ligh_position+offs_Z] |
448 | mov dword[att],1.0 |
459 | mov [d+offs_Z],eax ;d.Z=l.position.v[2] |
449 | jmp .els_0_end |
460 | mov dword[att],1.0 |
450 | .els_0: |
461 | jmp .els_0_end |
451 | ; distance attenuation |
462 | .els_0: |
- | 463 | ; distance attenuation |
|
- | 464 | ffree st0 ;l.position.v[3] |
|
452 | fld dword[ebx+offs_ligh_position] |
465 | fincstp |
453 | fsub dword[esi+offs_vert_ec] |
466 | fld dword[ebx+offs_ligh_position] |
454 | fstp dword[d] ;d.X=l.position.v[0]-v.ec.v[0] |
467 | fsub dword[esi+offs_vert_ec] |
455 | fld dword[ebx+offs_ligh_position+offs_Y] |
468 | fstp dword[d] ;d.X=l.position.v[0]-v.ec.v[0] |
456 | fsub dword[esi+offs_vert_ec+offs_Y] |
469 | fld dword[ebx+offs_ligh_position+offs_Y] |
Line 466... | Line 479... | ||
466 | fld dword[d+offs_Z] |
479 | faddp |
467 | fmul st0,st0 |
480 | fld dword[d+offs_Z] |
468 | faddp |
481 | fmul st0,st0 |
469 | fsqrt |
482 | faddp |
470 | fst dword[dist] ;dist=sqrt(d.X^2+d^2+d^2) |
483 | fsqrt |
471 | fcom dword[fl_1e_3] |
484 | fst dword[dist] ;dist=sqrt(d.X^2+d.Y^2+d.Z^2) |
472 | fstsw ax |
485 | fcom dword[fl_1e_3] |
473 | sahf |
486 | fstsw ax |
474 | jbe @f ;if (dist>1.0e-3) |
487 | sahf |
475 | fld1 |
488 | jbe @f ;if (dist>1.0e-3) |
476 | fdiv st0,st1 |
489 | fld1 |
Line 517... | Line 530... | ||
517 | @@: |
530 | fchs ;dot = -dot |
518 | ftst ;if (dot>0) |
531 | @@: |
519 | fstsw ax |
532 | ftst ;if (dot>0) |
520 | sahf |
533 | fstsw ax |
521 | jle .if0_end |
534 | sahf |
522 | ; diffuse light |
535 | jbe .if0_end |
523 | fld dword[ecx+offs_mate_diffuse] |
536 | ; diffuse light |
524 | fmul dword[ebx+offs_ligh_diffuse] |
537 | fld dword[ecx+offs_mate_diffuse] |
525 | fmul st0,st1 |
538 | fmul dword[ebx+offs_ligh_diffuse] |
526 | fadd dword[lR] |
539 | fmul st0,st1 |
527 | fstp dword[lR] ;lR+=dot * l.diffuse.v[0] * m.diffuse.v[0] |
540 | fadd dword[lR] |
Line 652... | Line 665... | ||
652 | @@: |
665 | fchs ;dot_spec = -dot_spec |
653 | ftst ;if (dot_spec > 0) |
666 | @@: |
654 | fstsw ax |
667 | ftst ;if (dot_spec > 0) |
655 | sahf |
668 | fstsw ax |
656 | jae .if0_end |
669 | sahf |
657 | fld dword[s] |
670 | jbe .if0_end |
658 | fmul st0,st0 |
671 | fld dword[s] |
659 | fld dword[s+offs_Y] |
672 | fmul st0,st0 |
660 | fmul st0,st0 |
673 | fld dword[s+offs_Y] |
661 | faddp |
674 | fmul st0,st0 |
662 | fld dword[s+offs_Z] |
675 | faddp |
Line 676... | Line 689... | ||
676 | ; testing specular buffer code |
689 | ; TODO: optimize |
677 | ; dot_spec= pow(dot_spec,m.shininess) |
690 | ; testing specular buffer code |
678 | stdcall specbuf_get_buffer, edx, dword[ecx+offs_mate_shininess_i], dword[ecx+offs_mate_shininess] |
691 | ; dot_spec= pow(dot_spec,m.shininess) |
679 | mov edi,eax ;edi = specbuf |
692 | stdcall specbuf_get_buffer, edx, dword[ecx+offs_mate_shininess_i], dword[ecx+offs_mate_shininess] |
680 | mov dword[idx],SPECULAR_BUFFER_SIZE |
693 | mov edi,eax ;edi = specbuf |
681 | fild dword[idx] |
694 | mov dword[idx],SPECULAR_BUFFER_SIZE ;idx = SPECULAR_BUFFER_SIZE |
682 | fld1 |
- | |
683 | fcomp |
695 | fld1 |
684 | fstsw ax |
696 | fcomp |
685 | sahf |
697 | fstsw ax |
- | 698 | fild dword[idx] |
|
686 | jae @f |
699 | sahf |
687 | fmul st0,st1 |
700 | jae @f ;if(dot_spec < 1.0) |
688 | @@: |
701 | fmul st0,st1 ;idx *= dot_spec |
689 | fistp dword[idx] ;if (dot_spec < 1.0) idx = (int)(dot_spec*SPECULAR_BUFFER_SIZE) |
702 | @@: |
690 | ;else idx = SPECULAR_BUFFER_SIZE; |
- | |
691 | ffree st0 ;dot_spec |
703 | fistp dword[idx] |
692 | fincstp |
704 | ffree st0 ;dot_spec |
693 | shl dword[idx],2 |
705 | fincstp |
694 | add edi,dword[idx] |
706 | shl dword[idx],2 |
695 | fld dword[edi+offs_spec_buf] ;dot_spec = specbuf.buf[idx] |
707 | add edi,dword[idx] |
696 | fld dword[ebx+offs_ligh_specular] |
708 | fld dword[edi+offs_spec_buf] ;dot_spec = specbuf.buf[idx] |