Index: ddraw/shadergen.cpp |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | static const char op_dirlight[] = "DirLight(lightX);\n";
|
281 | 281 | static const char op_pointlight[] = "PointLight(lightX);\n";
|
282 | 282 | static const char op_spotlight[] = "SpotLight(lightX);\n";
|
283 | | -static const char op_colorout[] = "gl_FrontColor = (gl_FrontMaterial.diffuse * diffuse) + (gl_FrontMaterial.ambient * ambient)\n\
|
| 283 | +static const char op_colorout[] = "gl_FrontColor = (gl_FrontMaterial.diffuse * diffuse) + (gl_FrontMaterial.ambient + ambient)\n\
|
284 | 284 | + (gl_FrontMaterial.specular * specular) + gl_FrontMaterial.emission;\n\
|
285 | 285 | gl_FrontSecondaryColor = (gl_FrontMaterial.specular * specular);\n";
|
286 | 286 | static const char op_colorvert[] = "gl_FrontColor = rgba0.bgra;\n";
|
— | — | @@ -482,6 +482,8 @@ |
483 | 483 | else vsrc->append(op_transform);
|
484 | 484 | if((id>>49)&1) vsrc->append(op_normalize);
|
485 | 485 | else vsrc->append(op_normalpassthru);
|
| 486 | + const string colorargs[] = {"gl_FrontMaterial.diffuse","gl_FrontMaterial.ambient","gl_FrontMaterial.specular",
|
| 487 | + "gl_FrontMaterial.emission","rgba0.bgra","rgba1.bgra"};
|
486 | 488 | if(numlights)
|
487 | 489 | {
|
488 | 490 | vsrc->append(op_resetcolor);
|
— | — | @@ -509,7 +511,36 @@ |
510 | 512 | vsrc->append(tmp);
|
511 | 513 | }
|
512 | 514 | }
|
513 | | - vsrc->append(op_colorout);
|
| 515 | + if((id>>60)&1)
|
| 516 | + {
|
| 517 | + bool hascolor1 = false;
|
| 518 | + if((id>>35)&1) hascolor1 = true;
|
| 519 | + bool hascolor2 = false;
|
| 520 | + if((id>>36)&1) hascolor2 = true;
|
| 521 | + int matcolor;
|
| 522 | + vsrc->append("gl_FrontColor = (");
|
| 523 | + matcolor = ((id>>23)&3);
|
| 524 | + if((matcolor == D3DMCS_COLOR1) && hascolor1) vsrc->append(colorargs[4]);
|
| 525 | + else if((matcolor == D3DMCS_COLOR2) && hascolor2) vsrc->append(colorargs[5]);
|
| 526 | + else vsrc->append(colorargs[0]);
|
| 527 | + vsrc->append(" * diffuse) + (");
|
| 528 | + matcolor = ((id>>27)&3);
|
| 529 | + if((matcolor == D3DMCS_COLOR1) && hascolor1) vsrc->append(colorargs[4]);
|
| 530 | + else if((matcolor == D3DMCS_COLOR2) && hascolor2) vsrc->append(colorargs[5]);
|
| 531 | + else vsrc->append(colorargs[1]);
|
| 532 | + vsrc->append(" + ambient)\n+ (");
|
| 533 | + matcolor = ((id>>25)&3);
|
| 534 | + if((matcolor == D3DMCS_COLOR1) && hascolor1) vsrc->append(colorargs[4]);
|
| 535 | + else if((matcolor == D3DMCS_COLOR2) && hascolor2) vsrc->append(colorargs[5]);
|
| 536 | + else vsrc->append(colorargs[2]);
|
| 537 | + vsrc->append(" * specular) + ");
|
| 538 | + matcolor = ((id>>29)&3);
|
| 539 | + if((matcolor == D3DMCS_COLOR1) && hascolor1) vsrc->append(colorargs[4]);
|
| 540 | + else if((matcolor == D3DMCS_COLOR2) && hascolor2) vsrc->append(colorargs[5]);
|
| 541 | + else vsrc->append(colorargs[3]);
|
| 542 | + vsrc->append(";\n");
|
| 543 | + }
|
| 544 | + else vsrc->append(op_colorout);
|
514 | 545 | }
|
515 | 546 | else
|
516 | 547 | {
|