Index: ddraw/glDirect3D.cpp |
— | — | @@ -45,7 +45,8 @@ |
46 | 46 | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA | D3DPBLENDCAPS_DESTALPHA |
|
47 | 47 | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR | D3DPBLENDCAPS_INVDESTCOLOR |
|
48 | 48 | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA | D3DPBLENDCAPS_BOTHINVSRCALPHA, //dwDestBlendCaps
|
49 | | - 0, //dwAlphaCmpCaps
|
| 49 | + D3DPCMPCAPS_ALWAYS | D3DPCMPCAPS_EQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_GREATEREQUAL |
|
| 50 | + D3DPCMPCAPS_LESS | D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_NEVER | D3DPCMPCAPS_NOTEQUAL, //dwAlphaCmpCaps
|
50 | 51 | D3DPSHADECAPS_COLORGOURAUDRGB, //dwShadeCaps
|
51 | 52 | D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_PERSPECTIVE, //dwTextureCaps
|
52 | 53 | D3DPTFILTERCAPS_NEAREST | D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_MIPNEAREST |
|
— | — | @@ -72,7 +73,8 @@ |
73 | 74 | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA | D3DPBLENDCAPS_DESTALPHA |
|
74 | 75 | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR | D3DPBLENDCAPS_INVDESTCOLOR |
|
75 | 76 | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA | D3DPBLENDCAPS_BOTHINVSRCALPHA, //dwDestBlendCaps
|
76 | | - 0, //dwAlphaCmpCaps
|
| 77 | + D3DPCMPCAPS_ALWAYS | D3DPCMPCAPS_EQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_GREATEREQUAL |
|
| 78 | + D3DPCMPCAPS_LESS | D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_NEVER | D3DPCMPCAPS_NOTEQUAL, //dwAlphaCmpCaps
|
77 | 79 | D3DPSHADECAPS_COLORGOURAUDRGB, //dwShadeCaps
|
78 | 80 | D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_PERSPECTIVE, //dwTextureCaps
|
79 | 81 | D3DPTFILTERCAPS_NEAREST | D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_MIPNEAREST |
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -1544,6 +1544,7 @@ |
1545 | 1545 | }
|
1546 | 1546 | if(prog.uniforms[137]!= -1) glUniform1f(prog.uniforms[137],device->glDDS7->fakex);
|
1547 | 1547 | if(prog.uniforms[138]!= -1) glUniform1f(prog.uniforms[138],device->glDDS7->fakey);
|
| 1548 | + if(prog.uniforms[139]!= -1) glUniform1i(prog.uniforms[139],device->renderstate[D3DRENDERSTATE_ALPHAREF]);
|
1548 | 1549 | if(device->glDDS7->zbuffer) SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
|
1549 | 1550 | else SetFBO(device->glDDS7->texture,0,false);
|
1550 | 1551 | SetViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
Index: ddraw/shadergen.cpp |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | Bit 2 - Alpha test enable FS
|
41 | 41 | Bits 3-5 - Alpha test function: FS
|
42 | 42 | 000=never 001=less 010=equal 011=lessequal
|
43 | | -100=greater 101=notequal 110=lessequal 111=always
|
| 43 | +100=greater 101=notequal 110=greaterequal 111=always
|
44 | 44 | Bits 6-7 - Table fog: FS
|
45 | 45 | 00 = none 01=exp 10=exp2 11=linear
|
46 | 46 | Bits 8-9 - Vertex fog: same as table VS
|
— | — | @@ -260,6 +260,7 @@ |
261 | 261 | static const char unif_tex[] = "uniform sampler2D texX;\n";
|
262 | 262 | static const char unif_size[] = "uniform float width;\n\
|
263 | 263 | uniform float height;\n";
|
| 264 | +static const char unif_alpharef[] = "uniform int alpharef;\n";
|
264 | 265 | // Variables
|
265 | 266 | static const char var_common[] = "vec4 diffuse;\n\
|
266 | 267 | vec4 specular;\n\
|
— | — | @@ -632,6 +633,7 @@ |
633 | 634 | tmp.replace(21,1,_itoa(i,idstring,10));
|
634 | 635 | fsrc->append(tmp);
|
635 | 636 | }
|
| 637 | + if((id>>2)&1) fsrc->append(unif_alpharef);
|
636 | 638 | // Variables
|
637 | 639 | fsrc->append(var_color);
|
638 | 640 | // Functions
|
— | — | @@ -889,6 +891,36 @@ |
890 | 892 | break;
|
891 | 893 | }
|
892 | 894 | }
|
| 895 | + if((id>>2)&1)
|
| 896 | + {
|
| 897 | + switch((id>>3)&7)
|
| 898 | + {
|
| 899 | + case 0:
|
| 900 | + fsrc->append("discard;\n");
|
| 901 | + break;
|
| 902 | + case 1:
|
| 903 | + fsrc->append("if(int(color.a * 255.0) >= alpharef) discard;");
|
| 904 | + break;
|
| 905 | + case 2:
|
| 906 | + fsrc->append("if(int(color.a * 255.0) != alpharef) discard;");
|
| 907 | + break;
|
| 908 | + case 3:
|
| 909 | + fsrc->append("if(int(color.a * 255.0) > alpharef) discard;");
|
| 910 | + break;
|
| 911 | + case 4:
|
| 912 | + fsrc->append("if(int(color.a * 255.0) <= alpharef) discard;");
|
| 913 | + break;
|
| 914 | + case 5:
|
| 915 | + fsrc->append("if(int(color.a * 255.0) == alpharef) discard;");
|
| 916 | + break;
|
| 917 | + case 6:
|
| 918 | + fsrc->append("if(int(color.a * 255.0) < alpharef) discard;");
|
| 919 | + break;
|
| 920 | + case 7:
|
| 921 | + default:
|
| 922 | + break;
|
| 923 | + }
|
| 924 | + }
|
893 | 925 | fsrc->append(op_colorfragout);
|
894 | 926 | fsrc->append(mainend);
|
895 | 927 | #ifdef _DEBUG
|
— | — | @@ -1005,4 +1037,5 @@ |
1006 | 1038 | genshaders[index].shader.uniforms[136] = glGetUniformLocation(genshaders[index].shader.prog,"ambientcolor");
|
1007 | 1039 | genshaders[index].shader.uniforms[137] = glGetUniformLocation(genshaders[index].shader.prog,"width");
|
1008 | 1040 | genshaders[index].shader.uniforms[138] = glGetUniformLocation(genshaders[index].shader.prog,"height");
|
| 1041 | + genshaders[index].shader.uniforms[139] = glGetUniformLocation(genshaders[index].shader.prog,"alpharef");
|
1009 | 1042 | }
|