Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -1190,6 +1190,26 @@ |
1191 | 1191 | return D3DERR_UNSUPPORTEDCOLOROPERATION;
|
1192 | 1192 | }
|
1193 | 1193 | }
|
| 1194 | + for(int i = 0; i < 8; i++)
|
| 1195 | + {
|
| 1196 | + switch(texstages[i].alphaop)
|
| 1197 | + {
|
| 1198 | + case D3DTOP_DISABLE:
|
| 1199 | + case D3DTOP_SELECTARG1:
|
| 1200 | + case D3DTOP_SELECTARG2:
|
| 1201 | + case D3DTOP_MODULATE:
|
| 1202 | + case D3DTOP_MODULATE2X:
|
| 1203 | + case D3DTOP_MODULATE4X:
|
| 1204 | + case D3DTOP_ADD:
|
| 1205 | + case D3DTOP_ADDSIGNED:
|
| 1206 | + case D3DTOP_ADDSIGNED2X:
|
| 1207 | + case D3DTOP_SUBTRACT:
|
| 1208 | + case D3DTOP_ADDSMOOTH:
|
| 1209 | + break;
|
| 1210 | + default:
|
| 1211 | + return D3DERR_UNSUPPORTEDALPHAOPERATION;
|
| 1212 | + }
|
| 1213 | + }
|
1194 | 1214 | if(lpdwPasses) *lpdwPasses = 1;
|
1195 | 1215 | return D3D_OK;
|
1196 | 1216 | }
|
Index: ddraw/shadergen.cpp |
— | — | @@ -578,7 +578,7 @@ |
579 | 579 | int args[4];
|
580 | 580 | bool texfail;
|
581 | 581 | const string blendargs[] = {"color","gl_Color","texture2DProj(texX,gl_TexCoord[Y]).rgb",
|
582 | | - "texture2DProj(texX,gl_TexCoord[Y]).a","texfactor","gl_SecondaryColor","vec3(1,1,1)","1",".rgb",".a"};
|
| 582 | + "texture2DProj(texX,gl_TexCoord[Y]).a","texfactor","gl_SecondaryColor","vec3(1,1,1)","1",".rgb",".a","alpha"};
|
583 | 583 | for(i = 0; i < 8; i++)
|
584 | 584 | {
|
585 | 585 | if((texstate[i].shaderid & 31) == D3DTOP_DISABLE)break;
|
— | — | @@ -634,7 +634,7 @@ |
635 | 635 | break;
|
636 | 636 | case D3DTA_TFACTOR:
|
637 | 637 | FIXME("Support texture factor value");
|
638 | | - arg2 = blendargs[4];
|
| 638 | + arg2 = blendargs[4]+blendargs[8];
|
639 | 639 | break;
|
640 | 640 | case D3DTA_SPECULAR:
|
641 | 641 | arg2 = blendargs[5]+blendargs[8];
|
— | — | @@ -678,6 +678,103 @@ |
679 | 679 | fsrc->append("color = " + arg1 + " + " + arg2 + " - " + arg1 + " * " + arg2 + ";\n");
|
680 | 680 | break;
|
681 | 681 | }
|
| 682 | + if(((texstate[i].shaderid>>17) & 31) == D3DTOP_DISABLE)break;
|
| 683 | + // Alpha stage
|
| 684 | + texfail = false;
|
| 685 | + args[2] = (texstate[i].shaderid>>22)&63;
|
| 686 | + switch(args[2]&7) //arg1
|
| 687 | + {
|
| 688 | + case D3DTA_CURRENT:
|
| 689 | + default:
|
| 690 | + arg1 = blendargs[10];
|
| 691 | + break;
|
| 692 | + case D3DTA_DIFFUSE:
|
| 693 | + arg1 = blendargs[1]+blendargs[9];
|
| 694 | + break;
|
| 695 | + case D3DTA_TEXTURE:
|
| 696 | + if((texstate[i].shaderid >> 59)&1)
|
| 697 | + {
|
| 698 | + arg1 = blendargs[3];
|
| 699 | + arg1.replace(17,1,_itoa(i,idstring,10));
|
| 700 | + arg1.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 701 | + }
|
| 702 | + else texfail = true;
|
| 703 | + break;
|
| 704 | + case D3DTA_TFACTOR:
|
| 705 | + FIXME("Support texture factor value");
|
| 706 | + arg1 = blendargs[4]+blendargs[9];
|
| 707 | + break;
|
| 708 | + case D3DTA_SPECULAR:
|
| 709 | + arg1 = blendargs[5]+blendargs[9];
|
| 710 | + break;
|
| 711 | + }
|
| 712 | + if(args[2] & D3DTA_COMPLEMENT)
|
| 713 | + arg1 = "(1.0 - " + arg1 + ")";
|
| 714 | + args[3] = (texstate[i].shaderid>>28)&63;
|
| 715 | + switch(args[3]&7) //arg2
|
| 716 | + {
|
| 717 | + case D3DTA_CURRENT:
|
| 718 | + default:
|
| 719 | + arg2 = blendargs[0];
|
| 720 | + break;
|
| 721 | + case D3DTA_DIFFUSE:
|
| 722 | + arg2 = blendargs[1]+blendargs[8];
|
| 723 | + break;
|
| 724 | + case D3DTA_TEXTURE:
|
| 725 | + if((texstate[i].shaderid >> 59)&1)
|
| 726 | + {
|
| 727 | + arg2 = blendargs[3];
|
| 728 | + arg2.replace(17,1,_itoa(i,idstring,10));
|
| 729 | + arg2.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 730 | + }
|
| 731 | + else texfail = true;
|
| 732 | + break;
|
| 733 | + case D3DTA_TFACTOR:
|
| 734 | + FIXME("Support texture factor value");
|
| 735 | + arg2 = blendargs[4]+blendargs[8];
|
| 736 | + break;
|
| 737 | + case D3DTA_SPECULAR:
|
| 738 | + arg2 = blendargs[5]+blendargs[8];
|
| 739 | + break;
|
| 740 | + }
|
| 741 | + if(args[3] & D3DTA_COMPLEMENT)
|
| 742 | + arg1 = "(1.0 - " + arg1 + ")";
|
| 743 | + if(!texfail) switch(texstate[i].shaderid & 31)
|
| 744 | + {
|
| 745 | + case D3DTOP_DISABLE:
|
| 746 | + default:
|
| 747 | + break;
|
| 748 | + case D3DTOP_SELECTARG1:
|
| 749 | + fsrc->append("alpha = " + arg1 + ";\n");
|
| 750 | + break;
|
| 751 | + case D3DTOP_SELECTARG2:
|
| 752 | + fsrc->append("alpha = " + arg2 + ";\n");
|
| 753 | + break;
|
| 754 | + case D3DTOP_MODULATE:
|
| 755 | + fsrc->append("alpha = " + arg1 + " * " + arg2 + ";\n");
|
| 756 | + break;
|
| 757 | + case D3DTOP_MODULATE2X:
|
| 758 | + fsrc->append("alpha = (" + arg1 + " * " + arg2 + ") * 2.0;\n");
|
| 759 | + break;
|
| 760 | + case D3DTOP_MODULATE4X:
|
| 761 | + fsrc->append("alpha = (" + arg1 + " * " + arg2 + ") * 4.0;\n");
|
| 762 | + break;
|
| 763 | + case D3DTOP_ADD:
|
| 764 | + fsrc->append("alpha = " + arg1 + " + " + arg2 + ";\n");
|
| 765 | + break;
|
| 766 | + case D3DTOP_ADDSIGNED:
|
| 767 | + fsrc->append("alpha = " + arg1 + " + " + arg2 + " - .5;\n");
|
| 768 | + break;
|
| 769 | + case D3DTOP_ADDSIGNED2X:
|
| 770 | + fsrc->append("alpha = (" + arg1 + " + " + arg2 + " - .5) * 2.0;\n");
|
| 771 | + break;
|
| 772 | + case D3DTOP_SUBTRACT:
|
| 773 | + fsrc->append("alpha = " + arg1 + " - " + arg2 + ";\n");
|
| 774 | + break;
|
| 775 | + case D3DTOP_ADDSMOOTH:
|
| 776 | + fsrc->append("alpha = " + arg1 + " + " + arg2 + " - " + arg1 + " * " + arg2 + ";\n");
|
| 777 | + break;
|
| 778 | + }
|
682 | 779 | }
|
683 | 780 | fsrc->append(op_colorfragout);
|
684 | 781 | fsrc->append(mainend);
|