Index: ddraw/ShaderGen3D.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2014 William Feely
|
| 3 | +// Copyright (C) 2012-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -320,6 +320,7 @@ |
321 | 321 | uniform float maxz;\n";
|
322 | 322 | static const char unif_alpharef[] = "uniform int alpharef;\n";
|
323 | 323 | static const char unif_key[] = "uniform ivec3 keyX;\n";
|
| 324 | +static const char unif_keybits[] = "uniform ivec4 keybitsX;\n";
|
324 | 325 | static const char unif_world[] = "uniform mat4 matWorld;\n";
|
325 | 326 | static const char unif_ditherbits[] = "uniform ivec4 ditherbits;\n";
|
326 | 327 | // Variables
|
— | — | @@ -331,6 +332,7 @@ |
332 | 333 | static const char var_xyzw[] = "vec4 xyzw;\n";
|
333 | 334 | static const char var_fogfactorvertex[] = "varying float fogfactor;\n";
|
334 | 335 | static const char var_fogfactorpixel[] = "float fogfactor;\n";
|
| 336 | +static const char var_keycomp[] = "ivec4 keycomp;\n";
|
335 | 337 | // Constants
|
336 | 338 | static const char const_nxyz[] = "const vec3 nxyz = vec3(0,0,0);\n";
|
337 | 339 | static const char const_threshold[] = "mat4 threshold = mat4(\n\
|
— | — | @@ -361,7 +363,8 @@ |
362 | 364 | static const char op_colorfragout[] = "gl_FragColor = color;\n";
|
363 | 365 | static const char op_dither[] = "color = dither(color);\n";
|
364 | 366 | static const char op_colorfragin[] = "color = gl_Color;\n";
|
365 | | -static const char op_colorkey[] = "if(ivec3(texture2DProj(texX,gl_TexCoord[Y])*255.5).rgb == keyZ) discard;\n";
|
| 367 | +static const char op_colorkeyin[] = "keycomp = ivec4(texture2DProj(texX,gl_TexCoord[Y])*vec4(keybitsZ)+.5);\n";
|
| 368 | +static const char op_colorkey[] = "if(keycomp.rgb == keyX) discard;\n";
|
366 | 369 | static const char op_texpassthru1[] = "gl_TexCoord[x] = ";
|
367 | 370 | static const char op_texpassthru2s[] = "vec4(sX,0,0,1);\n";
|
368 | 371 | static const char op_texpassthru2st[] = "vec4(stX,0,1);\n";
|
— | — | @@ -491,6 +494,7 @@ |
492 | 495 | bool haspoint = false;
|
493 | 496 | bool hasspot = false;
|
494 | 497 | bool dither = false;
|
| 498 | + BOOL haskey = FALSE;
|
495 | 499 | int count;
|
496 | 500 | int numlights;
|
497 | 501 | int vertexfog,pixelfog;
|
— | — | @@ -795,6 +799,10 @@ |
796 | 800 | String_Assign(&tmp, unif_key);
|
797 | 801 | tmp.ptr[17] = *(_itoa(i,idstring,10));
|
798 | 802 | String_Append(fsrc, tmp.ptr);
|
| 803 | + String_Assign(&tmp, unif_keybits);
|
| 804 | + tmp.ptr[21] = *(_itoa(i, idstring, 10));
|
| 805 | + String_Append(fsrc, tmp.ptr);
|
| 806 | + haskey = TRUE;
|
799 | 807 | }
|
800 | 808 | }
|
801 | 809 | }
|
— | — | @@ -805,6 +813,7 @@ |
806 | 814 | if(vertexfog && !pixelfog) String_Append(fsrc, var_fogfactorvertex);
|
807 | 815 | if(pixelfog) String_Append(fsrc, var_fogfactorpixel);
|
808 | 816 | if (dither) String_Append(fsrc, const_threshold);
|
| 817 | + if (haskey) String_Append(fsrc, var_keycomp);
|
809 | 818 | // Functions
|
810 | 819 | if (dither) String_Append(fsrc, func_dither);
|
811 | 820 | // Main
|
— | — | @@ -834,10 +843,13 @@ |
835 | 844 | {
|
836 | 845 | if((texstate[i].shaderid>>60)&1)
|
837 | 846 | {
|
| 847 | + String_Assign(&arg1, op_colorkeyin);
|
| 848 | + arg1.ptr[33] = *(_itoa(i, idstring, 10));
|
| 849 | + arg1.ptr[47] = *(_itoa((texstate[i].shaderid >> 54) & 7, idstring, 10));
|
| 850 | + arg1.ptr[63] = *(_itoa(i, idstring, 10));
|
| 851 | + String_Append(fsrc, arg1.ptr);
|
838 | 852 | String_Assign(&arg1, op_colorkey);
|
839 | | - arg1.ptr[26] = *(_itoa(i,idstring,10));
|
840 | | - arg1.ptr[40] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
841 | | - arg1.ptr[61] = *(_itoa(i,idstring,10));
|
| 853 | + arg1.ptr[21] = *(_itoa(i,idstring,10));
|
842 | 854 | String_Append(fsrc, arg1.ptr);
|
843 | 855 | }
|
844 | 856 | }
|
— | — | @@ -1434,7 +1446,13 @@ |
1435 | 1447 | }
|
1436 | 1448 | This->genshaders[index].shader.uniforms[150] = This->ext->glGetUniformLocation(This->genshaders[index].shader.prog,"ditherbits");
|
1437 | 1449 | This->genshaders[index].shader.uniforms[151] = This->ext->glGetUniformLocation(This->genshaders[index].shader.prog, "minz");
|
1438 | | - This->genshaders[index].shader.uniforms[151] = This->ext->glGetUniformLocation(This->genshaders[index].shader.prog, "maxz");
|
| 1450 | + This->genshaders[index].shader.uniforms[152] = This->ext->glGetUniformLocation(This->genshaders[index].shader.prog, "maxz");
|
| 1451 | + char unifkeybits[] = "keybitsX";
|
| 1452 | + for (int i = 0; i < 8; i++)
|
| 1453 | + {
|
| 1454 | + unifkeybits[7] = i + '0';
|
| 1455 | + This->genshaders[index].shader.uniforms[153 + i] = This->ext->glGetUniformLocation(This->genshaders[index].shader.prog, unifkeybits);
|
| 1456 | + }
|
1439 | 1457 | }
|
1440 | 1458 |
|
1441 | 1459 | } |
\ No newline at end of file |
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2014 William Feely
|
| 3 | +// Copyright (C) 2012-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -1995,8 +1995,13 @@ |
1996 | 1996 | {
|
1997 | 1997 | if(device->texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT)
|
1998 | 1998 | {
|
1999 | | - dwordto4int(device->texstages[i].texture->colorkey[0].key.dwColorSpaceLowValue,keycolor);
|
2000 | | - This->ext->glUniform3iv(prog.uniforms[142+i],1,keycolor);
|
| 1999 | + SetColorKeyUniform(device->texstages[i].texture->colorkey[0].key.dwColorSpaceLowValue,
|
| 2000 | + device->texstages[i].texture->texture->colorsizes, device->texstages[i].texture->texture->colororder,
|
| 2001 | + prog.uniforms[142 + i], device->texstages[i].texture->texture->colorbits, This->ext);
|
| 2002 | + This->ext->glUniform4i(prog.uniforms[153+i], device->texstages[i].texture->texture->colorsizes[0],
|
| 2003 | + device->texstages[i].texture->texture->colorsizes[1],
|
| 2004 | + device->texstages[i].texture->texture->colorsizes[2],
|
| 2005 | + device->texstages[i].texture->texture->colorsizes[3]);
|
2001 | 2006 | }
|
2002 | 2007 | }
|
2003 | 2008 | }
|