Skip to content

Commit

Permalink
Perform alpha test with integers instead of floats
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat committed Jul 15, 2024
1 parent db80131 commit c02b382
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/core/PICA/shader_gen_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,23 +398,23 @@ void FragmentGenerator::applyAlphaTest(std::string& shader, const PICARegs& regs
return;
}

shader += "float alphaReferenceFloat = float(alphaReference) / 255.0;\n";
shader += "if (!(";
shader += "int testingAlpha = int(combinerOutput.a * 255.0);\n";
shader += "if (";
switch (function) {
case CompareFunction::Never: shader += "false"; break;
case CompareFunction::Always: shader += "true"; break;
case CompareFunction::Equal: shader += "combinerOutput.a == alphaReferenceFloat"; break;
case CompareFunction::NotEqual: shader += "combinerOutput.a != alphaReferenceFloat"; break;
case CompareFunction::Less: shader += "combinerOutput.a < alphaReferenceFloat"; break;
case CompareFunction::LessOrEqual: shader += "combinerOutput.a <= alphaReferenceFloat"; break;
case CompareFunction::Greater: shader += "combinerOutput.a > alphaReferenceFloat"; break;
case CompareFunction::GreaterOrEqual: shader += "combinerOutput.a >= alphaReferenceFloat"; break;
case CompareFunction::Never: shader += "true"; break;
case CompareFunction::Always: shader += "false"; break;
case CompareFunction::Equal: shader += "testingAlpha != alphaReference"; break;
case CompareFunction::NotEqual: shader += "testingAlpha == alphaReference"; break;
case CompareFunction::Less: shader += "testingAlpha >= alphaReference"; break;
case CompareFunction::LessOrEqual: shader += "testingAlpha > alphaReference"; break;
case CompareFunction::Greater: shader += "testingAlpha <= alphaReference"; break;
case CompareFunction::GreaterOrEqual: shader += "testingAlpha < alphaReference"; break;

default:
Helpers::warn("Unimplemented alpha test function");
shader += "false";
break;
}

shader += ")) { discard; }\n";
shader += ") { discard; }\n";
}

0 comments on commit c02b382

Please sign in to comment.